[xsd-users] WG: CodeSynthesis problem
Boris Kolpackov
boris at codesynthesis.com
Thu Jun 17 04:48:27 EDT 2010
Hi Abhijit,
Abhijit Sovakar <Abhijit.Sovakar at cae.de> writes:
> We generated C++ classes for the EDXL-DE schema with CodeSynthesis.
> ( command line: xsd cxx-tree --generate-serialization --generate-doxygen
> --namespace-map urn:oasis:names:tc:emergency:EDXL:DE:1.0=edxl::de
> EDXL-DE.xsd )
I noticed that your schema uses element and attribute wildcards (xsd:any
and xsd:anyAttribute). If you need to access this data, you will need
to add the --generate-wildcard option to the above command line. The
wildcard data is represented in the object model as DOM fragments. For
more information on how to handle this see the 'wildcard' example in
the examples/cxx/tree/ directory as well as Section 2.12, "Mapping for
any and anyAttribute" in the C++/Tree Mapping User Manual:
http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/#2.12
> 1st Problem:
> However the generated code wasn’t able to read the xml file due to
> namespace issues.
You perform your own XML to DOM parsing and the parser that you have
created does not recognize XML namespaces by default. To turn the XML
namespace support on you will need to add the following line before
calling parse():
parser.setDoNamespaces (true);
I assume you also know that the XSD compiler generates parsing and
serialization functions that hide the details of creating the
Xerces-C++ parser/serializer and performing XML to DOM parsing
and DOM to XML serialization. There are, however, valid situations
where you may want to setup your own parsing/serialization. The XSD
distribution contains a number of examples ('multiroot', 'messaging',
'caching', 'embedded', and 'performance') that do this and include
boilerplate code for Xerces-C++ parser/serializer setup.
> 2.Problem:
> We initialized an EDXLDistribution element and wrote that to stdout.
> If using that output as input, it can’t be read as well as the p1
> namespace alias is treated as element name.
The above call to setDoNamespaces() also fixes this problem.
Boris
More information about the xsd-users
mailing list