cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vgritse...@apache.org
Subject cvs commit: xml-cocoon2/src/java/org/apache/cocoon/util TraxErrorHandler.java
Date Thu, 25 Jul 2002 14:00:32 GMT
vgritsenko    2002/07/25 07:00:32

  Modified:    src/java/org/apache/cocoon/util TraxErrorHandler.java
  Log:
  Include all warnings and errors reported by the XSLT engine into the
  TransformerException if transformation fails or terminated by the
  stylesheet.
  Compensate for the Xalan incremental processing bug.
  
  Revision  Changes    Path
  1.6       +29 -13    xml-cocoon2/src/java/org/apache/cocoon/util/TraxErrorHandler.java
  
  Index: TraxErrorHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/util/TraxErrorHandler.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- TraxErrorHandler.java	19 Jul 2002 13:09:31 -0000	1.5
  +++ TraxErrorHandler.java	25 Jul 2002 14:00:32 -0000	1.6
  @@ -66,6 +66,7 @@
    */
   public class TraxErrorHandler implements ErrorListener {
   
  +    private StringBuffer warnings = new StringBuffer("Errors in XSLT transformation:\n");
       private Logger logger = null;
   
       public TraxErrorHandler( Logger logger ) {
  @@ -73,50 +74,65 @@
       }
   
       public void warning( TransformerException exception )
  -            throws TransformerException {
  +            throws TransformerException
  +    {
           final String message = getMessage( exception );
           if ( this.logger != null ) {
  -            this.logger.warn( message, exception );
  +            this.logger.warn( message );
           } else {
               System.out.println( "WARNING: " + message );
           }
  +        warnings.append("Warning: ");
  +        warnings.append(message);
  +        warnings.append("\n");
       }
   
       public void error( TransformerException exception )
  -            throws TransformerException {
  +            throws TransformerException
  +    {
           final String message = getMessage( exception );
           if ( this.logger != null ) {
               this.logger.error( message, exception );
           } else {
               System.out.println( "ERROR: " + message );
           }
  +        warnings.append("Error: ");
  +        warnings.append(message);
  +        warnings.append("\n");
       }
   
       public void fatalError( TransformerException exception )
  -            throws TransformerException {
  +            throws TransformerException
  +    {
           final String message = getMessage( exception );
           if ( this.logger != null ) {
               this.logger.fatalError( message, exception );
           } else {
               System.out.println( "FATAL-ERROR: " + message );
           }
  -        throw exception;
  +        warnings.append("Fatal: ");
  +        warnings.append(message);
  +        warnings.append("\n");
  +        try {
  +            throw new TransformerException(warnings.toString());
  +        } finally {
  +            warnings = new StringBuffer();
  +        }
       }
   
       private String getMessage( TransformerException exception ) {
  -        SourceLocator locator = exception.getLocator();
   
  +        SourceLocator locator = exception.getLocator();
           if ( null != locator ) {
  -            // System.out.println("Parser fatal error: "+exception.getMessage());
               String id = ( locator.getPublicId() != locator.getPublicId() )
                       ? locator.getPublicId()
                       : ( null != locator.getSystemId() )
                       ? locator.getSystemId() : "SystemId Unknown";
  -            return new StringBuffer( "Error in TraxTransformer: " )
  -                    .append( id ).append( "; Line " ).append( locator.getLineNumber() )
  -                    .append( "; Column " ).append( locator.getColumnNumber() )
  -                    .append( "; " ).toString();
  +            return "File " + id
  +                    + "; Line " + locator.getLineNumber()
  +                    + "; Column " + locator.getColumnNumber()
  +                    + "; " + exception.getMessage();
           }
  -        return "Error in TraxTransformer: " + exception;
  +        return exception.getMessage();
       }
   }
  
  
  

----------------------------------------------------------------------
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