xml - 设置 xsl :value-of into an href attribute and the text field of a link in an XSLT

标签 xml xslt href

如何通过 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/

相关文章:

xml - 在 R 中使用可变 XML 结构解析 RSS 提要

java - 替换 Spring PayloadValidatingInterceptor 中的 XML MessageFormatter

Android 调试无法工作 XSLT 错误

php - AJAX改变页面内容

Python:for循环的紧凑/一个衬里

android - 在 Android 中为按钮组应用样式

javascript - XSL 在 Chrome 中无法正常渲染/运行

xslt - 可以用 xsd :dayTimeDuration() 指定的最长持续时间

Android TextView 启用 LinkiFy 和 Href 标签

javascript - 单击链接时突出​​显示工具提示中的文本