【问题标题】:Nodesets Length节点集长度
【发布时间】:2010-09-07 02:54:01
【问题描述】:

在 XLST 中,如何找出节点集的长度?

【问题讨论】:

    标签: xml xslt nodesets


    【解决方案1】:
    <xsl:variable name="length" select="count(nodeset)"/>
    

    【讨论】:

      【解决方案2】:

      没有必要把它放到一个

      <xsl:variable name="length" select="count(nodes/node)"/>
      

      不过……你可以按如下方式打印出来:

      <xsl:value-of select="count(nodes/node)"/>
      

      或在 if 子句中使用它,如下所示:

      <xsl:if test="count(comments/comment) > '0'">
          <ul>
              <xsl:apply-templates select="comments/comment"/>
          </ul>
      </xsl:if>
      

      【讨论】:

      • 你会想把 > 变成一个 >不过!
      【解决方案3】:

      在 XSLT 中,通常不将事物称为 Arrays,因为在 XSLT 中确实没有这样的事物。技术术语是 nodesets(由零个或多个节点组成)或在 XSLT 2.0 中为 sequences

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2015-09-07
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多