1/* 2 * reserved comment block 3 * DO NOT REMOVE OR ALTER! 4 */ 5/* 6 * Licensed to the Apache Software Foundation (ASF) under one 7 * or more contributor license agreements. See the NOTICE file 8 * distributed with this work for additional information 9 * regarding copyright ownership. The ASF licenses this file 10 * to you under the Apache License, Version 2.0 (the "License"); 11 * you may not use this file except in compliance with the License. 12 * You may obtain a copy of the License at 13 * 14 * http://www.apache.org/licenses/LICENSE-2.0 15 * 16 * Unless required by applicable law or agreed to in writing, software 17 * distributed under the License is distributed on an "AS IS" BASIS, 18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 * See the License for the specific language governing permissions and 20 * limitations under the License. 21 */ 22 23package com.sun.org.apache.xml.internal.serializer.dom3; 24 25import org.w3c.dom.DOMError; 26import org.w3c.dom.DOMErrorHandler; 27 28/** 29 * This is the default implementation of the ErrorHandler interface and is 30 * used if one is not provided. The default implementation simply reports 31 * DOMErrors to System.err. 32 * 33 * @xsl.usage internal 34 */ 35final class DOMErrorHandlerImpl implements DOMErrorHandler { 36 37 /** 38 * Default Constructor 39 */ 40 DOMErrorHandlerImpl() { 41 } 42 43 /** 44 * Implementation of DOMErrorHandler.handleError that 45 * adds copy of error to list for later retrieval. 46 * 47 */ 48 public boolean handleError(DOMError error) { 49 boolean fail = true; 50 String severity = null; 51 if (error.getSeverity() == DOMError.SEVERITY_WARNING) { 52 fail = false; 53 severity = "[Warning]"; 54 } else if (error.getSeverity() == DOMError.SEVERITY_ERROR) { 55 severity = "[Error]"; 56 } else if (error.getSeverity() == DOMError.SEVERITY_FATAL_ERROR) { 57 severity = "[Fatal Error]"; 58 } 59 60 System.err.println(severity + ": " + error.getMessage() + "\t"); 61 System.err.println("Type : " + error.getType() + "\t" + "Related Data: " 62 + error.getRelatedData() + "\t" + "Related Exception: " 63 + error.getRelatedException() ); 64 65 return fail; 66 } 67} 68