I made some local modifications for this. I am not sure if adding that registerNamespace is the right way to do it, as I am not very familiar with the codebase. The changes I did locally were to
a) Modify org.apache.commons.jxpath.ri.QName.java to include the namespace prefix (similar to the one in Apache Axis). Had to tweak it a bit to consider the prefix as the namespaceURI however to keep it compatible with existing code.
b) Maintain a HashMap of prefixes to namespace URIs in the TreeCompiler class.
c) Modify the TreeCompiler.qName(..) to populate the namespace URI in the QName instance returned.
d) Add the registerNamespace method to JXPathContextReferenceImpl and JXPathContext which in turn call a registerNamespace in Compiler class.


I can send across my changes if someone would like to look into it.

-Sudhir

From: Prasad A. Chodavarapu <[EMAIL PROTECTED]>
Subject: [JXPath] Registering namespace prefixes
Date: Wed, 3 Dec 2003 12:32:23 -0500
Content-Type: text/plain;
        charset="iso-8859-1"



Hi All:

Is there a way of registering a namespace prefix upfront in a
JXPathContext so that I can then use that prefix in xpath expressions?
Here's what I'm looking for, in pseudo-code.

JXPathContext domContext = JXPathContext.newContext(document);
domContext.registerNamespace
 (http://www.example.com/ns/sample, "prefix");
domContext.getValue("prefix:a/prefix:b");

Thanks
chap











---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to