Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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:

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

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
948 views
Welcome To Ask or Share your Answers For Others

1 Answer

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>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...