[xsde-users] c++/Hybrid: element names and line numbers

Boris Kolpackov boris at codesynthesis.com
Thu Jan 22 09:01:48 EST 2015


Hi Christian,

Christian Sell <christian at gsvitec.com> writes:

> sorry if I overlooked something - this should be a rather common issue:

Not really, not for XSD/e anyway. Generally, people who use XSD/e want as
small a footprint as possible so "syntactic sugar" like this is discarded as
quickly as possible. This is also a good example of power and flexibility
of XSD compared to XSD/e where this is much easier to achieve (at the
cost of footprint, of course).


> we need access to the element name under which a given XSD type was
> parsed, as well as the line number in the XML document.

This information is only available during parsing. If you want to
store it in the object model, then you will have to do two things:

1. Customize the object model types to include data members to
   store this information (Section 4.9, "Customizing the Object
   Model").

2. Cusotmize the corresponding parser implementations to extract
   this information and store it in the object model (Section
   6.1, "Customizing Parsers and Serializers").

This is not too difficult to implement for a few types but if you
need this for your entire object model, it will be daunting.

Some more details on #2 above: the information you are looking for is
available in the parsing context (see libxsde/xsde/cxx/parser/context.hxx).
There are accessors for element name/namespace. For line/column, you
will need to get the underlying Expat parser (xml_parser()) and query
it for this info (XML_GetCurrentLineNumber(), XML_GetCurrentColumnNumber()).
See also this earlier post for some more details:

http://www.codesynthesis.com/pipermail/xsde-users/2008-October/000081.html

Boris



More information about the xsde-users mailing list