Nodes outside of documents

DocumentFragment appears to be a placeholder for nodes or
node trees that can be in the process of being cut/pasted from
one document to another. During this phase it seems like the nodes
might not be attached to a particular document. This would be
very useful for creating templatized documents, for example,
where some commonly used document fragments are cached and
pasted into the document or rendered serially into an enclosing
document when converted to ascii in a web server.

However, the spec for Document clearly states that nodes may not
exist outside the context of a particular Document. This appears
to contradict the idea of DocumentFragments.

I apologize if I'm completely missing something here, but
any help clearing this up would be much appreciated!

I've built an HTML40 parser that builds up a DOM tree from
either a full document or valid document %block fragments.
It would be nice to not have to always have to create a
full Document object just for the fragments.
My template engine takes a top-level document and a hashtable
of named document fragments that are substituted into
the output stream whenever a SUBST tag is encountered.
This allows me to share document fragments with multiple
master template documents since the merging is done
at serialization time.

Also, just a comment on a possible future server-DOM, it
would be nice to be able to deprecate attributes like
Node.nextSibling, Node.previousSibling and Node.ownerDocument
that make the nodes completely encrusted into the collection
they reside in. This makes it very inefficient if some
of the nodes are remote objects and some are local.
And please bring iterators back!
Being able to mix and match nodes from different DOM
implementations would be very handy, especially for
distributed documents. As I understand it, the current
DOM forbids this.

Thanks,
- Claude Zervas

Received on Tuesday, 11 August 1998 02:57:35 UTC