我用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());
}
...全文
53 1 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
leolee 2001-09-03
  • 打赏
  • 举报
回复
难道就没有人知道吗?
太惨点了

81,122

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧