Subject: [xsl] Problem with SimpleTransform servlet From: Karen Fox <kfox@xxxxxxxxx> Date: Thu, 18 Oct 2001 13:25:26 -0600 |
I'm using the Xalan SimpleTransform servlet to transform an XML file into another XML file. It appears to be working as far as creating the new file, but all it writes is the header data. The rest is blank and the file appears to be open because I can't delete it without restarting JRun. I'm using Xalan 2.1.0 and the SimpleTransform code is below. We modified it slightly so we could call it from another servlet. // Imported TraX classes import javax.xml.transform.TransformerFactory; import javax.xml.transform.Transformer; import javax.xml.transform.stream.StreamSource; import javax.xml.transform.stream.StreamResult; import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerConfigurationException; // Imported java classes import java.io.FileOutputStream; import java.io.FileNotFoundException; import java.io.IOException; /** * Use the TraX interface to perform a transformation in the simplest manner possible * (3 statements). */ public class SimpleTransform2 { public static void main(String args[]) { } public void transform(String xmlFile, String xslFile, String outFile) throws TransformerException, TransformerConfigurationException, FileNotFoundException, IOException { System.out.println("Entering transform"); // Use the static TransformerFactory.newInstance() method to instantiate // a TransformerFactory. The javax.xml.transform.TransformerFactory // system property setting determines the actual class to instantiate -- // org.apache.xalan.transformer.TransformerImpl. TransformerFactory tFactory = TransformerFactory.newInstance(); // Use the TransformerFactory to instantiate a Transformer that will work with // the stylesheet you specify. This method call also processes the stylesheet // into a compiled Templates object. Transformer transformer = tFactory.newTransformer(new StreamSource(xslFile)); // Use the Transformer to apply the associated Templates object to an XML document // (foo.xml) and write the output to a file (foo.out). transformer.transform(new StreamSource(xmlFile), new StreamResult(new FileOutputStream(outFile))); //System.out.println("************* The result is in " + outFile + "*************"); } } This is all that prints out: <?xml version="1.0" encoding="UTF-8"?> <ROWSET xmlns:fo="http://www.w3.org/1999/XSL/Format"/> I'd appreciate any suggestions of what else I can try to fix this. Thank you. Karen Fox The MITRE Corporation kfox@xxxxxxxxx XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] ampersand output, Michael Kay | Thread | Re: [xsl] Problem with SimpleTransf, Karen Fox |
Re: [xsl] ampersand output, Eric Vitiello | Date | Re: [xsl] best way to generate form, Graham Seaman |
Month |