1 /* $Id: SaxDocumentParser.java 1 2010-02-24 13:03:05Z haidw $ */
2 package dol.helper.flattener;
5 import java.io.FileInputStream;
6 import java.io.InputStream;
8 import org.apache.xerces.parsers.SAXParser;
9 import org.xml.sax.Attributes;
10 import org.xml.sax.ContentHandler;
11 import org.xml.sax.ErrorHandler;
12 import org.xml.sax.InputSource;
13 import org.xml.sax.SAXException;
18 class SaxDocumentParser implements ContentHandler{
20 public ErrorHandler bc = new BugCatcher();
21 public SAXParser sp = null;
22 protected boolean foundIterator = false;
24 public SaxDocumentParser() {
27 sp.setFeature("http://xml.org/sax/features/validation",true);
28 sp.setFeature("http://apache.org/xml/features/validation/schema", true);
29 sp.setFeature("http://apache.org/xml/features/validation/schema-full-checking", true);
30 sp.setErrorHandler(bc);
31 sp.setContentHandler(this);
32 sp.setProperty("http://apache.org/xml/properties/schema/external-schemaLocation",
33 dol.util.SchemaLocation.getInternalSchemaLocation());
35 catch (Exception ex) {
40 public boolean parseDocument(String pathToFile){
41 return parseDocument(new File(pathToFile));
44 public boolean parseDocument(File file){
46 InputStream is = new FileInputStream(file);
47 InputSource iss = new InputSource(is);
53 return true;//foundIterator;
57 * Action to be done while parsing a start element of an XML
59 * @param elementName Description of the Parameter
60 * @param attributes Description of the Parameter
61 * @exception SAXException MyException If such and such occurs
63 public void startElement(String namespaceURI, String localName, String elementName, Attributes attributes) throws SAXException {
65 if (elementName.equals("iterator")) {
66 //System.out.println();
67 //System.out.println("Iterator found in document");
71 System.out.print(".");
76 public void startDocument() throws SAXException {
79 public void startPrefixMapping(String prefix, String uri) throws SAXException {
82 public void endDocument() throws SAXException {
85 public void endElement(String namespaceURI, String localName, String elementName) throws SAXException {
88 public void endPrefixMapping(String prefix) throws SAXException {
91 public void characters(char buf[], int offset, int len) throws SAXException {
94 public void skippedEntity(String string){
97 public void processingInstruction(String string1, String string2){
100 public void ignorableWhitespace(char[] characters,int int1,int int2){
103 public void setDocumentLocator(org.xml.sax.Locator dl){