重起TOMCAT就出现上述提示。
可能是TOMCAT配置问题,不知道DOM解析要做那些配置?

解决方案 »

  1.   

    执行builder.parse时捕获的异常是:“unknown protocol: c”
    Tomcat提示:
    ParserUtils: warning org.xml.sax.SAXParseException: URI was not reported to parser for entity [document]
    ParserUtils: warning org.xml.sax.SAXParseException: No base URI; hope URI is absolute: http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd
    ParserUtils: warning org.xml.sax.SAXParseException: No base URI; hope this SYSTEM id is absolute: http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd
    ParserUtils: warning org.xml.sax.SAXParseException: URI was not reported to parser
      

  2.   

    把http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd下载到本地,和你的读取xml的类同目录。builder.setEntityResolver(new EntityResolver() {
    public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
    InputStream in=${YourClass}.class.getResourceAsStream("web-jsptaglibrary_1_1.dtd");
    return new InputSource(in);
    }
    });把${YourClass}换成你自己的类。
      

  3.   

    可能是解析XML的JAR版本问题。
    我看了一下
    Project中有两个解析XML的JAR:
    1、
    J2EE 1.4 Library Container
      xml-apis.jar 
    2、
    WEB-INF\lib\xmlParserAPIs.jar我要使用的是xmlParserAPIs.jar
    如何在Eclipse中去掉
    J2EE 1.4 Library Container的
      xml-apis.jar ?
      

  4.   

    to Saro(这也不是江水,这是二十年流不尽的英雄血。) ( ) 
    ${YourClass}指什么啊?我用的就是下面几句话,没别的类啊 DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = null;
    try {
    builder = factory.newDocumentBuilder();
    Document doc = builder.parse(mpath);
      

  5.   

    主要是你的xml文件定义了DOCTYPE头,所以必须解析dtd。public class MyParser {
    public void parse(){
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = null;
    try {
    builder = factory.newDocumentBuilder();builder.setEntityResolver(new EntityResolver() {
    public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
    InputStream in=MyParser.class.getResourceAsStream("web-jsptaglibrary_1_1.dtd");
    return new InputSource(in);
    }
    });Document doc = builder.parse(mpath);}catch(Exception e){
    }
    }
    }
    把web-jsptaglibrary_1_1.dtd和类MyParser放同一个目录。
      

  6.   

    改你的tomcat的server.xml就可以了
      

  7.   

    TO:Saro(这也不是江水,这是二十年流不尽的英雄血。) 
    ==================================================
    多谢。Project中有多个解析XML的JAR:
    1、
    J2EE 1.4 Library Container
      xml-apis.jar 
    2、
    WEB-INF\lib\xmlParserAPIs.jar
    3、
    WEB-INF\lib\gnujaxp.jar均包含我要导入的包:
    import javax.xml.parsers.*;TOMCAT5。0,server.xml中有如下说明:
     <!-- Define the default virtual host
               Note: XML Schema validation will not work with Xerces 2.2.
    可能是版本冲突或不兼容,换做WEBLOGIC就没问题了。
    你的方法我下次再试。
    TO:
    xueqier() ( ) 信誉:100  2006-04-05 11:38:00  得分: 0  
     
     
       改你的tomcat的server.xml就可以了
    ======================================
    如何修改?  
     =============================
    另:
    昨天我试了一下,
    Document doc = builder.parse(mpath);//String mpath;
    将mpath改为file类型对象,读XML时不出错了。
    不过读到某节点时,NodeList childtypes = elementtype.getElementsByTagName("s:AttributeType");

    if (null != childtypes.item(i)) {
    childtypes.item(i)。XXX执行 if (null != childtypes.item(i)) {
    后,进入 childtypes.item(i)。XXX 句时,
    用Eclipse的CTRL+SHIF+I看到该对象(childtypes.item(i))值为NULL。
    不知道是不是XML文件调试的问题?