This looks like you are just passing an inappropriate value for "filePath". The javadoc for SaxReader.read(String) says:

"If the systemId contains a ':' character then it is assumed to be a URL otherwise its assumed to be a file name. If you want finer grained control over this mechansim then please explicitly pass in either a URL or a File instance instead of a String to denote the source of the document."

Now, this sounds like it'll only try to create a URL object if there's a ":" in the String passed in and it doesn't look like you have a ":" in your filePath, based on the first stacktrace. I'm not sure why you would have a problem with that. However, to get things working quickly, you can try adding a "file://" protocol to the value of filePath. You can also use one of the several other read methods, taking File, InputStream, etc. I usually do "myReader.read(new File(filePath))".

b


Shark Wang wrote:
Dears ,

    I use dom4j-1.5.2 and meet the "no protocol" errors ! pls help me,
thanks a lot !!!

    I had two files, biz.xml and biz.dtd, and I used the following
code the load
    the DOM content:

   1) Java code
    ------------------------------------------------------------
    SAXReader reader = new SAXReader();
    //try to load xml data into Document object
    Document doc = null;
    try {
      doc = reader.read(filePath);
    }catch (DocumentException ex) {
      logger.info("Can not load " + filePath);
      logger.debug(ex.getMessage(), ex);
    }
    //return Document object
    return doc;
    ---------------------------------------------------------------

    2) top lines in my biz.xml
    ---------------------------------------------------------------
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE managers SYSTEM "biz.dtd">

   3) the errors and exceptions throws from oc4j on UNIX
   ----------------------------------------------------------------
   org.dom4j.DocumentException: no protocol:
org.dom4j.DocumentException: no protocol:
/u01/oc4j/j2ee/home/applications/Biz/WEB-INF/biz.xml Nested except
ion: no protocol: /u01/oc4j/j2ee/home/applications/Biz/WEB-INF/biz.xml
        at org.dom4j.io.SAXReader.read(SAXReader.java:353)
        at org.dom4j.io.SAXReader.read(SAXReader.java:254)

  ... ... ....

  Nested exception:
java.net.MalformedURLException: no protocol:
/u01/oc4j/j2ee/home/applications/Biz/WEB-INF/biz.xml
        at java.net.URL.<init>(URL.java:537)
        at java.net.URL.<init>(URL.java:434)
        at java.net.URL.<init>(URL.java:383)
        at oracle.xml.parser.v2.XMLReader.pushXMLReader(XMLReader.java:205)
        at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:148)
        at org.dom4j.io.SAXReader.read(SAXReader.java:334)
        at org.dom4j.io.SAXReader.read(SAXReader.java:254)


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_idt77&alloc_id492&op=click
_______________________________________________
dom4j-user mailing list
dom4j-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dom4j-user


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
dom4j-user mailing list
dom4j-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dom4j-user

Reply via email to