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


Help: OASIS Mailing Lists Help | MarkMail Help



   RE: [xml-dev] XML Schema Question: specifying restrictions for a list of

[ Lists Home | Date Index | Thread Index ]

Peter, I don't know if this can be done in XSD, but here is a RELAX NG
schema ( compact syntax ) that can handle it:

start  = computer_list
computer_list = element computer_list { computer*  &  computerDefault }
computer = element computer { computerNames }
computerDefault = element computer { attribute default { xsd:boolean },
computerNames }
computerNames =  'HP' | 'Dell' 

You can interleave ('&' connector) the single 'computer with default
attribute' with one or more 'computers without default attribute'.


-----Original Message-----
From: Peter Loh Yoon Chao [mailto:yoonchao@starhub.net.sg] 
Sent: Wednesday, April 07, 2004 8:23 AM
To: xml-dev@lists.xml.org
Subject: [xml-dev] XML Schema Question: specifying restrictions for a list
of elements


I have the following construct in my XML document:

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

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:element maxOccurs="unbounded" name="computer">
		        <xs:restriction base="xs:string">
		          <xs:enumeration value="Dell"/>
		          <xs:enumeration value="HP"/>
                                <xs:extension base="xs:string">
                                  <xs:attribute name="default"
type="xs:boolean" use="optional" />

The above suffers from the following problems:
1.)  It allows the "default" attribute to be set to true for any number of
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.


The xml-dev list is sponsored by XML.org <http://www.xml.org>, an initiative
of OASIS <http://www.oasis-open.org>

The list archives are at http://lists.xml.org/archives/xml-dev/

To subscribe or unsubscribe from this list use the subscription
manager: <http://www.oasis-open.org/mlmanage/index.php>


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

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