On Mon, Feb 09, 2004 at 05:54:08AM -0500, Daniel Veillard wrote:
I can't really change it in a clean way now.
Understood, I'm working around this issue.
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.
In that case, the xmlNs node would have a temporary parent element, and a temporary grandparent document. I'm sorry that my logic doesn't make any sense out-of-context. Maybe an example is worth a thousand words: $ python Python 2.3.3 (#2, Jan 13 2004, 00:47:05) [GCC 3.3.3 20040110 (prerelease) (Debian)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from funkxml import * >>> bogus_ns = "http://bogus/" >>> nsd = NsDecl("bogus", bogus_ns) >>> greet = ExpName("greet", bogus_ns) >>> doc1 = Doc(Element("bogus", greet, nsd, "hello world")) >>> doc2 = Doc(Element("bogus", greet, nsd, "goodbye")) In this case, doc1 and doc2 share a single namespace declaration. That namespace declaration has an independent existence. >>> print nsd xmlns:bogus="http://bogus/" >>> print doc1 <?xml version="1.0"?> <bogus:greet xmlns:bogus="http://bogus/">hello world</bogus:greet> >>> print doc1.root <bogus:greet xmlns:bogus="http://bogus/">hello world</bogus:greet> >>> print doc1.root.ns_decls[0] xmlns:bogus="http://bogus/" >>> print doc2.root.ns_decls[0] xmlns:bogus="http://bogus/" In Python, print calls __str__, which is just: def __str__(self): return self.serialize(indent=True) For everything except namespace declarations, serialize is just this: def serialize(self, encoding=None, indent=False): n = None try: ignore, n = self.to_libxml2() return n.serialize(encoding, indent) finally: if n: n.get_doc().freeDoc() Unfortunately namespace declarations must do something different because of the issue at hand. Too bad, but no big deal.
So in any case adding a parent link instead of a document link sounds far more generic, no ?
Sure, if you ever revisit the architecture, a parent link would be fine, since the document link is only one step away through the parent element. The other nodes have both, so I only mentioned both for that reason. -- Anthony Carrico
Attachment:
signature.asc
Description: Digital signature