Re: is it possible in a schema

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 UTC