⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 loggingerrorlistener.java

📁 随书的代码
💻 JAVA
字号:
import javax.xml.transform.*;import java.util.logging.*;public class LoggingErrorListener implements ErrorListener {  private Logger logger;    public LoggingErrorListener(Logger logger) {    this.logger = logger;  }    public void warning(TransformerException exception) {       logger.log(Level.WARNING, exception.getMessage(), exception);       // Don't throw an exception and stop the processor    // just for a warning; but do log the problem  }    public void error(TransformerException exception)   throws TransformerException {        logger.log(Level.SEVERE, exception.getMessage(), exception);    // XSLT is not as draconian as XML. There are numerous errors    // which the processor may but does not have to recover from;     // e.g. multiple templates that match a node with the same    // priority. I do not want to allow that so I throw this     // exception here.    throw exception;      }    public void fatalError(TransformerException exception)   throws TransformerException {        logger.log(Level.SEVERE, exception.getMessage(), exception);    // This is an error which the processor cannot recover from;     // e.g. a malformed stylesheet or input document    // so I must throw this exception here.    throw exception;      }     }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -