cziegeler    2002/06/28 00:14:37

  Modified:    src/java/org/apache/cocoon/transformation
                        AbstractSAXTransformer.java
                        SourceWritingTransformer.java
               src/scratchpad/webapp/mount/editor editor.xmap test.xmap
  Log:
  Fixed EmptyStackException reported by Denis Thierry [[EMAIL PROTECTED]] and 
NPE in SourceWritingTransformer
  
  Revision  Changes    Path
  1.6       +14 -7     
xml-cocoon2/src/java/org/apache/cocoon/transformation/AbstractSAXTransformer.java
  
  Index: AbstractSAXTransformer.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/transformation/AbstractSAXTransformer.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- AbstractSAXTransformer.java       20 May 2002 06:53:15 -0000      1.5
  +++ AbstractSAXTransformer.java       28 Jun 2002 07:14:36 -0000      1.6
  @@ -191,6 +191,9 @@
       /** The SourceResolver for this request */
       protected SourceResolver     resolver;
   
  +    /** Are we already initialized for the current request? */
  +    private boolean isInitialized;
  +
       /** Empty attributes (for performance). This can be used
        *  do create own attributes, but make sure to clean them
        *  afterwords.
  @@ -240,6 +243,7 @@
           this.resolver = resolver;
           this.parameters = par;
           this.source = src;
  +        this.isInitialized = false;
   
           // get the current namespace
           this.namespaceURI = this.parameters.getParameter("namespaceURI", 
this.defaultNamespaceURI);
  @@ -286,12 +290,15 @@
        */
       public void startDocument()
       throws SAXException {
  -       try {
  -            this.setupTransforming();
  -        } catch (ProcessingException local) {
  -            throw new SAXException("ProcessingException: " + local, local);
  -        } catch (IOException ioe) {
  -            throw new SAXException("IOException: " + ioe, ioe);
  +        if ( !this.isInitialized ) {
  +            try {
  +                this.setupTransforming();
  +            } catch (ProcessingException local) {
  +                throw new SAXException("ProcessingException: " + local, local);
  +            } catch (IOException ioe) {
  +                throw new SAXException("IOException: " + ioe, ioe);
  +            }
  +            this.isInitialized = true;
           }
           if (this.ignoreEventsCount == 0) super.startDocument();
       }
  
  
  
  1.4       +5 -3      
xml-cocoon2/src/java/org/apache/cocoon/transformation/SourceWritingTransformer.java
  
  Index: SourceWritingTransformer.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/transformation/SourceWritingTransformer.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SourceWritingTransformer.java     4 Jun 2002 07:31:52 -0000       1.3
  +++ SourceWritingTransformer.java     28 Jun 2002 07:14:36 -0000      1.4
  @@ -578,10 +578,12 @@
                   attrs.addAttribute(null, SWT_ACTION_ATTRIBUTE, 
SWT_ACTION_ATTRIBUTE, "CDATA", action);
                   attrs.addAttribute(null, SWT_RESULT_ATTRIBUTE, 
SWT_RESULT_ATTRIBUTE, "CDATA", result);
                   if (this.serializer_name != null) attrs.addAttribute(null, 
SWT_SERIALIZER_ATTRIBUTE, SWT_SERIALIZER_ATTRIBUTE, "CDATA", this.serializer_name);
  -                super.startElement(uri, name, raw, attrs);
  +                super.contentHandler.startElement(uri, name, raw, attrs);
                   if (this.message != null && this.failed == true) 
super.characters(this.message.toCharArray(), 0, this.message.length());
  -                super.endElement(uri, name, raw);
  -                getLogger().debug("Source Written");
  +                super.contentHandler.endElement(uri, name, raw);
  +                if (this.getLogger().isDebugEnabled()) {
  +                    this.getLogger().debug("Source Written");
  +                }
               }
           // default
           } else {
  
  
  
  1.8       +1 -16     xml-cocoon2/src/scratchpad/webapp/mount/editor/editor.xmap
  
  Index: editor.xmap
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/scratchpad/webapp/mount/editor/editor.xmap,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- editor.xmap       22 Mar 2002 12:09:59 -0000      1.7
  +++ editor.xmap       28 Jun 2002 07:14:37 -0000      1.8
  @@ -17,21 +17,6 @@
       </map:generators>
       <map:serializers default="html"/>
       <map:transformers default="xslt">
  -    
  -     <!-- 
  -     
  -             Define 'sourcewriter' as the name for SourceWritingTransformer
  -             You can set up the default Serialiser here
  -             You can also set it in the invocation tag below
  -             or place serializer="serializer-name" in the source:write tag 
  -             NB. If you are using FileSource, you need to specify a Serializer.
  -     
  -     -->
  -     <map:transformer name="sourcewriter" logger="sitemap.transformer.tofile"
  -                             
src="org.apache.cocoon.transformation.SourceWritingTransformer" label="source">
  -                             <serializer>xml</serializer>
  -                     </map:transformer>
  -                     
       </map:transformers>
       <map:readers default="resource"/>
       <map:matchers default="wildcard"/>
  @@ -120,7 +105,7 @@
                                <map:transform 
src="editor/stylesheets/editor2writer.xsl">
                                        <map:parameter name="base" value="docs"/>
                                </map:transform>
  -                             <map:transform type="sourcewriter"/>
  +                             <map:transform type="write-source"/>
                                <map:serialize type="xml"/>
                        </map:match>
   
  
  
  
  1.4       +3 -14     xml-cocoon2/src/scratchpad/webapp/mount/editor/test.xmap
  
  Index: test.xmap
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/scratchpad/webapp/mount/editor/test.xmap,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- test.xmap 22 Mar 2002 12:09:59 -0000      1.3
  +++ test.xmap 28 Jun 2002 07:14:37 -0000      1.4
  @@ -21,17 +21,6 @@
       </map:serializers>
       <map:transformers default="xslt">
       
  -     <!-- Define 'filewriter' as the name for FileWritingTransformer -->
  -     <!-- You can set up the default Serialiser here -->
  -     <!-- You can also set it in the invocation tag below -->
  -     <!-- or place serializer="serializer-name" in the source:write tag -->
  -     <!-- if you leave it out altogether, 'xml' is used -->
  -    
  -     <map:transformer name="filewriter" logger="sitemap.transformer.tofile"
  -                             
src="org.apache.cocoon.transformation.SourceWritingTransformer">
  -                             <serializer>my-xml-serializer</serializer>
  -                     </map:transformer>
  -                     
       </map:transformers>
       <map:readers default="resource"/>
       <map:matchers default="wildcard"/>
  @@ -47,7 +36,7 @@
                        <map:match pattern="test/4">
                                <map:generate src="tests/test4.xml"/>
                                <map:transform type="cinclude"/>
  -                             <map:transform type="filewriter"/>
  +                             <map:transform type="write-source"/>
                                <map:transform src="stylesheets/simple-page2html.xsl">
                                        <map:parameter name="view-source" 
value="tests/test4.xml"/>
                                </map:transform>
  @@ -57,7 +46,7 @@
                        <map:match pattern="test/5">
                                <map:generate src="tests/test5.xml"/>
                                <map:transform src="tests/make-page.xsl"/>
  -                             <map:transform type="filewriter">
  +                             <map:transform type="write-source">
                                        <map:parameter name="serializer" value="xml"/> 
<!-- invoke the filewriter with 'xml' serializer -->
                                </map:transform> 
                                <map:transform src="stylesheets/simple-page2html.xsl">
  @@ -72,7 +61,7 @@
                                        <map:parameter name="logfile" 
value="before.log"/>
                                        <map:parameter name="append" value="no"/>
                                </map:transform>
  -                             <map:transform type="filewriter"/>
  +                             <map:transform type="write-source"/>
                                <map:transform type="log">
                                        <map:parameter name="logfile" 
value="after.log"/>
                                        <map:parameter name="append" value="no"/>
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     [EMAIL PROTECTED]
To unsubscribe, e-mail:          [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to