Re: parsing of scripts

From: Liam Quinn (liam@htmlhelp.com)
Date: Fri, Mar 12 1999


Message-Id: <3.0.6.32.19990312114046.00b8e100@mail.undergrad.math.uwaterloo.ca>
Date: Fri, 12 Mar 1999 11:40:46 -0500
To: Chris Nappin <CNappin@inri.co.uk>, "w3c (list)" <www-validator@w3.org>
From: Liam Quinn <liam@htmlhelp.com>
Subject: Re: parsing of scripts

At 02:32 PM 12/03/99 +0000, Chris Nappin wrote:
>
> However, I am having trouble getting my work validated. I am curious about 
>how the contents of script tags are delt with - this is the source of 
>failures for some of the pages I have been trying to get validated.
>
>An example url is:   http://www.afcea.org.uk/test/contents.html
>
>This is a contents frame, using heavy DHTML usage. The validator seems to 
>be complaining about the following type of code:
>
><script language="JavaScript" type="text/javascript">
><!--
>   document.write ('<some really long tag ');
>   document.write ('with lots of data></tag>');
>// -->
></script>

From <http://www.w3.org/TR/REC-html40/types.html#idx-CDATA-1>:

'Although the STYLE and SCRIPT elements use CDATA for their data model, for
these elements, CDATA must be handled differently by user agents. Markup
and entities must be treated as raw text and passed to the application as
is. The first occurrence of the character sequence "</" (end-tag open
delimiter) is treated as terminating the end of the element's content. In
valid documents, this would be the end tag for the element.'

So you need to escape your </tag>:

<script language="JavaScript" type="text/javascript">
<!--
   document.write ('<some really long tag ');
   document.write ('with lots of data><\/tag>');
// -->
</script>

-- 
Liam Quinn