Altova Mailing List Archives


Re: XSD "one or more" construct

From: Wors <grahamnospam.worsley@---------.--->
To: NULL
Date: 10/2/2005 4:06:00 PM
Wors wrote:
> When defining an XSD is there a way of specifying that one or more 
> elements in a structure must exist?
> 
> E.g. Structure A Element B Element C End Structure
> 
> If I make them both optional (minoccurs 0) then it means Structure A 
> may contain nothing which isn't right. What it must contain is B, C 
> or both B and C .
OK found out how to do this using the choice construct and setting 
maxoccurs to the number of choices allowed (min 1 max 2)

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="Example">
<xs:complexType>
<xs:sequence>
<xs:element name="A" maxOccurs="unbounded">
<xs:complexType>
<xs:choice maxOccurs="2">
<xs:element name="B"/>
<xs:element name="C"/>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

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.