//*********************************************************************************
// class tig.xml.SAXParsing.java
// Software released under the General Public License (version 2 or later), available at
// http://www.gnu.org/copyleft/gpl.html
//*********************************************************************************
package tig.xml;
import java.io.*;
import org.xml.sax.*;
import org.xml.sax.helpers.DefaultHandler;
import javax.xml.parsers.SAXParserFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
/**********************************************************************************
General utilities to parse an XML document, using SAX2. SAX implementation is used
@author Thierry Graff
@history Aug 10 2000 : Creation
@history Aug 10 2000 : Passed from SAX1 to SAX2
**********************************************************************************/
public class SAXParsing {
//*********************************************************************************
//************************* METHODES **********************************************
//*********************************************************************************
//************** SAXParse(File, HandlerBase) *************
/*********************************************************
Parses a XML file with a given handler. Developped to put the SAX factory code in a single place.
@param xmlFile XML file to parse.
@param handler Handler used to analyze the XML file.
**********************************************************/
public static void SAXParse(File xmlFile, org.xml.sax.DefaultHandler handler){
try{
SAXParserFactory theFactory=SAXParserFactory.newInstance();
SAXParser theSAXParser = theFactory.newSAXParser();
theSAXParser.parse(xmlFile, handler);
}catch(Throwable t){
System.out.println(t.getMessage());
t.printStackTrace();
}
/* }catch(FactoryConfigurationError e){ //pour newInstance()
System.out.println(e.getMessage());
}catch(ParserConfigurationException e){ //pour newSAXParser()
System.out.println(e.getMessage());
}catch(SAXException e){ //pour newSAXParser() et parse()
System.out.println(e.getMessage());
}catch(NullPointerException e){ //pour File()
System.out.println(e.getMessage());
}catch(IOException e){ //pour parse()
System.out.println(e.getMessage());
}catch(IllegalArgumentException e){ //pour parse()
System.out.println(e.getMessage());
}
*/
}//fin SAXParse(File, HandlerBase)
} //end class SAXParsing