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

Re: multiple xsd:attributes problem

From: Jeni Tennison <jeni@jenitennison.com>
Date: Tue, 29 Oct 2002 15:34:30 +0000
Message-ID: <38251490594.20021029153430@jenitennison.com>
To: "Wood, Marcus" <Marcus.Wood@egg.com>
CC: "'xmlschema-dev@w3.org'" <xmlschema-dev@w3.org>

Hi Marcus,

> I'm trying to implement a solution using xml schemas. The problem I
> am having is one concerend with xsd:attributes. I would like to know
> how, if possible you can declare two attributes but only require one
> or other but not both.

I'm afraid that you can't do this using XML Schema without using a
workaround such as saying that the elements with different attributes
are of different types, and using xsi:type in the instance document to
say which of the two they actually are. (Let us know if you want to
see that in action.)

Your best bet is to switch to RELAX NG [1] instead, where you can just
use a <choice> between the two attributes, or to combine your XML
Schema schema with some Schematron rules [2] that test whether both
attributes are present.

Cheers,

Jeni

[1] http://www.relaxng.org/
[2] http://www.topologi.com/public/Schtrn_XSD/Paper.html

---
Jeni Tennison
http://www.jenitennison.com/
Received on Tuesday, 29 October 2002 10:34:36 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:34 GMT