cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject cvs commit: xml-cocoon2/src/org/apache/cocoon/xml AbstractXMLPipe.java
Date Mon, 15 Oct 2001 10:21:36 GMT
cziegeler    01/10/15 03:21:36

  Modified:    src/org/apache/cocoon/components/xslt XSLTProcessorImpl.java
               src/org/apache/cocoon/util TraxErrorHandler.java
               src/org/apache/cocoon/xml AbstractXMLPipe.java
  Log:
  Fixed:
  - AbstractXMLPipe did ignore exceptions in endDocument()
  - XSLTProcessorImpl now returns null if a resource cannot be
    resolved instead of throwing an exception
  - TraxErrorHandler now logs warnings, errors and exceptions
    with the correct log level. If no locator is available
    the exceptions is also logged.
  
  Revision  Changes    Path
  1.9       +13 -2     xml-cocoon2/src/org/apache/cocoon/components/xslt/XSLTProcessorImpl.java
  
  Index: XSLTProcessorImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/components/xslt/XSLTProcessorImpl.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- XSLTProcessorImpl.java	2001/10/10 17:03:39	1.8
  +++ XSLTProcessorImpl.java	2001/10/15 10:21:36	1.9
  @@ -17,6 +17,7 @@
   import org.apache.avalon.framework.configuration.ConfigurationException;
   import org.apache.avalon.framework.logger.AbstractLoggable;
   import org.apache.avalon.framework.parameters.Parameters;
  +import org.apache.cocoon.ResourceNotFoundException;
   import org.apache.cocoon.ProcessingException;
   import org.apache.cocoon.components.store.Store;
   import org.apache.cocoon.environment.Source;
  @@ -374,8 +375,18 @@
                           + ", system id = " + is.getSystemId());
         return new StreamSource(is.getByteStream(),
                                 is.getSystemId());
  -    } catch (Exception e) {
  -      throw new TransformerException(e);
  +    } catch (ResourceNotFoundException rnfe) {
  +        // to obtain the same behaviour as when the resource is
  +        // transformed by the XSLT Transformer we should return null here.
  +        return null;
  +    } catch (java.net.MalformedURLException mue) {
  +        return null;
  +    } catch (java.io.IOException ioe) {
  +        return null;
  +    } catch (org.xml.sax.SAXException se) {
  +        throw new TransformerException(se);
  +    } catch (ProcessingException pe) {
  +        throw new TransformerException(pe);
       }
     }
   
  
  
  
  1.5       +30 -10    xml-cocoon2/src/org/apache/cocoon/util/TraxErrorHandler.java
  
  Index: TraxErrorHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/util/TraxErrorHandler.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- TraxErrorHandler.java	2001/10/11 07:28:25	1.4
  +++ TraxErrorHandler.java	2001/10/15 10:21:36	1.5
  @@ -14,6 +14,14 @@
   import javax.xml.transform.SourceLocator;
   import javax.xml.transform.TransformerException;
   
  +/**
  + * This ErrorListener simply logs the exception and in
  + * case of an fatal-error the exception is rethrown.
  + * Warnings and errors are ignored.
  + *
  + * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
  + * @version CVS $Revision: 1.5 $ $Date: 2001/10/15 10:21:36 $
  + */
   public class TraxErrorHandler implements ErrorListener {
   
       private Logger logger = null;
  @@ -26,23 +34,38 @@
       public void warning(TransformerException exception)
           throws TransformerException
       {
  -        printLocation(exception);
  +        final String message = getMessage(exception);
  +        if (this.logger != null) {
  +            this.logger.warn(message, exception);
  +        } else {
  +            System.out.println("WARNING: " + message);
       }
  +    }
   
       public void error(TransformerException exception)
           throws TransformerException
       {
  -        printLocation(exception);
  +        final String message = getMessage(exception);
  +        if (this.logger != null) {
  +            this.logger.error(message, exception);
  +        } else {
  +            System.out.println("ERROR: " + message);
  +        }
       }
   
       public void fatalError(TransformerException exception)
           throws TransformerException
       {
  -        printLocation(exception);
  +        final String message = getMessage(exception);
  +        if (this.logger != null) {
  +            this.logger.fatalError(message, exception);
  +        } else {
  +            System.out.println("FATAL-ERROR: " + message);
  +        }
           throw exception;
       }
   
  -    private void printLocation(TransformerException exception)
  +    private String getMessage(TransformerException exception)
       {
         SourceLocator locator = exception.getLocator();
   
  @@ -53,12 +76,9 @@
                       ? locator.getPublicId()
                         : (null != locator.getSystemId())
                           ? locator.getSystemId() : "SystemId Unknown";
  -        if(logger != null)
  -            logger.error("Error in TraxTransformer: " + id + "; Line " + locator.getLineNumber()
  -                           + "; Column " + locator.getColumnNumber()+"; ", exception);
  -        else
  -            System.out.println("Error in TraxTransformer: " + id + "; Line " + locator.getLineNumber()
  -                           + "; Column " + locator.getColumnNumber()+";" + exception);
  +        return "Error in TraxTransformer: " + id + "; Line " + locator.getLineNumber()
  +                           + "; Column " + locator.getColumnNumber()+"; ";
         }
  +      return "Error in TraxTransformer: " + exception;
       }
   }
  
  
  
  1.7       +2 -8      xml-cocoon2/src/org/apache/cocoon/xml/AbstractXMLPipe.java
  
  Index: AbstractXMLPipe.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/xml/AbstractXMLPipe.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- AbstractXMLPipe.java	2001/10/11 07:28:25	1.6
  +++ AbstractXMLPipe.java	2001/10/15 10:21:36	1.7
  @@ -18,7 +18,7 @@
    * handlers and lexical handlers.
    *
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - * @version CVS $Revision: 1.6 $ $Date: 2001/10/11 07:28:25 $
  + * @version CVS $Revision: 1.7 $ $Date: 2001/10/15 10:21:36 $
    */
   public class AbstractXMLPipe extends AbstractXMLProducer implements XMLPipe, Recyclable
{
   
  @@ -45,13 +45,7 @@
        */
       public void endDocument()
       throws SAXException {
  -        try {
  -            if (contentHandler != null) contentHandler.endDocument();
  -        } catch (SAXException e){
  -            throw e;
  -        } catch (Exception e){
  -            getLogger().debug("Exception in endDocument",e);
  -        }
  +        if (contentHandler != null) contentHandler.endDocument();
       }
   
       /**
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org


Mime
View raw message