current - XPath 编辑

XSLT/XPath Reference: XSLT elements, EXSLT functions, XPath functions, XPath axes

The current function can be used to get the context node in an XSLT instruction.

Syntax

current()

Returns

A node-set containing only the current node.

Notes

This function is an XSLT-specific addition to XPath. It is not a part of the core XPath function library.

For an outermost expression (an expression not occurring within another expression), the current node is always the same as the context node (which will be returned by the . or self syntax). The following two are symantically equivalent.

<xsl:value-of select="current()"/>
<xsl:value-of select="."/>

In an inner expression (e.g. in square brackets), the current node is still the same as it would have been in an outermost expression. Thus within all of the following three expressions the current function (not the entire expressions) returns the same node. Moreover, the latter two are semantically equivalent.

<xsl:value-of select="current()"/>
<xsl:value-of select="foo/bar[current() = X]"/>
<xsl:variable name="current" select="current()"/>
<xsl:value-of select="foo/bar[$current = X]"/>

And the next code is also semantically equivalent to the latter two, since the . occurs in an outermost expression.

<xsl:variable name="current" select="."/>
<xsl:value-of select="foo/bar[$current = X]"/>

But the . always relate to the narrowest context. Thus in

<xsl:value-of select="foo/bar[. = X]"/>

the . returns the bar node, which may be different from the current node.

Defined

XSLT 1.0 12.4

Gecko support

Supported.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:78 次

字数:2911

最后编辑:7 年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文