2

テンプレート内でテンプレート名を取得することは可能ですか? 例:

<xsl:template name="list">
<!-- Get name value (in this case "list") -->
</xsl:template>
4

4 に答える 4

1

私の知る限り、XSLT1.0もXSLT2.0もそのような機能を提供していません。

于 2013-01-15T14:53:34.263 に答える
1

As Martin says, there's probably no way to do this.

Even if such a capacity existed, surely using it couldn't be any simpler than just defining a variable with the value you want:

<xsl:template name="list">
   <xsl:variable name="class" select="'list'" />

and then using that variable where you need it. This also has the benefit that you can change the template name without rewriting all your CSS, or change the class name without rewriting your XSLT.

于 2013-01-15T15:30:03.113 に答える
1

XSLTがXML構文を使用するという事実の利点の1つは、スタイルシートの変換が簡単なことです。テンプレート名を保持する変数を含むようにすべての名前付きテンプレートを変更するのは非常に簡単です。

于 2013-01-15T17:16:19.233 に答える