Re: Identity constraint on two attribute values

Hi Kasim,

> Is there a way to say that two attribute values of attributes in an
> element are not supposed to be the same. My two attributes are both
> references to the same pool of keys. Those keys are ids of a complex
> type. Specifically, my element describes an arc, that has references
> to two points as its "from" and "to" attributes. I don't want the
> arc to have the same starting and end point.

No, not in XML Schema. You could supplement your XML Schema with some
Schematron (see http://www.topologi.com/public/Schtrn_XSD/Paper.html)
to do the test, something like:

  <sch:rule context="arc">
    <sch:assert test="@from != @to">
      The 'from' and 'to' attributes must have different values.
    </sch:assert>
  </sch:rule>

This acts as documentation in the schema for future users, and enables
you to use Topoligi's Schematron validator to test your XML documents.
  
Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/

Received on Wednesday, 17 July 2002 05:01:32 UTC