def parse(self, source): raise RuntimeError self._locator._public_id = source.getPublicId() self._locator._system_id = source.getSystemId() fp = source.getByteStream() handler = self.getContentHandler() if handler: handler.startDocument() lineno = 0 while 1: token, data = self._get_token(fp) if token is None: break lineno = lineno + 1 self._locator._lineno = lineno self._handle_token(token, data) handler = self.getContentHandler() if handler: handler.startDocument()
def feed(self, data): if not self._started: handler = self.getContentHandler() if handler: handler.startDocument() self._started = 1 data = self._buffer + data self._buffer = None lines = data.split("\n") if lines: for line in lines[:-1]: self._lineno = self._lineno + 1 self._locator._lineno = self._lineno if not line: e = xml.sax.SAXParseException( "ESIS input line contains no token type mark", None, self._locator) self.getErrorHandler().error(e) else: self._handle_token(line[0], line[1:]) self._buffer = lines[-1] else: self._buffer = ""