refactored GetVersion()
[sfa.git] / sfa / util / xml.py
index 90693f2..d6734e6 100755 (executable)
@@ -64,7 +64,7 @@ class XmlElement:
             namespaces = self.namespaces 
         elems = self.element.xpath(xpath, namespaces=namespaces)
         return [XmlElement(elem, namespaces) for elem in elems]
-    
+
     def add_element(self, tagname, **kwds):
         element = etree.SubElement(self.element, tagname, **kwds)
         return XmlElement(element, self.namespaces)
@@ -198,8 +198,9 @@ class XML:
         # set schema
         for key in self.root.attrib.keys():
             if key.endswith('schemaLocation'):
-                # schema location should be at the end of the list
-                schema_parts  = self.root.attrib[key].split(' ')
+                # schemaLocation should be at the end of the list.
+                # Use list comprehension to filter out empty strings 
+                schema_parts  = [x for x in self.root.attrib[key].split(' ') if x]
                 self.schema = schema_parts[1]    
                 namespace, schema  = schema_parts[0], schema_parts[1]
                 break
@@ -264,7 +265,7 @@ class XML:
         if not element:
             element = self.root
         element.remove_attribute(name) 
-        
+
     def add_element(self, *args, **kwds):
         """
         Wrapper around etree.SubElement(). Adds an element to