W3C home > Mailing lists > Public > www-xml-schema-comments@w3.org > April to June 2003

<all> is too restrictive.

From: by way of <alex@aoi.dyndns.org>
Date: Mon, 23 Jun 2003 09:23:16 -0600
Message-Id: <5.1.0.14.1.20030623092304.02e0ba20@localhost>
To: W3C XML Schema Comments list <www-xml-schema-comments@w3.org>
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, 23 June 2003 13:05:36 UTC

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