Results 1 to 1 of 1
Thread: transformer skipping file
- 04-07-2011, 04:41 PM #1
Member
- Join Date
- Apr 2011
- Posts
- 1
- Rep Power
- 0
transformer skipping file
Hello,
I am fairly new to using Java to work with XML, but think I have caught on pretty decently. The problem I am having is in with the processing of an XSL stylesheet for a given XML file.
The XML file being processed is basically a directory file, it has the following setup:
<files>
<tspair>
<opcfile name="test340.xml"/>
<tesfile name="test421.xml"/>
</tspair>
</files>
The XSL (in the ZIP attached) reads this file, and is supposed to combine the two files and do some other transforms within. I have successfully run this from the CMD with Saxon and Xalan respectively. The problem I am having from my little test app is that the "test340.xml" file is being omitted from the final result. Also in the ZIP i have included two result files, one good and one bad, the directory xml, the xsl and the two xml called for in the directory.
Here is the code:
I'm betting I am missing something simple, but I am at a loss. Any help is more than appreciated.Java Code:import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.StringWriter; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.transform.OutputKeys; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerConfigurationException; import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamSource; import org.w3c.dom.Document; public class Trans { /** * @param args * @throws Exception */ public static void main(String[] args) throws Exception { // TODO Auto-generated method stub String outDir = "C:/testDir"; String xmlfile = outDir + "/finalPair.xml"; String xslfile = outDir + "/finalConv.xsl"; String newXmlfile = outDir + "/new2.xml"; TransformerFactory tf = TransformerFactory.newInstance(); System.out.println("Opening XSL file..."); StreamSource xslSrc = new StreamSource(xslfile); Transformer t = null; try { t = tf.newTransformer(xslSrc); } catch (TransformerConfigurationException e) { // TODO Auto-generated catch block e.printStackTrace(); } System.out.println("Opening XML file..."); StreamResult output = null; try{ output = new StreamResult(new FileOutputStream(newXmlfile)); } catch(FileNotFoundException fnf){ fnf.printStackTrace(); } System.out.println("Running transformation..."); try{ t.transform(input, output); } catch(TransformerException xfe){ xfe.printStackTrace(); } System.out.println("Success"); } }
Thanks,
Tom
Similar Threads
-
Skipping an Integer
By BrainMelt in forum New To JavaReplies: 9Last Post: 03-30-2011, 04:54 AM -
Skipping Scanner
By chari_autumn in forum New To JavaReplies: 2Last Post: 01-04-2011, 06:29 AM -
Skipping links!!!
By jvh in forum New To JavaReplies: 2Last Post: 03-04-2010, 12:11 AM -
Java XML DOM/Transformer and attribute ordering
By BeMathis in forum Advanced JavaReplies: 0Last Post: 10-14-2009, 06:49 PM -
how to solve transformer exception
By java_arc in forum Advanced JavaReplies: 1Last Post: 04-19-2008, 12:46 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks