When neither NodeList or DocumentFragment works

Frans Englich frans.englich at telia.com
Tue Apr 5 14:54:26 BST 2005


Hello,

I have a tricky user-scenario with DOM. Sometimes one wants to manage 
collections of Nodes. Say, one first collects nodes to then do something with 
them. For example, one wants to write an own function conceptually similar to 
Document::getElementsByWhatever.

The NodeList solves this perfectly, but user-code can't create one, AFAICT.

The closest DOM-solution to this is DocumentFragment, which basically is a 
collection of nodes. The problem is that if one takes a Node in a document 
and appendChild()s it to a DocumentFragment, it have become the 
DocumentFragment's child, and not simply a "pointer" to the node in the 
document. This is per design, AFAICT.

In other words, one can't use DocumentFragment as a "collection of nodes in a 
document" since it becomes the parent of the nodes. For example, baseURI 
"breaks" for the nodes.

What is then alternative for getting a set/collection of nodes in a document? 
The only solution I know is to resort to implementation specific methods, 
such as QValueList<Node>.

Any ideas how to solve this? I must be doing something awfully wrong here.


Cheers,

		Frans

PS. It might happen people flag this as off-topic, but let's take that as it 
comes.




More information about the kfm-devel mailing list