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=14075>.
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=14075

java.io.NotSerializableException: org.apache.xalan.xsltc.trax.TransformerFactoryImpl

[EMAIL PROTECTED] changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|INVALID                     |



------- Additional Comments From [EMAIL PROTECTED]  2002-11-11 23:03 -------
Reopening the bug with following additional info.:

- dumpTemplate is a method that came with the sample Compile.java code.

- The templates class file created can have any extension that you choose to 
give it. The Compile.java class gives it a ".translet" extension.

The code for Compile.java is as follows:

--------------------------------------------------------------------------------

import java.io.File;
import java.io.FileOutputStream;
import java.io.ObjectOutputStream;

import java.util.Properties;

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 org.apache.xalan.xsltc.trax.TransformerFactoryImpl;
import org.apache.xalan.processor.TransformerFactoryImpl;

public class Compile {

    public static void main(String[] args){
        
        /*
        // Set the TransformerFactory system property.
        // Note: For more flexibility, load properties from a properties file.
        String key = "javax.xml.transform.TransformerFactory";
        String value = "org.apache.xalan.xsltc.trax.TransformerFactoryImpl";
        Properties props = System.getProperties();
        props.put(key, value);
        System.setProperties(props);
        */
        
        Compile app = new Compile();
        System.out.println("XSL File = " + args[0]);
        
        app.run(args[0]);
        
    }

    /**
     * Compiles an XSL stylesheet into a translet, wraps the translet
     * inside a Templates object and dumps it to a file.
     */
    public void run(String xsl) {
        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
     dumpTemplate(getBaseName(xsl)+".translet", templates);
        }
 catch (Exception e) {
            System.err.println("Exception: " + e); 
     e.printStackTrace();
        }
        System.exit(0);
    }

    /**
     * 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) {
 try {
     
        System.out.println("Writing File = " + file);
     FileOutputStream ostream = new FileOutputStream(file);
     ObjectOutputStream p = new ObjectOutputStream(ostream);
     p.writeObject(templates);
     p.flush();
     ostream.close();
 }
 catch (Exception e) {
     System.err.println(e);
     e.printStackTrace();
     System.err.println("Could not write file "+file);
 }
    }

    private void usage() {
        System.err.println("Usage: compile <xsl_file>");
        System.exit(1);
    }

}


--------------------------------------------------------------------------------

Reply via email to