2016-07-13 8 views
-1

私はこのようなリンクの中に条件を追加しようとしています。<xsl:choose> xsl条件を<a>タグ内に設定できません。式が空に戻ります

<a class="accordion-toggle" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapse" aria-expanded="true" aria-controls="collapse"> 
    <xsl:value-of select="./Data[@Name='Title']"/> 
    <div class=""></div> 
    <xsl:attribute name="class"> 
    <xsl:choose> 
     <xsl:when test="/Properties/Data[@ID='ISSOCIAL']/Option[@Selected='true']/Value = 1"> 
     pull-right down 
     </xsl:when> 
     <xsl:otherwise> 
     pull-right 
     </xsl:otherwise> 
    </xsl:choose> 
    </xsl:attribute> 
</a> 

残念ながら、divタグ内のクラスは<div class=""> ..emptyのようになります。

ただし、アンカータグ内の条件を追加せずに次のコードを実行するだけであれば、うまく描画できます。

<div class=""></div> 
<xsl:attribute name="class"> 
    <xsl:choose> 
    <xsl:when test="/Properties/Data[@ID='ISSOCIAL']/Option[@Selected='true']/Value = 1"> 
     pull-right down 
    </xsl:when> 
    <xsl:otherwise> 
     pull-right 
    </xsl:otherwise> 
    </xsl:choose> 
</xsl:attribute> 

出力なぜこれが起こっている上の任意のアイデアは、この<div class="pull-right down"></div>

のように見えますか?どんな助けもありがとう!

答えて

1

属性をdivに追加する場合は、xsl:attributedivの内側に配置する必要があります。

<div> 
    <xsl:attribute name="class"> 
    <xsl:choose> 
     <xsl:when test="/Properties/Data[@ID='ISSOCIAL']/Option[@Selected='true']/Value = 1"> 
     pull-right down 
     </xsl:when> 
     <xsl:otherwise> 
     pull-right 
     </xsl:otherwise> 
    </xsl:choose> 
    </xsl:attribute> 
</div> 

質問はあなたが単に

<div class="{if (/Properties/Data[@ID='ISSOCIAL']/Option[@Selected='true']/Value = 1) then 'pull-right down' else 'pull-right'}">..</div> 
+0

を使用することができますXSLT 2.0としてタグ付けされたように、私はXSL 2.0へのアクセスを持っていないルックス、私は私のタグを更新しますお詫び申し上げます。 1.0でこれを行うにはいくつかの方法がありますか?ありがとうございました。 – BaconJuice

+0

'div'に' xsl:attribute'を使いたいのであれば、私が言ったように、 'div'の内部に属しています。 –

関連する問題