attributeGroup

We discussed earlier how you can make use of the ref attribute to make a reference to an attribute declaration that is declared globally within your schema:

<?xml version="1.0" encoding="utf-8"?> 
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:attribute name="sku" type="xs:string"/>

  <xs:element name="catalog">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="item">
          <xs:complexType>
            <xs:attribute ref="sku"/>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

References are one way to organize your attributes and to reuse attributes—another way is the attribute group.

An <attributeGroup> allows you to declare attributes together within a common structure, and then reference that ...

Get Special Edition Using XML, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.