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

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 UTC