楼上,我查了一下JDK文档,org.w3c.dom里没有关于Namespace设置的,能否说明一下如何指定Namespace
解决方案 »
- 关于hibernate 查询 日期
- 求web service 高手指点指点!
- 关于Struts2无法直接访问action的问题
- oc4j报错 (NOTIFICATION J2EE JSP0008 Unable to dispatch JSP Page : 异常错误)
- 问4个struts的问题
- 100分求解在tomcat上成功发布的structs工程在weblogic上部署失败啊!
- javascript的问题.请各位帮忙.
- java了,最好学习什么数据库呢?
- Weblogic中的连接池满了,怎么办阿?
- weblogic引用EJB的问题
- org.apache.jasper.JasperException: /showperson.jsp(53,77) Unterminated <bean:write tag
- 求助
现在的问题是jdom只能设置一个Namespace,如何象上面那样设置多个
Document document = new Document(new Element("电子公文" , "http//www.egs.org.cn/eGovDoc")); //创建文档ROOT元素
Element docElement = new Element("公文体","http://www.egs.org.cn/eGovDoc/body");
你查一下Element类的这个方法addNamespaceDeclaration(Namespace additional),它好象可以添加多个Namespace
1.xmlns="...":xml命名空间(xmlnamespace)...是一个唯一的url
2.xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlschema的命名空间url地址
xsi是前缀。
3.xsi:schemaLocation="...":xmlschema的url地址
Element root=new Element("mainifest");
Document doc=new Document(root);
root.setNamespace(Namespace.getNamespace("","http://www.open.net/main"));
NameSpace ns=Namespace.getNamespace("xsi","http://www.w3.org/2001/XMLSchema-instance");
root.addNamespaceDeclaration(ns);
root.addAttribute(new Attribute("schemaLocation","http://www.open.net/main http://schemas.open.net/sys.xsd",ns));//第3个是属性,使用上面声明的NameSpace