开发者

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>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜