1 56 57 package org.enhydra.apache.xerces.jaxp; 58 59 import org.xml.sax.SAXException ; 60 import org.xml.sax.SAXParseException ; 61 import org.xml.sax.helpers.DefaultHandler ; 62 63 class DefaultValidationErrorHandler extends DefaultHandler { 64 static private int ERROR_COUNT_LIMIT = 10; 65 private int errorCount = 0; 66 67 public void error(SAXParseException e) throws SAXException { 69 if (errorCount >= ERROR_COUNT_LIMIT) { 70 return; 72 } else if (errorCount == 0) { 73 System.err.println("Warning: validation was turned on but an org.xml.sax.ErrorHandler was not"); 75 System.err.println("set, which is probably not what is desired. Parser will use a default"); 76 System.err.println("ErrorHandler to print the first " + 77 ERROR_COUNT_LIMIT + " errors. Please call"); 78 System.err.println("the 'setErrorHandler' method to fix this."); 79 } 80 81 String systemId = e.getSystemId(); 82 if (systemId == null) { 83 systemId = "null"; 84 } 85 String message = "Error: URI=" + systemId + 86 " Line=" + e.getLineNumber() + 87 ": " + e.getMessage(); 88 System.err.println(message); 89 errorCount++; 90 } 91 } 92 | Popular Tags |