You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by mo...@apache.org on 2001/10/08 14:06:52 UTC

cvs commit: xml-xalan/java/src/org/apache/xalan/xsltc/trax TransformerFactoryImpl.java TransformerImpl.java

morten      01/10/08 05:06:52

  Modified:    java/src/org/apache/xalan/xsltc/trax
                        TransformerFactoryImpl.java TransformerImpl.java
  Log:
  Implemented default ErrorListeners for the Transformer and TransformerFactory
  implementations. The two classes are both changed to implement the
  ErrorListener interface and will by default use themselves as ErrorListener.
  PR:		bugzilla 3858
  Obtained from:	n/a
  Submitted by:	morten@xml.apache.org
  Reviewed by:	morten@xml.apache.org
  
  Revision  Changes    Path
  1.21      +66 -3     xml-xalan/java/src/org/apache/xalan/xsltc/trax/TransformerFactoryImpl.java
  
  Index: TransformerFactoryImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/trax/TransformerFactoryImpl.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- TransformerFactoryImpl.java	2001/10/08 07:39:47	1.20
  +++ TransformerFactoryImpl.java	2001/10/08 12:06:52	1.21
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: TransformerFactoryImpl.java,v 1.20 2001/10/08 07:39:47 morten Exp $
  + * @(#)$Id: TransformerFactoryImpl.java,v 1.21 2001/10/08 12:06:52 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -93,14 +93,14 @@
    * Implementation of a JAXP1.1 TransformerFactory for Translets.
    */
   public class TransformerFactoryImpl
  -    extends SAXTransformerFactory implements SourceLoader {
  +    extends SAXTransformerFactory implements SourceLoader, ErrorListener {
   
       // This constant should be removed once all abstract methods are impl'ed.
       private static final String NYI = "Not yet implemented";
   
       // This error listener is used only for this factory and is not passed to
       // the Templates or Transformer objects that we create!!!
  -    private ErrorListener _errorListener = null; 
  +    private ErrorListener _errorListener = this; 
   
       // This URIResolver is passed to all created Templates and Transformers
       private URIResolver _uriResolver = null;
  @@ -631,6 +631,69 @@
   	catch (TransformerException e) {
   	    return null;
   	}
  +    }
  +
  +    /**
  +     * Receive notification of a recoverable error. 
  +     * The transformer must continue to provide normal parsing events after
  +     * invoking this method. It should still be possible for the application
  +     * to process the document through to the end.
  +     *
  +     * @param exception The warning information encapsulated in a transformer 
  +     * exception.
  +     * @throws TransformerException if the application chooses to discontinue
  +     * the transformation (always does in our case).
  +     */
  +    public void error(TransformerException e)
  +	throws TransformerException {
  +	System.err.println("ERROR: "+e.getMessageAndLocation());
  +	Throwable wrapped = e.getException();
  +	if (e != null)
  +	    System.err.println("     : "+wrapped.getMessage());
  +	throw(e); 	
  +    }
  +
  +    /**
  +     * Receive notification of a non-recoverable error. 
  +     * The application must assume that the transformation cannot continue
  +     * after the Transformer has invoked this method, and should continue
  +     * (if at all) only to collect addition error messages. In fact,
  +     * Transformers are free to stop reporting events once this method has
  +     * been invoked.
  +     *
  +     * @param exception The warning information encapsulated in a transformer
  +     * exception.
  +     * @throws TransformerException if the application chooses to discontinue
  +     * the transformation (always does in our case).
  +     */
  +    public void fatalError(TransformerException e)
  +	throws TransformerException {
  +	System.err.println("FATAL: "+e.getMessageAndLocation());
  +	Throwable wrapped = e.getException();
  +	if (e != null)
  +	    System.err.println("     : "+wrapped.getMessage());
  +	throw(e);
  +    }
  +
  +    /**
  +     * Receive notification of a warning.
  +     * Transformers can use this method to report conditions that are not
  +     * errors or fatal errors. The default behaviour is to take no action.
  +     * After invoking this method, the Transformer must continue with the
  +     * transformation. It should still be possible for the application to
  +     * process the document through to the end.
  +     *
  +     * @param exception The warning information encapsulated in a transformer
  +     * exception.
  +     * @throws TransformerException if the application chooses to discontinue
  +     * the transformation (never does in our case).
  +     */
  +    public void warning(TransformerException e)
  +	throws TransformerException {
  +	System.err.println("WARNING: "+e.getMessageAndLocation());
  +	Throwable wrapped = e.getException();
  +	if (e != null)
  +	    System.err.println("       : "+wrapped.getMessage());
       }
   
   }
  
  
  
  1.20      +68 -3     xml-xalan/java/src/org/apache/xalan/xsltc/trax/TransformerImpl.java
  
  Index: TransformerImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/trax/TransformerImpl.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- TransformerImpl.java	2001/10/08 07:43:41	1.19
  +++ TransformerImpl.java	2001/10/08 12:06:52	1.20
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: TransformerImpl.java,v 1.19 2001/10/08 07:43:41 morten Exp $
  + * @(#)$Id: TransformerImpl.java,v 1.20 2001/10/08 12:06:52 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -108,13 +108,14 @@
   
   import java.util.Properties;
   
  -public final class TransformerImpl extends Transformer implements DOMCache {
  +public final class TransformerImpl extends Transformer
  +    implements DOMCache, ErrorListener {
   
       private AbstractTranslet _translet = null;
       private String           _encoding = null;
       private ContentHandler   _handler = null;
   
  -    private ErrorListener _errorListener = null;
  +    private ErrorListener _errorListener = this;
       private URIResolver   _uriResolver = null;
       private Properties    _properties = null;
   
  @@ -806,4 +807,68 @@
   	    return(null);
   	}
       }
  +
  +    /**
  +     * Receive notification of a recoverable error. 
  +     * The transformer must continue to provide normal parsing events after
  +     * invoking this method. It should still be possible for the application
  +     * to process the document through to the end.
  +     *
  +     * @param exception The warning information encapsulated in a transformer 
  +     * exception.
  +     * @throws TransformerException if the application chooses to discontinue
  +     * the transformation (always does in our case).
  +     */
  +    public void error(TransformerException e)
  +	throws TransformerException {
  +	System.err.println("ERROR: "+e.getMessageAndLocation());
  +	Throwable wrapped = e.getException();
  +	if (e != null)
  +	    System.err.println("     : "+wrapped.getMessage());
  +	throw(e); 	
  +    }
  +
  +    /**
  +     * Receive notification of a non-recoverable error. 
  +     * The application must assume that the transformation cannot continue
  +     * after the Transformer has invoked this method, and should continue
  +     * (if at all) only to collect addition error messages. In fact,
  +     * Transformers are free to stop reporting events once this method has
  +     * been invoked.
  +     *
  +     * @param exception The warning information encapsulated in a transformer
  +     * exception.
  +     * @throws TransformerException if the application chooses to discontinue
  +     * the transformation (always does in our case).
  +     */
  +    public void fatalError(TransformerException e)
  +	throws TransformerException {
  +	System.err.println("FATAL: "+e.getMessageAndLocation());
  +	Throwable wrapped = e.getException();
  +	if (e != null)
  +	    System.err.println("     : "+wrapped.getMessage());
  +	throw(e);
  +    }
  +
  +    /**
  +     * Receive notification of a warning.
  +     * Transformers can use this method to report conditions that are not
  +     * errors or fatal errors. The default behaviour is to take no action.
  +     * After invoking this method, the Transformer must continue with the
  +     * transformation. It should still be possible for the application to
  +     * process the document through to the end.
  +     *
  +     * @param exception The warning information encapsulated in a transformer
  +     * exception.
  +     * @throws TransformerException if the application chooses to discontinue
  +     * the transformation (never does in our case).
  +     */
  +    public void warning(TransformerException e)
  +	throws TransformerException {
  +	System.err.println("WARNING: "+e.getMessageAndLocation());
  +	Throwable wrapped = e.getException();
  +	if (e != null)
  +	    System.err.println("       : "+wrapped.getMessage());
  +    }
  +
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org