刚才简单的看了下JDOM的文档,好像不支持schema校验,不过对xsl倒是支持的不错!
gz
gz
解决方案 »
- 一个关于算法的问题(都进来帮我解决下)
- 大家帮我看看这程序
- 关于hibernate 的session和缓存问题。
- 禁止JS弹出新页面
- 只剩30分了..关于JSTL急需高手帮助...
- ssh2项目下类的命名问题
- 要调用dephi写好的web service,不知道如何调用,有什么好的教程介绍一下?
- 大家一起来讨论关于shark和jawe开发工作流(公文审批)!
- 初级问题
- HTTP Status 500 - An exception occurred processing JSP page /WEB-INF/include/tag
- 找北京地区JSP,java程序员,5000元/月
- 如何把一个CMP对应表的纪录装入内存?
import org.jdom.input.*;
import org.jdom.output.*;
import java.io.*;public class TestXml {
public TestXml() {
} public void save(){
try {
Element element = new Element("all-item");
Comment comment = new Comment("asdAsdasdasd");
Document doc = new Document(null);
ProcessingInstruction pi = new ProcessingInstruction
("xml-stylesheet", "href=\"bookList.html.xsl\" type=\"text/xsl\"");
doc.addContent(pi);
doc.setRootElement(element);
Element childItem = new Element("item");
Element itemChildTopic = new Element("topic");
Element itemChildContent = new Element("content");
childItem.addContent(itemChildTopic);
childItem.addContent(itemChildContent);
element.addContent(childItem);
OutputStream out = new FileOutputStream("d:/asdfgh.xml");
XMLOutputter outp = new XMLOutputter("", true, "GBK");
outp.output(doc, out);
out.close();
} catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
TestXml testXml = new TestXml();
testXml.save();
}}
web.xml里面的这句话 是用来验证文档的 具体什么意思自己查查看吧
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">