Ejemplo n.º 1
0
    def evaluate(self, context):
        """Evaluate the left, then if op =// the parsedStep, then the right, push context each time"""
        """Returns a node set"""

        rt = self._left.evaluate(context)
        if type(rt) != type([]):
            raise "Invalid Expression for a PathExpr %s" % str(self._left)

        origState = context.copyNodePosSize()
        if self._step:
            res = []
            l = len(rt)
            for ctr in range(l):
                r = rt[ctr]
                context.setNodePosSize((r,ctr+1,l))
                subRt = self._step.select(context)
                res = Set.Union(res,subRt)
            rt = res
        res = []
        l = len(rt)
        for ctr in range(l):
            r = rt[ctr]
            context.setNodePosSize((r,ctr+1,l))
            subRt = self._right.select(context)
            if type(subRt) != type([]):
                raise Exception("Right Expression does not evaluate to a Node Set")
            res = Set.Union(res,subRt)

        context.setNodePosSize(origState)
        return res
Ejemplo n.º 2
0
 def evaluate(self, context):
     lSet = self._left.evaluate(context)
     if type(lSet) != type([]):
         raise "Left Expression does not evaluate to a node set"
     rSet = self._right.evaluate(context)
     if type(rSet) != type([]):
         raise "Right Expression does not evaluate to a node set"
     set = Set.Union(lSet, rSet)
     set = Util.SortDocOrder(set)
     return set
    def evaluate(self, context):
        res = []
        rt = self._left.select(context)
        l = len(rt)

        origState = context.copyNodePosSize()

        for ctr in range(l):
            context.setNodePosSize((rt[ctr], ctr + 1, l))
            subRt = self._middle.select(context)
            res = Set.Union(res, subRt)

        rt = res
        res = []
        l = len(rt)
        for ctr in range(l):
            context.setNodePosSize((rt[ctr], ctr + 1, l))
            subRt = self._right.select(context)
            res = Set.Union(res, subRt)

        context.setNodePosSize(origState)
        return res