xsl-list
[Top] [All Lists]

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

2008-10-23 08:38:37
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 http://en.wikipedia.org/wiki/Xhtml  That page
suggests an even more complex looking way to escape a script element.

 <script type="text/javascript">
 <!--//--><![CDATA[//><!--
   function loadpdf() {
   
document.getElementById("pdf-object").src="http://www.w3.org/TR/xhtml1/xhtml1.pdf";;
 }
 //--><!]]>
 </script>

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.)

Darcy
On Wed, Oct 22, 2008 at 6:19 PM, David Carlisle 
<davidc(_at_)nag(_dot_)co(_dot_)uk> 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.
________________________________________________________________________

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--