Logo Search packages:      
Sourcecode: harpia version File versions  Download package

def harpia::amara::saxtools::xpattern_state_machine::event (   self,
  is_start,
  ns,
  local 
)

Register an event and effect ant state transitions
found in the state table

Definition at line 232 of file saxtools.py.

00232                                         :
        """
        Register an event and effect ant state transitions
        found in the state table
        """
        #We only have a chunk ready for the handler in
        #the explicit case below
        self.entering_xpatterns = []
        self.leaving_xpatterns = []
        self.tree_depth += is_start and 1 or -1
        #print "event", (is_start, ns, local), self._state, self.tree_depth, self.depth_marks
        #An end event is never significant unless we know we're expecting it
        if not is_start and self.depth_marks and self.tree_depth != self.depth_marks[-1]:
            return self._state
        lookup_from = self._state_table[self._state]
        #FIXME: second part should be an element node test "*", should not match, say, start document
        if not lookup_from.has_key((is_start, ns, local)) and (ns, local) == (None, None):
            return self._state

        if lookup_from.has_key((is_start, ns, local)) or lookup_from.has_key((is_start, ns, ANY)):
            try:
                new_state = lookup_from[(is_start, ns, local)]
            except KeyError:
                new_state = lookup_from[(is_start, ns, ANY)]
            if (new_state in self._live_states):
                #Entering a defined XPattern chunk
                self.entering_xpatterns.append(self._live_states[new_state])
                self.current_xpatterns.append(self._live_states[new_state])
            elif (self._state in self._live_states):
                #Leaving a defined XPattern chunk
                self.leaving_xpatterns.append(self.current_xpatterns.pop())
            if is_start:
                self.depth_marks.append(self.tree_depth - 1)
            else:
                self.depth_marks.pop()
            self._state = new_state
        elif lookup_from.has_key((is_start, ANY, EXPLICIT)):
            new_state = lookup_from[(is_start, ANY, EXPLICIT)]
            if (new_state in self._live_states):
                #Entering a defined XPattern chunk
                self.entering_xpatterns.append(self._live_states[new_state])
                self.current_xpatterns.append(self._live_states[new_state])
            elif (self._state in self._live_states):
                #Leaving a defined XPattern chunk
                self.leaving_xpatterns.append(self.current_xpatterns.pop())
            self._state = new_state
            if is_start:
                self.depth_marks.append(self.tree_depth - 1)
            else:
                self.depth_marks.pop()
        elif lookup_from.has_key((is_start, ANY, IMPLICIT)):
            new_state = lookup_from[(is_start, ANY, IMPLICIT)]
            self._state = new_state
            if is_start:
                self.depth_marks.append(self.tree_depth - 1)
            else:
                self.depth_marks.pop()
        #print self.entering_xpatterns,self.leaving_xpatterns,self.current_xpatterns
        return self._state

    def status(self):


Generated by  Doxygen 1.6.0   Back to index