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

Re: Beginner question : complex cross field/attribute validation possible ?

From: Jeni Tennison <jeni@jenitennison.com>
Date: Sun, 11 Aug 2002 16:05:33 +0100
Message-ID: <148302478841.20020811160533@jenitennison.com>
To: "Frank Langel" <frank.langel@webmethods.com>
CC: xmlschema-dev@w3.org

Hi Frank,

> i looked into the XML Schema specs, but i am not sure if a
> validation rule such as
> - for instance : if field a==21 and b==32 and field x==field z then
> c must be not null)
> can be expressed in XML Schema ?

No, it can't. This is what's known as a co-occurrence constraint,
where the values or presence of particular elements or attributes
influence the value of another element or attribute (or whether it can
be present). It's one of the areas where XML Schema is particularly

However, you can embed Schematron rules in your XML Schema to test
this kind of thing. Schematron rules use XPath syntax, so your test
might be something like:

  <sch:report test="(a = 21 and b = 32 and x = z) and
    a is 21, b is 32, x equals z, but c doesn't have a value.

[Here assuming that "c must be not null" means "c must have a string

Have a look at Topologi's Schematron validator and Eddie's description
of how to incorporate Schematron into XML Schema at



Jeni Tennison
Received on Sunday, 11 August 2002 11:05:39 UTC

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