views:

210

answers:

1

I've had the following <a> tag:

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

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

+1  A: 

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;&lt;/a&gt;</xsl:text>
tpeczek
That's a pretty good idea, looks like this is going to work. I'll check on Sunday when I'm back to work. Thanks!
Kobi
That worked, though the result is exceptionally ugly. What a shame for that next developer. Thanks!
Kobi