List of usage examples for javax.xml.transform ErrorListener fatalError
public abstract void fatalError(TransformerException exception) throws TransformerException;
Receive notification of a non-recoverable error.
The processor may choose to continue, but will not normally proceed to a successful completion.
The method should throw an exception if it is unable to process the error, or if it wishes execution to terminate immediately.
From source file:net.sf.joost.trax.TrAXHelper.java
/** * Helpermethod for getting an InputSource from a StreamSource. * @param source <code>Source</code> * @return An <code>InputSource</code> object or null * @throws TransformerConfigurationException *//*from w ww. jav a2 s . c o m*/ protected static InputSource getInputSourceForStreamSources(Source source, ErrorListener errorListener) throws TransformerConfigurationException { if (DEBUG) log.debug("getting an InputSource from a StreamSource"); InputSource input = null; String systemId = source.getSystemId(); if (systemId == null) { systemId = ""; } try { if (source instanceof StreamSource) { if (DEBUG) log.debug("Source is a StreamSource"); StreamSource stream = (StreamSource) source; InputStream istream = stream.getInputStream(); Reader reader = stream.getReader(); // Create InputSource from Reader or InputStream in Source if (istream != null) { input = new InputSource(istream); } else { if (reader != null) { input = new InputSource(reader); } else { input = new InputSource(systemId); } } } else { //Source type is not supported if (errorListener != null) { try { errorListener .fatalError(new TransformerConfigurationException("Source is not a StreamSource")); return null; } catch (TransformerException e2) { if (DEBUG) log.debug("Source is not a StreamSource"); throw new TransformerConfigurationException("Source is not a StreamSource"); } } if (DEBUG) log.debug("Source is not a StreamSource"); throw new TransformerConfigurationException("Source is not a StreamSource"); } //setting systemId input.setSystemId(systemId); // } catch (NullPointerException nE) { // //catching NullPointerException // if(errorListener != null) { // try { // errorListener.fatalError( // new TransformerConfigurationException(nE)); // return null; // } catch( TransformerException e2) { // log.debug(nE); // throw new TransformerConfigurationException(nE.getMessage()); // } // } // log.debug(nE); // throw new TransformerConfigurationException(nE.getMessage()); } catch (SecurityException sE) { //catching SecurityException if (errorListener != null) { try { errorListener.fatalError(new TransformerConfigurationException(sE)); return null; } catch (TransformerException e2) { if (DEBUG) log.debug(sE); throw new TransformerConfigurationException(sE.getMessage()); } } if (DEBUG) log.debug(sE); throw new TransformerConfigurationException(sE.getMessage()); } return (input); }