xml-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eric Hodges <harmo...@swbell.net>
Subject RE: Yet another question about creating a Document
Date Thu, 19 Oct 2000 20:46:24 GMT

> -----Original Message-----
> From: Arnaud Le Hors [mailto:lehors@us.ibm.com]
> Sent: Thursday, October 19, 2000 3:27 PM
> To: general@xml.apache.org
> Subject: Re: Yet another question about creating a Document
> 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.

I guess I don't follow.  I thought that was only true if you were validating
the DOM.  And since there doesn't seem to be a way of asking the
DocumentType for the name of its root element, this is difficult to figure
out even if you are validating.

> > 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.

Again, I don't think the name of the root element is well known for
non-validating uses of DOM.  Is it?  Am I missing something?

> > 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.

But you wouldn't force everyone to make the additional calls.  Some of us
want a document with a doctype and no root element.

> > > 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.

That's what I'm doing, though.

> 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.

That assumes that the code that handles the doctype can find out about the
contents of the doctype.  Is there an easy way to find out the name of the
root element in a given doctype?

View raw message