Re: contentScriptType and type on script elements

On Tuesday, January 8, 2008, 3:54:27 PM, Erik wrote:

(Your mail is responded to in a differnet order than how you wrote it)

ED> Spec[1] says: "The contentScriptType attribute on the 'svg' element  
ED> specifies the default scripting language for the given document fragment."
ED> which seems to be in conflict with "Identifies the default scripting  
ED> language for the given document."
ED> [1]
ED> [2]

Its not in conflict. The wording in 1.2T is correct:

contentScriptType = "content-type"

    Identifies the default scripting language for the given document.
    This attribute sets the default scripting language for all the
    instances of script in the document fragment. This language must
    be used for all scripts that do not specify their own scripting
    language. The value content-type specifies a media type, per
    Multipurpose Internet Mail Extensions (MIME) PartTwo [RFC2046].
    The default value is "application/ecmascript".

    Animatable: no.

The wording in 1.1 differs in two details, firstly it assigns a
default of text/ecmascript to identify ECMAScript (while in practice
that language was subsequently registered as application/ecmascript)
and secondly the description fails to cover the case where there is
more than one SVG document fragment in the document.

SVGT 1.2 has a more precise definition of a conforming document

So in this document

<foo xmlns="">
  <svg contentScriptType="foo/bar"
      Hello, World
  <svg contentScriptType="application/ecmascript"
      Goodbye, World
      Goodbye, cruel World
    <script type="foo/bar">
      Hello again, World!

There are three SVG document fragments; in two of them the default
script language is ECMAScript. Of the four script elements, the ones
with Hello are in foo/bar and the ones with Goodbye are ECMAScript.

ED> Reading the SVG 1.1 and 1.2T specs on how 'type' works on 'script'  
ED> elements leads me to a couple of questions:

ED> 1. Given the markup below should the script element with id="s1" run?

No, because there is no script element in the SVG document fragment
(either for 1.1 or 1.2T)

ED> <svg contentScriptType="foo/bar"
ED> xmlns=""><foo  
ED> xmlns=""><script id="s1"  
ED> xmlns=""> alert('whee'); </script></foo></svg>

ED> The script element has to move across the unknown markup to get the  
ED> default scripttype, and if it gets that it shouldn't be executed unless it
ED> understands "foo/bar". Otherwise, one could see it such that it defaults
ED> to "text/ecmascript" even though it lacks a direct 'svg' parent. The  
ED> script is executed in ASV3, Safari 3, Firefox 3, Opera 9.x and Batik 1.7.
ED> I guess this can mean that either 'contentScriptType' is not supported, or
ED> that all viewers assume ecmascript always or that the namespace border
ED> isn't crossed and that it assumes that it is ecmascript.

Several of those reasons may be true; a simpler test will determine
whether contentScriptType and/or type are implemented. If they are
not, then the more complex test is not useful. if they both are
implemented, then your test demonstrates failure to conform to the
definition of an SVG document fragment.

ED> The spec isn't
ED> very clear on how it should work, if you are allowed to cross namespace
ED> boundaries in search of an 'svg' parent element, or what happens if there
ED> is none (although it is a required attribute in 1.1 none of the viewers
ED> seemed to respect that).

That should be an erratum for 1.1 since it can't be both required and
also have a default value :)

ED> 2. Does 'contentScriptType' work on document fragments or on documents?

Document fragments.

ED> That is does nesting 'svg' elements mean that you use the innermost or
ED> outermost 'svg' element when getting 'contentScriptType'?


 Chris Lilley          
 Interaction Domain Leader
 Co-Chair, W3C SVG Working Group
 W3C Graphics Activity Lead
 Co-Chair, W3C Hypertext CG

Received on Thursday, 10 January 2008 21:32:01 UTC