Re: [gdome]Right implementation for DocumentFragment



On Fri, 9 Mar 2001, Daniel Veillard wrote:

> On Thu, Mar 08, 2001 at 09:03:38PM +0100, Paolo Casarini wrote:
> > Now some methods in GdomeNode implementation have the right behavior when
> > the node is a XML_DOCUMENT_FRAG_NODE (appendChild, insertBefore and
> > replaceChild).
> 
>   Hum, I would like to point out that libxml do not generate them,
> the only place where such a node is generated is in xmlNewDocFragment()
I know it. I use xmlNewDocFragment in the Document.createDocumentFrament
method to create such nodes, then the gdome user can work with it 
appending, inserting, removing or replacing nodes from its child list.
When he think it's time to insert it in the DOM Tree (libxml tree), calls
for example insertBefore methods on a node of the real tree with the
Document Fragment node as the newchild parameter.
The appendChild and insertBeforeChild methods applied on a Document
Fragment node simply append or insert the full children list of the DF
node to the the DOM tree (gdome does this).
DF nodes will never be present in the libxml tree.
>From DOM2 specs: 'DocumentFragment is a "lightweight" or
"minimal" Document object. It is very common to want to be able to extract
a portion of a document's tree or to create a new fragment of a document.'  

> which was added for DOM support but not used anywhere in the libxml 
> library.
This is not a problem to me... I think... I hope :-)

If you want to know how it works, look at the test-node in test directory
of gdome2 CVS tree (test_df_node function).

Thanx
   Paolo
--
Paolo Casarini - casarini cs unibo it





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]