生成的HTML頁面包含有時在我的頁面中不存在的引用鏈接。我應該將這個鏈接顯示爲一個簡單的標籤。 目前做到這一點:XSLT:如何在不復制代碼的情況下創建條件鏈接
<xsl:choose>
<xsl:when test="$nb_action != 0">
<a href="#action">Action (offensive, defensive, reconnaissance)</a>
</xsl:when>
<xsl:otherwise>
Action (offensive, defensive, reconnaissance)
</xsl:otherwise>
</xsl:choose>
我不知道如何來簡化我的代碼,如何停用節點<a></a>
?
我的第一個想法是委託一個特殊的CSS類:
<a href="#action">
<xsl:if test="$nb_action = 0">
<xsl:attribute name="class">inactive</xsl:attribute>
</xsl:if>Action (offensive, defensive, reconnaissance)
</a>
但它仍然是一個鏈接...
遵循一種解決方法:
<a><xsl:if test="$nb_action != 0">
<xsl:attribute name="href">#action</xsl:attribute>
</xsl:if>Action (offensive, defensive, reconnaissance)</a>
這是正確的寫一個html <a>
標籤沒有href
?
我喜歡你的解決方案,謝謝:)) – chepseskaf 2010-07-21 16:08:36
一個小問題:爲了將$ textval聲明爲字符串數據類型,使用'select =''動作(冒犯,防禦,偵察)「」'。否則它將被定義爲結果樹片段。 – 2010-07-21 19:49:47
@Alejandro:其實我相信樹片段是OP想要的,我應該使用'copy-of'而不是'value-of'。更新。 – kennytm 2010-07-21 20:01:29