XSL - 如何禁用属性的输出转义?

发布于 09-03 08:19 字数 880 浏览 10 评论 0原文

我有以下 标记:

<a href="http://myserver/_forms?url={@FileRef}&amp;id=5">...</a>

其中一个文件名为 “File's got apostrope.xml”。 XSL 的输出是:

<a href="http://myserver/_forms?url=/blah/File&amp;#39;s got apostrophe.xml&id=5">...</a>

问题是撇号被 HTML 转义(两次?)到 &#39; 中,这会破坏链接。

我还尝试使用 ,结果相同:

<a>
  <xsl:attribute name="href">
    <xsl:value-of select="concat('http://myserver/_forms?url=', @FileRef, '&amp;id=5')"
         disable-output-escaping="yes" />
  </xsl:attribute>
</a>

输出 效果很好 - 未转义的值打印在页面上。

如何在不转义字符串的情况下设置属性?

I've had the following <a> tag:

<a href="http://myserver/_forms?url={@FileRef}&id=5">...</a>

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>

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>

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

↘紸啶2024-09-10 08:19:16

您可以生成您的 作为文本:

<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>

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>
你没皮卡萌2024-09-10 08:19:16

我知道我在这方面有点晚了,但我认为属性标签是方法,你只是不想连接......

<a>
  <xsl:attribute name="href">
    http://myserver/_forms?url=<xsl:value-of select="@FileRef" disable-output-escaping="yes" />&id=5
  </xsl:attribute>
</a>

I know I'm a bit late on this, but I think the attribute tag is the way to, you just don't want to concat...

<a>
  <xsl:attribute name="href">
    http://myserver/_forms?url=<xsl:value-of select="@FileRef" disable-output-escaping="yes" />&id=5
  </xsl:attribute>
</a>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文