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());
+    }
 }


Reply via email to