You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@xml.apache.org by Roberto Tiella <ti...@sodalia.it> on 2001/02/01 12:17:26 UTC

stopping the SAX parser

Hi,

I would like to stop the SAX parser in a endElement method in
DocumentHandler when a certain condition occours to avoid further
parsing, any suggestions ?

thanks, roberto.

--
Roberto Tiella
Process Reuse And Technologies Area
SODALIA s.p.a.
v. Valentina Zambra,1 38100 TRENTO ITALY
phone: +39 0461 316430 fax: +39 0461 316401



Re: stopping the SAX parser

Posted by Dane Foster <df...@equitytg.com>.
Throw a SAXException.

ex.

try
{
    parser.parse( new InputSource( someURI ) );
}
catch( SAXException sax )
{
    if( sax.getMessage().equals( "My condition is true so stop parsing" ) )
    {
        //do any necessary cleanup or whatever you want to do
    }
}


public void endElement( String ns, String localName, String nsName ) throws
SAXException
{
    if( myTestCondition == true ) throw new SAXException( "My condition is
true so stop parsing" );
}


Dane Foster
Equity Technology Group, Inc
http://www.equitytg.com.


----- Original Message -----
From: "Roberto Tiella" <ti...@sodalia.it>
To: "xml mailing list" <ge...@xml.apache.org>
Sent: Thursday, February 01, 2001 6:17 AM
Subject: stopping the SAX parser


Hi,

I would like to stop the SAX parser in a endElement method in
DocumentHandler when a certain condition occours to avoid further
parsing, any suggestions ?

thanks, roberto.

--
Roberto Tiella
Process Reuse And Technologies Area
SODALIA s.p.a.
v. Valentina Zambra,1 38100 TRENTO ITALY
phone: +39 0461 316430 fax: +39 0461 316401



---------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          general-unsubscribe@xml.apache.org
For additional commands, e-mail: general-help@xml.apache.org