[xsd-users] bug (?) with choice of two sequences with same element

Boris Kolpackov boris at codesynthesis.com
Thu Jan 5 07:44:18 EST 2006


Eelko,

Eelko de Groot <efdegroot at corp.csnet.nl> writes:

> When a schema contains a choice of two sequences of elements and both
> sequences contain the same element, the xsd tool produces two
> classes/structs with the same name.

Yes, this is not supported yet. But even when it is supported, it
won't be pretty; the second element will be renamed to something
like ElementB1.


> Is there a solution for this?

While your schema is legal per the spec, using the same element name
more than once in a single type definition is not generally considered
a very good idea. I personally haven't seen a single instance of such
design where it would make sense. I would therefore suggest that you
use some other name for the second element.

If you absolutely must use the same name, you can create a "relaxed"
copy of your schema and use it for code generation (while using the
original schema for validation, if any), e.g.:


<complexType name="TestChoiceType">
  <choice>
    <sequence>
      <element name="ElementA" type="string"/>
      <element name="ElementB" type="string" minOccurs="1" maxOccurs="2"/>
    </sequence>
  </choice>
</complexType>


hth,
-boris
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 652 bytes
Desc: Digital signature
Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20060105/47be1e27/attachment.pgp


More information about the xsd-users mailing list