我目前正在尝试让我的代码调用 xml 文件和 xsl - 然后执行转换并根据 xml 内容输出多个结果文件。
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 TestTransformation {
public static void main(String[] args) throws TransformerException {
System.setProperty("javax.xml.transform.TransformerFactory","net.sf.saxon.TransformerFactoryImpl");
TransformerFactory tFactory = TransformerFactory.newInstance();
Source xslt = new StreamSource(new File("transformer.xslt"));
Transformer transformer = tFactory.newTransformer(xslt);
Source xmlText = new StreamSource(new File("data.xml"));
transformer.transform(xmlText, new StreamResult(new File("output.xml")));
但我希望转换产生多个输出文件..任何想法将不胜感激!!
最佳答案
i want the transform to produce multiple output files.
您可以在 XSLT 样式表本身中执行此操作:http://www.w3.org/TR/xslt20/#result-trees
假设您确实使用 XSLT 2.0 处理器。在 XSLT 1.0 中,您可以使用 EXSLT 扩展:http://exslt.org/exsl/elements/document/index.html相反 - 只要您的处理器支持它。
关于java - 在 Java 中使用 Transformer 实现 XSLT 的多个输出?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30562483/