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

时间:2022-11-28 13:20:10

I've had the following <a> tag:

我有以下标签:

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

One of the files is called "File's got apostrophe.xml". The output of the XSL is:

其中一个文件叫做“File's got apostrophee .xml”。XSL的输出是:

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

The problem is that the apostrophe is HTML-escaped (twice?) into &amp;#39;, which breaks the link.

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

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, '&amp;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?

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

2 个解决方案

#1


17  

You can generate your <a> as text:

您可以将作为文本生成:

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

#2


5  

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

我知道我有点晚了,但是我认为属性标签是一种方式,你只是不希望concat。

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

#1


17  

You can generate your <a> as text:

您可以将作为文本生成:

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

#2


5  

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

我知道我有点晚了,但是我认为属性标签是一种方式,你只是不希望concat。

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