xml schemas - work around the min=1 max=1 in the 'all' group

E

edkawas

Hi,

Can the following be done?

I have some elements, that can have other sub elements with mixed
content.

The sub elements can either be restricted via min=1, max=1 or min=1
max=unbounded.

The order of the sub elements is not important and will vary.

Examples of an instance are,

<foo>
<boo>bob is my uncle</boo>
<soo>64<soo>
<foo>

or

<foo>
<soo>64<soo>
<boo>bob is my uncle</boo>
<foo>

or

<foo>
<soo>64<soo>
<soo>64<soo>
<soo>64<soo>
<soo>64<soo>
<soo>64<soo>
<boo>bob is my uncle</boo>
<foo>

or

<foo>
<soo>64<soo>
<boo>bob is my uncle</boo>
<soo>64<soo>
<soo>64<soo>
<soo>64<soo>
<soo>64<soo>
<foo>

Notice how boo is bound with the restriction min=max=1
and soo is >=1!

I am pretty new to schemas, but I do believe that the only way to do
this is something like the following:

....
<xsd:element name="soo" type="xsd:int" />
<xsd:element name="boo" type="xsd:string" />

<xsd:element name="foo">
<xsd:complexType>
<xsd:choice>
<xsd:sequence>
<xsd:element ref="soo" minOccurs="1" maxOccurs="unbounded" />
<xsd:element ref="boo" minOccurs="1" maxOccurs="1" />
</xsd:sequence>
<xsd:sequence>
<xsd:element ref="boo" minOccurs="1" maxOccurs="1" />
<xsd:element ref="soo" minOccurs="1" maxOccurs="unbounded" />
</xsd:sequence>
</xsd:choice>
</xsd:complexType>
</xsd:element>
....

Do i really have to enumerate through all of the possibilities? I hope
not, because when the number of children of foo grows (let the number
of children = n), the possibilities would be n! There has to be
something that i am missing.

Any ideas?

Thanks,

Eddie
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top