[xsd-users] Issue parsing document using namespace declaration with cxx-parser

Boris Kolpackov boris at codesynthesis.com
Fri Jul 2 17:11:23 EDT 2010


Hi Matthew,

Wood, Matthew D <matthew.d.wood at intel.com> writes:
 
> When I run the code, it catches a xml_schema::exception with 
> message ":2:256 error: unexpected attribute 'xmlns'" instead 
> of treating it as the namespace declaration for the elements.

Ok, I did some debugging and it appears that there is a bug (or
misfeature) in Xerces-C++ in that it reports attributes such as
xmlns:p="..." as belonging to the XML namespace while attributes
such as xmlns="..." as unqualified.

On the other hand, the XML Schema validation code generated with
the --generate-validation option expects special attributes to be
in the XML namespace and when it sees an unqualified xmlns attribute,
it reports it as unexpected.   

I have worked around this problem and you can download the fix via
these links:

http://codesynthesis.com/~boris/tmp/xsd-3.3.0-cxx-parser-xmlns.zip
http://codesynthesis.com/~boris/tmp/xsd-3.3.0-cxx-parser-xmlns.tar.gz

Simply copy the file in the archive over your vanilla XSD 3.3.0
distribution (no XSD compiler update is necessary). I have also
filed a bug report with the Xerces-C++ project:

https://issues.apache.org/jira/browse/XERCESC-1934

You may be wondering how come this issue hasn't been detected a 
long time ago. The answer is that when people use Xerces-C++ with
C++/Parser, they normally use the XML Schema validation in Xerces-C++
rather than in the generated code. If the XML Schema validation is
performed in the generated code then it makes sense to use the Expat
parser since it is smaller and faster (--xml-parser expat). And Expat
always reports the xmlns attributes as belonging to the XML namespace.

Boris



More information about the xsd-users mailing list