Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: using the maxOccurs contruct with sequences.

From: Jeff Rafter <lists@----------.--->
To: Ken_Gross@-----------.---
Date: 3/14/2005 1:10:00 AM
> In the following example, there are two representations of an unbounded 
> sequence of elements in  "ReportOptionsModel".   Is the first 
> representation ever justified?  If it is, when should it be used?

Hi Ken,

With a single element in the sequence (as you have in each example) it 
is really up to you or the preference of the users of your XML Schema. 
When working with multiple elements in the sequence though, the 
difference is important:

         <xs:complexType name="ReportOptionsModel">
           <xs:sequence maxOccurs="unbounded">
             <xs:element name="FilterA"/>
             <xs:element name="FilterB"/>
           </xs:sequence>
         </xs:complexType>

         <xs:complexType name="ReportOptionsModel2">
           <xs:sequence>
             <xs:element name="FilterA" maxOccurs="unbounded"/>
             <xs:element name="FilterB" maxOccurs="unbounded"/>
           </xs:sequence>
         </xs:complexType>

In the first case, the instance might have:

   <FilterA/>
   <FilterB/>
   <FilterA/>
   <FilterB/>
   <FilterA/>
   <FilterB/>
   ...

In the second case it would be:

   <FilterA/>
   <FilterA/>
   <FilterA/>
   <FilterA/>
   <FilterB/>
   <FilterB/>
   ...

Where all of the FilterA elements would appear before all of the FilterB 
elements.

In XML Schemas where you have some sequences with only a single element 
another consideration is how the document will be modified in subsequent 
versions. If it is your anticipation that more elements will be added to 
the sequence at a later date (and you are indifferent to the order shown 
above) then I would place it on the containing <xs:sequence>. In all 
other cases I would place the cardinality constraint on the 
<xs:element>. That is just my taste though, I prefer to have the 
cardinality constraint as close to the thing it constrains as possible.

All the best,
Jeff Rafter

From K.Buchcik@4... Mon Mar 14 18:03:23 2005
Received: from lisa.w3.org ([128.30.52.


transparent
Print
Mail
Like It
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