Forum Moderators: open

Message Too Old, No Replies

XML Schema: Choices and Sequences

         

matthewwithanm

4:01 pm on Mar 27, 2008 (gmt 0)

10+ Year Member



Could somebody please tell me the difference between this:

<xs:complexType name="A">
<xs:choice minOccurs="0" maxOccurs="5">
<xs:element name="foo" />
<xs:element name="bar" />
</xs:choice>
</xs:complexType>

and this:

<xs:complexType name="A">
<xs:sequence minOccurs="0" maxOccurs="5">
<xs:choice>
<xs:element name="foo" />
<xs:element name="bar" />
</xs:choice>
</xs:sequence>
</xs:complexType>

They both seem to validate documents the same, however the first option causes xsddoc to list "foo" and "bar" as elements whereas with the second "A.foo" and "A.bar" are listed under complexTypes instead.

Are the two somehow different or is this just a quirk of the documentation tool?

Thanks!

httpwebwitch

7:28 pm on Apr 2, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Though the two are different, they do essentially the same thing. The <xs:choice> renders the <xs:sequence> irrelevant. Since each element in a sequence can be either "foo" or "bar", it doesn't make sense to insist that they be in a particular order... the difference is subtle and probably inconsequential.

So it's not really a quirk of your documentation tool, it's a quirk of defining Schema in a weird sort of redundant way