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

RE: One of more elements required

From: Stan Kitsis <Stan.Kitsis@microsoft.com>
Date: Wed, 22 Oct 2008 15:10:55 -0700
To: Age Bosma <agebosma@gmail.com>, "xmlschema-dev@w3.org" <xmlschema-dev@w3.org>
Message-ID: <03A576FA617C6544AEF9B925FB2B4E2A22440D7059@NA-EXMSG-C114.redmond.corp.microsoft.com>
RE: One of more elements required

If I understand your requirements right, you want

   <xsd:choice minOccurs="1" maxOccurs="unbounded">
      <xsd:element name="platform" type="platformType"/>
      <xsd:element name="device" type="deviceType"/>
   </xsd:choice>

Stan Kitsis

-----Original Message-----
From: xmlschema-dev-request@w3.org [mailto:xmlschema-dev-request@w3.org] On Behalf Of Age Bosma
Sent: Wednesday, October 22, 2008 12:51 PM
To: xmlschema-dev@w3.org
Subject: One of more elements required


Hi,

I can't seem to find a solution for the following problem. I hope you
can help me out. Here's a stripped down version of what I've got:

<xsd:complexType name="rootType">
   <xsd:sequence>
      <xsd:element name="platform" type="platformType" minOccurs="0"
maxOccurs="unbounded"/>
      <xsd:element name="device" type="deviceType" minOccurs="0"
maxOccurs="unbounded"/>
   </xsd:sequence>
</xsd:complexType>


Basically, as you can see, the parent element can have zero or more
platform elements AND zero or more device elements.

I'd like to add an additional requirement. The parent element should at
least have one of the two child (platform OR device) elements. How can
this be expressed in XML Schema? Can it be done at all?

Using 'choice' doesn't seem like an option to me since that would only
allow me to include one of the two and not both.

Thank in advance,

Age Bosma
Received on Wednesday, 22 October 2008 22:11:38 GMT

Subscribe to the Stylus Scoop newsletter for helpful XML tips and tutorials.
Email
First Name
Last Name
Company

Download Stylus Studio 6 XML Enterprise Edition

Subscribe in XML format
RSS 2.0
Atom 0.3
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-2007 All Rights Reserved.