W3C home > Mailing lists > Public > www-dom@w3.org > January to March 1999

RE: HTML APIs

From: Miles Sabin <msabin@cromwellmedia.co.uk>
Date: Mon, 4 Jan 1999 18:15:11 -0000
Message-ID: <c=US%a=_%p=Cromwell_Media%l=ODIN-990104181511Z-64948@odin.cromwellmedia.co.uk>
To: "'Lauren Wood'" <lauren@sqwest.bc.ca>, "'www-dom@w3.org'" <www-dom@w3.org>
Lauren Wood wrote,

> In a schematic way of thinking, you can say that the
> HTML document goes through the HTML parser, which adds
> all the omitted tags, default attribute values, etc
> and is turned into the structure model (that internal
> representation of the document which the DOM
> implementation uses). The DOM functions, methods, etc
> then act on this structure model, not on the source
> document. So by the time the DOM gets to the document,
> all the missing pieces have already been filled in by
> the parser. 

That might be so for DOM implementations embedded in UAs
(tho' I'm not even sure about that), but what about
server side uses of the DOM where the structure model is
built using the creation APIs,

  public void foo(HTMLDocument doc)
  {
    // assume doc is newly created.

    NodeList bodyList = doc.getElementsByTagName("BODY");
    NodeList frameSetList = doc.getElementsByTagName("FRAMESET");

    if(bodyList.getLength() == 0 && frameSetList.getLength() == 0)
      doc.setBody(doc.createElement("BODY"));                       // 1
    else if(frameSetList.getLength() == 1)
      frameSetList.item(0).appendChild(doc.createElement("FRAME")); // 2
    else if(bodyList.getLength() == 1)
      bodyList.item(0).appendChild(doc.createElement("P"));         // 3
  }

As far as I can see from the REC, any of the following might
legitimately be true,

* (1) might never be executed, because a call on
  HTMLDocument.getElementsByTagName() might trigger auto
  insertion of HTML and BODY elements into an otherwise
  empty document.

* (2) might never be executed, for the same reason.

* (3) might never be executed, because an implementation
  might _not_ auto insert of HTML and BODY elements on a
  call to HTMLDocument.getElementsByTagName().

And I there a quite a few other possibilities too.

Maybe these are slightly perverse examples, but I does
look as tho' the spec needs a little tightening up here.

Cheers,


Miles

-- 
Miles Sabin                          Cromwell Media
Internet Systems Architect           5/6 Glenthorne Mews
+44 (0)181 410 2230                  London, W6 0LJ
msabin@cromwellmedia.co.uk           England


  
  
Received on Monday, 4 January 1999 13:19:24 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:13:46 GMT