thisによると、match
のXPath式のパラメータを使用することは可能です。しかし、xsl:template
のxsl:param
が同じテンプレート内で使用される場合は動作しないようです。XSLT 2.0の一致するXPath式でテンプレートパラメータを使用することはできませんか?
<?xml version="1.0" encoding="UTF-8"?>
<myRoot>
<myNode myAttribute="3">
<myChildAttribute myChildAttribute="a" />
</myNode>
<myNode myAttribute="2">
<myChildAttribute myChildAttribute="b" />
</myNode>
<myNode myAttribute="1" />
</myRoot>
、そのような私のXSLファイルを次のように
私のXMLファイルが見えます。 SAXON 9HEを実行したとき
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" encoding="UTF-8"/>
<xsl:template match="myRoot">
<xsl:apply-templates select="myNode">
<xsl:sort select="@myAttribute" />
<xsl:with-param name="myParam" select="max(myNode/@myAttribute)" />
</xsl:apply-templates>
</xsl:template>
<xsl:template match="myNode[node() and @myAttribute = $myParam]">
<xsl:param name="myParam" />
<xsl:for-each select="myChildAttribute">
INSERT INTO a(b) VALUES ('<xsl:value-of select="@myChildAttribute" />');
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
は、残念ながら同じテンプレートのマッチXPath式では、テンプレートのパラメータを使用することはできません、次のエラー
XPST0008: Variable myParam has not been declared (or its declaration is not in scope)
で終わります! ?
ありがとうDimitre!今私には明らかです。 'xsl:sort'は変換の前のバージョンから残っています。ヒントのおかげで、私はそれを削除します。 – Jagger