set default namespace to a dummy vvalue if the xml nsmap is empty
authorTony Mack <tmack@paris.CS.Princeton.EDU>
Thu, 27 Oct 2011 15:45:08 +0000 (11:45 -0400)
committerTony Mack <tmack@paris.CS.Princeton.EDU>
Thu, 27 Oct 2011 15:45:08 +0000 (11:45 -0400)
sfa/util/xml.py

index 06d61c9..78e4c6a 100755 (executable)
@@ -55,14 +55,13 @@ class XML:
         # set namespaces map
         self.namespaces = dict(self.root.nsmap)
         if 'default' not in self.namespaces and None in self.namespaces: 
+            # If the 'None' exist, then it's pointing to the default namespace. This makes 
+            # it hard for us to write xpath queries for the default naemspace because lxml 
+            # wont understand a None prefix. We will just associate the default namespeace 
+            # with a key named 'default'.     
             self.namespaces['default'] = self.namespaces[None]
-        # If the 'None' exist, then it's pointing to the default namespace. This makes 
-        # it hard for us to write xpath queries for the default naemspace because lxml 
-        # wont understand a None prefix. We will just associate the default namespeace 
-        # with a key named 'default'.     
-        if None in self.namespaces:
-            default_namespace = self.namespaces.pop(None)
-            self.namespaces['default'] = default_namespace
+        else:
+            self.namespaces['default'] = 'default' 
 
         # set schema 
         for key in self.root.attrib.keys():