1 16 17 package org.apache.xerces.jaxp; 18 19 import org.xml.sax.SAXException ; 20 import org.xml.sax.SAXParseException ; 21 import org.xml.sax.helpers.DefaultHandler ; 22 23 26 27 class DefaultValidationErrorHandler extends DefaultHandler { 28 static private int ERROR_COUNT_LIMIT = 10; 29 private int errorCount = 0; 30 31 public void error(SAXParseException e) throws SAXException { 33 if (errorCount >= ERROR_COUNT_LIMIT) { 34 return; 36 } else if (errorCount == 0) { 37 System.err.println("Warning: validation was turned on but an org.xml.sax.ErrorHandler was not"); 39 System.err.println("set, which is probably not what is desired. Parser will use a default"); 40 System.err.println("ErrorHandler to print the first " + 41 ERROR_COUNT_LIMIT + " errors. Please call"); 42 System.err.println("the 'setErrorHandler' method to fix this."); 43 } 44 45 String systemId = e.getSystemId(); 46 if (systemId == null) { 47 systemId = "null"; 48 } 49 String message = "Error: URI=" + systemId + 50 " Line=" + e.getLineNumber() + 51 ": " + e.getMessage(); 52 System.err.println(message); 53 errorCount++; 54 } 55 } 56 | Popular Tags |