[xsd-users] How to create XML with mappings for substitution groups with same type using cxx-tree

Boris Kolpackov boris at codesynthesis.com
Mon Aug 17 09:13:13 EDT 2009


Hi Alex,

Alex Jakes <Alex.Jakes at acis.uk.com> writes:

> Your reply to Ninh suggested using DOM directly to parse the document 
> as in the multiroot example.  I have done this and it works for parsing
> such files. The problem comes when I want to generate XML using the XSD
> generated code.  I would normally just build the data structure I want
> in memory and then serialise it.  Do you have any suggestions for how
> I might do this?

There is the ANSI/NIST-ITL schema which has the same issue. To resolve
it I implemented custom xml_schema::type which stores the substitution
group information for each type in the object model. It is automatically
retrieved during parsing and used to assign proper element names during
serialization. The application can also set it if, for example, creating
the object model from scratch. This is essentially approach #3 as listed
in my reply to Ninh.

You can try the same method for your schema. The source code for NIST-ITL
test is available from this page:

http://wiki.codesynthesis.com/Schemas/NIST-ITL

The xml-schema-custom.* files should be usable as-is. You will just need
to compile your schemas with new options (see itl.options and xsd.options)
and change your application to use the new approach.

Let me know if there are any snags.

Boris




More information about the xsd-users mailing list