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:


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


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


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" />

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 test="a/following-sibling::*[1][self::b]">
    Every a must be followed by a b
  <sch:assert test="b/following-sibling::*[1][self::a]">
    Every b must be followed by an a

Or of course with natural language documentation.



Jeni Tennison
Received on Sunday, 17 February 2002 03:38:40 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:14:59 UTC