[Zope-dev] XML Document appendChild questions

Martijn Faassen M.Faassen@vet.uu.nl
Wed, 28 Jul 1999 13:00:32 +0200


Paul Prescod wrote:
> 
> Martijn Faassen wrote:
> >
> > This is possible, thought the provision (in the DOM spec):
> >
> > Adds the node newChild to the end of the list of children of this node.
> > If the newChild is already in the tree, it is first removed.
> 
> Right. Since the DOM talks only of single documents (don't ask me why),
> what they are doing is talking about a node in the document versus a node
> floating in space.

I see. Zope might need a 'Node floating in Space Document', then, to
make things
easier (especially from DTML -- from Python it's not so big a problem to 
manipulate nodes).
 
> > would imply that it is possible for a newChild to be added that is not
> > already in the tree. But apparently it can't come from another tree, as
> > that is cloning it, really?
> 
> I don't understand that sentence.

Okay, I wasn't aware that the DOM spec was only about single documents 
(plus any nodes floating in space). So that part about 'if the newChild
is already in the tree, it is first removed' seemed to imply that
newChild could come from some other places -- and my idea was another
document. I didn't think of nodes floating in space as a concept. (I'm
not that familiar with the DOM yet)

> It can't come from another document as
> far as the DOM spec is concerned, but I don't have a problem with Zope
> making the logical extension to multiple documents.

As long as we don't conflict with any (future?) standard I suppose..

> You clone a node when
> you want a copy that you can put somewhere else (in the same tree, in
> standard DOM, in any tree, in an extended DOM).

Yes, I figured that this was the case. Sometimes one wants to add a node
to a document that is not yet in that document (it's the first). In that
case you can't clone a node from the doc, modify it, and move it back
into the tree -- what's the DOM's stance on this (as the DOM doesn't
talk about multiple documents)?
 
> > > The more important point is that a single element cannot have two parents.
> > > You should clone it.
> >
> > Yeah, but that isn't supported by XML Document yet. :)
> 
> There's your real problem. :)

I'll be working on that problem. :)
 

Regards,

Martijn