ode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From va...@apache.org
Subject svn commit: r582554 - /ode/trunk/utils/src/main/java/org/apache/ode/utils/DOMUtils.java
Date Sat, 06 Oct 2007 23:25:58 GMT
Author: vanto
Date: Sat Oct  6 16:25:55 2007
New Revision: 582554

URL: http://svn.apache.org/viewvc?rev=582554&view=rev
Log:
fixing NPE in getParentNamespace()

Modified:
    ode/trunk/utils/src/main/java/org/apache/ode/utils/DOMUtils.java

Modified: ode/trunk/utils/src/main/java/org/apache/ode/utils/DOMUtils.java
URL: http://svn.apache.org/viewvc/ode/trunk/utils/src/main/java/org/apache/ode/utils/DOMUtils.java?rev=582554&r1=582553&r2=582554&view=diff
==============================================================================
--- ode/trunk/utils/src/main/java/org/apache/ode/utils/DOMUtils.java (original)
+++ ode/trunk/utils/src/main/java/org/apache/ode/utils/DOMUtils.java Sat Oct  6 16:25:55 2007
@@ -335,24 +335,26 @@
         HashMap<String,String> pref = new HashMap<String,String>();
         Map mine = getMyNamespaces(el);
         Node n = el.getParentNode();
-        do {
-            if (n instanceof Element) {
-                Element l = (Element) n;
-                NamedNodeMap nnm = l.getAttributes();
-                int len = nnm.getLength();
-                for (int i = 0; i < len; ++i) {
-                    Attr a = (Attr) nnm.item(i);
-                    if (isNSAttribute(a)) {
-                        String key = getNSPrefixFromNSAttr(a);
-                        String uri = a.getValue();
-                        // prefer prefix bindings that are lower down in the tree.
-                        if (pref.containsKey(key) || mine.containsKey(key)) continue;
-                        pref.put(key, uri);
-                    }
-                }
-            }
-            n = n.getParentNode();
-        } while (n != null && n.getNodeType() != Node.DOCUMENT_NODE);
+        if (n != null) {
+	        do {
+	            if (n instanceof Element) {
+	                Element l = (Element) n;
+	                NamedNodeMap nnm = l.getAttributes();
+	                int len = nnm.getLength();
+	                for (int i = 0; i < len; ++i) {
+	                    Attr a = (Attr) nnm.item(i);
+	                    if (isNSAttribute(a)) {
+	                        String key = getNSPrefixFromNSAttr(a);
+	                        String uri = a.getValue();
+	                        // prefer prefix bindings that are lower down in the tree.
+	                        if (pref.containsKey(key) || mine.containsKey(key)) continue;
+	                        pref.put(key, uri);
+	                    }
+	                }
+	            }
+	            n = n.getParentNode();
+	        } while (n != null && n.getNodeType() != Node.DOCUMENT_NODE);
+        }
         return pref;
     }
 



Mime
View raw message