Re: [xsl] using xsl:output-character to render characters in 2 ways

Subject: Re: [xsl] using xsl:output-character to render characters in 2 ways
From: Andrew Welch <andrew.j.welch@xxxxxxxxx>
Date: Tue, 22 Dec 2009 17:20:07 +0000
>> One of the reasons I am using a character map in this example is to
>> create a CDATA section in the output:
>>
>> <script type="text/javascript">//<![CDATA[
>> some.onload(function(){
>> });
>> //]]></script>
>>
>> As I need '//' to appear before the CDATA section I cannot use the
>> cdata-section-elements <xsl:output/> attribute.
>>
>> (Here's an example of why I need the '//':
>> http://javascript.about.com/library/blxhtml.htm )
>>
>> Is there a way I can produce this kind of CDATA section in the output
>> without resorting to character maps?
>
> Though I loath to recommend it, you could use disable-output-escaping= as
> follows:
>
> <script type="text/javascript">//<xsl:text
> disable-output-escaping="yes">&lt;</xsl:text>![CDATA[
> some.onload(function(){
> }};
> //<xsl:text disable-output-escaping="yes">]]&gt;</xsl:text></script>

Or if you use the "html" output method, then

<script type="text/javascript">//&lt;![CDATA[
some.onload(function(){
});
//]]&gt;</script>

should serialise as

<script type="text/javascript">//<![CDATA[
  some.onload(function(){
  });
  //]]>
</script>

-- 
Andrew Welch
http://andrewjwelch.com
Kernow: http://kernowforsaxon.sf.net/

Current Thread