Re: [xml] DOM parser and HTML entities inside the <script> tag



On Fri, 2012-07-20 at 09:03 -0500, Raymond Irving wrote: 
Thanks for the feedback Micheal.

I thought that the first occurrence of </script or </style would be signal
the end of the element's content but I guess the W3C had something else in
mind.

HTML 4 (that you are using) was based on ISO 8879 SGML, and the
ISO-defined rules for parsing CDATA elements are as described: the first
</ ends the element. It's better either to use external JavaScript or to
surround it with a CDATA section,
<![CDATA[

then your script here

]]></script>

However, be careful not to have ]]> inside the script!


Or, short answer, it wasn't a W3C decision :-) For what it's worth I
always thought it should work as you describe, although people would
still get caught out.

Liam

-- 
Liam Quin - XML Activity Lead, W3C, http://www.w3.org/People/Quin/
Pictures from old books: http://fromoldbooks.org/
Ankh: irc.sorcery.net irc.gnome.org freenode/#xml
Co-author, 5th edition of Beginning XML, Wrox, July 2012





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]