286N/A/*
286N/A * reserved comment block
286N/A * DO NOT REMOVE OR ALTER!
286N/A */
286N/A/*
286N/A * Copyright 2005 The Apache Software Foundation.
286N/A *
286N/A * Licensed under the Apache License, Version 2.0 (the "License");
286N/A * you may not use this file except in compliance with the License.
286N/A * You may obtain a copy of the License at
286N/A *
286N/A * http://www.apache.org/licenses/LICENSE-2.0
286N/A *
286N/A * Unless required by applicable law or agreed to in writing, software
286N/A * distributed under the License is distributed on an "AS IS" BASIS,
286N/A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
286N/A * See the License for the specific language governing permissions and
286N/A * limitations under the License.
286N/A */
286N/Apackage com.sun.org.apache.xerces.internal.xpointer;
286N/A
286N/Aimport java.io.PrintWriter;
286N/A
286N/Aimport com.sun.org.apache.xerces.internal.xni.XNIException;
286N/Aimport com.sun.org.apache.xerces.internal.xni.parser.XMLErrorHandler;
286N/Aimport com.sun.org.apache.xerces.internal.xni.parser.XMLParseException;
286N/A
286N/A/**
286N/A * The Default XPointer error handler used by the XInclude implementation.
286N/A * XPointer error's are thrown so that they may be caught by the XInclude
286N/A * implementation and reported as resource errors.
286N/A *
286N/A */
286N/Aclass XPointerErrorHandler implements XMLErrorHandler {
286N/A
286N/A //
286N/A // Data
286N/A //
286N/A
286N/A /** Print writer. */
286N/A protected PrintWriter fOut;
286N/A
286N/A //
286N/A // Constructors
286N/A //
286N/A
286N/A /**
286N/A * Constructs an error handler that prints error messages to
286N/A * <code>System.err</code>.
286N/A */
286N/A public XPointerErrorHandler() {
286N/A this(new PrintWriter(System.err));
286N/A } // <init>()
286N/A
286N/A /**
286N/A * Constructs an error handler that prints error messages to the
286N/A * specified <code>PrintWriter</code.
286N/A */
286N/A public XPointerErrorHandler(PrintWriter out) {
286N/A fOut = out;
286N/A } // <init>(PrintWriter)
286N/A
286N/A //
286N/A // ErrorHandler methods
286N/A //
286N/A
286N/A /** Warning. */
286N/A public void warning(String domain, String key, XMLParseException ex)
286N/A throws XNIException {
286N/A printError("Warning", ex);
286N/A } // warning(XMLParseException)
286N/A
286N/A /** Error. */
286N/A public void error(String domain, String key, XMLParseException ex)
286N/A throws XNIException {
286N/A printError("Error", ex);
286N/A //throw ex;
286N/A } // error(XMLParseException)
286N/A
286N/A /** Fatal error. */
286N/A public void fatalError(String domain, String key, XMLParseException ex)
286N/A throws XNIException {
286N/A printError("Fatal Error", ex);
286N/A throw ex;
286N/A } // fatalError(XMLParseException)
286N/A
286N/A //
286N/A // Private methods
286N/A //
286N/A
286N/A /** Prints the error message. */
286N/A private void printError(String type, XMLParseException ex) {
286N/A
286N/A fOut.print("[");
286N/A fOut.print(type);
286N/A fOut.print("] ");
286N/A String systemId = ex.getExpandedSystemId();
286N/A if (systemId != null) {
286N/A int index = systemId.lastIndexOf('/');
286N/A if (index != -1)
286N/A systemId = systemId.substring(index + 1);
286N/A fOut.print(systemId);
286N/A }
286N/A fOut.print(':');
286N/A fOut.print(ex.getLineNumber());
286N/A fOut.print(':');
286N/A fOut.print(ex.getColumnNumber());
286N/A fOut.print(": ");
286N/A fOut.print(ex.getMessage());
286N/A fOut.println();
286N/A fOut.flush();
286N/A
286N/A } // printError(String,SAXParseException)
286N/A
286N/A} // class DefaultErrorHandler