如何通过 XSLT 转换设置既是指向链接又具有链接文本的 href?到目前为止,这是我所拥有的,这给了我错误“xsl:value-of 不能是 xsl:text 元素的子元素”:
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="actionUrl"/>
</xsl:attribute>
<xsl:text><xsl:value-of select="actionUrl"/></xsl:text>
</xsl:element>
最佳答案
<xsl:text>
定义 XSL 文档中的文本部分。只有真实的纯文本可以放在此处,而 XML 节点不能。你只需要 <xsl:value-of select="actionUrl"/>
,无论如何都会打印文本。
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="actionUrl"/>
</xsl:attribute>
<xsl:value-of select="actionUrl"/>
</xsl:element>
关于xml - 设置 xsl :value-of into an href attribute and the text field of a link in an XSLT,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2563021/