[xsd-users] Add element that read from file to C++/Tree

Boris Kolpackov boris at codesynthesis.com
Wed Sep 30 13:36:28 EDT 2009


Hi,

sun-rise <sun.rise.ma at gmail.com> writes:

> <xsd:complexType name="desc" mixed="true">
>   <xsd:choice minOccurs="0" maxOccurs="unbounded">
>     <xsd:any namespace="http://www.w3.org/1999/xhtml" processContents="skip" />
>   </xsd:choice>
> </xsd:complexType>

This type has mixed content and the text that may appear between
elements is not stored in the object model. There are two ways to 
handle mixed content in C++/Tree: You can use the DOM association
feature to access the data via the DOM interface. Or you can use
type customization to implement custom parsing, storage, and 
serialization of mixed content, depending on your application
requirements.

The DOM association approach, while simple, does not support 
serialization. For more information, see the 'mixed' example in 
the examples/cxx/tree/ directory.

The type customization approach requires a bit more work but is much 
more flexible. Seeing that there were a few similar questions in the
past, I created an example based on your use case. It will appear in
the next release of XSD and you can also download it separately for 
3.2.0:

With Linux/UNIX makefile:

  http://www.codesynthesis.com/~boris/tmp/xsd-3.2.0-custom-mixed.tar.gz

With MS VC++ projects/solutions:

  http://www.codesynthesis.com/~boris/tmp/xsd-3.2.0-custom-mixed.zip

Simply unpack the contents of one of these archives into your XSD 
distribution directory.

The example includes the README file and does something very similar to 
what you are trying to achieve. Let us know if you have any questions
or run into any problems.

Boris




More information about the xsd-users mailing list