W3C home > Mailing lists > Public > xmlschema-dev@w3.org > February 2002

Re: how does one represent an alternating set of elements?

From: Jeni Tennison <jeni@jenitennison.com>
Date: Sun, 17 Feb 2002 08:38:37 +0000
Message-ID: <1313048773.20020217083837@jenitennison.com>
To: John Utz <utz@singingfish.com>
CC: "G. Ken Holman" <gkholman@CraneSoftwrights.com>, xmlschema-dev@w3.org
Hi John,

I believe that this an example of a (or possibly the only)
non-deterministic content model that cannot be disambiguated. It is
the same as the "chess problem" (you need a sequence of moves of
white, then black, repeated a number of times, ending with either
white or black) that was described on XML-Dev last June. See:

  http://www.oasis-open.org/cover/determinism200106.html

The full thread, where deterministic content models are discussed with
the usual XML-Dev thoroughness, is here:

  http://lists.xml.org/archives/xml-dev/200106/msg00307.html

And a white paper written by Sam Wilmott from Omnimark, which
demonstrates that this content model is irreducible is here:

  http://www.oasis-open.org/cover/omnimarkContentModelAlgebra200101.html

Either RELAX NG or Schematron deal with this problem fine because they
don't require deterministic content models. I'd probably use the
closest content model that you can get for the XML Schema schema,
which is probably:

  <xsl:choice maxOccurs="unbounded">
    <xs:element ref="a" />
    <xs:element ref="b" />
  </xsl:choice>

And add supplementary tests within a Schematron schema adjunct:

  <sch:assert test="*[1][self::a]">
    The first element must be an a element
  </sch:assert>
  <sch:assert test="a/following-sibling::*[1][self::b]">
    Every a must be followed by a b
  </sch:assert>
  <sch:assert test="b/following-sibling::*[1][self::a]">
    Every b must be followed by an a
  </sch:assert>

Or of course with natural language documentation.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/
Received on Sunday, 17 February 2002 03:38:40 GMT

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