【问题标题】:Getting the value of sibling nodes in XSLT获取 XSLT 中兄弟节点的值
【发布时间】:2012-12-18 10:00:06
【问题描述】:

我有以下 XML

<CN>12<CN>
<CT>XYXY</CT>

我需要结果 AS

<DIV>12  XYXY</DIV>

我正在使用流动的 XSLT,但它不起作用

<xsl:variable name="x"><xsl:value-of  select="CN"/></xsl:variable>

<xsl:template match="CT">
 <div class="chap-title"><span><xsl:value-of select="$x"/></span></div>
</xsl:template>

【问题讨论】:

    标签: xslt-2.0


    【解决方案1】:

    输入:

    <input>
        <CN>12</CN>
        <CT>XYXY</CT>
    </input>
    

    XSLT:

    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                    version="2.0">
    
        <xsl:output indent="yes"
                    method="xml"
                    encoding="UTF-8" />
    
        <xsl:template match="/input">
            <DIV>
                <xsl:value-of select="CN"/>
                <xsl:text>  </xsl:text>
                <xsl:value-of select="CT"/>
            </DIV>
        </xsl:template>
    
    </xsl:stylesheet>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-02-27
      • 1970-01-01
      • 1970-01-01
      • 2015-12-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多