fix xpath error
authorTony Mack <tmack@paris.CS.Princeton.EDU>
Tue, 24 May 2011 17:07:43 +0000 (13:07 -0400)
committerTony Mack <tmack@paris.CS.Princeton.EDU>
Tue, 24 May 2011 17:07:43 +0000 (13:07 -0400)
sfa/rspecs/pg_rspec.py
sfa/rspecs/rspec.py

index c715f53..9f35d30 100755 (executable)
@@ -62,7 +62,12 @@ class PGRSpec(RSpec):
         RSpec.create(self)
         if self.type:
             self.xml.set('type', self.type) 
-        
+       
+    def remove_element(self, element_name, root_node=None):
+        if not element_name.startswith('rspecv2:'):
+            element_name = 'rspecv2:' + element_name
+        RSpec.remove_element(self, element_name, root_node)
     def get_network(self):
         network = None 
         nodes = self.xml.xpath('//rspecv2:node[@component_manager_uuid][1]', namespaces=self.namespaces)
index 91bac6c..48f79b3 100755 (executable)
@@ -51,11 +51,13 @@ class RSpec:
                 tree = etree.parse(StringIO(rspec), parser)
             except:
                 raise InvalidRSpec('Must specify a xml file or xml string. Received: ' + rspec )
-
         self.xml = tree.getroot()  
         if namespaces:
            self.namespaces = namespaces
 
+    def xpath(self, xpath):
+        return this.xml.xpath(xpath, namespaces=self.namespaces)
+
     def add_attribute(self, elem, name, value):
         """
         Add attribute to specified etree element    
@@ -98,8 +100,7 @@ class RSpec:
         if not root_node:
             root_node = self.xml
 
-        elements = root_node.xpath('//rspecv2:%s | //%s' % (element_name, element_name), \
-                                                            namespaces=self.namespaces)
+        elements = root_node.xpath('//%s ' % element_name, namespaces=self.namespaces)
         for element in elements:
             parent = element.getparent()
             parent.remove(element)