xsl-list
[Top] [All Lists]

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

2008-10-23 11:27:37



If output is set to html and remove the script template, then XSLT
(saxon at least) does not escape the output.

there is no way t escape anything inside an html script element as
neither < nor & is recognised as special markup. the only markup that is
recognised as markup is </script> script in html acts like a CDATA
section acts in XML.

But if the output is set to XML, then it does seem necessary to use a
javascript comment on the CDATA because even though the output is set
to strict XHTML, the browser I tried (firefox) doesn't seem to
understand CDATA in the script element.

If you serve the file with an xml mime type then the CDATA section isn't
needed and if it is there it will be parsed correctly, if you generate
XHTML but serve it as html then you are generating XML but parsing it
with an html parser which leads to parse errors, but the solution is
just don't do that, surely.

 Hence the complicated workaround of putting a javascript comment in
front of the CDATA.  I  wished browsers would just understand CDATA
when the doctype is xhtml 

they undertand XML syntax if you tell them it is an XML file, which means
using an XML mime type (not just using an XML doctype, which doesn't
affect whether an xml parser is used, just whether the html renderer
uses standard or quirks mode

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>
--~--

<Prev in Thread] Current Thread [Next in Thread>