I am busy trying to get my xsl as performant as possible. So here is what i have.
<xsl:when test=".//div[starts-with(@class,'ls-col ') or @class='ls-col']">
<xsl:apply-templates select=".//div[starts-with(@class,'ls-col ') or @class='ls-col']" mode="col"/>
</xsl:when>`
So the logic here is if the div with ls-col exist apply the template with mode=”col”.
So i was thinking the way this looks to me is that it will evaluate this twice
.//div[starts-with(@class,'ls-col ') or @class='ls-col']
Is there a way to save this and just use it in the apply template.
As Tim C says, if it was an xsl:if you could just rely on the apply-templates doing nothing when the condition isn’t true. But if there’s an ‘otherwise’ branch, just put the condition in a variable: