Keep xml files valid :-/
[sfa.git] / sfatables / xmlextension.py
index c852a26..809ea36 100644 (file)
@@ -5,18 +5,19 @@
 #   - The parameters that the processor needs to evaluate the context
 
 import libxml2
-
-match_dir = 'matches'
+from sfatables.globals import *
 
 class Xmlextension:
-    context = ""
-    processor = ""
-    operand = "VALUE"
-    arguments = []
+    def __init__(self, file_path):
+
+        print file_path
+        self.context = ""
+        self.processor = ""
+        self.operand = "VALUE"
+        self.arguments = []
+        self.terminal = 0
 
-    def __init__(self, component_name):
-        filename = match_dir+"/"+component_name+".xml"
-        self.xmldoc = libxml2.parseFile(filename)
+        self.xmldoc = libxml2.parseFile(file_path)
 
         # TODO: Check xmldoc against a schema
         p = self.xmldoc.xpathNewContext()
@@ -35,6 +36,9 @@ class Xmlextension:
         help = p.xpathEval('//rule/argument/help')
         target = p.xpathEval('//rule/argument/operand')
 
+        context = p.xpathEval('//attributes/attribute[@terminal="yes"]')
+        self.terminal = (context != [])
+
         self.arguments = map(lambda (name,help,target):{'name':name.content,'help':help.content,'target':target.content}, zip(name,help,target))
         
         p.xpathFreeContext()