[xsde-users] XML Serialization fails

Boris Kolpackov boris at codesynthesis.com
Fri Mar 25 09:46:22 EDT 2011


Matthias,

Matthias Maschek <matthias.maschek at uma.at> writes:

> I have a little problem with serialization. I generated the class files 
> via Hybrid like in the Hello World tutorial
> (xsde cxx-hybrid --generate-parser --generate-aggregate my.xsd). After
> that i tried to get the implementation running in my code. But when i
> try to parse an XML i always get a unexpected element encountered
> exception on the first contained element of the root element.

Are you having problems with parsing or serialization? In the email's
subject and at the beginning of the above paragraph you say  serialization.
In the last sentence you say parsing. Which one is it?


> I tripple checked already the XML file against the XSD via validators
> and there is no error. What i had problems with was the line from the
> tutorial:
> xml_schema::document_pimpl doc_p (hello_p.root_parser (),
>                                   hello_p.root_name ());
> 
> document_pimpl did not exist in that namespace.

That's very odd. What is the exact command line you used to compile
the schema? If it includes --generate-parser and --generate-aggregate
options, then xml_schema::document_pimpl should be defined in the
-pimpl.hxx header file.

Regarding the unexpected element error, if your schema uses namespaces
(has targetNamespace attribute), then you also need to provide the
root namespace to the parser:

xml_schema::document_pimpl doc_p (hello_p.root_parser (),
                                  hello_p.root_namespace (),
                                  hello_p.root_name ());

Boris



More information about the xsde-users mailing list