I want to be able to pass my input files and output files into this program with a seperate main method. My intentions are to access this through a GUI.
public class SimpleTransform {
public static void main(String[] args) throws TransformerException, TransformerConfigurationException, FileNotFoundException, IOException {
// Use the static TransformerFactory.newInstance() method to instantiate
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer(new StreamSource("demiprocess.xsl"));
transformer.transform(new StreamSource("Anzer.xml"), new StreamResult(new FileOutputStream("lee.xml")));
System.out.println("*The result is in birds.out ***");
}
}
This is what I tried but I keep getting errors:
public class Simple {
private String xmlFile ;
private String xslFile;
private String outputFile;
/**
* Constructor for objects of class Simple
*/
public Simple(String xmlFile, String xslFile,String outputFile) {
this.xmlFile = xmlFile;
this.xslFile = xslFile;
this.outputFile= outputFile;
}
public String SimpleTransform() throws TransformerException,TransformerConfigurationException,FileNotFoundException, IOException {
String mystring = "";
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer(new StreamSource(xslFile));
transformer.transform(new StreamSource(xmlFile), new StreamResult(new FileOutputStream(outputFile)));
return mystring = "***The result is in birds.out *****";
}
}
i get this error “file:///C:/Users/Abiodun/Desktop/New%20system/new%20system/demiprocess.xsl; Line #1; Column #10; stylesheet requires attribute: version”
It seems like you are missing the version attribute in your XSL file declaration. Does it start with something similar to this?