2017-02-23 51 views
0

我得到的是錯誤的xsl:文本不能包含子元素同時創造錨標記href值。這裏是n0t創建的xsl:文本不能包含子元素

這裏是我的代碼 http://xsltransform.net/bwdwsL

<a><xsl:attribute name="href"> 
        <xsl:text>http://m.timesofindia.com?upcahe=<xsl:value-of select="'dd'"/></xsl:text> 
      </xsl:attribute>Next</a> 
+0

請在您的問題中發佈所有必要的代碼,而不是在外部鏈接中。 –

回答

1

您的屬性值是完全靜態的,所以您可以簡單地使用文字屬性與eg

<a href="http://m.timesofindia.com?upcahe=dd">Next</a> 

如果要使用XPath計算屬性值的一部分,請使用attribute value templates

<a href="http://m.timesofindia.com?upcahe={'dd'}">Next</a> 

如果你真的需要再使用xsl:attribute

<xsl:attribute name="href">http://m.timesofindia.com?upcahe=<xsl:value-of select="'dd'"/></xsl:attribute> 

或用xsl:text

<xsl:attribute name="href"> 
    <xsl:text>http://m.timesofindia.com?upcahe=</xsl:text> 
    <xsl:value-of select="'dd'"/> 
</xsl:attribute> 

同樣,所有如果纔有意義,從XML文檔中XPath表達式選擇數據而不是靜態字符串。

相關問題