开发者

Complaring Mulitple Element's text with multiple Elements text in xslt

开发者 https://www.devze.com 2023-03-05 16:24 出处:网络
Input xml is : <A> <B> <c>1</c> <c>2</c> </B> <D> <c>2</c>

Input xml is :

<A>
    <B>
        <c>1</c>
        <c>2</c>
    </B>
    <D>
        <c>2</c>
     开发者_StackOverflow中文版   <c>3</c>
    </D>
</A>

From the above xml i want the o/p as <c>2</c>


It is not clear what the criteria is for outputting that single element. Do you want to group and then only output groups with more than one item? In that case

<xsl:template match="/">
  <xsl:for-each-group select="descendant::c" group-by=".">
    <xsl:if test="current-group()[2]">
      <xsl:copy-of select="."/>
    </xsl:if>
  </xsl:for-each-group>
</xsl:template>

might suffice. If not then explain in more detail why the output should be as posted.

0

精彩评论

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