You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-dev@ws.apache.org by ve...@apache.org on 2008/12/18 02:45:42 UTC

svn commit: r727615 - in /webservices/commons/trunk/modules/axiom/modules: axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/ axiom-tests/src/test/java/org/apache/axiom/om/

Author: veithen
Date: Wed Dec 17 17:45:42 2008
New Revision: 727615

URL: http://svn.apache.org/viewvc?rev=727615&view=rev
Log:
WSCOMMONS-207: Modified OMElementImpl and ElementImpl so that the findNamespace method works as described in the Javadoc of the OMElement interface, namely allows to search by prefix.

Modified:
    webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java
    webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java
    webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/OMElementTestBase.java

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java?rev=727615&r1=727614&r2=727615&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java Wed Dec 17 17:45:42 2008
@@ -820,7 +820,7 @@
     private OMNamespace findDeclaredNamespace(String uri, String prefix) {
 
         if (uri == null) {
-            return null;
+            return namespaces == null ? null : (OMNamespace)namespaces.get(prefix);
         }
         // If the prefix is available and uri is available and its the xml
         // namespace

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java?rev=727615&r1=727614&r2=727615&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java Wed Dec 17 17:45:42 2008
@@ -470,7 +470,7 @@
      */
     private OMNamespace findDeclaredNamespace(String uri, String prefix) {
         if (uri == null) {
-            return null;
+            return namespaces == null ? null : (OMNamespace)namespaces.get(prefix);
         }
 
         //If the prefix is available and uri is available and its the xml namespace

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/OMElementTestBase.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/OMElementTestBase.java?rev=727615&r1=727614&r2=727615&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/OMElementTestBase.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/OMElementTestBase.java Wed Dec 17 17:45:42 2008
@@ -130,4 +130,12 @@
     public void testDetachWithoutBuild() throws Exception {
         testDetach(false);
     }
+
+    public void testFindNamespaceByPrefix() throws Exception {
+        OMElement root =
+                AXIOMUtil.stringToOM(getOMFactory(), "<a:root xmlns:a='urn:a'><child/></a:root>");
+        OMNamespace ns = root.getFirstElement().findNamespace(null, "a");
+        assertNotNull(ns);
+        assertEquals("urn:a", ns.getNamespaceURI());
+    }
 }