Re: Combining maxOccurs="unbounded" with all indicator

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
as:

  (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
Schematron.

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.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/

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