xs:all - why is minOccurs, maxOccurs restricted to "0" or "1" for child xs:element ?

I've run into an issue when trying to define a schema for some XML based file-formats we developed a while ago (before the official XMLSchema was released).

We have one particular file that is shown as a tree view in a Windows application.  Each tree node maps to an XML element.  We had rules for what children each node could have (as well as what properties).  We don't enforce any order of these children, but sometimes we restricted effectively the "minOccurs" and "maxOccurs" of these children.

For example, we might have:

<Edge>
	<Material ... />
	<Texture ... />
	<Texture ... />
</Edge>

The rule in this particular case was that "Material" shows up exactly once, and "Texture" shows up 1 or 2 times.  These could be in any order (M-T-T, or T-M-T, or M-T, etc.).  Another example might be:

<RandPopAreal>
	<Elevation ... />
	<Point model="tree1.rgb"/>
	<Point model="tree2.rgb"/>
	<Point model="tree3.rgb"/>
	<Light ... />
	<Point model="tree4.rgb"/>
	<Point model="tree5.rgb"/>
	<Light ... />
	<Point model="tree6.rgb"/>
	<Point model="tree7.rgb"/>
</RandPopAreal>

Where let's say that "Elevation" has to show up exactly once, "Light" can show up 2-6 times, and "Point" can show up unbounded, and these can be in any order.

What I'd like to be able to say is something like:

 <xs:element name="Edge">
  <xs:complexType>
   <xs:all>
    <xs:element ref="Material" minOccurs="1" maxOccurs="1"/>
    <xs:element ref="Texture" minOccurs="1" maxOccurs="2"/> 
   </xs:all>
  </xs:complexType>
 </xs:element>
 <xs:element name="RandPopAreal">
  <xs:complexType>
   <xs:all>
    <xs:element ref="Point" minOccurs="0" maxOccurs="unbounded"/>
    <xs:element ref="Light" minOccurs="2" maxOccurs="6"/>
    <xs:element ref="Elevation" minOccurs="1" maxOccurs="1"/>
   </xs:all>
  </xs:complexType>
 </xs:element>


The problem is that minOccurs and maxOccurs for <xs:element> under <xs:all> have to be "0" or "1".  It seems that the Schema's definition of <xs:group name="allModel"> ... is the part that's placing this restriction.  Is there some fundamental reason why <xs:all> places such restrictions on the child element's minOccurs and maxOccurs?  Or is there another way to define the schema to have the same effect that I'm after?

I know that in the first case, I could spell out a "sequence of choices" and spell out all the possible combinations of order, but for the 2nd case and others that would be prohibitive.

If you're wondering why we need this "any order" requirement, there are several reasons.  One for example, is that the user wants to sort the children by name or some other property.  Another is that they want to group disparate types together for some reason.  And another would be that order mattered, but it needed more than a single sequence. And I'm sure there are others.

Thanks!
-Daniel

Received on Wednesday, 27 March 2002 18:47:04 UTC