transform.java

来自「JAVA案例开发集锦源代码 袁然 郑自国编」· Java 代码 · 共 31 行

JAVA
31
字号
import javax.xml.transform.Source;import javax.xml.transform.Transformer;import javax.xml.transform.TransformerFactory;import javax.xml.transform.stream.StreamSource;import javax.xml.transform.stream.StreamResult;import java.io.*;public class Transform {    //转换XSLT文件到标准输出    public static void main(String[] args) throws Exception {        if (args.length != 2) {            System.err.println(                "Usage: java Transform [xmlfile] [xsltfile]");            System.exit(1);        }        File xmlFile = new File(args[0]);        File xsltFile = new File(args[1]);        Source xmlSource = new StreamSource(xmlFile);        Source xsltSource = new StreamSource(xsltFile);        TransformerFactory transFact =                TransformerFactory.newInstance();        Transformer trans = transFact.newTransformer(xsltSource);        trans.transform(xmlSource, new StreamResult(System.out));    }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?