01: /*
02: * Copyright 2002-2006 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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;
20: import javax.xml.transform.TransformerException;
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 {
33:
34: private final Log logger;
35:
36: /**
37: * Create a new SimpleTransformErrorListener for the given
38: * Commons Logging logger instance.
39: */
40: public SimpleTransformErrorListener(Log logger) {
41: this .logger = logger;
42: }
43:
44: public void warning(TransformerException ex)
45: throws TransformerException {
46: logger.warn("Ignored XSLT transformation warning", ex);
47: }
48:
49: public void error(TransformerException ex)
50: throws TransformerException {
51: throw ex;
52: }
53:
54: public void fatalError(TransformerException ex)
55: throws TransformerException {
56: throw ex;
57: }
58:
59: }
|