W3C home > Mailing lists > Public > xmlschema-dev@w3.org > September 2003

Re: Restricting two attributes to be unequal

From: Jeni Tennison <jeni@jenitennison.com>
Date: Sat, 27 Sep 2003 11:17:23 +0100
Message-ID: <97659586455.20030927111723@jenitennison.com>
To: "Brett Randall" <brett_s_r@hotmail.com>
Cc: xmlschema-dev@w3.org

Hi Brett,

> What I would like to do firstly is to prevent attribute values
> "from" and "to" from being equal in documents based on this schema,
> forcing them to be unequal. A unique or key won't do as I want to
> force uniqueness over two attributes.
> Out of interest, if I can force them to be unequal, can I also force
> from<to?

You can do neither with XML Schema; of the schema languages currently
available, only Schematron is expressive enough for this kind of
constraint. For example, you can use the Schematron rule:

  <sch:rule context="myelement">
    <sch:assert test="@from &lt; @to">
      The value of the from attribute must be less than the value of
      the to attribute.

See http://www.topologi.com/resources/schtrn_xsd_paper.html to learn
how to embed Schematron into XML Schema so that tools such as
Topologi's Schematron Validator can automatically validate against



Jeni Tennison
Received on Saturday, 27 September 2003 06:17:39 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:15:13 UTC