Jukka said:
[…] Thomas 'PointedEars' Lahn [wrote]:
No, it illustrates that a markup validator is to be used (before
publishing content).
No markup validator reports <script type="text/javscript"> as an error
AISB, you will have to prove your assertions if you want to be taken
seriously.
(because it is not a reportable markup error).
You are wrong.
The HTML 4.01 and 5 (Draft) Specifications state that the value of the
`type' attribute of the `script' element must be a "(valid MIME/)content
type" [1,2] (from here: MIME type). A valid MIME type should not only
conform to syntactical requirements for MIME types (although the HTML5 draft
states that this suffices [2]), but it should also be registered with IANA
[10], which limits the acceptable attribute values.
The set of MIME types that are reasonable to use here is further limited by
the element type. A markup validator could (indeed, it should) report at
least a warning for a non-registered MIME type such as "text/javscript", as
their use is "discouraged" by RFC 2616 [3], which HTML 4.01 through RFCs
2045 and 2046 [4], and HTML5 directly [5], refer to.
Since the W3C Markup Validator already does experimental markup validation
that is not based on a DTD, for HTML5 [6] (because there is no HTML5 DTD
[7]), it is not too much of a stretch to expect it to report that as an
error or at least issue a warning. Unfortunately, it does neither for now;
but other validators might do that already, and the W3C Markup Validator
could do that in the future. The set of registered MIME types, especially
the set of programming languages that can be used for client-side scripting
from within (X)HTML (or SVG), does not change so often to make it
unfeasible.
In addition to hard-coded validation, it is also possible to validate XHTML,
the XHTML syntax of HTML5 or any other XML-based document against an XML
Schema Definition (cf. [8,9]). XML Schema allows the definition of
restrictions for attribute values so that `type="text/javscript"' would not
pass validation. For a simple example ([8] slightly adapted):
…
<xs:simpleType name="ScriptType">
<xs:annotation>
<xs:documentation>
Media types for ECMAScript implementations, as per [RFC 4329]
</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xsd:enumeration value="application/ecmascript"/>
<xsd:enumeration value="application/javascript"/>
<xsd:enumeration value="text/ecmascript"/>
<xsd:enumeration value="text/javascript"/>
</xs:restriction>
</xs:simpleType>
…
<xs:element name="script">
<xs:annotation>
<xs:documentation>
script statements, which may include CDATA sections
</xs:documentation>
</xs:annotation>
<xs:complexType mixed="true">
<xs:attribute name="id" type="xs:ID"/>
<xs:attribute name="charset" type="Charset"/>
<xs:attribute name="type" use="required" type="ScriptType"/>
<xs:attribute name="src" type="URI"/>
<xs:attribute name="defer">
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:enumeration value="defer"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute ref="xml:space" fixed="preserve"/>
</xs:complexType>
</xs:element>
For maximum flexibility, such a Schema or an equivalent list of acceptable
MIME types could be generated from [10] or resources such as /etc/mime.types
dynamically, or updated regularly.
So in fact there are various ways, including those mentioned, that allow
such errors in attribute values to be flagged upon markup validation.
PointedEars
___________
[1] <
http://www.w3.org/TR/html401/interact/scripts.html#adef-type-SCRIPT>
[2] <
http://dev.w3.org/html5/spec/scripting-1.html#attr-script-type>
[3] <
http://tools.ietf.org/html/rfc2616#section-3.7>
[4] <
http://www.w3.org/TR/html401/types.html#h-6.7>
[5] <
http://dev.w3.org/html5/spec/infrastructure.html#valid-mime-type>
[6] <
http://validator.w3.org/whatsnew.html>, "2008-11-20 — 0.8.4 release"
[7] <
http://dev.w3.org/html5/spec/syntax.html#the-doctype>
[8] <
http://www.w3.org/TR/xhtml1-schema/>
[9] <
http://schneegans.de/sv/>
[10] <
http://www.iana.org/assignments/media-types/index.html>