The sample DTD we created in Chapter 5 included a parameter entity named attrs. You can define an attribute group named attrs in your schema as follows:
<schema> <attributeGroup name="attrs"> <attribute name = "id" type = "ID"/> <attribute name = "class" type = "string"/> <attribute name = "style" type = "string"/> <attribute name = "lang" type = "NMTOKEN"/> <attribute name = "xml:lang" type = "NMTOKEN"/> <attribute name = "dir"> <simpleType source = "ENUMERATION"> <enumeration value = "ltr"/> <enumeration value = "rtl"/> </simpleType> </attribute> <attribute name = "onclick" type = "string"/> <attribute name = "ondblclick" type = "string"/> <attribute name = "onmousedown" type = "string"/> <attribute name = "onmouseup" type = "string"/> <attribute name = "onmouseover" type = "string"/> <attribute name = "onmousemove" type = "string"/> <attribute name = "onmouseout" type = "string"/> <attribute name = "onkeypress" type = "string"/> <attribute name = "onkeydown" type = "string"/> <attribute name = "onkeyup" type = "string"/> <attribute name = "href" type = "string"/> <attribute name = "name" type = "string"/> <attribute name = "target" type = "string"/> </attributeGroup> </schema>
You can use attrs as follows:
<element name = "option"> <type content = "textOnly"> <attributeGroup ref = "attrs"/> <attribute name = "selected"/>
Thus, you declare the attributeGroup element as a child element of the schema element to create a document scope group of attributes. You can then reference the document scope attributeGroup element in a type element by including an attributeGroup element in the type element with the ref attribute set equal to the name of the document scope group. As you can see, this greatly simplifies the schema.
NOTE
Attribute groups can contain only simple data types.