Re: mixing childs in any order and any quantity

(Fermín wrote:)
> >Consider a <book> element whose content can
> >be up to one <title> (minOccurs=0, maxOccurs=1), up to one <author>
> >(minOccurs=0, maxOccurs=1) and many <chapter> (minOccurs=0,
> >maxOccurs=unbounded) that comes together, but combining child tags in any
> >order.
> >How would be the XML Schema definition for such <book> element, please?
>
(Ken wrote:)
> As I see it, you are obliged to make the effort
> to enumerate the combinations in a fashion that
> is not ambiguous.  For your above example, the
> following shorthand notation would describe the content of book:
>
>  title, ( ( chapter+, author ) | ( author, chapter+ ) )

If <book> can be empty and any of the three components (<title>,
<author> and <chapter>) can be left out, I guess the shortest way to
express the rules for <book> in a W3C schema (without violating the
UPA-restriction) would be something like:

book :
(
( title, ( ( author, chapter* ) | ( chapter+, author? ) )? )
|
( author, ( ( title, chapter* ) | ( chapter+,  title? ) )? )
|
( chapter+, ( ( title, author? ) | ( author, title? ) )? )
)?

A total, unambiguous enumeration like this is very hard to read and
understand. Comparing this example to how easy the original
description of a <book>-element was to understand, makes a nice
example of how difficult it sometimes can be to express W3C schema
rules and to communicate them to human xml-users (e.g. authors editing
xml-data). I have additional examples of this conflict (precision vs.
understandability), if anyone should be interested :o)

-Marie

-------------------------
Marie Bilde Rasmussen, MA, BSc
Gyldendal Publishers, Dictionaries
(Copenhagen, DENMARK)
-------------------------

Received on Friday, 6 October 2006 14:45:45 UTC