[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
RE: [xsl] Problem with SimpleTransform servlet
Subject: RE: [xsl] Problem with SimpleTransform servlet From: Wolfgang Bogacz <wbogacz@xxxxxxxxxxx> Date: Thu, 18 Oct 2001 16:31:02 -0400 |
I don't think there's a problem here with the Java since you're certainly getting output. And since '<ROWSET>' printed out, I'm inclined to think both the data and xsl files are accessed, too. We'll need to see the data and the xsl you're using. -----Original Message----- From: Karen Fox [mailto:kfox@xxxxxxxxx] Sent: Thursday, October 18, 2001 3:25 PM To: XSL List Subject: [xsl] Problem with SimpleTransform servlet 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 XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Problem with SimpleTransf, Karen Fox | Thread | RE: [xsl] Problem with SimpleTransf, Duffey, Kevin |
Re: [xsl] Problem with SimpleTransf, Karen Fox | Date | Re: [xsl] XSL and function calls, Mike Brown |
Month |