From bdf8dd800494b4c336e391bd0127b000b077b7aa Mon Sep 17 00:00:00 2001 From: Tony Mack Date: Thu, 27 Oct 2011 11:45:08 -0400 Subject: [PATCH] set default namespace to a dummy vvalue if the xml nsmap is empty --- sfa/util/xml.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/sfa/util/xml.py b/sfa/util/xml.py index 06d61c9c..78e4c6a2 100755 --- a/sfa/util/xml.py +++ b/sfa/util/xml.py @@ -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(): -- 2.43.0