W3C home > Mailing lists > Public > xmlschema-dev@w3.org > November 2004

Re: Combining maxOccurs="unbounded" with all indicator

From: Jeni Tennison <jeni@jenitennison.com>
Date: Mon, 1 Nov 2004 13:26:53 +0000
Message-ID: <333399071.20041101132653@jenitennison.com>
To: Frans Englich <frans.englich@telia.com>
CC: "Xmlschema-dev" <xmlschema-dev@w3.org>

Hi Frans,

> How do I achieve this -- allow multiple unbounded elements to be
> freely mixed with each others and simple elements?

This is probably the most frequent of FAQs.

DTDs have a similar restriction, and the traditional approach is to
define the model using something like:

  ((include | group)*, kcfgfile, (include | group)*)

However, this allows zero <include> or <group> elements. To get the
minimum of one for both of these elements requires a content model
that's really quite complex, although if you use groups that will make
it easier to specify.

Another approach is to accept that you can't express this constraint
using XML Schema and instead use a more forgiving content model, such

  (include | kcfgfile | group)*

and express the extra constraints about the number of times each of
these elements can appear in a separate schema language, such as

Or you can define the content model with order constrained, as in:

  (include+, kcfgfile, group+)

and use a (XSLT) transformation to get from your unordered XML to an
ordered XML which you then validate against the schema.

Or you can change your markup language so that you only accept the
elements in a constrained order.

Or you can change your schema language to RELAX NG, which supports
this kind of constraint very easily.



Jeni Tennison
Received on Monday, 1 November 2004 13:26:58 UTC

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