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, component_name):
17 filename = match_dir+"/"+component_name+".xml"
18 self.xmldoc = libxml2.parseFile(filename)
20 # TODO: Check xmldoc against a schema
21 p = self.xmldoc.xpathNewContext()
23 # <context select="..."/>
24 # <rule><argument param="..."/></rule>
25 # <processor name="..."/>
27 context = p.xpathEval('//context/@select')
28 self.context = context[0].content
30 processor = p.xpathEval('//processor/@filename')
31 self.context = processor[0].content
33 name = p.xpathEval('//rule/argument/name')
34 help = p.xpathEval('//rule/argument/help')
35 target = p.xpathEval('//rule/argument/operand')
37 self.arguments = map(lambda (name,help,target):{'name':name.content,'help':help.content,'target':target.content}, zip(name,help,target))