Defining Groups of Elements and Attributes in XML Schemas

The XML Schema Recommendation allows you to specify groups of elements and groups of attributes. Here is an example of an element group, purchaseType:

 <xsd:group name="purchaseType">
               
     <xsd:choice>
               
         <xsd:element name="retail"/>
               
         <xsd:element name="internet"/>
               
         <xsd:element name="mailOrder"/>
               
     </xsd:choice>
               
 </xsd:group>
               

            

Specification of a group makes it easier to update the schema. You only need to update the group definition. There is no need to change the references to the group.

Here is an example of an attributeGroup, deliveryDetail.

 <xsd:attributeGroup name="deliveryDetail">
               
     <xsd:attribute name="method"/>
               
     <xsd:attribute name="vendor"/>
               
     <xsd:attribute name="dateShipped"/>
               
     <xsd:attribute name="dateArrived"/>
               
 </xsd:attributeGroup>
               

            

This section discusses the following topics:

 
Free Stylus Studio XML Training: