You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Baback Elmieh <be...@ccs.neu.edu> on 2000/08/04 00:14:58 UTC
Stylesheet serialization problem
Hi,
I'm having a problem with the org.apache.xalan.xslt.StylesheetRoot
class, I noticed that it was a Serializable class so I tried to write a
simple program to write a compiled stylesheet to file and I seem to be
bumping into a NotSerializableException. Here is my stack trace:
org.apache.xalan.xpath.xml.StringToStringTable
java.io.NotSerializableException:
org.apache.xalan.xpath.xml.StringToStringTable
void java.io.ObjectOutputStream.writeObject(java.lang.Object)
void com.winwin.xmlsystem.testSimpleObj.main(java.lang.String[])
My code that produces this bug is as follows (I have made the xsl
inline just in case it's form is the problem, it is pretty much the
simplest valid XSL file I could think of)
import org.apache.xalan.xslt.*;
import java.io.*;
class testSimpleObj
{
public static void main (String[] args)
{
StylesheetRoot compiledXSL = null;
// some simple xsl
String xslText = "<?xml version='1.0' encoding='iso-8859-1'?>" +
"<xsl:stylesheet xmlns:xsl='http://www.w3.org/XSL/Transform/1.0'>" +
"<xsl:template match='/'>" +
"<xsl:value-of select='.' />" +
"</xsl:template>" +
"</xsl:stylesheet>";
try {
// compile the XSL file as per the Getting Started instructions
// on Xalan website:
XSLTProcessor processor = XSLTProcessorFactory.getProcessor();
InputStream xslis= new ByteArrayInputStream(xslText.getBytes());
XSLTInputSource xslSource = new XSLTInputSource(xslis);
compiledXSL = processor.processStylesheet(xslSource);
}
catch(org.xml.sax.SAXException e)
{
System.err.println(e.getMessage());
e.printStackTrace();
}
if (compiledXSL != null)
{
// try to write it if the parse went okay:
try {
FileOutputStream os = new FileOutputStream("style.obj");
ObjectOutputStream bOut = new ObjectOutputStream(os);
bOut.writeObject(compiledXSL);
}
catch (IOException e)
{
System.err.println(e.getMessage());
e.printStackTrace();
}
}
}
}
Could anyone let me know if this is a reproducable bug or if I'm just
hitting something weird?
Thanks,
- Baback