xalan-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mk...@apache.org
Subject cvs commit: xml-xalan/java/src/org/apache/xalan/xsltc/trax TransformerImpl.java
Date Tue, 04 Feb 2003 16:08:13 GMT
mkwan       2003/02/04 08:08:13

  Modified:    java/src/org/apache/xalan/xsltc/trax Tag: XSLTC_DTM
                        TransformerImpl.java
  Log:
  Propagate a patch from HEAD to XSLTC_DTM.
  This patch was contributed by Prakash Sridharan (psridharan@selectica.com).
  Messages displayed using xsl:message are now reported to an ErrorListener
  registered in a Transformer instance. The warning() callback is used for
  this purpose.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.37.2.16 +33 -1     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.37.2.15
  retrieving revision 1.37.2.16
  diff -u -r1.37.2.15 -r1.37.2.16
  --- TransformerImpl.java	3 Feb 2003 21:20:16 -0000	1.37.2.15
  +++ TransformerImpl.java	4 Feb 2003 16:08:13 -0000	1.37.2.16
  @@ -202,6 +202,34 @@
        */
       private Hashtable _parameters = null;
   
  +    /**
  +     * This class wraps an ErrorListener into a MessageHandler in order to
  +     * capture messages reported via xsl:message.
  +     */
  +    static class MessageHandler 
  +           extends org.apache.xalan.xsltc.runtime.MessageHandler 
  +    {
  +	private ErrorListener _errorListener;
  +     
  +	public MessageHandler(ErrorListener errorListener) {
  +	    _errorListener = errorListener;
  +	}
  +     
  +	public void displayMessage(String msg) {
  +	    if(_errorListener == null) {
  +		System.err.println(msg); 
  +	    }
  +	    else {
  +		try {
  +		    _errorListener.warning(new TransformerException(msg));
  +		}
  +		catch (TransformerException e) {
  +		    // ignored 
  +		}
  +	    }
  +	}
  +    }
  +
       protected TransformerImpl(Properties outputProperties, int indentNumber, 
   	TransformerFactoryImpl tfactory) 
       {
  @@ -657,6 +685,8 @@
       /**
        * Implements JAXP's Transformer.setErrorListener()
        * Set the error event listener in effect for the transformation.
  +     * Register a message handler in the translet in order to forward
  +     * xsl:messages to error listener.
        *
        * @param listener The error event listener to use
        * @throws IllegalArgumentException
  @@ -669,6 +699,8 @@
               throw new IllegalArgumentException(err.toString());
   	}
           _errorListener = listener;
  +	// Register a message handler to report xsl:messages
  +	_translet.setMessageHandler(new MessageHandler(_errorListener));
       }
   
       /**
  
  
  

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


Mime
View raw message