Re: [xsl] Un-cdata-section-elements

Subject: Re: [xsl] Un-cdata-section-elements
From: David Carlisle <davidc@xxxxxxxxx>
Date: Tue, 21 Mar 2006 13:39:59 GMT
> Is there any way to undo the CDATA section rules for outputting XHTML
> 1.0? I'm trying to create something like ;

In theory you should never need to do this.
If you are outputting HTML then the javascript wil be output by XSLT
using CDATA conventions as script is a CDATA element in HTML.

If you are outputting XHTML then script is a normal element (as CDATA
elements do not exist in XML) an any conforming XHTML engine will
correctly interpret any &lt; and &amp; as XML markup and decode them
_before_ passing the resulting string to the javascript engine.

This theory though assumes that people only give html to html systems
and xhtml to xhtml systems, however unfortunately it seems to be
increasngly common to give xhtml to html systems, which leads to these
problems.

In XSLT1 you'd probably have to use disable-output-escaping. to generate
  // <![CDATA[
in XSLT2 it would be better to use a character map, pick a couple of
unused characters, and declare a character map so that one is serialised
as   // <![CDATA[ and the other as //]]> and just arrange to put these
characters as the first and last characters in the script element
content. Similarly use a couple of characters representing an unescaped
  < and &.

> but the JavaScript
> engines complain (it doesn't understand CDATA, of course)
If the page is handled by a conforming XHTML system all aspects of the
XML markup will be resolved before javascript sees the file.

David


________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

Current Thread