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,

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

<element name="TestRoom">

        <element name="Room">

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

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



Received on Monday, 4 August 2003 07:20:27 UTC

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