DOM level 1 - ECMAScript binding

Hi,

The DOM level 1-ECMAScript binding
(http://www.w3.org/TR/REC-DOM-Level-1/ecma-script-language-binding.html)
remains a bit of mystery to me - even in its very elementary
understanding in using DOM/ECMA w/ XML/HTML.

I'm not sure if the constructs familiar from JavaScript are DOM/ECMA
compliant of just an easier syntax to the end user, and I need some
scripting which "will work in any DOM1/ECMA compliant browser"...

For example, in an HTML document, one might change an image named
"picture1" w/ a command "document.images.picture1.src = 'foo.gif'; "

As far as I understand the spec,
document.images.namedItem['picture1'].src = "foo.gif";
would be the "correct way" to say this? Yes, no ? (actually, I don't
even see the "document" being part of the binding!)

Now, going into the XML world,  assuming for example a document

<doc id="document1" someAttr="foo">
    <para>
        This is a paragraph with a picture. <image src="bar.gif
name="aPic" id="pic1" someAttribute="grrr" />
    </para>
<doc>

The way I could change the image with an ECMAScript command would be
"document.getElementsByTagName('image').item[x] = 'foo.gif'"; (if I know
the "number" of the image)  or

other wise do a for-next loop, to check whether the 'name' attribute =
aPic or 'id' attribute  = 'pic1'

As far as I can see, no "JavaScript-like way" to do it, i.e. say
document.images[imageName].someAttribute = aValue ,
document.doc.someAttr = "bar", etc. ??

Sorry, if this is obvious! I guess the simple question that remains
is "what does the DOM-ECMAScript language biding actually tell me" ? 
Am I missing somthing fundamental here?

Regards,
Teemu Ropponen

Received on Tuesday, 23 May 2000 06:39:32 UTC