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

XML Schema Question

From: Asleson, Ryan <asleson@BIWORLDWIDE.com>
Date: Mon, 23 Aug 2004 07:42:38 -0500
Message-ID: <6D46CCFBEB83D21199EB0001FAD4E4EE0FBDE2FE@mail5.biperf.com>
To: "'xmlschema-dev@w3.org'" <xmlschema-dev@w3.org>


My apologies if this isn't the correct place to ask this question, but I
didn't know where else to go.  

Suppose I have a simple XML document that looks like this:

<?xml version="1.0"?>

The above XML is successfully validated by the schema shown below:

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

    <xs:element name="father" type="xs:string"/>
    <xs:element name="mother" type="xs:string"/>
    <xs:element name="son" type="xs:string"/>
    <xs:element name="daughter" type="xs:string"/>
    <xs:element name="pet" type="xs:string"/>
    <xs:element name="family">
                <xs:element ref="father" minOccurs="0"/>
                <xs:element ref="mother" minOccurs="0"/>
                <xs:element ref="son" minOccurs="0" maxOccurs="unbounded"/>
                <xs:element ref="daughter" minOccurs="0"
                <xs:element ref="pet" minOccurs="0" maxOccurs="unbounded"/>

However, if the XML document is changed so that the "pet" element occurs
before the "daughter" element, a validation error is thrown.  The error
states that all instances of "pet" must occur after any instances of

This is the problem.  I don't want the order of child elements within the
"family" element to matter, or be validated.  I don't care what order the
father, mother, son, daughter, and pet tags are in, nor do I want to
validate the order.

How can I specify this in the XML schema?  According to the documentation
I've seen, the complexType tag must use an occurrence indicator of all,
choice, or sequence.  All might work, since order doesn't matter, but
apparently it specifies that each child element can occur once and only once
once, which doesn't work.  Choice doesn't work because only one of the
elements can appear.  Sequence might work because it allows me to specify
multiple occurrences of child elements, but it enforces the order of the
child elements, which I don't want.

How can I specify this complex type in the XML schema?  I'm sure it can be
done, I'm just not sure how.

Thank you very much!!

This e-mail message is being sent solely for use by the intended recipient(s) and may contain confidential information.  Any unauthorized review, use, disclosure or distribution is prohibited.  If you are not the intended recipient, please contact the sender by phone or reply by e-mail, delete the original message and destroy all copies. Thank you.
Received on Monday, 23 August 2004 12:44:41 UTC

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