1 # Matches and targets are specified using XML files.
2 # They provide the following information:
3 # - The context required by the match
4 # - The processor that actually implements the match or target
5 # - The parameters that the processor needs to evaluate the context
8 from sfatables.globals import *
16 def __init__(self, dir, component_name):
17 filename = dir+"/"+component_name+".xml"
20 self.xmldoc = libxml2.parseFile(filename)
22 # TODO: Check xmldoc against a schema
23 p = self.xmldoc.xpathNewContext()
25 # <context select="..."/>
26 # <rule><argument param="..."/></rule>
27 # <processor name="..."/>
29 context = p.xpathEval('//context/@select')
30 self.context = context[0].content
32 processor = p.xpathEval('//processor/@filename')
33 self.context = processor[0].content
35 name = p.xpathEval('//rule/argument/name')
36 help = p.xpathEval('//rule/argument/help')
37 target = p.xpathEval('//rule/argument/operand')
39 self.arguments = map(lambda (name,help,target):{'name':name.content,'help':help.content,'target':target.content}, zip(name,help,target))