我必须进行 xsl 转换,在其中我将传递示例输入 xml 以最终实现最终转换 xml,我已经使用转换器的 java api 编写了程序,请有人告诉我如何编写相同的程序以便它与xalan api 2.7.1 也是,下面是带有 jaa 的代码,我需要将它与 xalan 兼容
import javax.xml.transform.*;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
public class TestMain {
public static void main(String[] args) throws IOException, URISyntaxException, TransformerException {
TransformerFactory factory = TransformerFactory.newInstance();
Source xslt = new StreamSource(new File("transform.xslt"));
Transformer transformer = factory.newTransformer(xslt);
Source text = new StreamSource(new File("input.xml"));
transformer.transform(text, new StreamResult(new File("output.xml")));
}
}