You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Andrew Fawcett <An...@coda.com> on 2000/07/19 09:06:26 UTC

RE: NotSerializableException thrown when Serializing StylesheetRo ot object?

Thanks Cory, 

However I am afraid that's not really what I want to do. I want to use Java
serialization to store a compiled Stylesheet so that I can then later
de-serialize via Java. I want this in order to see if I can save any time
over compiling the stylesheets each time my application starts. Looking at
my example perhaps my use of System.out was misleading, in the real app it
would be a FileOutputStream. 

Perhaps a better question would be. What if any saving would I get by
de-serializing a StylesheetRoot object (assuming it did work) vs compiling
one each time via processStylesheet?

Thanks.

-----Original Message-----
From: Cory Isaacson (Compuflex) [mailto:cisaacson@compuflex.com]
Sent: 18 July 2000 19:02
To: xalan-dev@xml.apache.org
Subject: Fw: NotSerializableException thrown when Serializing
StylesheetRoot object?


I believe this code will do what you want, but its from an old test I made
and it may need some tweaking.

Cory

OutputFormat outputFormat = new OutputFormat(xmlDoc);
XMLSerializer serializer = new XMLSerializer(response.getWriter(),
outputFormat);
serializer.serialize(xmlDoc);
serializer.flush();

----- Original Message -----
From: "Andrew Fawcett" <An...@coda.com>
To: <xa...@xml.apache.org>
Sent: Tuesday, July 18, 2000 10:37 AM
Subject: NotSerializableException thrown when Serializing StylesheetRoot
object?


> Hi,
>
> I am presently attempting to serialize a compiled Stylesheet using the
> following Java code. I was wondering if anyone else has had any experience
> with this. Any comments or advise would be much appreciated. ;-)
>
> import java.io.*;
> import java.util.Date;
> import org.apache.xalan.xslt.*;
>
> public class XSL
> {
> public static void main(String[] args)
> throws Throwable
> {
> XSLTProcessor processor =
> XSLTProcessorFactory.getProcessor();
> StylesheetRoot stylesheet =
> processor.processStylesheet("file:///c:/test.xsl");
> ObjectOutputStream ostream = new
> ObjectOutputStream(System.out);
> ostream.writeObject(stylesheet);
> }
> }
>
> This is the style sheet.
>
> <?xml version="1.0"?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> version="1.0">
> <xsl:template match="*">
> <xsl:copy>
> <xsl:apply-templates/>
> </xsl:copy>
> </xsl:template>
> <xsl:template match="text()">
> <xsl:value-of
> select="translate(.,'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
> 'abcdefghijklmnopqrstuvwxyz')"/>
> </xsl:template>
> </xsl:stylesheet>
>
> The writeObject method eventually throws the following exception. I am
using
> version 1.1.D01 of Xalan.
>
> java.io.NotSerializableException:
> org.apache.xalan.xpath.xml.StringToStringTable
>         at
> java.io.ObjectOutputStream.outputObject(ObjectOutputStream.java:845)
>         at
> java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:342)
>         at
> java.io.ObjectOutputStream.outputClassFields(ObjectOutputStream.java:1567)
>         at
> java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:453)
>         at
>
org.apache.xalan.xslt.ElemTemplateElement.writeObject(ElemTemplateElement.ja
> va:252)
>         at java.lang.reflect.Method.invoke(Native Method)
>         at
>
java.io.ObjectOutputStream.invokeObjectWriter(ObjectOutputStream.java:1585)
>         at
> java.io.ObjectOutputStream.outputObject(ObjectOutputStream.java:907)
>         at
> java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:342)
>         at
> java.io.ObjectOutputStream.outputClassFields(ObjectOutputStream.java:1567)
>         at
> java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:453)
>         at
> java.io.ObjectOutputStream.outputObject(ObjectOutputStream.java:911)
>         at
> java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:342)
>         at
> java.io.ObjectOutputStream.outputClassFields(ObjectOutputStream.java:1567)
>         at
> java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:453)
>         at
org.apache.xalan.xslt.Stylesheet.writeObject(Stylesheet.java:531)
>         at java.lang.reflect.Method.invoke(Native Method)
>         at
>
java.io.ObjectOutputStream.invokeObjectWriter(ObjectOutputStream.java:1585)
>         at
> java.io.ObjectOutputStream.outputObject(ObjectOutputStream.java:907)
>         at
> java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:342)
>         at XSL.main(XSL.java:17)
>