6.6. Adding Attributes to LREs

Attributes can be added to LREs in three ways: by directly typing the attribute and its value in the LRE, by using the <xsl:attribute> element, or by using the <xsl:attribute-set> element in conjunction with either the use-attribute-sets on an element or xsl:use-attribute-sets attribute on an LRE. Because LREs are passed through to the output result tree, using attributes directly in LRE elements can be difficult if the value of the attribute is to be generated or extracted from some node-set in the input document. For example, if we wanted to output a new element called <newblock> instead of our <block>s in Markup City, and then add an attribute with the text content of the <block>, the template in Example 6-14 ...

Get XSLT and XPATH: A Guide to XML Transformations now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.