Author: asankha
Date: Thu Aug 3 22:11:46 2006
New Revision: 428625
URL: http://svn.apache.org/viewvc?rev=428625&view=rev
Log:
Not the ideal solution to the issue, as the root cause lies with the Jaxen
code; but is a workaround to get the namespaces we add to an AXIOMXPath, back
again
Modified:
webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/xpath/AXIOMXPath.java
Modified:
webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/xpath/AXIOMXPath.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/xpath/AXIOMXPath.java?rev=428625&r1=428624&r2=428625&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/xpath/AXIOMXPath.java
(original)
+++
webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/xpath/AXIOMXPath.java
Thu Aug 3 22:11:46 2006
@@ -2,12 +2,18 @@
import org.jaxen.BaseXPath;
import org.jaxen.JaxenException;
+import org.jaxen.SimpleNamespaceContext;
+
+import java.util.HashMap;
+import java.util.Map;
public class AXIOMXPath extends BaseXPath {
-
+
private static final long serialVersionUID = -5839161412925154639L;
- /**
+ private Map namespaces = new HashMap();
+
+ /**
* Construct given an XPath expression string.
*
* @param xpathExpr the XPath expression.
@@ -16,5 +22,33 @@
*/
public AXIOMXPath(String xpathExpr) throws JaxenException {
super(xpathExpr, new DocumentNavigator());
+ }
+
+ /**
+ * This override captures any added namespaces, as the Jaxen BaseXPath
class nor
+ * NamespaceContext (or SimpleNamespaceContext) exposes thier internal map
of the
+ * prefixes to the namespaces. This method - although is not the ideal
solution to
+ * the issue, attempts to provide an override to changing the Jaxen code.
+ * @param prefix a namespace prefix
+ * @param uri the URI to which the prefix matches
+ * @throws JaxenException if the underlying implementation throws an
exception
+ */
+ public void addNamespace(String prefix, String uri) throws JaxenException {
+ try {
+ super.addNamespace(prefix, uri);
+ } catch (JaxenException e) {
+ // the intention here is to prevent us caching a namespace, if the
+ // underlying implementation does not accept it
+ throw e;
+ }
+ namespaces.put(prefix, uri);
+ }
+
+ /**
+ * Expose the prefix to namespace mapping for this expression
+ * @return a Map of namespace prefixes to the URIs
+ */
+ public Map getNamespaces() {
+ return namespaces;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]