Results 1 to 1 of 1
  1. #1
    twfurst is offline Member
    Join Date
    Apr 2011
    Rep Power

    Default transformer skipping file


    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:

    <opcfile name="test340.xml"/>
    <tesfile name="test421.xml"/>

    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:

    Java Code:
    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 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;
            	t = tf.newTransformer(xslSrc);
            catch (TransformerConfigurationException e) {
    			// TODO Auto-generated catch block
            System.out.println("Opening XML file...");
            StreamResult output = null;
            	output = new StreamResult(new FileOutputStream(newXmlfile));
            catch(FileNotFoundException fnf){
            System.out.println("Running transformation...");
            	t.transform(input, output);
            catch(TransformerException xfe){
    I'm betting I am missing something simple, but I am at a loss. Any help is more than appreciated.


    Attached Files Attached Files

Similar Threads

  1. Skipping an Integer
    By BrainMelt in forum New To Java
    Replies: 9
    Last Post: 03-30-2011, 05:54 AM
  2. Skipping Scanner
    By chari_autumn in forum New To Java
    Replies: 2
    Last Post: 01-04-2011, 07:29 AM
  3. Skipping links!!!
    By jvh in forum New To Java
    Replies: 2
    Last Post: 03-04-2010, 01:11 AM
  4. Java XML DOM/Transformer and attribute ordering
    By BeMathis in forum Advanced Java
    Replies: 0
    Last Post: 10-14-2009, 07:49 PM
  5. how to solve transformer exception
    By java_arc in forum Advanced Java
    Replies: 1
    Last Post: 04-19-2008, 01:46 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts