W3C home > Mailing lists > Public > xmlschema-dev@w3.org > January 2006

Re: optional, but at least one required

From: Vegard McFadzean <vmcfadzean@gmail.com>
Date: Wed, 04 Jan 2006 22:08:52 -0700
Message-ID: <43BCA9E4.2040103@gmail.com>
CC: xmlschema-dev@w3.org

Use a 'group' for the 'a', 'b', and 'c' element definitions and 
reference this 'group' in the 'options' element definition:

    <?xml version="1.0" encoding="UTF-8"?>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <xsd:element name="options">
            <xsd:complexType>
                <xsd:sequence>
                    <xsd:group ref="optionsGroup"/>
                </xsd:sequence>
            </xsd:complexType>
        </xsd:element>
        <xsd:group name="optionsGroup">
            <xsd:choice>
                <xsd:element name="a"/>
                <xsd:element name="b"/>
                <xsd:element name="c"/>
            </xsd:choice>
        </xsd:group>
    </xsd:schema>

Brian Bonner wrote:
> Hello,
>
> Is there a way through restrictions or xmlschema in general to create
> the following criteria?
>
> <options>
>      <a></a>
>      <b></b>
>      <c></c>
> </options>
>
> where the rule is that a, b and c are all optional, but at least one
> of a, b or c is required.
>
> Thanks.
>
> Brian
>
>
>
>   
Received on Friday, 6 January 2006 04:54:45 GMT

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