Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Using XML Schema to Force At Least One Item?

From: "Kenneth Love" <klove@---.--.--->
To: NULL
Date: 4/1/2005 8:52:00 AM
Sorry if this is a newbie question.  I couldn't get the correct magic
incantation for Google to get an answer.  :-(

I'm trying to satisfy a requirement that "at least one of the following
*must* be present" in an XML Schema.  I have come up with two examples
that almost work.

Here's the first:

<xs:element name="LightExample1" maxOccurs="3">
   <xs:complexType>
      <xs:choice>
         <xs:element name="A"/>
         <xs:element name="B"/>
         <xs:element name="C"/>
      </xs:choice>
   </xs:complexType>
</xs:element>

This doesn't work because it allows multiple A, B, or C elements.

Here's the second example:

<xs:element name="LightExample2">
   <xs:complexType>
      <xs:sequence>
         <xs:element name="A" minOccurs="0"/>
         <xs:element name="B" minOccurs="0"/>
         <xs:element name="C" minOccurs="0"/>
      </xs:sequence>
   </xs:complexType>
</xs:element>

This *almost* works.  The only problem is that it allows an empty
<LightExample2/> element which fails the "at least one of" portion of
the requirement.

Is it possible to do this?

Kenneth



transparent
Print
Mail
Digg
delicious
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent