XSLT current

基本介紹

  • 外文名:XSLT current
  • 屬於:current() 函式
  • 定義:返回僅包含當前節點的節點集
  • 特點:當前節點與上下文節點是相同的
正文,定義和用法,語法,例子,

正文

定義和用法

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()

例子

<?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>

熱門詞條

聯絡我們