W3C home > Mailing lists > Public > xmlschema-dev@w3.org > March 2005

Either-Or elements

From: <RPearse@360commerce.com>
Date: Mon, 21 Mar 2005 13:02:04 -0600
To: xmlschema-dev@w3.org
Message-ID: <OF327F5B93.E7D784AF-ON86256FCB.0067DC5C-86256FCB.00688FAC@360commerce.com>
Using a DTD, I can specify that the something element can only have foo or 
bar, but not both with this: <!ELEMENT something ((foo|bar)*)>

In an XSD, I would have this:

<?xml version="1.0"?>

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<xsd:element name="something" type="somethingType" />

<xsd:complexType name="somethingType">
                <xsd:element name="foo" minOccurs="1" maxOccurs="1" />
                <xsd:element name="bar" minOccurs="1" maxOccurs="1" />

How would I specify that the user has to have the foo or bar element, but 
not both? Currently, this XSD seems to require that you have exactly one 
foo and one bar in your instance document.


Received on Tuesday, 22 March 2005 04:57:24 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:56:07 UTC