XSLT ignore if contains 0 elements
How can I ignore style if there are 0 elements?
<xsl:template match="DifferenceNodes">
<div class="code">
<xsl:apply-templates select="DifferenceNode"/>
</div>
</xsl:template>开发者_StackOverflow社区
I want it to make div
with class code only if DifferenceNode
contains at least one element
Change the match criteria for the DifferenceNodes
. Add a predicate filter that ensures it only matches when there are DifferenceNode
children.
<xsl:template match="DifferenceNodes[DifferenceNode]">
<div class="code">
<xsl:apply-templates select="DifferenceNode"/>
</div>
</xsl:template>
精彩评论