RE: [xsl] double escaping problem [re-visited]

Subject: RE: [xsl] double escaping problem [re-visited]
From: pkeane <pkeane@xxxxxxxxxxxxxxx>
Date: Mon, 12 Nov 2007 20:28:20 -0600 (CST)
Treat it as a workaround rather than a cure. Because DOE doesn't work in all
environments, and it stops you reusing your code as a step in a pipeline. It
would be better to fix the input side so it doesn't double-escape special
characters in the first place

Michael Kay

Hmmm. I was afraid of that. I am still baffled as to how to go about telling my stylesheet that the input it gets from a particular source tree by way of the document() function that it will have already been escaped and therefore that '&amp;' need not be escaped again (making it '&amp;amp;').


Here's the xml coming from http://example.com/collections.xml:
--------------------------
[...]
<collections>
<collection name="Art &amp; Art History Collection" id="1"/>
<collection name="Photography Collection" id="2"/>
</collections>
----------------------------


In my stylesheet I have (this is simplified somewhat):
-----------------------------
[...]
<xsl:template match="insert-collections">
<ul>
<xsl:apply-templates select="document('http://example.com/collections.xml')/collection"/>
</ul>
</xsl:template>


  <xsl:template match="collection">
    <li><xsl:value-of select="@name"/></li>
  </xsl:template>
[...]
----------------------------------------


And the output results in this xhtml: ------------------------ [...] <ul> <li>Art &amp;amp; Art History Collection</li> <li>Photography Collection</li> </ul> [...] ----------------------------

I DID just notice that if I generate the source collecitons list such that "collection name" goes in the element's text node (rather than in an attribute), I do not have the problem. But I suspect there may be other cases (and perhaps I need to avoid them??) when I will transform text in attributes into displayed text in my xhtml result document.

thanks!
Peter Keane



On Mon, 12 Nov 2007, Michael Kay wrote:

My apologies -- it seems when I add
disable-output-escaping="yes" on the <xsl:value-of/> element,
my problem goes away.  So unless that's an egregiously
improper use of DOE, I think my problem is solved.

Current Thread