You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by va...@apache.org on 2007/10/07 01:25:58 UTC

svn commit: r582554 - /ode/trunk/utils/src/main/java/org/apache/ode/utils/DOMUtils.java

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;
     }