[XMLSCHEMA-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Either-Or elements

From: Stan Kitsis <skits@microsoft.com>
Date: Mon, 21 Mar 2005 21:20:57 -0800
Message-ID: <15A5AEEF6D717C4FB7D010F14B5C752901D319C3@RED-MSG-43.redmond.corp.microsoft.com>
To: <RPearse@360commerce.com>, <xmlschema-dev@w3.org>
RE: Either-Or elements

<xsd:complexType name="somethingType"> 
        <xsd:choice> 
                <xsd:element name="foo" /> 
                <xsd:element name="bar" /> 
        </xsd:choice> 
</xsd:complexType> 

 
________________________________

From: xmlschema-dev-request@w3.org on behalf of RPearse@360commerce.com
Sent: Mon 3/21/2005 11:02 AM
To: xmlschema-dev@w3.org
Subject: Either-Or elements



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:sequence> 
                <xsd:element name="foo" minOccurs="1" maxOccurs="1" /> 
                <xsd:element name="bar" minOccurs="1" maxOccurs="1" /> 
        </xsd:sequence> 
</xsd:complexType> 

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. 

Thanks, 

Robert 
Received on Tuesday, 22 March 2005 05:21:53 GMT

Subscribe to the Stylus Scoop newsletter for helpful XML tips and tutorials.
Email
First Name
Last Name
Company

Download Stylus Studio 6 XML Enterprise Edition

Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.