⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 transform.java

📁 dom4j与Transform配合操作XML文档,并调用Xslt进行格式化的例子
💻 JAVA
字号:
package com.zhujiayun.test;
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 { 
  /**
   * Performs an XSLT transformation, sending the results
   * to System.out.
   */
  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("E:\\\\xslt test\\\\page.xml");
    File xsltFile = new File("E:\\\\xslt test\\\\pagination.xsl");     // JAXP reads data using the Source interface
    Source xmlSource = new StreamSource(xmlFile);
    Source xsltSource = new StreamSource(xsltFile);
    // the factory pattern supports different XSLT processors
    TransformerFactory transFact = TransformerFactory.newInstance();
    Transformer trans = transFact.newTransformer(xsltSource);
    trans.transform(xmlSource, new StreamResult(System.out));
  }
}

⌨️ 快捷键说明

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