XSLT If id has class -
i can't find anywhere. how can write if statement in xslt show words 'yes' if div id of 'cat' has class assigned called 'true'?
if div in question current node, , don't know whether has id of 'cat' or class attribute, might write
<xsl:if test=".[@id='cat' , contains(@class,'true')]"> yes </xsl:if>
if you're in template matches on div[@id='cat']
, can use simpler test test="contains(@class,'true')"
. (and conversely.)
note test formulated succeed divs class="untrue"
-- if that's issue situation, solution becomes bit messier.
in xslt 1.0, simplest way write this:
<xsl:if test=".[@id='cat' , contains(concat(' ', @class, ' '),' true ')]"> yes </xsl:if>
in xslt 2.0, i'd write like:
<xsl:if test=".[@id='cat' , tokenize(@class, '\s') = 'true')]"> yes </xsl:if>
Comments
Post a Comment