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 UTC