IQ Development

Online application experts without
any of the 'web 2.0' rubbish hype

XML, XSLT, flash, a CMS and Disable Output Escaping (DOE)

→ Posted by: Tim Southcombe on the: 9 Oct 2007

A number of requirements for a recent project using our CMS Site Foundry had us learning a few new things about XSLT and XML, as well as observing the arguments for and against Disable Output Escaping.

Site Foundry already outputs XML in definable templates - but the main requirement was that it had to feed into flash, and provide a non-flash version for users without flash. This is always a conundrum with any content management - do you really want to keep two versions of the site maintained? Of course the answer is always no.

So to this end, we decided to go down the route of providing XML from the CMS, allowing all content to be read by a flash application. This same XML would be viewable as XHTML via an XSLT document that would then link in with CSS, images etc in the usual way (see image below).

Diagram showing CMS outputting content via XML and XSLT And it all worked rather well, until we tried to get the non-flash version working in Firefox. It was funny reading all the geek rhetoric flying about; is it a problem, or just the way it should be? As in all these arguments, both parties have valid points, but really, the only point that counts more often than not, is that a clients wants something a particular way and if there is a solution, then it has to be done regardless of the high ideals.

In out case, we really had no choice: we came to the conclusion that if you have a situation that requires an indeterminate amount of formatted HTML elements to transmitted by XML, then the only way to do this dynamically is by encapsulating it in

After more furious googling, we found a javascript solution http://pagexi.com/js/disableOutputEscaping.js that got everything displaying correctly in Firefox.  

To get it working include the following bits in your XSLT document:

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<body onload="go_decoding();">
<div id="cometestme" style="display:none;">
    <xsl:text disable-output-escaping="yes">&amp;amp;</xsl:text>
</div>
<span name="decodeable">
    <xsl:value-of select="content/body" disable-output-escaping="yes" />
</span>
</body>
</html>
</xsl:template>
</xsl:stylesheet> 

Any block of text that requires DOE, surround it with a span (or whatever tag takes your fancy) and give it a name equal to decodeable.

See, all rather easy, and everyone gets to have the world the way they want it.

View comments (0) | View trackbacks (0) | Permalink | Trackback

→ There are no comments for this post ←

→ Comments have been disabled for this post ←

Out our window
Blog categories
News