Creating all Groups

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 elementsthat 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 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 they can appear only once, at most. Another important point is that if you use it, an <xsd:all> group must contain all the element declarations in a content model (that is, you can't declare additional elements in the content model but outside the group).



Real World XML
Real World XML (2nd Edition)
ISBN: 0735712867
EAN: 2147483647
Year: 2005
Pages: 440
Authors: Steve Holzner

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net