Author: ajith
Date: Sun May 14 21:50:28 2006
New Revision: 406536

URL: http://svn.apache.org/viewcvs?rev=406536&view=rev
Log:
Changed the output of the getNamespaceURI method to return empty string instead 
of null for the default namespace. This is needed to fix the XMLBeans issue

Modified:
    
webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/llom/OMStAXWrapper.java

Modified: 
webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/llom/OMStAXWrapper.java
URL: 
http://svn.apache.org/viewcvs/webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/llom/OMStAXWrapper.java?rev=406536&r1=406535&r2=406536&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/llom/OMStAXWrapper.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/llom/OMStAXWrapper.java
 Sun May 14 21:50:28 2006
@@ -408,6 +408,7 @@
         String returnString = null;
         if (parser != null) {
             returnString = parser.getNamespaceURI(i);
+
         } else {
             if (isStartElement() || isEndElement()
                     || (currentEvent == NAMESPACE)) {
@@ -418,6 +419,18 @@
                         : ns.getName();
             }
         }
+
+         /*
+           The following line is necessary to overcome an issue where the empty
+           namespace URI returning null rather than the empty string. Our 
resolution
+           is to return "" if the return is actually null
+
+           Note that this is not the case for  getNamespaceURI(prefix) method
+           where the contract clearly specifies that the return may be null
+
+         */
+        if (returnString==null) returnString = "";
+
         return returnString;
     }
 
@@ -748,17 +761,24 @@
      * @param s
      * @return Returns String.
      */
-    public String getNamespaceURI(String s) {
+    public String getNamespaceURI(String prefix) {
+
         String returnString = null;
         if (parser != null) {
-            returnString = parser.getNamespaceURI(s);
+            returnString = parser.getNamespaceURI(prefix);
         } else {
             if (isStartElement() || isEndElement()
                     || (currentEvent == NAMESPACE)) {
 
-                // Nothing to do here! How to get the namespacace references
+               if (rootNode instanceof OMElement){
+                   OMNamespace namespaceURI =
+                           ((OMElement) rootNode).findNamespaceURI(prefix);
+                   return namespaceURI!=null?namespaceURI.getName():null;
+               }
             }
         }
+
+
         return returnString;
     }
 


Reply via email to