[xsd-users] XSD::choice
Boris Kolpackov
boris at codesynthesis.com
Wed Oct 3 14:13:22 EDT 2007
Hi Shiva,
Balasubramanyam, Shivakumar <sbalasub at qualcomm.com> writes:
> I am looking for documentation or examples that shows the usage of
> xs:choice type.
As you have mentioned below, xs:choice itself does not have a
representation in the generated code. Instead, elements inside
choice are marked as optional.
> I have a choice type of two elements; looking at the generated code this
> is no different than two optional elements.
>
> If schema validation is turned off, does code synthesis allow both types
> to be populated?
Yes. The generated code contains only a minimal amount of checks that
make sure the resulting object model is consistent (that is, your
application won't crash when you try to access it).
> Or my question is, whose job is it to validate that only one of these
> types need to be populated.
In the C++/Tree mapping, if your XML documents may be invalid, you need
to turn on XML Schema validation.
We are also working on a new hybrid mapping that will be similar to
C++/Tree and will have XML Schema validation implemented in the
generated code.
Boris
More information about the xsd-users
mailing list