KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > util > xml > SimpleTransformErrorListener


1 /*
2  * Copyright 2002-2006 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.springframework.util.xml;
18
19 import javax.xml.transform.ErrorListener JavaDoc;
20 import javax.xml.transform.TransformerException JavaDoc;
21
22 import org.apache.commons.logging.Log;
23
24 /**
25  * Simple <code>javax.xml.transform.ErrorListener</code> implementation:
26  * logs warnings using the given Commons Logging logger instance,
27  * and rethrows errors to discontinue the XML transformation.
28  *
29  * @author Juergen Hoeller
30  * @since 1.2
31  */

32 public class SimpleTransformErrorListener implements ErrorListener JavaDoc {
33
34     private final Log logger;
35
36
37     /**
38      * Create a new SimpleTransformErrorListener for the given
39      * Commons Logging logger instance.
40      */

41     public SimpleTransformErrorListener(Log logger) {
42         this.logger = logger;
43     }
44
45
46     public void warning(TransformerException JavaDoc ex) throws TransformerException JavaDoc {
47         logger.warn("Ignored XSLT transformation warning", ex);
48     }
49
50     public void error(TransformerException JavaDoc ex) throws TransformerException JavaDoc {
51         throw ex;
52     }
53
54     public void fatalError(TransformerException JavaDoc ex) throws TransformerException JavaDoc {
55         throw ex;
56     }
57
58 }
59
Popular Tags