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.



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

Jeni Tennison
Received on Tuesday, 29 October 2002 10:34:36 UTC

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