[Javascript] RE: How to get valid XHTML when links contain "invalid characters"

David Dorward david at dorward.me.uk
Wed Feb 1 13:55:53 CST 2006


On Wed, 2006-02-01 at 14:41 -0500, Janie Hadsel wrote:
> I tried to write a note to the list last night after I developed my
> own solution, but found out the hard way that replying to a list
> message doesn't work (at least not in gmail). Your approaches were all
> interesting. I'd like to learn more about CDATA. I've seen that in
> other scripts recently but didn't read anything about it when I first
> learned JavaScript.

CDATA is a markup thing, not a JavaScript thing. In a nutshell, in XML
documents, you wrap code with CDATA markers (you can grab the syntax
from the XHTML 1.0 spec) and data within those markers is not parsed by
the XML parser.

In practise, its a poor idea in XHTML documents since you have to hide
the CDATA markers from the JavaScript parser when the document is served
as text/html, and then leap through even more hoops to hide the whole
lot from pre-JavaScript browsers. XHTML served as text/html is not a
good idea (and XHTML served as application/xhtml+xml is very badly
supported so is also a bad idea, so basically - XHTML client side is a
bad idea, stick to HTML 4.01).

If you insist on using XHTML then sticking JavaScript in external files
is the recommended way to deal with characters that have special meaning
in XML.

-- 
David Dorward                           <http://dorward.me.uk/>
"Anybody remotely interesting is mad, in some way or another."
                             -- The Greatest Show in the Galaxy



More information about the Javascript mailing list