commons-digester 使用规则文件时解析错误问题

03-12-03 mcindo

我使用的commons-digester解析xml文件,配置文件时一个,规则文件(也就是匹配规则)是另一个,使用

URL rulesURL = getClass().getClassLoader().getResource("com/xx/web/util/xml/project-rule.xml");
Digester digester = DigesterLoader.createDigester(rulesURL);
<p>

加载规则文件时提示

11:16:31,637 ERROR [STDERR] java.net.MalformedURLException
11:16:31,637 ERROR [STDERR]     at java.net.URL.<init>(URL.java:571)
11:16:31,637 ERROR [STDERR]     at java.net.URL.<init>(URL.java:434)
11:16:31,637 ERROR [STDERR]     at java.net.URL.<init>(URL.java:383)
11:16:31,647 ERROR [STDERR]     at org.apache.xerces.impl.XMLEntityManager.start
Entity(XMLEntityManager.java:740)
11:16:31,647 ERROR [STDERR]     at org.apache.xerces.impl.XMLEntityManager.start
DocumentEntity(XMLEntityManager.java:685)
11:16:31,647 ERROR [STDERR]     at org.apache.xerces.impl.XMLDocumentScannerImpl
.setInputSource(XMLDocumentScannerImpl.java:252)
11:16:31,647 ERROR [STDERR]     at org.apache.xerces.parsers.StandardParserConfi
guration.parse(StandardParserConfiguration.java:503)
<p>

URL不对? 我将他读dtd的url,和我自己的url都打出来了,一样的.为什么我加载时会报这个错呢?

下面是打出来的路径:

11:16:31,297 INFO  [STDOUT] ruleURL:jar:file:/D:/jboss3.2.1-tomcat4.1.24/server/
default/tmp/deploy/server/default/deploy/yjjy.ear/52.yjjy.ear-contents/so.jar!/c
om/xx/web/util/xml/project-rule.xml
11:16:31,507 INFO  [STDOUT] dtdUrl:jar:file:/D:/jboss3.2.1-tomcat4.1.24/server/default/tmp/deploy/server/default/deploy/jbossweb-tomcat.sar/commons-digester.jar/22.commons-digester.jar!/org/apache/commons/digester/xmlrules/digester-rules.dtd
<p>

shui 什么原因???

mcindo
2003-12-03 12:58

给点建议也行呀

mcindo
2003-12-05 12:12

看来只能把rule写在代码中了!