2017-08-17 6 views
0

"Artproof"変数がtrueです。変数がXLSTで変数を宣言して初期化します

<xsl:variable name="ArtProof" select="'True'"/>  

<xsl:choose> 
    <xsl:when test="$ArtProof = 'True'"> 
     <xsl:variable name="color_of_artproof" select="'green'"/> 
    </xsl:when> 
    <xsl:otherwise> 
     <xsl:variable name="color_of_artproof" select="'red'"/> 
    </xsl:otherwise> 
</xsl:choose> 

設定色の条件がtrueの場合 iは、テキストの色を変更したい:

"color_of_artproof" 変数がNULL値を与えている、とテキストが黒です。

答えて

0

変数はその親要素にスコープされます。 xsl:when命令内で変数を定義すると、別のコンテキストで変数を使用することはできません。

ような何か試してみてください:

<xsl:variable name="color_of_artproof"> 
    <xsl:when test="$ArtProof = 'True'">green</xsl:when> 
    <xsl:otherwise>red</xsl:otherwise> 
</xsl:variable> 
関連する問題