[xsd-users] cxx-tree failing generated xml file

Boris Kolpackov boris at codesynthesis.com
Wed Jun 13 12:12:14 EDT 2007


Hi Michael,

Michael Kesler <mkesler at datawolf.cc> writes:

> I have one application which writes an XML configuration file, which is
> read by another application.  Both applications use the XSD generated
> classes, the first writing the data and the second reading the data.
>
> When I try to read the data, I get these exceptions:
>
>    * settings.xml:2:181 error: Unknown element 'Settings'
>    * settings.xml:2:181 error: Attribute 'xmlns' is not declared for
>      element 'Settings'
>    * settings.xml:2:181 error: Attribute
>      '{http://www.w3.org/2000/xmlns/}xsi' is not declared for element
>      'Settings'
>    * settings.xml:2:181 error: Attribute
>      '{http://www.w3.org/2001/XMLSchema-instance}schemaLocation' is not
>      declared for element 'Settings'
>    * settings.xml:4:8 error: Unknown element 'dsn'
>    * settings.xml:6:9 error: Unknown element 'user'
>    * settings.xml:9:13 error: Unknown element 'password'
>
> What I don't understand is that the xsd-generated classes are writing
> this XML file that it can't read.

This is most likely because the second application (the one that read
the XML file) cannot find the schema to validate the instance. By default
XSD has validation in the underlying parser turned on so if the schema
is not found then all elements in your instance are "unknown" to the
schema processor.

One way to get rid of this is to disable validation by passing the
xml_schema::flags::dont_validate flag to the parsing function you
call.

hth,
-boris




More information about the xsd-users mailing list