我有一个做简单转换的对象。我创建了一个样式表,将XML数据转换为CSV。转换后,将创建一个CSV文件,但内容为空。
public class Simplex
{
private String xmlFile ;
private String xslFile;
private String outputFile;
/**
* Constructor for objects of class Simple
*/
public Simplex(String xmlFile, String xslFile,String outputFile)
{
this.xmlFile = xmlFile;
this.xslFile = xslFile;
this.outputFile= outputFile;
}
public String simplexTransform() 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 = "*Data Has Been Transformed,Check ouput File *";
}
}