当前位置:K88软件开发文章中心编程语言XmlXSLT01 → 文章内容

XSLT current() 函数

减小字体 增大字体 作者:佚名  来源:网上搜集  发布时间:2019-1-26 18:46:52

由 gelin678 创建,Carrie 最后一次修改 2015-09-06 XSLT current() 函数XSLT current() 函数的作用是返回一个仅包含当前节点的节点集。 完整的 XSLT 函数参考对象 定义和用法 current() 函数返回仅包含当前节点的节点集。通常,当前节点与上下文节点是相同的。 <xsl:value-of select="current()"/> 等于 <xsl:value-of select="."/> 不过,有一点不同。让我们看一下下面的 XPath 表达式:"catalog/cd"。表达式选择了当前节点的 <catalog> 子节点,然后选择了 <catalog> 节点的 <cd> 子节点。这意味着,在计算的每一步上,"." 都有不同的意义。 下面这行: <xsl:apply-templates select="//cd[@title=current()/@ref]"/> 将处理 title 属性的值等于当前节点的 ref 属性的值的所有 cd 元素。 与这个不同: <xsl:apply-templates select="//cd[@title=./@ref]"/> 这个会处理 title 属性和 ref 属性具有相同值的所有 cd 元素。 语法 node-set current() 实例 1 <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <html> <body> <xsl:for-each select="catalog/cd/artist"> Current node: <xsl:value-of select="current()"/> <br /> </xsl:for-each> </body> </html> </xsl:template> </xsl:stylesheet> 完整的 XSLT 函数参考对象

XSLT current() 函数