W3C home > Mailing lists > Public > xmlschema-dev@w3.org > March 2002

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

From: <dbowen@es.com>
Date: Wed, 27 Mar 2002 16:46:33 -0700
Message-ID: <AFE3FBA300B6F04282BE07949DB2E123A4184B@TORINO.corp.es.com>
To: <xmlschema-dev@w3.org>
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:

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

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:

	<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"/>

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:element ref="Material" minOccurs="1" maxOccurs="1"/>
    <xs:element ref="Texture" minOccurs="1" maxOccurs="2"/> 
 <xs:element name="RandPopAreal">
    <xs:element ref="Point" minOccurs="0" maxOccurs="unbounded"/>
    <xs:element ref="Light" minOccurs="2" maxOccurs="6"/>
    <xs:element ref="Elevation" minOccurs="1" maxOccurs="1"/>

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.

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

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:55:55 UTC