W3C home > Mailing lists > Public > xmlschema-dev@w3.org > October 2006

Re: mixing childs in any order and any quantity

From: Marie Bilde Rasmussen <mariebilderas@gmail.com>
Date: Fri, 6 Oct 2006 16:45:36 +0200
Message-ID: <c36097090610060745q7fa95cf3t1627e82a057d8550@mail.gmail.com>
To: "G. Ken Holman" <gkholman@cranesoftwrights.com>
Cc: xmlschema-dev@w3.org

(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 Bilde Rasmussen, MA, BSc
Gyldendal Publishers, Dictionaries
(Copenhagen, DENMARK)
Received on Friday, 6 October 2006 14:45:45 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:55 GMT