本文介绍了XSL - 如何禁用属性的输出转义?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<a href="http://myserver/_forms?url={@FileRef}&id=5">...</a>
其中一个文件名为 "File's got apostrophe.xml"
.XSL 的输出是:
One of the files is called "File's got apostrophe.xml"
. The output of the XSL is:
<a href="http://myserver/_forms?url=/blah/File&#39;s got apostrophe.xml&id=5">...</a>
问题是撇号被 HTML 转义(两次?)到 &#39;
中,这会破坏链接.
The problem is that the apostrophe is HTML-escaped (twice?) into &#39;
, which breaks the link.
我也尝试过使用 ,结果相同:
I've also tried using <xsl:attribute>
, with same results:
<a>
<xsl:attribute name="href">
<xsl:value-of select="concat('http://myserver/_forms?url=', @FileRef, '&id=5')"
disable-output-escaping="yes" />
</xsl:attribute>
</a>
输出 <xsl:value-of select="@FileRef" disable-output-escaping="yes"/>
效果很好 - 未转义的值打印在页面上.
Outputting <xsl:value-of select="@FileRef" disable-output-escaping="yes" />
works well - the unescaped value is printed on the page.
如何在不转义字符串的情况下设置属性?
How can I set the attribute without escaping the string?
推荐答案
您可以生成您的 <a>作为文本:
You can generate your <a> as text:
<xsl:text disable-output-escaping="yes"><a href="</xsl:text>
<xsl:value-of select="concat('http://myserver/_forms?url=', @FileRef, '&id=5')" disable-output-escaping="yes" />
<xsl:text disable-output-escaping="yes">" >/a<</xsl:text>
这篇关于XSL - 如何禁用属性的输出转义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!