<all> is too restrictive.

At present, particles within <all> must have a maxOccurs of 0 or 1, and <all>
may not contain <group>, <choice>, <sequence>, or <any>.

I feel this is excessively restrictive. Consider the following document
snippet:

<some-element xmlns="http://example.com/some/namespace">
	<foo />
	<baz />
	<bar>
		<one />
		<two />
	</bar>
	<xyzzy xmlns="http://example.com/some/other/namespace" />
	<baz />
</some-element>

Now, say <some-element> must contain <foo>, optionally <bar>, and any number
of <baz>, but we want to allow these elements to occur in any order. Also say
we want to allow any elements with other namespaces to be freely interspersed
among these elements.

I would think to put together an XML Schema <element> like so:

<xs:element name="some-element">
	<xs:complexType><xs:all>
		<xs:element ref="foo" />
		<xs:element ref="bar" minOccurs="0" />
		<xs:element ref="baz" minOccurs="0" maxOccurs="unbounded" />
		<xs:any minOccurs="0" maxOccurs="unbounded" namespace="##other"
			processContents="skip" />
	</xs:all></xs:complexType>
</xs:element>

Surprise! That doesn't work. There's <choice>, but that doesn't allow us to
specify that <foo> is mandatory, and <bar> may not occur more than once,
while at the same time allowing any number of <baz> and elements from other
namespaces. I'm probably missing something, but it doesn't look like XML
Schema 1.0 allows for describing that without something absurd like this:

<xs:element name="some-element">
	<xs:complexType>
		<xs:choice>
			<xs:sequence>
				<xs:any minOccurs="0" maxOccurs="unbounded" namespace="##other"
					processContents="skip" />
				<xs:element ref="foo" />
				<xs:any minOccurs="0" maxOccurs="unbounded" namespace="##other"
					processContents="skip" />
				<xs:element ref="bar" minOccurs="0" />
				<xs:any minOccurs="0" maxOccurs="unbounded" namespace="##other"
					processContents="skip" />
				<xs:element ref="baz" minOccurs="0" maxOccurs="unbounded" />
				<xs:any minOccurs="0" maxOccurs="unbounded" namespace="##other"
					processContents="skip" />
			</xs:sequence>
			<xs:sequence>
				<xs:any minOccurs="0" maxOccurs="unbounded" namespace="##other"
					processContents="skip" />
				<xs:element ref="bar" minOccurs="0" />
				<xs:any minOccurs="0" maxOccurs="unbounded" namespace="##other"
					processContents="skip" />
				<xs:element ref="foo" />
				<xs:any minOccurs="0" maxOccurs="unbounded" namespace="##other"
					processContents="skip" />
				<xs:element ref="baz" minOccurs="0" maxOccurs="unbounded" />
				<xs:any minOccurs="0" maxOccurs="unbounded" namespace="##other"
					processContents="skip" />
			</xs:sequence>
			......
		</xs:choice>
	</xs:complexType>
</xs:element>

Not only is this ugly even in this small example, but as the size of this
construct increases exponentially with the number of described child elements
of <some-element>, it is not scalable, either. The real-world schema I've
been working on would probably be hundreds of megabytes in size.

Alex.

Received on Monday, 7 July 2003 16:49:47 UTC