I'm new to XML so bear with me. I need to transform an xml file to another xml file. It needs xslt 2.0. I am using saxon's s9api. Using their documentation this what I have so far:
import java.io.File;
import javax.xml.transform.stream.StreamSource;
import net.sf.saxon.s9api.DocumentBuilder;
import net.sf.saxon.s9api.Processor;
import net.sf.saxon.s9api.SaxonApiException;
import net.sf.saxon.s9api.XsltCompiler;
import net.sf.saxon.s9api.XsltExecutable;
import net.sf.saxon.s9api.XsltTransformer;
class Main{
public static void main(String args[]){
Processor processor = new Processor(false);
XsltCompiler compiler = processor.newXsltCompiler();
DocumentBuilder builder = processor.newDocumentBuilder();
try {
builder.build(new File("C:\\XMLFILE.xml"));
} catch (SaxonApiException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try {
XsltExecutable xsl = compiler.compile(new StreamSource(new File("C:\\XSLFILE.xsl")));
XsltTransformer trans = xsl.load();
trans.transform();
} catch (SaxonApiException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
Is this the right direction? If it is and this is actually performing the transformation how do I specify the output xml.