如何设置一个href,它既是链接,也有通过XSLT转换的链接文本?这是我到目前为止所做的,它给出了错误"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>
Run Code Online (Sandbox Code Playgroud)
zne*_*eak 43
<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>
Run Code Online (Sandbox Code Playgroud)
lex*_*ore 28
你也可以这样做:
<a href="{actionUrl}"><xsl:value-of select="actionUrl"/></a>
Run Code Online (Sandbox Code Playgroud)
你不需要xsl:text元素:
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="actionUrl"/>
</xsl:attribute>
<xsl:value-of select="actionUrl"/>
</xsl:element>
Run Code Online (Sandbox Code Playgroud)