[xsd-users] Missing a parsing function

Boris Kolpackov boris at codesynthesis.com
Thu Jan 22 08:35:26 EST 2015


Hi Albert,

Babinskas, Albert <albert.babinskas at imagingsciences.com> writes:

> But my problem is I don't have a function to serialize reference_t.
> I don't have this:
> ::reference(ref)

The easiest way would be to define the 'reference' element and let
XSD generate the code for you. If you don't want to modify the schema,
you can create a separate one on the side that includes the original
and only defines the global element(s).

If you don't want to go this route, then you will need to create
the empty DOM document yourself, call the serialization operator
of reference_t, and then save the DOM document to XML (yes, quite
a bit more work than above but could be better if you have, say,
hundreds of such types).

The 'messaging' example is probably the closest to what you would
want. In particular, it has the serialize() function that saves
DOM to XML, so you can just take that.

The part that will be different is this line in driver.cxx:

xml_schema::element_map::serialize (*doc->getDocumentElement (), *res);

In your case you will have something like:

reference_t& ref = ...

*doc->getDocumentElement () << ref;

Boris



More information about the xsd-users mailing list