firefox doesn't like 'disable-output-escaping' setting... looking for alternatives

D

David Henderson

I know 'disable-output-escaping' has been discussed in the past, but I can't
put my finger on any of the threads to see if my current problem is
addressed. Sorry for re-asking the question if it has already been
answered...



I have an XML doc that I am transforming via XSLT and JavaScript in the
browser. This allows me to return unsorted data to the browser and allow
the user to sort it with a mouseclick and not hit the server just to perform
the same query with a new sortby clause. My XSLT works fine in Internet
Explorer, but FireFox doesn't seem to respect the 'disable-output-escaping'
attribute like I'd expect. The result is that the output HTML includes <
and " instead of valid HTML.



Here's a fragment of the XML:

<Book isbn="0545010225" author="Rowling, J. K.;" pubDate="21 July 2007">
Harry Potter and the Deathly Hallows
</Book>



Here's the XSLT fragment that transforms it to HTML:

<xsl:template match="Book">

<tr>

<td class="link">

<xsl:text disable-output-escaping="yes">&lt;a
href=&quot;http://localhost/cgi-bin/book_details?isbn=</xsl:text>

<xsl:value-of select="@isbn"/>

<xsl:text disable-output-escaping="yes">&quot; target=&quot;_blank&quot;
&gt;</xsl:text>

<center><xsl:value-of select="@defectid"/></center>

<xsl:text disable-output-escaping="yes">&lt;/a&gt;</xsl:text>

</td>

<td><xsl:value-of select="@author"/></td>

<td><xsl:value-of select="@pubDate"/></td>

<td><xsl:value-of select="."/></td>

</tr>

</xsl:template>



The result HTML should look something like this:

<tr>

>0545010225</a></td>

<td>Rowling, J. K.;</td>

<td> 21 July 2007</td>
<td>Harry Potter and the Deathly Hallows</td>

</tr>



In FireFox, the 'disable-output-escaping="yes"' is being ignored, so I end
up with:

<tr>

<td class="link">&lt;a
href=&quot;http://localhost/cgi-bin/book_details?isbn=0545010225&quot;
target=&quot;_blank&quot; &gt;0545010225&lt;/a&gt</td>

<td>Rowling, J. K.;</td>

<td> 21 July 2007</td>
<td>Harry Potter and the Deathly Hallows</td>

</tr>



.. not quite what I was going for. Anyone have a suggestion?

-David.
 
M

Martin Honnen

David said:
I have an XML doc that I am transforming via XSLT and JavaScript in the
browser. This allows me to return unsorted data to the browser and allow
the user to sort it with a mouseclick and not hit the server just to perform
the same query with a new sortby clause. My XSLT works fine in Internet
Explorer, but FireFox doesn't seem to respect the 'disable-output-escaping'
attribute like I'd expect. The result is that the output HTML includes &lt;
and &quot; instead of valid HTML.

disable-output-escaping is an optional feature only supported when the
XSLT processor serializes the result tree. Firefox does not serialize at
all so it does not support disable-output-escaping.

Instead of

<xsl:text disable-output-escaping="yes">&lt;a
href=&quot;http://localhost/cgi-bin/book_details?isbn=</xsl:text>

<xsl:value-of select="@isbn"/>

<xsl:text disable-output-escaping="yes">&quot; target=&quot;_blank&quot;
&gt;</xsl:text>

<center><xsl:value-of select="@defectid"/></center>

<xsl:text disable-output-escaping="yes">&lt;/a&gt;</xsl:text>

you should simply use literal result elements with attribute value
templates e.g.

<a href="http://localhost/cgi-bin/book_details?isbn={@isbn}"
target="_blank"><center><xsl:value-of select="@defectid"/></a>
 
J

Joseph Kesselman

Martin said:
you should simply use literal result elements with attribute value
templates

Yes. Think in terms of generating XML document structure, ***NOT*** in
terms of generating XML syntax. Trying to force the former by mucking
with the latter is not just a bad idea, it often doesn't work, as this
example demonstrates.
 
Joined
Dec 30, 2010
Messages
1
Reaction score
0
HTML fragments CDATA

Ok so I enclose my html fragments in CDATA so that the xslt parser doesn't parse the html fragments with in my xml. In Chrome I set 'disable-output-escaping' to 'yes' and the cdata elements are not escaped and the html renders correctly.

This is not working in FF since they dont support the 'disable-output-escaping' attribute. Is there a way around this?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top