views:

21

answers:

1

Is there any difference between limiting the occurrences of an element in the element tag or the sequence tag, what would be the best place to do it? Or it's just a matter of style?

Example:

<xs:element name="Provider">
    <xs:complexType>
        <xs:sequence minOcurrs="1" maxOccurs="unbounded">
            <xs:element ref="Distribuitor"/>
        </xs:sequence>
    </xs:complexType>
</xs:element>

or

<xs:element name="Provider">
    <xs:complexType>
        <xs:sequence>
            <xs:element ref="Distribuitor"  minOcurrs="1" maxOccurs="unbounded"/>
        </xs:sequence>
    </xs:complexType>
</xs:element>
A: 

I would say to put it on the element instead because the sequence specifies the order in which the elements must appear. I believe if you put it on the elements themselves, you are being more clear on what you want. I don't think in your case it makes a difference with 1 element, but imagine if you had 10 elements for example and each element could have a different number of minOcurrs and maxOccurs, you probably would want to specify it on each element then instead of at the sequence level.

Xaisoft