Attribute Value Templates
Although they’re technically defined in the XSLT specification (in
section 7.6.2, to be exact), we’ll discuss attribute value templates here. An attribute value template is an XPath expression that is evaluated, and the result of that evaluation replaces the attribute value template. For example, we could create an HTML <table> element like this:
<table border="{@size}"/>
In this example, the XPath expression @size is evaluated, and its value, whatever that happens to be, is inserted into the output tree as the value of the border attribute. Attribute value templates can be used in any literal result elements in your stylesheet (for HTML elements and other things that aren’t part of the XSLT namespace, for example). You can also use attribute value templates in the following XSLT attributes:
The
nameandnamespaceattributes of the<xsl:attribute>elementThe
nameandnamespaceattributes of the<xsl:element>elementThe
format,lang,letter-value,grouping-separator, andgrouping-sizeattributes of the<xsl:number>elementThe
nameattribute of the<xsl:processing-instruction>elementThe
lang,data-type,order, andcase-orderattributes of the<xsl:sort>element