xml-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Arnaud Le Hors <leh...@us.ibm.com>
Subject Re: Yet another question about creating a Document
Date Thu, 19 Oct 2000 20:27:23 GMT
Eric Hodges wrote:
> 
> But those people can just add the element they need to add.  This doesn't
> make any sense to me.  Why make some people remove a bogus element so others
> won't have to add a useful element?

But why would it be bogus?? Given the doctype there is only ONE element
that can be put as the document element. So, it makes perfect sense to
create it automatically.

> The implementation of createDocument() assumes too much about how it will be
> used.
> 
> When I create other nodes, I don't have to supply their children.

There is no other place in the DOM where what child you're going to have
is well known at the time of creation of the parent.

> I can't imagine why the current implementation would be better.  What is the
> advantage of adding an element when the document is created?

You just save a few calls. Rather than forcing everybody to have those
same additional calls it was deemed better to have this done by the DOM
implementation itself.

> > Why don't you simply start from the element that is created for you
> > instead of throwing it away to put another one in place?
> 
> Because I don't know what the first element is going to be when I create the
> document.  Just like I don't know what the doctype is going to be.
> 
> Do parsers just ignore the DOM API?  Or do they cache everything before they
> start building the document?
> 
> Sorry for all the questions and gripes, I'm just sort of frustrated by DOM.
> Nothing personal.

No problem. Your frustration comes from trying to use something that's
not designed for what you're trying to do. The createDocument() stuff in
DOM Level 2 is meant to create a document in memory from scratch. The
idea is that you know what type of document you want to create, you
create a doctype (or not), then create the document along with its root
element and go from there. What's in DOM Level 2 works just fine for
that.
On the other hand it doesn't fit well the need of parsers, given that in
this case you want to create the document before you know anything else.
Parsers are left with two possibilities. Either buffering all the
information up to the point where they can actually create the document
knowing what the doctype is, or use proprietary APIs to create the
document.
It's obviously not satisfactory. Hopefully, DOM Level 3 will fill in
that hole.
-- 
Arnaud  Le Hors - IBM Cupertino, XML Technology Group

Mime
View raw message