def evalForward(self, nodes, valid):
"""Evaluate the axis, name test and predicate
Despite the result set returns whether we possibly made multiple hops
in the dendency graph, i.e. evaluated a 'descendant' axis. In this
caste it is the responsibility of the caller to calculate all possible
paths that lead to the result set.
"""
search = None
if self.__axis == "child":
nodes = self.__evalAxisChild(nodes, True)
elif self.__axis == "descendant":
nodes = self.__evalAxisDescendant(nodes, True)
search = True
elif self.__axis == "descendant-or-self":
nodes = self.__evalAxisDescendant(nodes, True) | nodes
search = True
elif self.__axis == "direct-child":
nodes = self.__evalAxisChild(nodes, False)
elif self.__axis == "direct-descendant":
nodes = self.__evalAxisDescendant(nodes, False)
search = False
elif self.__axis == "direct-descendant-or-self":
nodes = self.__evalAxisDescendant(nodes, False) | nodes
search = False
elif self.__axis == "self":
pass
else:
assert False, "Invalid axis: " + self.__axis
if self.__test == "*":
pass
elif '*' in self.__test:
nodes = set(i for i in nodes if fnmatchcase(i.getName(), self.__test))
else:
nodes = set(i for i in nodes if i.getName() == self.__test)
if self.__pred:
nodes = nodes & self.__pred.evalBackward()
return (nodes, search)
评论列表
文章目录