[thelist] Confused - how does all this fit together ?

Hendrik Schwachenwalde come2los at yahoo.ca
Fri Dec 3 23:41:45 CST 2004


Thanks PPK,

I'd like to follow up with a couple more questions:

> > 3. - The document to be rendered can be accessed  
using
> > the appropriate DOM Level. Which DOM Level is
> > appropriate depends on the document type.
> 
> No. Each document can be accessed by any DOM level.
> The various levels
> only denote extensions to the original Level 1 DOM,
> which contains the
> basics. For most Web purposes Level 1 contains
> plenty of
> functionality.
> 
> The document type has little to do with the DOM,
> except that the
> browser somehow has to handle malformed HTML (like
> <p>This is
> <b>bold</p>.</b>) Exactly how they handle it is
> still an open
> question, and the answer will likely vary from
> browser to browser.

I read that an XHTML document served with MIME
text/xml does not have any of the objects/properties
defined in the DOM HTML while if served with MIME
application/xhtml+xml it does. Is that true? Maybe I
am mixing things up here - even though the DOCTYPE
would still be the same the difference in MIME type 
would then determine which parts of the DOM apply.

> > 5. - Each 'window' or 'frame' is associated with
 it's
> > own Global JavaScript object which can hold
 multiple
> > XML DOM objects (created by
> > document.implementation.createDocument()).
> 
> No about the multiple objects. For Web purposes
> it doesn't really
> matter. Each window holds one document, which is
> plenty to keep
> everybody happy.

Does that mean that in your ImportXML() example at

http://www.quirksmode.org/dom/importxml.html

the line

xmlDoc = document.implementation.createDocument("",
"", null);

overwrites the window.document object? If so what
happens to the previous document tree? Is everything
discarded? What about the rendering?

> As to your code example, my Mozilla gives '1' for
> the length of the
> body collection, as it should.
> 
> > Based on these assumptions I tried to start with a
> > simple document of the strictest type:
> > 
> >
>
-test.xhtml-------------------------------------------
> > 
> > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
> > "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
> > <html xmlns="http://www.w3.org/1999/xhtml"
> > xml:lang="en"><head><title>xdom</title><script
> > type="text/javascript" src="xdom.js"></script>
> > <link rel="stylesheet" type="text/css"
> >
> href="test.css"></link></head><body> </body></html>
> > 
> >
> -xdom.js--------------------------------------------
> > 
> > function js_main(){
> >
> alert(document.getElementsByTagName('body').length);
> > }
> > window.onload=js_main;
> > 
> >
>
-----------------------------------------------------
> > 

Now that was a surprise to me. So I extended my test
and found the following:

If I try to load the file 'test.xhtml' in Mozilla
using Ctrl-O (from the filesystem = no MIME type) I
get the error. If I put 'test.xhtml' on the server and
serve it with MIME application/xhtml+xml I get the
correct result! In both cases Mozilla determines the
Render Mode: Standards compliance mode.
IE6 on the other hand shows the correct result from
the filesystem (Ctrl-O) but cannot handle the proper
MIME type.

That leads to two questions:

1. Is this Mozilla behaviour a bug?

2. If the object tree of a document depends not only
on the document code but also on the MIME type with
which the document was served how come the MIME type
cannot be retrieved via DOM methods? That would also
mean that most of the script samples regarding DOM are
only valid if the document, the script is running on,
was served with the right MIME type!


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


More information about the thelist mailing list