开发者

XSLT ignore if contains 0 elements

开发者 https://www.devze.com 2023-02-07 01:30 出处:网络
How can I ignore style if there are 0 elements? <xsl:template match=\"DifferenceNodes\"> <div class=\"code\">

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

精彩评论

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