cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject cvs commit: xml-cocoon/src/org/apache/cocoon/transformation TraxTransformer.java
Date Mon, 23 Apr 2001 17:12:02 GMT
dims        01/04/23 10:12:01

  Modified:    src/org/apache/cocoon/components/language/markup Tag:
                        xml-cocoon2 AbstractMarkupLanguage.java
                        Logicsheet.java LogicsheetCodeGenerator.java
               src/org/apache/cocoon/serialization Tag: xml-cocoon2
                        AbstractTextSerializer.java HTMLSerializer.java
                        TextSerializer.java XMLSerializer.java
               src/org/apache/cocoon/transformation Tag: xml-cocoon2
                        TraxTransformer.java
  Log:
  Fixes for TRaX error reporting.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.35  +3 -1      xml-cocoon/src/org/apache/cocoon/components/language/markup/Attic/AbstractMarkupLanguage.java
  
  Index: AbstractMarkupLanguage.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/markup/Attic/AbstractMarkupLanguage.java,v
  retrieving revision 1.1.2.34
  retrieving revision 1.1.2.35
  diff -u -r1.1.2.34 -r1.1.2.35
  --- AbstractMarkupLanguage.java	2001/04/20 20:49:51	1.1.2.34
  +++ AbstractMarkupLanguage.java	2001/04/23 17:11:35	1.1.2.35
  @@ -53,7 +53,7 @@
    * logicsheets as the only means of code generation. Code generation should be decoupled
from this context!!!
    * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
    * @author <a href="mailto:dims@yahoo.com">Davanum Srinivas</a>
  - * @version CVS $Revision: 1.1.2.34 $ $Date: 2001/04/20 20:49:51 $
  + * @version CVS $Revision: 1.1.2.35 $ $Date: 2001/04/23 17:11:35 $
    */
   public abstract class AbstractMarkupLanguage extends AbstractLoggable implements MarkupLanguage,
Composable, Configurable {
       /** The supported language table */
  @@ -264,6 +264,8 @@
               preprocessFilter.setParent(reader);
               // Create code generator
               LogicsheetCodeGenerator codeGenerator = new LogicsheetCodeGenerator();
  +            codeGenerator.setLogger(getLogger());
  +            codeGenerator.init();
               // set the transformer chain builder filter
               TransformerChainBuilderFilter tranBuilder = getTranformerChainBuilder(codeGenerator,
resolver);
               tranBuilder.setLanguageDescriptor(language);
  
  
  
  1.1.2.17  +15 -6     xml-cocoon/src/org/apache/cocoon/components/language/markup/Attic/Logicsheet.java
  
  Index: Logicsheet.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/markup/Attic/Logicsheet.java,v
  retrieving revision 1.1.2.16
  retrieving revision 1.1.2.17
  diff -u -r1.1.2.16 -r1.1.2.17
  --- Logicsheet.java	2001/04/20 20:49:51	1.1.2.16
  +++ Logicsheet.java	2001/04/23 17:11:37	1.1.2.17
  @@ -48,7 +48,7 @@
    * transformed into an equivalent XSLT stylesheet anyway... This class should probably
be based on an interface...
    * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
    * @author <a href="mailto:dims@yahoo.com">Davanum Srinivas</a>
  - * @version CVS $Revision: 1.1.2.16 $ $Date: 2001/04/20 20:49:51 $
  + * @version CVS $Revision: 1.1.2.17 $ $Date: 2001/04/23 17:11:37 $
    */
   public class Logicsheet extends AbstractLoggable {
       /** The trax TransformerFactory */
  @@ -72,6 +72,18 @@
       }
   
       /**
  +     * Helper for TransformerFactory.
  +     */
  +    private synchronized SAXTransformerFactory getTransformerFactory()
  +    {
  +        if(tfactory == null)  {
  +            tfactory = (SAXTransformerFactory) TransformerFactory.newInstance();
  +            tfactory.setErrorListener(new TraxErrorHandler(getLogger()));
  +        }
  +        return tfactory;
  +    }
  +
  +    /**
        * The constructor. It does preserve the namespace from the stylesheet.
        * @param inputSource The stylesheet's input source
        * @exception IOException IOError processing input source
  @@ -79,13 +91,10 @@
        */
       public void setInputSource(InputSource inputSource) throws SAXException, IOException
{
           try {
  -            tfactory = (SAXTransformerFactory)TransformerFactory.newInstance();
  -            tfactory.setErrorListener(new TraxErrorHandler(getLogger()));
  -
               // Create a Templates ContentHandler to handle parsing of the
               // stylesheet.
               javax.xml.transform.sax.TemplatesHandler templatesHandler =
  -                                                tfactory.newTemplatesHandler();
  +                                                getTransformerFactory().newTemplatesHandler();
   
               // Create an XMLReader and set its ContentHandler.
               org.xml.sax.XMLReader reader =
  @@ -116,7 +125,7 @@
        */
       public TransformerHandler getTransformerHandler() {
           try {
  -            TransformerHandler handler = tfactory.newTransformerHandler(templates);
  +            TransformerHandler handler = getTransformerFactory().newTransformerHandler(templates);
               handler.getTransformer().setErrorListener(new TraxErrorHandler(getLogger()));
               return handler;
           } catch (TransformerConfigurationException e) {
  
  
  
  1.1.2.15  +19 -15    xml-cocoon/src/org/apache/cocoon/components/language/markup/Attic/LogicsheetCodeGenerator.java
  
  Index: LogicsheetCodeGenerator.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/markup/Attic/LogicsheetCodeGenerator.java,v
  retrieving revision 1.1.2.14
  retrieving revision 1.1.2.15
  diff -u -r1.1.2.14 -r1.1.2.15
  --- LogicsheetCodeGenerator.java	2001/04/20 20:49:52	1.1.2.14
  +++ LogicsheetCodeGenerator.java	2001/04/23 17:11:38	1.1.2.15
  @@ -28,7 +28,7 @@
   import javax.xml.transform.TransformerException;
   
   import org.apache.log.Logger;
  -import org.apache.avalon.logger.Loggable;
  +import org.apache.avalon.logger.AbstractLoggable;
   
   import org.apache.cocoon.util.TraxErrorHandler;
   
  @@ -37,12 +37,10 @@
    *
    * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
    * @author <a href="mailto:dims@yahoo.com">Davanum Srinivas</a>
  - * @version CVS $Revision: 1.1.2.14 $ $Date: 2001/04/20 20:49:52 $
  + * @version CVS $Revision: 1.1.2.15 $ $Date: 2001/04/23 17:11:38 $
    */
  -public class LogicsheetCodeGenerator implements MarkupCodeGenerator, Loggable {
  +public class LogicsheetCodeGenerator extends AbstractLoggable implements MarkupCodeGenerator
{
   
  -    protected Logger log;
  -
       private Logicsheet corelogicsheet;
   
       private ContentHandler serializerContentHandler;
  @@ -53,21 +51,21 @@
   
       private StringWriter writer;
   
  +    /** The trax TransformerFactory */
  +    private SAXTransformerFactory tfactory = null;
  +
       /**
  -    * The default constructor
  +    * Initialize the LogicsheetCodeGenerator.
       */
  -    public LogicsheetCodeGenerator() {
  +    public void init() {
   
  -        SAXTransformerFactory factory = (SAXTransformerFactory) TransformerFactory.newInstance();
  -        factory.setErrorListener(new TraxErrorHandler(log));
           Properties format = new Properties();
   
           try {
               // set the serializer which would act as ContentHandler for the last transformer
               // FIXME (SSA) change a home made content handler, that extract the PCDATA
               // from the last remaining element
  -            TransformerHandler handler = factory.newTransformerHandler();
  -            handler.getTransformer().setErrorListener(new TraxErrorHandler(log));
  +            TransformerHandler handler = getTransformerFactory().newTransformerHandler();
   
               // Set the output properties
               format.put(OutputKeys.METHOD,"text");
  @@ -79,14 +77,20 @@
               handler.setResult(new StreamResult(writer));
               this.serializerContentHandler = handler;
           } catch (TransformerConfigurationException tce) {
  -            log.error("LogicsheetCodeGenerator: unable to get TransformerHandler", tce);
  +            getLogger().error("LogicsheetCodeGenerator: unable to get TransformerHandler",
tce);
           }
       }
   
  -    public void setLogger(Logger logger) {
  -        if (this.log == null) {
  -            this.log = logger;
  +    /**
  +     * Helper for TransformerFactory.
  +     */
  +    private synchronized SAXTransformerFactory getTransformerFactory()
  +    {
  +        if(tfactory == null)  {
  +            tfactory = (SAXTransformerFactory) TransformerFactory.newInstance();
  +            tfactory.setErrorListener(new TraxErrorHandler(getLogger()));
           }
  +        return tfactory;
       }
   
       /**
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.12  +16 -2     xml-cocoon/src/org/apache/cocoon/serialization/Attic/AbstractTextSerializer.java
  
  Index: AbstractTextSerializer.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/serialization/Attic/AbstractTextSerializer.java,v
  retrieving revision 1.1.2.11
  retrieving revision 1.1.2.12
  diff -u -r1.1.2.11 -r1.1.2.12
  --- AbstractTextSerializer.java	2001/04/17 15:33:18	1.1.2.11
  +++ AbstractTextSerializer.java	2001/04/23 17:11:45	1.1.2.12
  @@ -22,23 +22,37 @@
   import javax.xml.transform.OutputKeys;
   import javax.xml.transform.sax.SAXTransformerFactory;
   
  +import org.apache.cocoon.util.TraxErrorHandler;
  +
   /**
    * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
    *         (Apache Software Foundation, Exoffice Technologies)
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - * @version CVS $Revision: 1.1.2.11 $ $Date: 2001/04/17 15:33:18 $
  + * @version CVS $Revision: 1.1.2.12 $ $Date: 2001/04/23 17:11:45 $
    */
   public abstract class AbstractTextSerializer extends AbstractSerializer implements Configurable,
Cacheable {
   
       /**
        * The trax <code>TransformerFactory</code> used by this serializer.
        */
  -    protected SAXTransformerFactory factory = (SAXTransformerFactory) TransformerFactory.newInstance();
  +    private SAXTransformerFactory tfactory = null;
   
       /**
        * The <code>Properties</code> used by this serializer.
        */
       protected Properties format = new Properties();
  +
  +    /**
  +     * Helper for TransformerFactory.
  +     */
  +    protected synchronized SAXTransformerFactory getTransformerFactory()
  +    {
  +        if(tfactory == null)  {
  +            tfactory = (SAXTransformerFactory) TransformerFactory.newInstance();
  +            tfactory.setErrorListener(new TraxErrorHandler(getLogger()));
  +        }
  +        return tfactory;
  +    }
   
       /**
        * Set the configurations for this serializer.
  
  
  
  1.1.2.20  +2 -2      xml-cocoon/src/org/apache/cocoon/serialization/Attic/HTMLSerializer.java
  
  Index: HTMLSerializer.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/serialization/Attic/HTMLSerializer.java,v
  retrieving revision 1.1.2.19
  retrieving revision 1.1.2.20
  diff -u -r1.1.2.19 -r1.1.2.20
  --- HTMLSerializer.java	2001/04/20 20:50:11	1.1.2.19
  +++ HTMLSerializer.java	2001/04/23 17:11:47	1.1.2.20
  @@ -20,7 +20,7 @@
   
   /**
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - * @version CVS $Revision: 1.1.2.19 $ $Date: 2001/04/20 20:50:11 $
  + * @version CVS $Revision: 1.1.2.20 $ $Date: 2001/04/23 17:11:47 $
    */
   
   public class HTMLSerializer extends AbstractTextSerializer implements Poolable {
  @@ -33,7 +33,7 @@
       public void setOutputStream(OutputStream out) {
           try {
               super.setOutputStream(out);
  -            handler = factory.newTransformerHandler();
  +            handler = getTransformerFactory().newTransformerHandler();
               format.put(OutputKeys.METHOD,"html");
               handler.setResult(new StreamResult(out));
               handler.getTransformer().setOutputProperties(format);
  
  
  
  1.1.2.15  +2 -2      xml-cocoon/src/org/apache/cocoon/serialization/Attic/TextSerializer.java
  
  Index: TextSerializer.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/serialization/Attic/TextSerializer.java,v
  retrieving revision 1.1.2.14
  retrieving revision 1.1.2.15
  diff -u -r1.1.2.14 -r1.1.2.15
  --- TextSerializer.java	2001/04/20 20:50:12	1.1.2.14
  +++ TextSerializer.java	2001/04/23 17:11:49	1.1.2.15
  @@ -20,7 +20,7 @@
   
   /**
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - * @version CVS $Revision: 1.1.2.14 $ $Date: 2001/04/20 20:50:12 $
  + * @version CVS $Revision: 1.1.2.15 $ $Date: 2001/04/23 17:11:49 $
    */
   
   public class TextSerializer extends AbstractTextSerializer implements Poolable {
  @@ -33,7 +33,7 @@
       public void setOutputStream(OutputStream out) {
           try {
               super.setOutputStream(out);
  -            handler = factory.newTransformerHandler();
  +            handler = getTransformerFactory().newTransformerHandler();
               format.put(OutputKeys.METHOD,"text");
               handler.setResult(new StreamResult(out));
               handler.getTransformer().setOutputProperties(format);
  
  
  
  1.1.2.20  +2 -2      xml-cocoon/src/org/apache/cocoon/serialization/Attic/XMLSerializer.java
  
  Index: XMLSerializer.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/serialization/Attic/XMLSerializer.java,v
  retrieving revision 1.1.2.19
  retrieving revision 1.1.2.20
  diff -u -r1.1.2.19 -r1.1.2.20
  --- XMLSerializer.java	2001/04/20 20:50:12	1.1.2.19
  +++ XMLSerializer.java	2001/04/23 17:11:50	1.1.2.20
  @@ -20,7 +20,7 @@
   
   /**
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - * @version CVS $Revision: 1.1.2.19 $ $Date: 2001/04/20 20:50:12 $
  + * @version CVS $Revision: 1.1.2.20 $ $Date: 2001/04/23 17:11:50 $
    */
   
   public class XMLSerializer extends AbstractTextSerializer implements Poolable {
  @@ -33,7 +33,7 @@
       public void setOutputStream(OutputStream out) {
           try {
               super.setOutputStream(out);
  -            this.handler = factory.newTransformerHandler();
  +            this.handler = getTransformerFactory().newTransformerHandler();
               format.put(OutputKeys.METHOD,"xml");
               handler.setResult(new StreamResult(out));
               handler.getTransformer().setOutputProperties(format);
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.24  +15 -7     xml-cocoon/src/org/apache/cocoon/transformation/Attic/TraxTransformer.java
  
  Index: TraxTransformer.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/transformation/Attic/TraxTransformer.java,v
  retrieving revision 1.1.2.23
  retrieving revision 1.1.2.24
  diff -u -r1.1.2.23 -r1.1.2.24
  --- TraxTransformer.java	2001/04/20 20:50:17	1.1.2.23
  +++ TraxTransformer.java	2001/04/23 17:11:59	1.1.2.24
  @@ -68,7 +68,7 @@
    *         (Apache Software Foundation, Exoffice Technologies)
    * @author <a href="mailto:dims@yahoo.com">Davanum Srinivas</a>
    * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
  - * @version CVS $Revision: 1.1.2.23 $ $Date: 2001/04/20 20:50:17 $
  + * @version CVS $Revision: 1.1.2.24 $ $Date: 2001/04/23 17:11:59 $
    */
   public class TraxTransformer extends ContentHandlerWrapper
   implements Transformer, Composable, Recyclable, Configurable, Cacheable, Disposable {
  @@ -131,11 +131,7 @@
           }
           if(templates == null)
           {
  -            if(tfactory == null)  {
  -                tfactory = (SAXTransformerFactory) TransformerFactory.newInstance();
  -                tfactory.setErrorListener(new TraxErrorHandler(getLogger()));
  -            }
  -            templates = tfactory.newTemplates(new SAXSource(new InputSource(systemID)));
  +            templates = getTransformerFactory().newTemplates(new SAXSource(new InputSource(systemID)));
               if (this.useStore == true)
               {
                   // Is this a local file
  @@ -150,9 +146,21 @@
                   }
               }
           }
  -        TransformerHandler handler = tfactory.newTransformerHandler(templates);
  +        TransformerHandler handler = getTransformerFactory().newTransformerHandler(templates);
           handler.getTransformer().setErrorListener(new TraxErrorHandler(getLogger()));
           return handler;
  +    }
  +
  +    /**
  +     * Helper for TransformerFactory.
  +     */
  +    private synchronized SAXTransformerFactory getTransformerFactory()
  +    {
  +        if(tfactory == null)  {
  +            tfactory = (SAXTransformerFactory) TransformerFactory.newInstance();
  +            tfactory.setErrorListener(new TraxErrorHandler(getLogger()));
  +        }
  +        return tfactory;
       }
   
       /**
  
  
  

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