Dec 22, 2008

XSLT note 3 - attribute tricks

When you want to output the value of node to destination, you can use . This works only when the destination is not in side of an attribute. If the output is in side of an attribute, you need to use {}. For example.




If you want to output a attribute of source element, you need to use @attributeName, or attribute::attributeName.

To add an attribute to an output node, you can also use xsl:attribute, like the following.


Some time we want to convert element to attribute. For example, we want to convert


We can use this template