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

Variation depending on attribute value

From: Camilla Brenchley <cbrenchley@transhotel.com>
Date: Mon, 4 Aug 2003 13:17:42 +0200
To: "Xmlschema-Dev" <xmlschema-dev@w3.org>
Message-ID: <JKEGLBMFMFBPIFCOOHHJGEFMCAAA.cbrenchley@transhotel.com>

Hi all,

Given the below schema, is it possible to specify that if the attribute
"Type" equals "Double" then the element "WithDoubleBed" is required, i.e.
minOccurs="1", and if it equals "DoubleOneChild" then the element "ChildAge"
is required?

Thanks in advance,
Camilla


<?xml version="1.0" encoding="windows-1252"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema">

<element name="TestRoom">
   <complexType>
	<all>

        <element name="Room">
          <complexType>

            <all>
              <element name="WithDoubleBed" type="string" minOccurs="0"/>
              <element name="ChildAge" type="integer" minOccurs="0"/>
            </all>

            <attribute name="Type" use="required">
              <simpleType>
                <restriction base="string">
                  <enumeration value="Single"/>
                  <enumeration value="Double"/>
                  <enumeration value="DoubleOneChild"/>
                </restriction>
              </simpleType>
            </attribute>

          </complexType>
        </element>

	</all>
   </complexType>
</element>

</schema>
Received on Monday, 4 August 2003 07:20:27 GMT

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