def _handle_token(self, token, data): handler = self.getContentHandler() if token == '-': if data and handler: handler.characters(decode(data)) elif token == ')': if handler: handler.endElement(decode(data)) elif token == '(': if self._is_empty: self._empties[data] = 1 if handler: handler.startElement(data, self._attributes) self._attrs.clear() self._is_empty = 0 elif token == 'A': name, value = data.split(' ', 1) if value != "IMPLIED": type, value = value.split(' ', 1) self._attrs[name] = (decode(value), type) elif token == '&': # entity reference in SAX? pass elif token == '?': if handler: if ' ' in data: target, data = data.split(None, 1) else: target, data = data, "" handler.processingInstruction(target, decode(data)) elif token == 'N': handler = self.getDTDHandler() if handler: handler.notationDecl(data, self._public_id, self._system_id) self._public_id = None self._system_id = None elif token == 'p': self._public_id = decode(data) elif token == 's': self._system_id = decode(data) elif token == 'e': self._is_empty = 1 elif token == 'C': pass else: e = SAXParseException("unknown ESIS token in event stream", None, self._locator) self.getErrorHandler().error(e)
def _handle_token(self, token, data): handler = self.getContentHandler() if token == '-': if data and handler: handler.characters(decode(data)) elif token == ')': if handler: handler.endElement(decode(data)) elif token == '(': if self._is_empty: self._empties[data] = 1 self._is_empty = 0 if handler: handler.startElement(data, self._attributes) self._attrs.clear() elif token == 'A': name, value = data.split(' ', 1) if value != "IMPLIED": type, value = value.split(' ', 1) self._attrs[name] = (decode(value), type) elif token == '&': # entity reference in SAX? pass elif token == '?': if handler: if ' ' in data: target, data = data.split(None, 1) else: target, data = data, "" handler.processingInstruction(target, decode(data)) elif token == 'N': handler = self.getDTDHandler() if handler: handler.notationDecl(data, self._public_id, self._system_id) self._public_id = None self._system_id = None elif token == 'p': self._public_id = decode(data) elif token == 's': self._system_id = decode(data) elif token == 'e': self._is_empty = 1 elif token == 'C': pass else: e = SAXParseException("unknown ESIS token in event stream", None, self._locator) self.getErrorHandler().error(e)
def endElement(self, name): for handler in self._handlers: handler.endElement(name)