我用JDOM做XSLT转换,在resin的环境下运行servlet,为什么会出现异常!!(在main()里,是没有错误的类)

leolee 2001-08-31 06:40:47
public static void executeXSL(Document myDocument) {
try {
TransformerFactory tFactory = TransformerFactory.newInstance();
// Make the input sources for the XML and XSLT documents
org.jdom.output.DOMOutputter outputter = new org.jdom.output.DOMOutputter();
org.w3c.dom.Document domDocument = outputter.output(myDocument);
javax.xml.transform.Source xmlSource = new javax.xml.transform.dom.DOMSource(domDocument);
StreamSource xsltSource = new StreamSource(new FileInputStream("D:\\table.xsl"));

//Make the output result for the finished document
/*
* Note that here we are just going to output the results to the
* System.out, since we don't actually have a HTTPResponse object
* in this example
*/
//StreamResult xmlResult = new StreamResult(response.getOutputStream());
FileOutputStream fout=new FileOutputStream("D:\\c.html");
ByteArrayOutputStream byteArray=new ByteArrayOutputStream();
StreamResult xmlResult = new StreamResult(byteArray);//System.out
System.out.println("here");
//Get a XSLT transformer
Transformer transformer = tFactory.newTransformer(xsltSource);
//do the transform
/* transformer.transform(xmlSource, xmlResult);
byteArray.writeTo(fout);
fout.flush();
fout.close();
String str=new String(byteArray.toByteArray());
System.out.println("String Format:"+str);*/
}
catch(Exception ex){
System.out.println("Error in executeXSL"+ex);
}
}
public static Document readDocument() {
try {
SAXBuilder builder = new SAXBuilder();
Document anotherDocument = builder.build(new File("D:\\c.xml"));
return anotherDocument;
} catch(JDOMException e) {
System.out.println("readDoucment");
e.printStackTrace();
} catch(NullPointerException e) {
System.out.println("readDoucment");
e.printStackTrace();
}
return null;
}
public void init() throws ServletException {
executeXSL(readDocument());
}
...全文
26 点赞 收藏 1
写回复
1 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
leolee 2001-09-03
难道就没有人知道吗?
太惨点了
回复
相关推荐
发帖
Web 开发
创建于2007-09-28

8.0w+

社区成员

Java Web 开发
申请成为版主
帖子事件
创建了帖子
2001-08-31 06:40
社区公告
暂无公告