In my second xsl:template match, how do I test for the match pattern? For example if the match patter is title, I want to output different value?
<xsl:template match="secondary-content">
<div class="secondary">
<xsl:apply-templates select="title" />
<xsl:apply-templates select="block/content | content" />
</div>
</xsl:template>
<xsl:template match="title|content|block/content">
<xsl:copy-of select="node()" />
</xsl:template>
Good question, +1.
In the second template, use this test expression:
test="self::title"
or
test="local-name() = 'title'"
For example, you can use
<xsl:choose>
<xsl:when test="self::title">
<someThing>foo</someThing>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="node()" />
</xsl:otherwise>
</xsl:choose>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With