[xsd-users] Limiting the "depth" of serialized objects

Boris Kolpackov boris at codesynthesis.com
Tue Oct 12 07:56:16 EDT 2010


Hi Gene,

Falendysz, Gene <Gene.Falendysz at itron.com> writes:

> I have an object that has as an element a list. Currently when I serialize
> this object it serializes each of the elements in the list with all of 
> their sub-elements. What I require is that only the href of the list
> elements gets included in the serialization of the main object.

You can get this behavior by customizing the sub-element's type (Egg in
the your example) and providing your own serialization operator. Your
own implementation would need to somehow decide when to serialize the
complete object and when to only write the href attribute. It seems 
that checking whether the element to which we are serializing is the
root of the document will do the trick in your case.

The 'wildcard' example in the examples/cxx/tree/custom/ directory of the
XSD distribution shows how to customize a type and its serialization
operator. See also the C++/Tree Mapping Customization Guide:

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

Boris



More information about the xsd-users mailing list