- From: Jukka K. Korpela <jkorpela@cs.tut.fi>
- Date: Wed, 4 Jun 2008 12:05:59 +0300
- To: "Andras" <lgandras@hotmail.com>, <www-validator@w3.org>
Andras wrote:
> My suggestion is simple.
Yes, but completely wrong.
> Whenever a script is in the head on an XHTML
> 1.0 document, it should validate '<' (less than) characters:
No, it must not validate, since it is not valid. Simple as that.
By the specification of XML, "<" is only allowed at the start of a tag.
> <script type='javascript'>
> var myvar = 0;
> for (var i = 0; i < 10; i ++){
Note that the type attribute is valid but wrong (in the sense of
violating specifications). Its value shall be an Internet media type (in
this case, "text/javascript"), but this limitation cannot be expressed
in the DTD, so it passes validation. Note that using a wrong type
attribute may cause the script to be ignored - browsers may expect it to
be in some language unknown to them.
> That's supposed to be valid, but the validator tells that the '<'
> occurred as data.
You supposed wrongly.
Note that using "<" instead, though valid and correct in theory, is
not a practical move, since in pre-XHTML HTML, rules and different, and
IE is not understand real XHTML. The practical solution is to move the
script to an external file and refer to it via <script
type="text/javascript" src="foo.js"></script>
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/
Received on Wednesday, 4 June 2008 09:06:14 UTC