You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by mk...@apache.org on 2005/06/03 17:52:46 UTC

cvs commit: xml-xalan/java/src/org/apache/xml/utils DefaultErrorHandler.java

mkwan       2005/06/03 08:52:46

  Modified:    java/src/org/apache/xalan Version.java
               java/src/org/apache/xalan/processor
                        TransformerFactoryImpl.java
               java/src/org/apache/xalan/transformer
                        TransformerIdentityImpl.java TransformerImpl.java
               java/src/org/apache/xalan/xsltc/compiler Parser.java
               java/src/org/apache/xalan/xsltc/compiler/util ErrorMsg.java
               java/src/org/apache/xalan/xsltc/trax
                        TransformerFactoryImpl.java
               java/src/org/apache/xml/utils DefaultErrorHandler.java
  Log:
  Patch for XALANJ-2134.
  Change the error handling behavior to be conformant with the requirement
  from JAXP 1.3 that the default ErrorListener will report all warnings and errors
  to System.err and does not throw any Exceptions.
  
  Revision  Changes    Path
  1.18      +0 -0      xml-xalan/java/src/org/apache/xalan/Version.java
  
  
  
  
  1.61      +2 -2      xml-xalan/java/src/org/apache/xalan/processor/TransformerFactoryImpl.java
  
  Index: TransformerFactoryImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/processor/TransformerFactoryImpl.java,v
  retrieving revision 1.60
  retrieving revision 1.61
  diff -u -r1.60 -r1.61
  --- TransformerFactoryImpl.java	31 May 2005 15:12:59 -0000	1.60
  +++ TransformerFactoryImpl.java	3 Jun 2005 15:52:45 -0000	1.61
  @@ -930,7 +930,7 @@
     }
   
     /** The error listener.   */
  -  private ErrorListener m_errorListener = new DefaultErrorHandler();
  +  private ErrorListener m_errorListener = new org.apache.xml.utils.DefaultErrorHandler(false);
   
     /**
      * Get the error listener in effect for the TransformerFactory.
  
  
  
  1.35      +2 -2      xml-xalan/java/src/org/apache/xalan/transformer/TransformerIdentityImpl.java
  
  Index: TransformerIdentityImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/transformer/TransformerIdentityImpl.java,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- TransformerIdentityImpl.java	20 May 2005 14:25:13 -0000	1.34
  +++ TransformerIdentityImpl.java	3 Jun 2005 15:52:45 -0000	1.35
  @@ -1432,7 +1432,7 @@
   
     /** The error listener for TrAX errors and warnings. */
     private ErrorListener m_errorListener =
  -    new org.apache.xml.utils.DefaultErrorHandler();
  +    new org.apache.xml.utils.DefaultErrorHandler(false);
   
     /**
      * The URIResolver, which is unused, but must be returned to fullfill the
  
  
  
  1.165     +2 -2      xml-xalan/java/src/org/apache/xalan/transformer/TransformerImpl.java
  
  Index: TransformerImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/transformer/TransformerImpl.java,v
  retrieving revision 1.164
  retrieving revision 1.165
  diff -u -r1.164 -r1.165
  --- TransformerImpl.java	20 May 2005 14:25:13 -0000	1.164
  +++ TransformerImpl.java	3 Jun 2005 15:52:45 -0000	1.165
  @@ -321,7 +321,7 @@
      * The SAX error handler, where errors and warnings are sent.
      */
     private ErrorListener m_errorHandler =
  -    new org.apache.xml.utils.DefaultErrorHandler();
  +    new org.apache.xml.utils.DefaultErrorHandler(false);
   
     /**
      * The trace manager.
  
  
  
  1.68      +3 -1      xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Parser.java
  
  Index: Parser.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Parser.java,v
  retrieving revision 1.67
  retrieving revision 1.68
  diff -u -r1.67 -r1.68
  --- Parser.java	23 Jan 2005 00:37:17 -0000	1.67
  +++ Parser.java	3 Jun 2005 15:52:45 -0000	1.68
  @@ -1010,6 +1010,8 @@
   	            final ErrorMsg err = 
   		        new ErrorMsg(ErrorMsg.ILLEGAL_ATTRIBUTE_ERR, 
   				attrQName, node);
  +		    // Workaround for the TCK failure ErrorListener.errorTests.error001..
  +	            err.setWarningError(true);
   		    reportError(WARNING, err);
   	        }
   	    }
  
  
  
  1.27      +14 -1     xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/ErrorMsg.java
  
  Index: ErrorMsg.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/ErrorMsg.java,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- ErrorMsg.java	31 May 2005 15:12:59 -0000	1.26
  +++ ErrorMsg.java	3 Jun 2005 15:52:45 -0000	1.27
  @@ -40,6 +40,7 @@
       private String _message = null;
       private String _url = null;
       Object[] _params = null;
  +    private boolean _isWarningError;
   
       // Compiler error messages
       public static final String MULTIPLE_STYLESHEET_ERR = "MULTIPLE_STYLESHEET_ERR";
  @@ -285,5 +286,17 @@
       private String getErrorMessage() {
         return _bundle.getString(_code);
       }
  +    
  +    // If the _isWarningError flag is true, the error is treated as
  +    // a warning by the compiler, but should be reported as an error
  +    // to the ErrorListener. This is a workaround for the TCK failure 
  +    // ErrorListener.errorTests.error001.
  +    public void setWarningError(boolean flag) {
  +    	_isWarningError = flag;
  +}
  +
  +    public boolean isWarningError() {
  +        return _isWarningError;
  +    }
   }
   
  
  
  
  1.78      +9 -4      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.77
  retrieving revision 1.78
  diff -u -r1.77 -r1.78
  --- TransformerFactoryImpl.java	31 May 2005 15:12:59 -0000	1.77
  +++ TransformerFactoryImpl.java	3 Jun 2005 15:52:46 -0000	1.78
  @@ -623,9 +623,14 @@
   	// Pass messages to listener, one by one
   	final int count = messages.size();
   	for (int pos = 0; pos < count; pos++) {
  -	    String message = messages.elementAt(pos).toString();
  -	    _errorListener.error(
  -		new TransformerConfigurationException(message));
  +	    ErrorMsg msg = (ErrorMsg)messages.elementAt(pos);
  +	    // Workaround for the TCK failure ErrorListener.errorTests.error001.
  +	    if (msg.isWarningError())
  +	        _errorListener.error(
  +		    new TransformerConfigurationException(msg.toString()));
  +	    else
  +	    	_errorListener.warning(
  +		    new TransformerConfigurationException(msg.toString()));
   	}
       }
   
  
  
  
  1.16      +35 -9     xml-xalan/java/src/org/apache/xml/utils/DefaultErrorHandler.java
  
  Index: DefaultErrorHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/utils/DefaultErrorHandler.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- DefaultErrorHandler.java	17 Feb 2004 04:21:14 -0000	1.15
  +++ DefaultErrorHandler.java	3 Jun 2005 15:52:46 -0000	1.16
  @@ -42,6 +42,13 @@
     PrintWriter m_pw;
   
     /**
  +   * if this flag is set to true, we will rethrow the exception on
  +   * the error() and fatalError() methods. If it is false, the errors 
  +   * are reported to System.err. 
  +   */
  +  boolean m_throwExceptionOnError = true;
  +
  +  /**
      * Constructor DefaultErrorHandler
      */
     public DefaultErrorHandler(PrintWriter pw)
  @@ -62,7 +69,16 @@
      */
     public DefaultErrorHandler()
     {
  +    this(true);
  +  }
  +
  +  /**
  +   * Constructor DefaultErrorHandler
  +   */
  +  public DefaultErrorHandler(boolean throwExceptionOnError)
  +  {
       m_pw = new PrintWriter(System.err, true);
  +    m_throwExceptionOnError = throwExceptionOnError;
     }
   
   
  @@ -192,10 +208,15 @@
      */
     public void error(TransformerException exception) throws TransformerException
     {
  -    // printLocation(exception);
  -    // ensureLocationSet(exception);
  -
  -    throw exception;
  +    // If the m_throwExceptionOnError flag is true, rethrow the exception.
  +    // Otherwise report the error to System.err.
  +    if (m_throwExceptionOnError)
  +      throw exception;
  +    else
  +    {
  +      printLocation(m_pw, exception);
  +      m_pw.println(exception.getMessage());
  +    }
     }
   
     /**
  @@ -220,10 +241,15 @@
      */
     public void fatalError(TransformerException exception) throws TransformerException
     {
  -    // printLocation(exception);
  -    // ensureLocationSet(exception);
  -
  -    throw exception;
  +    // If the m_throwExceptionOnError flag is true, rethrow the exception.
  +    // Otherwise report the error to System.err.
  +    if (m_throwExceptionOnError)
  +      throw exception;
  +    else
  +    {
  +      printLocation(m_pw, exception);
  +      m_pw.println(exception.getMessage());
  +    }
     }
     
     public static void ensureLocationSet(TransformerException exception)
  
  
  

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