Re: Type attribute in script elememt - content-type format

On Sat, 13 Aug 2005, Bent Lynggård wrote:

> Your validator accepts <script type="javascript" ...> as a valid element.

That's a tag, not an element, but basically a validator _must_ accept the 
construct because it _is_ valid according to the document type definition 
used. So would <script type="almost whatever I put here!"> be.

> Internet Explorer 6, Netscape 8, Firefox 1, and Opera 8 for Windows all
> ignore such script element.

Not really. They just treat its content as being in an unrecognized 
scripting language.

> As I read http://www.ietf.org/rfc/rfc2045.txt page 10, the type attribute
> must have a type/subtype format, i.e. text/javascript.

According to the authoritative registry of media types,
http://www.iana.org/assignments/media-types/
the type text/javascript is obsolete, and application/javascript
is what you should use for JavaScript. Whether browsers catch this up is a 
different issue; so is question whether source programs in a high-level
languages _should_ have primary type text, application, or something else. 
Now returning to validation,...

> Shouldn't the
> validator mark type="javascript" as an error?

No, and it must not; it might conceivably issue a warning, but that would 
mean that it works as an informal checker along with its role as a 
validator.

The attribute is declared with CDATA value, which basically means 
"anything goes", and a validator thus _must_ accept anything here.
The story is the same for attribute values that are specified as URL 
values in the prose of the HTML specification; from the validator 
viewpoint, they are just CDATA.

If you regard this as too permissive, then the problem is in the DTD,
not in the validator, which by definition runs a check against a DTD.
Actually, the problem is deeper: in the metalanguage used for writing a 
DTD, since the metalanguage would not let us specify, for example,
that an attribute's value shall be of the form "foo/bar", where foo and 
bar are names.

More on what validation is:
http://www.cs.tut.fi/~jkorpela/html/validation.html

-- 
Jukka "Yucca" Korpela, http://www.cs.tut.fi/~jkorpela/

Received on Sunday, 14 August 2005 06:53:11 UTC