草草晴空

Simple Coder

Simple JAXP

/*
Created on 2005–9-5
**/
package hp.alex.jaxp;

/**
@author wanbin
*/
import java.io.File;

import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
/**
A simple demo of JAXP 1.1
*/
public class SimpleJAXP {
/**
Accept two command line arguments: the name of an XML file, and the name
of an XSLT stylesheet. The result of the transformation is written to stdout.
*/
public static void main(String[] args) throws TransformerException {
if (args.length != 2) {
System.err.println(“Usage:“);
System.err.println(“ java “ + SimpleJAXP.class.getName()
+ “ xmlFileName xsltFileName“);
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);
Result result = new StreamResult(new File(“result.html”));
// create an instance of TransformerFactory
TransformerFactory transFact = TransformerFactory.newInstance();
Transformer trans = transFact.newTransformer(xsltSource);
trans.transform(xmlSource, result);
}

}

 
阅读更多
个人分类: XML
上一篇excel macro(1)
想对作者说点什么? 我来说一句

jaxp的四个jar包

2010年05月05日 1.15MB 下载

没有更多推荐了,返回首页

关闭
关闭