Changeset 6257


Ignore:
Timestamp:
05/10/10 14:17:53 (10 years ago)
Author:
melissa
Message:

Log transformation warnings using SLF4J instead of printing to System.err.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/components/common/src/loci/common/xml/XMLTools.java

    r6243 r6257  
    4141import javax.xml.parsers.SAXParser; 
    4242import javax.xml.parsers.SAXParserFactory; 
     43import javax.xml.transform.ErrorListener; 
    4344import javax.xml.transform.Result; 
    4445import javax.xml.transform.Source; 
     
    134135    // Java XML factories are not declared to be thread safe 
    135136    TransformerFactory factory = TransformerFactory.newInstance(); 
     137    factory.setErrorListener(new XMLListener()); 
    136138    Transformer transformer = factory.newTransformer(); 
    137139    transformer.transform(source, result); 
     
    316318      // Java XML factories are not declared to be thread safe 
    317319      TransformerFactory transformerFactory = TransformerFactory.newInstance(); 
     320      transformerFactory.setErrorListener(new XMLListener()); 
    318321      return transformerFactory.newTemplates(xsltSource); 
    319322    } 
     
    461464  } 
    462465 
     466  // -- Helper class -- 
     467 
     468  /** ErrorListener implementation that logs errors and warnings using SLF4J. */ 
     469  static class XMLListener implements ErrorListener { 
     470    public void error(TransformerException e) { 
     471      LOGGER.warn("", e); 
     472    } 
     473 
     474    public void fatalError(TransformerException e) { 
     475      LOGGER.warn("", e); 
     476    } 
     477 
     478    public void warning(TransformerException e) { 
     479      LOGGER.debug("", e); 
     480    } 
     481  } 
     482 
    463483} 
Note: See TracChangeset for help on using the changeset viewer.