Important: |
---|
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist. |
Defines a named set of attributes.
Syntax
<xsl:attribute-set name = QName use-attribute-sets = QNames> </xsl:attribute-set> |
Attributes
- name
-
[required] Name of the attribute set.
- use-attribute-sets
-
A white space-separated list of attribute sets specified as a qualified name. Specifying a use-attribute-setsattribute is equivalent to adding <xsl:attribute> elements for each of the attributes in each of the named attribute sets to the beginning of the content of the element with the use-attribute-setsattribute, in the same order in which the names of the attribute sets are specified in the use-attribute-setsattribute. It is an error if using use-attribute-setsattributes on <xsl:attribute-set> elements causes an attribute set to directly or indirectly use itself.
Element Information
Number of occurrences |
Unlimited |
Parent elements |
|
Child elements |
Remarks
The <xsl:attribute-set> element defines a named set of attributes. The nameattribute specifies the name of the attribute set. The value of the nameattribute is a qualified name. The content of the <xsl:attribute-set> element consists of zero or more <xsl:attribute> elements that specify the attributes in the set.
Attribute sets are used by specifying a use-attribute-setsattribute on <xsl:element>, <xsl:copy>, or <xsl:attribute-set> elements. The value of the use-attribute-setsattribute is a white space-separated list of names of attribute sets. Each name is specified as a qualified name. Specifying a use-attribute-setsattribute is equivalent to adding <xsl:attribute> elements for each of the attributes in each of the named attribute sets to the beginning of the content of the element with the use-attribute-setsattribute, in the same order in which the names of the attribute sets are specified in the use-attribute-setsattribute. It is an error if using use-attribute-setsattributes on <xsl:attribute-set> elements causes an attribute set to directly or indirectly use itself.
Attribute sets can also be used by specifying an xsl:use-attribute-setsattribute on a literal result element. The value of the xsl:use-attribute-setsattribute is a white space-separated list of names of attribute sets. The xsl:use-attribute-setsattribute has the same effect as the use-attribute-setsattribute on <xsl:element> with the additional rule that attributes specified on the literal result element itself are treated as if they were specified by <xsl:attribute> elements before any actual <xsl:attribute> elements but after any <xsl:attribute> elements implied by the xsl:use-attribute-setsattribute. Thus, for a literal result element, attributes from attribute sets named in an xsl:use-attribute-setsattribute will be added first, in the order listed in the attribute; next, attributes specified on the literal result element will be added; finally, any attributes specified by <xsl:attribute> elements will be added. Because adding an attribute to an element replaces any existing attribute of that element with the same name, attributes specified in attribute sets can be overridden by attributes specified on the literal result element itself.
The template within each <xsl:attribute> element in an <xsl:attribute-set> element is instantiated each time the attribute set is used; it is instantiated using the same current node and current node list as is used for instantiating the element bearing the use-attribute-setsor xsl:use-attribute-setsattribute. However, it is the position in the style sheet of the <xsl:attribute> element rather than of the element bearing the use-attribute-setsor xsl:use-attribute-setsattribute that determines which variable bindings are visible; thus, only variables and parameters declared by top-level <xsl:variable> and <xsl:param> elements are visible.
Example
The following example creates a named attribute set
called "
title-style
" and uses it in a template rule.
Copy Code | |
---|---|
<xsl:template match="chapter/heading"> <fo:block quadding="start" xsl:use-attribute-sets="title-style"> <xsl:apply-templates/> </fo:block> </xsl:template> <xsl:attribute-set name="title-style"> <xsl:attribute name="font-size">12pt</xsl:attribute> <xsl:attribute name="font-weight">bold</xsl:attribute> </xsl:attribute-set> |
The "
fo:block
" element is output as follows:
Copy Code | |
---|---|
<fo:block quadding="start" font-size="12pt" font-weight="bold"> ... </fo:block> |
Multiple definitions of an attribute set with the same expanded-name are merged. An attribute from a definition that has higher import precedence takes precedence over an attribute from a definition that has lower import precedence.
It is an error if there are two attribute sets that have the same expanded-name and equal import precedence and that both contain the same attribute, unless there is a definition of the attribute set with higher import precedence that also contains the attribute.