XTP: xsl:if <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="example"> <table> <xsl:attribute name="class"> <xsl:if test="@class"> <value-of select="@class"/> </xsl:if> <xsl:if test="not(@class)">example</xsl:if> </xsl:attribute> <tr> <td> <xsl:apply-templates/> </td> </tr> </table> </xsl:template> </xsl:stylesheet> <example class="special-example"> This is an example. </example> <table class="special-example"> <tr> <td>This is an example</td> </tr> </table> $template(example) << <table> $attribute("class") <tr> <td> $apply-templates(); </td> </tr> </table> >> Tags in stylesheets are parsed, not raw text. So you can add attributes to elements. adds an attribute to an element. expands to . The XPath pattern selects a value based on a boolean. is a Resin extension. evaluates conditionally.