我得到的是错误 XSL:文本在锚定标签中创建href
值时不得包含子元素。此处是N0T创建
这是我的代码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>
您的属性值是完全静态的,因此您可以简单地将字面属性与例如。
<a href="http://m.timesofindia.com?upcahe=dd">Next</a>
如果要使用XPath计算属性值的一部分,则使用属性值模板,例如
<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>
再次,只有当您的xpath表达式从XML文档中选择数据而不是静态字符串时,所有这些才有意义。