<xsl:value-of select="$variable1"/>
<xsl:value-of select="$variable2"/>
variable1は$variable2の値になります。どうすればこれを行うことができますか?
それはいけません。あなたができることは次のようなものです:
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
<xsl:output method="xml" indent="yes"/>
<!-- Dictionary mapping names to values -->
<xsl:variable name="dict">
<value name="var1">1</value>
<value name="var2">2</value>
</xsl:variable>
<xsl:template match="/">
<!-- Name of the value in 'variable1' -->
<xsl:variable name="variable1" select="'var1'"/>
<!-- Get the value in 'variable2' using 'variable1' -->
<xsl:variable name="variable2" select="msxsl:node-set($dict)/value[@name=$variable1]"/>
<root>
<xsl:text>variable2: </xsl:text><xsl:value-of select="$variable2"/>
</root>
</xsl:template>
</xsl:stylesheet>
msxsl:node-set
フラグメントをノード セットに変換する Microsoft 固有の拡張機能です。Microsoft 以外のプロセッサを使用している場合は、同等の機能を利用できるはずです。
ほとんどのプログラミング言語と同様に、実行時に XSLT 変数名にアクセスすることはできません。
ですから、なぜこれをやりたいのか、どのような問題を解決しようとしているのかを説明していただければ、それを解決する正しい方法をお教えします.