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

Re: Identity constraint on two attribute values

From: Jeni Tennison <jeni@jenitennison.com>
Date: Wed, 17 Jul 2002 10:01:30 +0100
Message-ID: <75940630545.20020717100130@jenitennison.com>
To: "Kasim Rehman" <kr241@cam.ac.uk>
CC: xmlschema-dev@w3.org

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.

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


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

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:55:57 UTC