[xml] handling namespaces



Hello,

I am struggling to understand how libxml2 is meant to handle namespaces. Most recently, I created an in-memory document using the public API that causes libxslt to hang on xlstCopyNamespaceList() when I call xsltApplyStylesheet().

I am developing a small application that has a feature similar to XInclude. An element in one document causes the inclusion of a subtree of another document. I use the xmlCopyNode() routine to obtain a subtree suitable for being inserted into another document, and I had hoped that the library layer handles namespaces transparently, but it seems not so. I should say that I also tried xmlDocCopyNode(), but I saw no difference in behavior. I observe that the ns field of xmlNode is only populated if the node has a namespace declaration in the original document. Further, the resulting document I created is corrupt, as evidenced from the observation that when it is used as a stylesheet in a transformation, the transformation method never returns, but rather goes into xsltCopyNamespaceList() indefinitely.

Perhaps someone can address the following issues:

1) In some xmlDoc, how do I determine the namespace of a particular xmlNode, following XML rules for inheritance?

2) How do I copy xmlNode instances across documents so as to correct for namespaces?

3) Is the behavior I described a bug in the library, or my misuse of it?

Sincerely,
Eric Levy



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