[xsd-users] XSD wildcard content

Boris Kolpackov boris at codesynthesis.com
Thu Jun 25 23:09:23 EDT 2009


Hi Krzysztof,

Krzysztof Mariański <kmarianski at mikronika.com.pl> writes:

>    <Private type="aaa" source="dd">cant read this value</Private>
>
> [...]
>
> Element 'Private' has element 'any' with sequence cardinality class (see  
> attached schema).
> Problem is I cannot read a value of <Private> element.
> I can't also write (serialize) such an element, because in code  
> (according to  
> http://codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/#2.12.3) 
> I must create element, which I don't want to do. If I create element  
> (for example <dummy>) and then set its text content I get something like  
> this:
>    <Private type="aaa" source="dd">
>       <dummy>some value</dummy>
>    </Private>
>
> Is there any possibility to get rid of 'dummy' and to write (and read!)  
> the value directly to 'Private' element?

The reason why the 'Private' element can have text content (the one
which you want to read/write) is because it has mixed content, not 
because it has the 'any' wildcard.

The recommended way to handle types with mixed content in C++/Tree
is to customize them and read/write the data using the DOM interface
in the parsing c-tor and in the serialization operator, respectively.

For more information on type customization see the C++/Tree Mapping 
Customization Guide:

http://wiki.codesynthesis.com/Tree/Customization_guide

As well as the examples in the examples/cxx/tree/custom/ directory.
The 'wildcard' example in this directory does something very
similar to what you want to do so your can use it as a reference
point.

Boris






More information about the xsd-users mailing list