OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   XML Schema Question: specifying restrictions for a list of elements

[ Lists Home | Date Index | Thread Index ]
  • To: <xml-dev@lists.xml.org>
  • Subject: XML Schema Question: specifying restrictions for a list of elements
  • From: "Peter Loh Yoon Chao" <yoonchao@starhub.net.sg>
  • Date: Wed, 7 Apr 2004 20:23:13 +0800
  • Importance: Normal
  • In-reply-to: <830178CE7378FC40BC6F1DDADCFDD1D1023870B4@RED-MSG-31.redmond.corp.microsoft.com>

Hi,

I have the following construct in my XML document:

        <computer_list>
          <computer default="true">Dell</do_type>
          <computer>HP</do_type>
        </computer_list>

Only 1 of <computer> can have the "default" attribute set to true.  I am
trying to specify the corresponding XML schema to enforce this.  I tried the
following among other variations:

                    <xs:element name="computer_list">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element maxOccurs="unbounded" name="computer">
                            <xs:complexType>
                              <xs:simpleContent>
		        <xs:restriction base="xs:string">
		          <xs:enumeration value="Dell"/>
		          <xs:enumeration value="HP"/>
		        </xs:restriction>
                                <xs:extension base="xs:string">
                                  <xs:attribute name="default"
type="xs:boolean" use="optional" />
                                </xs:extension>
                              </xs:simpleContent>
                            </xs:complexType>
                          </xs:element>
                        </xs:sequence>
                      </xs:complexType>
                    </xs:element>

The above suffers from the following problems:
1.)  It allows the "default" attribute to be set to true for any number of
<computer>.
2.)  With the <xs:restriction> element, the parser complained that "Element
'extension' is invalid, misplaced, or occurs too often."

Would really appreciate any input as to the modifications required to
achieve my objectives.  Thanks.

Peter





 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS