我希望能够在 xml 数据上应用一个或多个样式表。我有这段代码,我想知道如何修改它,以便我可以在单个 xml 数据上应用尽可能多的样式表,并将结果打印在 GUI 的文本区域(因为我假设 settext() 只接受字符串)和同时保存在一个文件中。这些是我的代码..谢谢
/**
* 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 *****";
}
}