Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java xslt & output xml files

 
manish ahuja
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Currently we are using the following java code to run the xslt & passing the appropriate input xml.
Now the xslt transformation is as such that for the input file it takes it returns multiple output xml files. So its like a xml to xml's transformation.

What we need to acheive is to capture these output xml files from xslt in our java code & do some further processing on the same.

Do post your suggestions on what would be an ideal way to go about the same.

Here is the java code for xslt
------------------

import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamSource;
import javax.xml.transform.stream.StreamResult;
import java.io.*;

public class Transform {

public static void main(String[] args) throws Exception {
if (args.length != 2) {
System.err.println(
"Usage: java Transform [xmlfile] [xsltfile]");
System.exit(1);
}

File xmlFile = new File(args[0]);
File xsltFile = new File(args[1]);

Source xmlSource = new StreamSource(xmlFile);
Source xsltSource = new StreamSource(xsltFile);

TransformerFactory transFact =
TransformerFactory.newInstance();
Transformer trans = transFact.newTransformer(xsltSource);

trans.transform(xmlSource, new StreamResult(System.out));
}
}

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


Regards,
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic