Author: indika
Date: Wed Oct 24 03:40:14 2007
New Revision: 587853
URL: http://svn.apache.org/viewvc?rev=587853&view=rev
Log:
enhance to add all namesapses that can applicable to the given
element(Namespaces with in scope of the element )
Modified:
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/OMElementUtils.java
Modified:
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/OMElementUtils.java
URL:
http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/OMElementUtils.java?rev=587853&r1=587852&r2=587853&view=diff
==============================================================================
---
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/OMElementUtils.java
(original)
+++
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/OMElementUtils.java
Wed Oct 24 03:40:14 2007
@@ -21,6 +21,8 @@
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.om.OMContainer;
+import org.apache.axiom.om.OMDocument;
import org.apache.axiom.om.xpath.AXIOMXPath;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -28,6 +30,8 @@
import org.jaxen.JaxenException;
import java.util.Iterator;
+import java.util.List;
+import java.util.ArrayList;
/**
* Holds Axiom utility methods used by Synapse
@@ -59,23 +63,42 @@
}
/**
- * Add xmlns NS declarations of element 'elem' into XPath expression
- * @param xpath
+ * Add all applicable xmlns NS declarations of element 'elem' into XPath
expression
+ * @param xpath
xmlns:m0="http://services.samples/xsd"
* @param elem
* @param log
*/
public static void addNameSpaces(AXIOMXPath xpath, OMElement elem, Log
log) {
- try {
- Iterator it = elem.getAllDeclaredNamespaces();
+
+ OMElement currentElem = elem;
+
+ while (currentElem != null) {
+ Iterator it = currentElem.getAllDeclaredNamespaces();
while (it.hasNext()) {
+
OMNamespace n = (OMNamespace) it.next();
- xpath.addNamespace(n.getPrefix(), n.getNamespaceURI());
+ if (n != null) {
+
+ try {
+ xpath.addNamespace(n.getPrefix(), n.getNamespaceURI());
+ } catch (JaxenException je) {
+ String msg = "Error adding declared name space with
prefix : "
+ + n.getPrefix() + "and uri : " +
n.getNamespaceURI()
+ + " to the XPath : " + xpath;
+ log.error(msg);
+ throw new SynapseException(msg, je);
+ }
+ }
+ }
+
+ OMContainer parent = currentElem.getParent();
+ //if the parent is a document element or parent is null ,then
return
+ if (parent == null || parent instanceof OMDocument) {
+ return;
+ }
+ if (parent instanceof OMElement) {
+ currentElem = (OMElement) parent;
}
- } catch (JaxenException je) {
- String msg = "Error adding declared name spaces of " + elem + " to
the XPath : " + xpath;
- log.error(msg);
- throw new SynapseException(msg, je);
}
}
-
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]