DocumentBuilderFactory dbf =
DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
dbf.setValidating(true);
if (useSchema)
dbf.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaLanguage",
"http://www.w3.org/2001/XMLSchema");
DocumentBuilder db = dbf.newDocumentBuilder();
DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
dbf.setValidating(true);
if (useSchema)
dbf.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaLanguage",
"http://www.w3.org/2001/XMLSchema");
DocumentBuilder db = dbf.newDocumentBuilder();
解决方案 »
- [toString() 不可用 - 无任何暂挂线程]
- j2se重要吗?
- 怎样得到某年有多少天?
- 基本数据结构的问题
- 为什么在我的java 帮助文件(doc目录下)中找不到像setMnemonic(),getContentPane()之类的方法.
- ?关于JComponent.repaint(Graphics g,int x,int y,int width,int height) 与 paintComponent()
- List列表组件的问题
- java图形界面!!!
- jb中编译EJB出现提示:""TestSesMod.ejbgrpx": Spaces in the temporary directory path may cause WebLogic EJBC utility to produce fat
- TopoSearch.java
- 菜鸟入门书籍推荐, 各位龙虾请伸出友爱的钳子吧!!
- 常量池是存取哪些数据的?
感谢你的回复
对xml进行schema的验证,通常有2种方法指定schema,一是在xml文档中指定,如同我的问题里面写的。另外是在程序里面通过setAttribute指定,如同你回复的一样。可是两种方法我都没搞定。当通过setAttribute来指定schema和schemalanguage之类的属性时,总提示no attributes are implemented at org.apache.crimson.jaxp.DocumentBuilderFactoryImp.setAttribute(Unknow Source).
你有没有示例代码贴出来看看?多谢多谢
谢谢楼上诸位兄台.
原因是我在j2sdk1.4.2的环境下,jaxp的版本过低
需要较新的jaxp 库
两种指定schema的方法都可以运行通过
怪自己看的不够仔细
结贴,接分