Re: [xml] How to stop SAX parsing ?

Date view Thread view Subject view Author view

From: Daniel Veillard (Daniel.Veillard@w3.org)
Date: Mon Jun 26 2000 - 10:57:54 EDT


On Mon, Jun 26, 2000 at 04:37:12PM +0200, Petr Kozelka wrote:
>
> I am implementing a SAX parser which invokes some external applications or commands.
> When the command fails, I need the parser to stop parsing and ignore the rest of the file.
> How can I do this ? Is there a SAX function which I can call from inside of my SAX handler to stop sending SAX events ?

  Hum, not yet ...
  The simplest to implement this would not be to add a new SAX
callback but rather modify the xmlParserCtxtPtr passed to the
callbacks. The best seems to be:
  - set ctxt->instate to XML_PARSER_EOF
  - hack xmlCurrentChar() to return 0
    if (ctxt->instate == XML_PARSER_EOF)
  Doing both should led to a quick termination of parsing
(but endElement(s)/endDocument will certainly be called anyway).

Daniel

-- 
Daniel.Veillard@w3.org | W3C, INRIA Rhone-Alpes  | Today's Bookmarks :
Tel : +33 476 615 257  | 655, avenue de l'Europe | Linux XML libxml WWW
Fax : +33 476 615 207  | 38330 Montbonnot FRANCE | Gnome rpm2html rpmfind
 http://www.w3.org/People/all#veillard%40w3.org  | RPM badminton Kaffe
----
Message from the list xml@xmlsoft.org
Archived at : http://xmlsoft.org/messages/
to unsubscribe: echo "unsubscribe xml" | mail  majordomo@xmlsoft.org


Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Wed Aug 02 2000 - 12:30:16 EDT