Re: [xml] Namespace declaration parent, doc: also broken?

On Sun, Feb 08, 2004 at 04:51:17PM -0500, Anthony Carrico wrote:
On Sun, Feb 08, 2004 at 12:18:26PM +0800, William M. Brack wrote:
Perhaps you could elaborate?

I can see from the C documentation link you provided that the parent
and document references aren't available. I was mislead by the Python
binding's class structure where xmlNode is a superclass of xmlNs.

As for the philosophical point, I can get the parent of an attribute,
so why not a namespace declaration? Both are defined on a particular
element, right?

  Right, let's say it's historical. I have tried to keep the xmlNs
nodes small, I should probably have modified them too to add navigation
informations like on other node types, in retrospective it was an error
but I can't really change it in a clean way now.

For my code, the practical issue boils down to memory managment. As
you probably know, Python's gc doesn't extend to libxml2
nodes. Sometimes I would like a function to return a lone namespace
declaration (or an attribute, an element, etc.). This requires
creating a temporary document to hold it. I wish the client could
always use the node itself to access the temporary document to free
it, but I guess a special case is currently necessary for xmlNs.

The application is a functional xml library for Python which has
import/export support for libxml2 (and uses libxml2 for parsing,
serialization, RelaxNG, etc.). In this case, ironically, "functional"
means that the Python elements don't have parent pointers. Temporary
documents seem to be necessary for libxml2 export of any non-document
node. Hopefully that explains why I might want the document reference
to be available.

  There must be a misunderstanding on my part. What is the relevance
of building a document to print a namespace node in isolation, namespaces
must be within an element, so the element context should be used, 
I can't follow your reasoning there. You can't put an xmlNs node as
the child of a document node.
  So in any case adding a parent link instead of a document link sounds
far more generic, no ?


Daniel Veillard      | Red Hat Network
veillard redhat com  | libxml GNOME XML XSLT toolkit | Rpmfind RPM search engine

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