cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bernhard Huber <berni_hu...@a1.net>
Subject Re: Xalan Serializer content-handler was: Re: Current CVS broken !
Date Wed, 20 Nov 2002 17:05:42 GMT
hello,

does anybody have XALAN serializer problems?

i don't want just to patch XMLSerializer, HTMLSerializer, and 
TextSerializer, and LogicsheetCodeGenerator as i 'm not 100% aware of 
the total impact of these changes.
Perhaps the problems only occur in Xalan settings, not for the xsltc
settings...
Any comments, experiences ?

Anyway the patches:
diff -u -r 
src/java/org/apache/cocoon/components/language/markup/LogicsheetCodeGenerator.java 
build/cocoon/src/org/apache/cocoon/components/language/markup/LogicsheetCodeGenerator.java
--- 
src/java/org/apache/cocoon/components/language/markup/LogicsheetCodeGenerator.java 
Sun Sep 29 16:29:50 2002
+++ 
build/cocoon/src/org/apache/cocoon/components/language/markup/LogicsheetCodeGenerator.java

Sat Nov 16 09:35:20 2002
@@ -104,7 +104,10 @@
              // Set the output properties
              format.put(OutputKeys.METHOD,"text");
              // FIXME (SSA) remove the nice identing. For debug purpose 
only.
-            format.put(OutputKeys.INDENT,"yes");
+            format.put(OutputKeys.INDENT,"no");
+//@HB added
+format.put( "{http://xml.apache.org/xslt}indent-amount", "0" );
+format.put( "{http://xml.apache.org/xslt}content-handler", 
"org.apache.xalan.serialize.SerializerToText" );
              handler.getTransformer().setOutputProperties(format);

              this.writer = new StringWriter();
diff -u -r src/java/org/apache/cocoon/serialization/HTMLSerializer.java 
build/cocoon/src/org/apache/cocoon/serialization/HTMLSerializer.java
--- src/java/org/apache/cocoon/serialization/HTMLSerializer.java	Sun Sep 
29 16:30:00 2002
+++ 
build/cocoon/src/org/apache/cocoon/serialization/HTMLSerializer.java	Sat 
Nov 16 21:53:46 2002
@@ -80,6 +80,8 @@
      throws ConfigurationException {
          super.configure( conf );
          this.format.put(OutputKeys.METHOD,"html");
+        // HB modified
+        this.format.put( "{http://xml.apache.org/xslt}content-handler", 
"org.apache.xalan.serialize.SerializerToHTML" );
      }

      /**
diff -u -r src/java/org/apache/cocoon/serialization/TextSerializer.java 
build/cocoon/src/org/apache/cocoon/serialization/TextSerializer.java
--- src/java/org/apache/cocoon/serialization/TextSerializer.java	Tue Jul 
  2 21:40:40 2002
+++ 
build/cocoon/src/org/apache/cocoon/serialization/TextSerializer.java	Sat 
Nov 16 21:42:54 2002
@@ -53,6 +53,11 @@
  import javax.xml.transform.OutputKeys;
  import javax.xml.transform.sax.TransformerHandler;
  import javax.xml.transform.stream.StreamResult;
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.cocoon.CascadingIOException;
+
+import java.io.IOException;
  import java.io.OutputStream;

  /**
@@ -67,27 +72,37 @@
      public TextSerializer() {
      }

-    public void setOutputStream(OutputStream out) {
+    public void setOutputStream(OutputStream out) throws IOException {
          try {
              super.setOutputStream(out);
              handler = this.getTransformerHandler();
-            format.put(OutputKeys.METHOD,"text");
+            // HB moved to configure 
format.put(OutputKeys.METHOD,"text");
              handler.setResult(new StreamResult(this.output));
              handler.getTransformer().setOutputProperties(format);
              this.setContentHandler(handler);
              this.setLexicalHandler(handler);
         } catch (Exception e) {
-            getLogger().error("TextSerializer.setOutputStream()", e);
-            throw new RuntimeException(e.toString());
+            throw new CascadingIOException(e.toString(), e);
          }
      }

      /**
+     * Set the configurations for this serializer.
+     */
+    public void configure(Configuration conf)
+    throws ConfigurationException {
+        super.configure( conf );
+        this.format.put(OutputKeys.METHOD,"text");
+        // HB modified
+        this.format.put( "{http://xml.apache.org/xslt}content-handler", 
"org.apache.xalan.serialize.SerializerToText" );
+    }
+
+    /**
       * Recyce the serializer. GC instance variables
       */
      public void recycle() {
          super.recycle();
          this.handler = null;
      }
-
  }
+
diff -u -r src/java/org/apache/cocoon/serialization/XMLSerializer.java 
build/cocoon/src/org/apache/cocoon/serialization/XMLSerializer.java
--- src/java/org/apache/cocoon/serialization/XMLSerializer.java	Tue Jul 
  2 21:40:40 2002
+++ build/cocoon/src/org/apache/cocoon/serialization/XMLSerializer.java 
Sat Nov 16 21:55:12 2002
@@ -53,6 +53,11 @@
  import javax.xml.transform.OutputKeys;
  import javax.xml.transform.sax.TransformerHandler;
  import javax.xml.transform.stream.StreamResult;
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.cocoon.CascadingIOException;
+
+import java.io.IOException;
  import java.io.OutputStream;

  /**
@@ -67,22 +72,33 @@
      public XMLSerializer() {
      }

-    public void setOutputStream(OutputStream out) {
+    public void setOutputStream(OutputStream out) throws IOException {
          try {
              super.setOutputStream(out);
              this.handler = this.getTransformerHandler();
-            format.put(OutputKeys.METHOD,"xml");
+            // HB moved to configure format.put(OutputKeys.METHOD,"xml");
              handler.setResult(new StreamResult(this.output));
              handler.getTransformer().setOutputProperties(format);
              this.setContentHandler(handler);
              this.setLexicalHandler(handler);
          } catch (Exception e) {
-            getLogger().error("XMLSerializer.setOutputStream()", e);
-            throw new RuntimeException(e.toString());
+            throw new CascadingIOException(e.toString(), e);
          }
      }

      /**
+     * Set the configurations for this serializer.
+     */
+    public void configure(Configuration conf)
+    throws ConfigurationException {
+        super.configure( conf );
+
+        format.put(OutputKeys.METHOD,"xml");
+        // HB modified
+        this.format.put( "{http://xml.apache.org/xslt}content-handler", 
"org.apache.xalan.serialize.SerializerToXML" );
+    }
+
+    /**
       * Recycle the serializer. GC instance variables
       */
      public void recycle() {
@@ -90,3 +106,4 @@
          this.handler = null;
      }
  }
+


Gittings, Paul (Australia) wrote:
> Bernhard ,
> 
> thanks for posting that fix, I thought I was going mad. 
> 
> I've got the HTMLSerializer working using your patch but I'm still 
> getting the same problem with the XMLSerialzer.  Where exactly in the 
> XMLSerializer.java file was I supposed to put the:
> 
>   *** this*.format.put(/ 
> "{http://xml.apache.org/xslt}content-handler"/,/ 
> "org.apache.xalan.serialize.SerializerToXML"/ );
> 
> I'm assuming I put it in the wrong spot.
> 
hope the patch above helps, add the '+' lines to the original code...

regards bernhard


---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Mime
View raw message