Hi Dave, I was able to use the XalanDocumentPrefixResolver to get the issue resolved. This was used because when parsing through a document it will be hard for me to find out which nodes have namespace declarations.
One more question that I have is the usage of Default namespace. XalanDocumentPrefixResolver does not seem to find nodes that use default namespace. What do I need to do to resolve that issue... For example an xml document: <map xmlns="http://www.test.org"><device/></map> I tried to use Xpath expression (/map/device) and got no result back. Looking for the root node /map also does not return me anything. Thanks, Ravin -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Wednesday, October 06, 2004 10:19 AM To: [email protected] Subject: Re: XPathWrapper Question > C:\>XPathWrapper c:\xpathtest.xml / /rootns:root:/q1:foo > The sample works if the namespace declaration for q1 is moved to the root node. > However, we cannot change the declaration. The issue occurs in the execute > statement in the code. XPathWrapper is meant as a demonstration sample, not as production code. It has the limitation that any namespace bindings you use must be declared on the document element. > theXPathProcessor.initXPath(*contextXPath, > theXPathConstructionContext, > XalanDOMString(strQuery.c_str()), > ElementPrefixResolverProxy(rootElem, theEnvSupport, theDOMSupport)); > > XObjectPtr xObj = contextXPath->execute(currentNode, > ElementPrefixResolverProxy(rootElem, theEnvSupport, theDOMSupport), > theExecutionContext); You do exactly what XPathWrapper does -- you create an ElementPrefixResolverProxy and give it the document element. So, the only namespace bindings available are those declared on that element. What you need is another implementation of the PrefixResolver abstract base class that knows about the prefixes and namespace URIs you are interested in. You can implement your own, or you can use an instance of XalanDocumentPrefixResolver, if you want to make all of the namespace bindings in the entire document available. Beware, however, that this is less efficient than creating your own PrefixResolver that only knows about the prefixes you are interested in. Also, XalanDocumentPrefixResolver does not work well when a document contains multiple namespace declarations for the same prefix, but with different namespace URIs. Dave
