Re: gnome bug 135093
David Malcolm <[email protected]> Fri, 22 Apr 2005 16:23:00 -0400
| Newsgroups | gmane.editors.conglomerate.devel |
|---|---|
| Message-ID | <[email protected]> |
On Fri, 2005-04-22 at 16:15 -0400, Thierry Moisan wrote: > >[snip] > > > > > > > >>I fixed the frontend except for one thing : in bug 135093 there's this line: > >> > >> > > > >I'm looking forward to seeing this! > > > > > > > Ok so I'm sending the patch for the frontend only. Tell me if there's > anything wrong. Did you forget to attach the patch? > > >>I've also looked for the cong_document_for_each_node function at this link : > >>http://gtkdoc.conglomerate.org/0.7.16/CongDocument.html#cong-document-for-each-node > >> > >>but the explanation of the funtion is a TODO. So could someone fill this > >>TODO or explain me how this funtion works and how to understand and use > >>this (or maybe both) : > >> > >> > > > >I've committed this documentation of the function to CVS (it won't yet > >appear on the website): > > > >/** > > * cong_document_for_each_node: > > * @doc: the document > > * @callback: a callback to be invoked for every node in the document > > * @callback_data: data for the callback > > * > > * Perform a depth-first traversal of the nodes in the DOM tree of this document, calling the supplied callback for each node, > > * passing it the supplied data. > > * > > * If the callback returns TRUE, then traversal is halted: you can use this to test for the presence of a node satisfying some condition > > * Otherwise, traversal continues. If you wish to perform some operation on every node in the tree, your callback should always return FALSE. > > * > > * Entity declarations are only visited once; it does not traverse below an entity reference, to avoid potential infinite loops. > > * > > * Returns: TRUE if one of the callback calls returned TRUE (stopping the traversal prematurely); FALSE if the full traversal occurred > > */ > > > >Does this help? > > > >Dave > > > > > > > > > Yeah thanks this helps a lot. But I have some questions left : > 1) what is a node? CongNodePtr/xmlNodePtr are used interchangably; it's a pointer to a libxml2 representation of a DOM node. So every fragment of text in the document appears as a DOM node of type TEXT (have a look in src/cong-node.h) > 2) by a traversal do you mean that this goes trough all the nodes of > the DOM tree? Yes. > 3) Could the callback be like number = number+1 and number would be the Yes, and pass a pointer to an integer as the data. Or you could have a struct containing the integer, and pass a pointer to that (in case you want to count more than one thing). > callback_data? If not please explain me what's a callback and what would > be callback_data. Have a look here: http://www.indopedia.org/Callback_(computer_science).html