Creating all Groups

Schemas support another type of group: the all group. All the elements in an all group may appear once or not at all, and they may appear in any order. This group must be used at the top level of the content model, and the group's children must be individual elements—that is, this group must itself contain no groups. In addition, any element in this content model can appear no more than once (which means that the allowed values of minOccurs and maxOccurs are 0 and 1 only).

Here's an example; in this case, I'm converting the transactionType type into an all group:

<xsd:complexType name="transactionType">
    <xsd:all>
        <xsd:element name="Lender" type="address"/>
        <xsd:element name="Borrower" type="address"/>
        <xsd:element ref="note" minOccurs="0"/>
        <xsd:element name="books" type="books"/>
    </xsd:all>
    <xsd:attribute name="borrowDate" type="xsd:date"/>
</xsd:complexType>

This means that the elements in this type may now appear in any order but can appear only once, at most. Another important point is that if you use it, the <xsd:all> group must contain all the element declarations in a content model. (That is, you can't declare additional elements that are in the content model but outside the group.)

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.21.93.168