[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Either ... or ... in Schema


either or
DTD:

<!ELEMENT ElementName (enum1 | enum2 | enum3 | enum4)>

XML Schema:

<xs:element name="ElementName" type="Enum"/>

<xs:complexType name="Enum">
 <xs:choice>
  <xs:element name="enum1" type="xs:string"/>
  <xs:element name="enum2" type="xs:string"/>
  <xs:element name="enum3" type="xs:string"/>
  <xs:element name="enum4" type="xs:string"/>
 </xs:choice>
</xs:complexType>

Or:

<xs:element name="ElementName">
 <xs:complexType>
  <xs:choice>
   <xs:element name="enum1" type="xs:string"/>
   <xs:element name="enum2" type="xs:string"/>
   <xs:element name="enum3" type="xs:string"/>
   <xs:element name="enum4" type="xs:string"/>
  </xs:choice>
 </xs:complexType>
</xs:element>

Or do you want string content of ElementName to be an enumeration?

<xs:simpleType name="Enum">
 <xs:restriction base="xs:string">
  <xs:enumeration value="enum1-string"/>
  <xs:enumeration value="enum2-string"/>
  <xs:enumeration value="enum3-string"/>
  <xs:enumeration value="enum4-string"/>
 </xs:restriction>
</xs:simpleType>

RELAX NG:

<element name="ElementName">
 <choice>
  <element name="enum1"><text/></element>
  <element name="enum2"><text/></element>
  <element name="enum3"><text/></element>
  <element name="enum4"><text/></element>
 </choice>
</element>

Or:

<element name="ElementName">
 <choice>
  <value>enum1-string</value>
  <value>enum2-string</value>
  <value>enum3-string</value>
  <value>enum4-string</value>
 </choice>
</element>

Mike

-----Original Message-----
From: rajac [mailto:rajac@n...]
Sent: Wednesday, February 27, 2002 9:37 AM
To: xml-dev@l...
Subject:  Either ... or ... in Schema


Hi,
  In DTD, i have something like this,
   <Element ElementName   (enum1|enum2|enum3|......)>
   This indicates that ElementName must have atleat one of these
nodes(enum1,enum2,enum3,......).

  How this can be done in XML Schema?.

Regards,
Raja


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.