2016-04-06 14 views
0

属性を持つ要素をxslt変数に格納し、この変数を使用して要素を表示する方法はありますか?xslt変数の値を表示する方法

例:

<element name="value1" attribute2="value2" /> 

私はこのような何か試してみました:

<xsl:variable name="myVariable" select="../element[@name=value1]" /> 

、次に表示:

<xsl:template match=".."> 
    <xsl:value-of select="$myVariable" /> 
</xsl:template> 

をそして私はすべての属性で指定された名前を持つ要素を表示したいです。あなたは、出力使用copy-of、例えばにノードをコピーしたい場合は

おかげ

Krp0

答えて

0

value1の周りにqoutesがありませんでした。変数の値にアクセスするには、すべての属性を持つ要素をコピーするxsl:copy-ofを使用します。

<xsl:template match="/"> 
    <xsl:variable name="myVariable" select="element[@name='value1']" /> 
    <xsl:copy-of select="$myVariable" /> 
</xsl:template> 
0

value-ofは、選択した値の文字列値を持つテキストノードを作成します<xsl:copy-of select="$myVariable"/>

関連する問題