Re: [xsl] Content of Script element getting wrapped by CDATA

Subject: Re: [xsl] Content of Script element getting wrapped by CDATA
From: "Darcy Parker" <darcyparker@xxxxxxxxx>
Date: Thu, 23 Oct 2008 08:38:09 -0400
It does seem complicated to hide the CDATA section... but it is
necessary if you have invalid XML characters in your javascript code
and do not wish to escape them individually.  And unfortunately the
browsers I have tried don't recognize the CDATA.  The technique of
escaping the CDATA is documented as a best practice in many books and
websites including  That page
suggests an even more complex looking way to escape a script element.

 <script type="text/javascript">
   function loadpdf() {

Overall it is very confusing trying to output the content of a script
element in a form that is recognizable by most browsers and at the
same time readable.  Maybe I am missing something though and you're
trying to point out an easier way to deal with this problem?

(I agree that if the system is adding the CDATA automatically that it
is a bug.  You should have control over this.)

On Wed, Oct 22, 2008 at 6:19 PM, David Carlisle <davidc@xxxxxxxxx> wrote:
> but why all the complication over hiding the CDATA section, why not just
> not have it. If you are outputting as html the CDATA section is clearly
> in error: you can't have CDATA sections in script (which is a CDATA
> element so <! doesn't start a marked section in that context)
> If you are outputting xhtml and sending to an xhtml system the
> CDATA section isn't needed, but if  it is there it will be resolved by
> the xml parser and not seen by the javascript engine.
> If the system is adding CDATA in html mode automatically then that would
> be a bug.
> David
> ________________________________________________________________________
> The Numerical Algorithms Group Ltd is a company registered in England
> and Wales with company number 1249803. The registered office is:
> Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.
> This e-mail has been scanned for all viruses by Star. The service is
> powered by MessageLabs.
> ________________________________________________________________________

Current Thread