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

Re: is it possible in a schema

From: Jeni Tennison <jeni@jenitennison.com>
Date: Tue, 9 Apr 2002 18:09:07 +0100
Message-ID: <53639335115.20020409180907@jenitennison.com>
To: Rob Tice <rob.tice@fdgroup.com>
CC: "'xmlschema-dev@w3.org'" <xmlschema-dev@w3.org>
Hi Rob,

> I have a list of 5 elements. I want to have at least 2 of them
> appearing. With none of them appearing twice.
>
> Is there a cleann way of defining this other than defining a choice
> between each possible combination!!

Aside from defining a choice between each possible combination, your
best bet is to create a more generous model:

  <xs:choice minOccurs="2">
    <xs:element name="E1" />
    <xs:element name="E2" />
    <xs:element name="E3" />
    <xs:element name="E4" />
    <xs:element name="E5" />
  </xs:choice>

and then use Schematron to report whether there's more than one of the
same element:

<sch:rule context="*">
  <sch:report test="preceding-sibling::*[name() = name(current())]">
    There's more than one <sch:name /> element.
  </sch:report>
</sch:rule>

See http://www.topologi.com/public/Schtrn_XSD/Paper.html for details
about how to incorporate Schematron rules into XML Schema schemas.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/
Received on Tuesday, 9 April 2002 13:09:13 GMT

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