誰かが私にこれを説明できますか?(最新のlibxsltを使用):
<a><xsl:copy-of select="(@attrib|exsl:node-set(0))"/></a>
<b><xsl:copy-of select="(@attrib|exsl:node-set(0))[position()=1]"/></b>
<x><xsl:copy-of select="(@attrib|exsl:node-set(0))[1]"/></x>
<xsl:variable name="value" select="@attrib"/>
<y><xsl:copy-of select="($value|exsl:node-set(0))[1]"/></y>
結果(現在のノードで@attrib = 1の場合):
<a attrib="1">0</a>
<b attrib="1"/>
<x>0</x>
<y attrib="1"/>
<a>
<b>
期待される動作を示します。
<x>
私見は正しくありません。
しかし、なぜ変数に入れる@attrib
とそれが「修正」されるの<y>
でしょうか。
ところで:存在しないときはすべてが正しい@attrib is
です。ここで使用されるコピーはデバッグ用です。元の使用法はXPathの結果を数値に変換し、属性が欠落しているとNaNにはなりませんが、特定のデフォルト値になります。