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>
<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 関数リファレンス その他の拡張