[xsd-users] Report line number when error is encountered

Alessandro Carpi alessandro.carpi at gmail.com
Wed Mar 2 09:35:49 EST 2011


2011/3/2 Boris Kolpackov <boris at codesynthesis.com>

> Hi Alessandro,
>
> Alessandro Carpi <alessandro.carpi at gmail.com> writes:
>
> > It would nice if, when this kind of errors are encountered (aka.
> expression
> > parser returns a null pointer because is written wrongly) , the XML
> parser
> > prints the XML line of the wrong expression.
>
> In other words you want to get the line/column information of the current
> position so that you can print it together with your application-specific
> error.
>
Actually yes. I was thinking to throw a sort of "not valid xml  exception"
 in order to obtain the printing of line and column for free :-)

>
> The way to get to this information depends on the underlying XML parser
> you are using (Expat or Xerces-C++). But the general approach would be
> to create the parser yourself, then use this parser to parse the document
> and query it for the current line/column information in case of an error.
> This is fairly easy to implement with Expat and slightly more difficult
> with Xerces-C++.
>
> I'm using Xercesc-C++ because it is already present to the target system.
If the above solution is not praticable, how can I obtain such informations
from the underlying parser ?

 Thank you very much :-)

-- 
--
Alessandro Carpi


More information about the xsd-users mailing list