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/components/xslt XSLTProcessorImpl.java
Date Sun, 14 Apr 2002 00:39:28 GMT
vgritsenko    02/04/13 17:39:28

  Modified:    src/java/org/apache/cocoon/components/xslt
                        XSLTProcessorImpl.java
  Log:
  Use Source.toSAX in transform()
  
  Revision  Changes    Path
  1.20      +18 -24    xml-cocoon2/src/java/org/apache/cocoon/components/xslt/XSLTProcessorImpl.java
  
  Index: XSLTProcessorImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/xslt/XSLTProcessorImpl.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- XSLTProcessorImpl.java	10 Apr 2002 12:56:23 -0000	1.19
  +++ XSLTProcessorImpl.java	14 Apr 2002 00:39:28 -0000	1.20
  @@ -51,7 +51,6 @@
   package org.apache.cocoon.components.xslt;
   
   import org.apache.avalon.framework.activity.Disposable;
  -import org.apache.avalon.framework.component.Component;
   import org.apache.avalon.framework.component.ComponentException;
   import org.apache.avalon.framework.component.ComponentManager;
   import org.apache.avalon.framework.component.Composable;
  @@ -69,10 +68,8 @@
   import org.apache.cocoon.util.TraxErrorHandler;
   import org.xml.sax.InputSource;
   import org.xml.sax.XMLFilter;
  -import org.xml.sax.XMLReader;
   import org.xml.sax.ContentHandler;
   import org.xml.sax.SAXException;
  -import org.xml.sax.helpers.XMLReaderFactory;
   
   import javax.xml.transform.URIResolver;
   import javax.xml.transform.TransformerException;
  @@ -80,17 +77,13 @@
   import javax.xml.transform.Templates;
   import javax.xml.transform.Result;
   import javax.xml.transform.Transformer;
  -import javax.xml.transform.sax.SAXSource;
   import javax.xml.transform.sax.SAXTransformerFactory;
   import javax.xml.transform.sax.TemplatesHandler;
   import javax.xml.transform.sax.TransformerHandler;
  -import javax.xml.transform.stream.StreamResult;
   import javax.xml.transform.stream.StreamSource;
   import java.io.File;
   import java.io.InputStream;
   import java.io.IOException;
  -import java.io.StringWriter;
  -import java.io.Writer;
   import java.util.HashMap;
   
   /**
  @@ -119,7 +112,7 @@
    *
    * @author <a href="mailto:ovidiu@cup.hp.com">Ovidiu Predescu</a>
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - * @version CVS $Id: XSLTProcessorImpl.java,v 1.19 2002/04/10 12:56:23 stefano Exp $
  + * @version CVS $Id: XSLTProcessorImpl.java,v 1.20 2002/04/14 00:39:28 vgritsenko Exp $
    * @version 1.0
    * @since   July 11, 2001
    */
  @@ -293,8 +286,8 @@
                       + ", result = " + result);
               }
               TransformerHandler handler = getTransformerHandler(stylesheet);
  -            Transformer transformer = handler.getTransformer();
   
  +            Transformer transformer = handler.getTransformer();
               if (params != null) {
                   transformer.clearParameters();
                   String[] names = params.getNames();
  @@ -302,15 +295,12 @@
                       transformer.setParameter(names[i], params.getParameter(names[i]));
                   }
               }
  -            InputSource is = source.getInputSource();
  -            InputStream bs = is.getByteStream();
  +
               this.getLogger().debug("XSLTProcessorImpl: starting transform");
               // FIXME (VG): Is it possible to use Source's toSAX method?
  -            try {
  -                transformer.transform(new StreamSource(bs, is.getSystemId()), result);
  -            } finally {
  -                bs.close();
  -            }
  +            handler.setResult(result);
  +            source.toSAX(handler);
  +
               this.getLogger().debug("XSLTProcessorImpl: transform done");
           } catch (Exception e) {
               throw new ProcessingException("Error in running Transformation", e);
  @@ -331,15 +321,18 @@
               try {
                   _factory = (SAXTransformerFactory) ClassUtils.loadClass(factoryName).newInstance();
               } catch (ClassNotFoundException cnfe) {
  -                this.getLogger().error("Cannot find the requested TrAX factory '" + factoryName
+ "'. Using default TrAX Transformer Factory instead.");
  +                getLogger().error("Cannot find the requested TrAX factory '" + factoryName
  +                        + "'. Using default TrAX Transformer Factory instead.");
                   if (this.factory != null) return this.factory;
                   _factory = (SAXTransformerFactory) TransformerFactory.newInstance();
               } catch (ClassCastException cce) {
  -                this.getLogger().error("The indicated class '" + factoryName + "' is not
a TrAX Transformer Factory. Using default TrAX Transformer Factory instead.");
  +                getLogger().error("The indicated class '" + factoryName
  +                        + "' is not a TrAX Transformer Factory. Using default TrAX Transformer
Factory instead.");
                   if (this.factory != null) return this.factory;
                   _factory = (SAXTransformerFactory) TransformerFactory.newInstance();
               } catch (Exception e) {
  -                this.getLogger().error("Error found loading the requested TrAX Transformer
Factory '" + factoryName + "'. Using default TrAX Transformer Factory instead.");
  +                getLogger().error("Error found loading the requested TrAX Transformer Factory
'"
  +                        + factoryName + "'. Using default TrAX Transformer Factory instead.");
                   if (this.factory != null) return this.factory;
                   _factory = (SAXTransformerFactory) TransformerFactory.newInstance();
               }
  @@ -351,7 +344,8 @@
           // FIXME (SM): implementation-specific parameter passing should be 
           // made more extensible.
           if (_factory.getClass().getName().equals("org.apache.xalan.processor.TransformerFactoryImpl"))
{
  -            _factory.setAttribute("http://xml.apache.org/xalan/features/incremental", new
Boolean (incrementalProcessing));
  +            _factory.setAttribute("http://xml.apache.org/xalan/features/incremental",
  +                    new Boolean (incrementalProcessing));
           }
           
           return _factory;
  @@ -359,10 +353,9 @@
   
       private Templates getTemplates(Source stylesheet, String id)
       throws IOException, ProcessingException {
  -        if (!useStore)
  +        if (!useStore) {
               return null;
  -
  -        getLogger().debug("XSLTProcessorImpl getTemplates: stylesheet " + id);
  +        }
   
           // we must augment the template ID with the factory classname since one
           // transformer implementation cannot handle the instances of a 
  @@ -395,8 +388,9 @@
   
       private void putTemplates (Templates templates, Source stylesheet, String id)
       throws IOException, ProcessingException {
  -        if (!useStore)
  +        if (!useStore) {
               return;
  +        }
   
           // we must augment the template ID with the factory classname since one
           // transformer implementation cannot handle the instances of a 
  
  
  

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