1 16 package org.apache.xerces.xpointer; 17 18 import java.io.PrintWriter ; 19 20 import org.apache.xerces.xni.XNIException; 21 import org.apache.xerces.xni.parser.XMLErrorHandler; 22 import org.apache.xerces.xni.parser.XMLParseException; 23 24 31 class XPointerErrorHandler implements XMLErrorHandler { 32 33 37 38 protected PrintWriter fOut; 39 40 44 48 public XPointerErrorHandler() { 49 this(new PrintWriter (System.err)); 50 } 52 56 public XPointerErrorHandler(PrintWriter out) { 57 fOut = out; 58 } 60 64 65 public void warning(String domain, String key, XMLParseException ex) 66 throws XNIException { 67 printError("Warning", ex); 68 } 70 71 public void error(String domain, String key, XMLParseException ex) 72 throws XNIException { 73 printError("Error", ex); 74 } 77 78 public void fatalError(String domain, String key, XMLParseException ex) 79 throws XNIException { 80 printError("Fatal Error", ex); 81 throw ex; 82 } 84 88 89 private void printError(String type, XMLParseException ex) { 90 91 fOut.print("["); 92 fOut.print(type); 93 fOut.print("] "); 94 String systemId = ex.getExpandedSystemId(); 95 if (systemId != null) { 96 int index = systemId.lastIndexOf('/'); 97 if (index != -1) 98 systemId = systemId.substring(index + 1); 99 fOut.print(systemId); 100 } 101 fOut.print(':'); 102 fOut.print(ex.getLineNumber()); 103 fOut.print(':'); 104 fOut.print(ex.getColumnNumber()); 105 fOut.print(": "); 106 fOut.print(ex.getMessage()); 107 fOut.println(); 108 fOut.flush(); 109 110 } 112 } | Popular Tags |