DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=16095>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=16095 Use xsltc Summary: Use xsltc Product: XalanJ2 Version: 2.4Dx Platform: All OS/Version: Windows NT/2K Status: NEW Severity: Normal Priority: Other Component: org.apache.xalan.extensions AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] Hello, i whould like use xalanj2 (2.4.1) java library to compile some file xsl to translet file, but when I can try to build the translet file I receive this error: Exception: java.io.NotSerializableException: org.apache.xalan.extensions.ExtensionNamespacesManager java.io.NotSerializableException: org.apache.xalan.extensions.ExtensionNamespacesManager at java.io.ObjectOutputStream.outputObject(ObjectOutputStream.java:1148) at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:366) at java.io.ObjectOutputStream.outputClassFields (ObjectOutputStream.java:1827) at java.io.ObjectOutputStream.defaultWriteObject (ObjectOutputStream.java:480) at java.io.ObjectOutputStream.outputObject(ObjectOutputStream.java:1214) at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:366) at test.Compile.dumpTemplate(Compile.java:83) at test.Compile.run(Compile.java:55) at test.Compile.main(Compile.java:28) and so, I resolve the problem with change this two class ExtensionNamespaceManager and ExtensionNamespaceSupport To support Serializable interface and I recompile xalan My question is this: Is this the correct operation ? also I looking for a path to xalan for this bug but I don�t find nothing can someone help me ? thanks n.b. I�m sorry for my little English This is my java source package test; import java.io.File; import java.io.FileOutputStream; import java.io.ObjectOutputStream; import javax.xml.transform.stream.StreamSource; import javax.xml.transform.stream.StreamResult; import javax.xml.transform.Templates; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerFactory; import java.net.MalformedURLException; import org.apache.xalan.xsltc.compiler.XSLTC; import org.apache.xalan.xsltc.Translet; import org.apache.xalan.xsltc.trax.TransformerFactoryImpl; public class Compile { public static void main(String[] args){ Compile app = new Compile(); System.out.println(app.run("D:\\xslt\\Certificato.xsl")); } /** * Compiles an XSL stylesheet into a translet, wraps the translet * inside a Templates object and dumps it to a file. */ public String run(String xsl) { String outputPath=null; try { // Get an input stream for the XSL stylesheet StreamSource stylesheet = new StreamSource(xsl); // The TransformerFactory will compile the stylesheet and // put the translet classes inside the Templates object TransformerFactory factory = TransformerFactory.newInstance(); Templates templates = factory.newTemplates(stylesheet); // Send the Templates object to a '.translet' file System.out.println(getBaseName(xsl)); outputPath="D:\\xslt\\" + getBaseName(xsl)+".translet"; dumpTemplate(outputPath, templates); } catch (Exception e) { System.err.println("Exception: " + e); e.printStackTrace(); outputPath=null; } return outputPath; } /** * Returns the base-name of a file/url */ private String getBaseName(String filename) { int start = filename.lastIndexOf(File.separatorChar); int stop = filename.lastIndexOf('.'); if (stop <= start) stop = filename.length() - 1; return filename.substring(start+1, stop); } /** * Writes a Templates object to a file */ private void dumpTemplate(String file, Templates templates) throws Exception { FileOutputStream ostream = new FileOutputStream(file); ObjectOutputStream p = new ObjectOutputStream(ostream); p.writeObject(templates); p.flush(); ostream.close(); } private void usage() { System.err.println("Usage: compile <xsl_file>"); System.exit(1); } } and this is my xsl file <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xalan="http://xml.apache.org/xalan" xmlns:counter="MyCounter" extension-element-prefixes="counter" version="1.0"> <xsl:output method="xml" omit-xml-declaration="no" encoding="ISO-8859-1" indent="no"/> <xalan:component prefix="counter" elements="init incr" functions="read format ConvertToDate"> <xalan:script lang="javascript"> var counters = new Array(); function init (xslproc, elem) { name = elem.getAttribute ("name"); value = parseInt(elem.getAttribute ("value")); counters[name] = value; return null; } function read (name) { return "" + (counters[name]); } function format (valore) { return "form" + valore; } function ConvertToDate(Valore){ if (Valore.length != 10) return Valore; return Valore.substr(0,4) + "/" + Valore.substr(5,2) + "/" + Valore.substr(8,2) ; } function incr (xslproc, elem) { name = elem.getAttribute ("name"); counters[name]++; return null; } </xalan:script> </xalan:component> <xsl:template match="StampaCDP"> <StampaCDP tipo="java.lang.tipo"> <xsl:apply-templates select="InformazioniComplementari"/> <xsl:apply-templates select="StatoGiuridico"/> </StampaCDP> </xsl:template> <xsl:template match="InformazioniComplementari"> <InformazioniComplementari tipo="java.lang.tipo"> <xsl:apply-templates select="NumeroElenco"/> <xsl:apply-templates select="DataCDP"/> </InformazioniComplementari > </xsl:template> <xsl:template match="StatoGiuridico"> <StatoGiuridico tipo="java.lang.tipo"> </StatoGiuridico > </xsl:template> <xsl:template match="DataCDP"> <DataCDP tipo="java.lang.tipo"><xsl:value-of select="counter:ConvertToDate(string(.))"/></DataCDP > </xsl:template> <xsl:template match="NumeroElenco"> <NumeroElenco tipo="java.lang.tipo"> <xsl:value-of select="counter:format(string(.))"/> </NumeroElenco > </xsl:template> </xsl:stylesheet>
