Re: [xml] Document comments



On Wed, Apr 09, 2003 at 01:57:53PM +0000, Bjorn Reese wrote:
Daniel Veillard wrote:

  xmlAddChild((xmlNodePtr) doc, comment)
those kind of operations work on the common part of the node structures.

Is this an officially endorsed practice? I mainly ask, because I feel
reluctant about casting between two conceptually different structs.

  On a case by case basis yes, I do taht a lot in the code. The structures
(except xmlNs nodes) share a header part used for navigation and linking.

doc.addChild(comment)
[...]
root.addPrevSibling(comment)

I got both to work by upgrading to the latest libxml2 version.
Sorry about that.

 heh ... 

   xmlDocSetRootElement() is more expected to be used for elements nodes
for example it will wipe out the old root if it already exists.

I fail to see the purpose of xmlNewDocComment() then.

  I don't see the link between your sentence and mine ...

Well, at the time of writing, the only possibility I could see
for adding a document comment was to use xmlDocSetRootElement().
If that function only was intended to set the actual root element,

 yup,

and not to add document comments as well, then I had difficulty
understanding why xmlNewDocComment() was needed at all. That is,
why have a special function for this, rather than just using
xmlNewComment()? I guess, that question is not relevant after
all.

   Well xmlNewDocComment() is really xmlNewComment() but with the
doc link of the returned object preinitialized.

Daniel

-- 
Daniel Veillard      | Red Hat Network https://rhn.redhat.com/
veillard redhat com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/



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