The error message is pretty accurate- since you're not loading your doc from a URL, there is no base URL to derive the relative URL of your DTD. What does file.getContents() do? If it is just loading the contents of the file from disk into a string or something, you'd be better off just passing a URL to the sax reader. Otherwise I believe you are able to set a base URL on the sax reader for entity resolution, you might give that a shot.

Samuel Cheung wrote:

Hi,

I have the follow code to parse a file, and my file reference an external DTD ../style/modulesynopsis.dtd like this:

<?xml version="1.0"?>
<!DOCTYPE modulesynopsis SYSTEM "../style/modulesynopsis.dtd">
....

but I got an Nested exception: org.xml.sax.SAXParseException: Relative URI "../style/modulesynopsis.dtd"; can not be resolved without a base URI.

Could some one please tell me what did I miss?
And How can I switch to use xerces instead of crimson parser?

Thanks for any help


<<<<<<< My code >>>>>>>>>>>>


SAXReader reader = new SAXReader( DOMDocumentFactory.getInstance() );
try {
Document document = reader.read( file.getContents() );
} catch (Exception e) {
}


<< complete Exception >>>
Nested exception: org.xml.sax.SAXParseException: Relative URI "../style/modulesynopsis.dtd"; can not be resolved without a base URI.


at org.apache.crimson.parser.Parser2.fatal(Parser2.java:3182)
at org.apache.crimson.parser.Parser2.fatal(Parser2.java:3176)
at org.apache.crimson.parser.Parser2.resolveURI(Parser2.java:2758)
at org.apache.crimson.parser.Parser2.maybeExternalID(Parser2.java:2730)
at org.apache.crimson.parser.Parser2.maybeDoctypeDecl(Parser2.java:1129)
at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:489)
at org.apache.crimson.parser.Parser2.parse(Parser2.java:305)
at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:442)
at org.dom4j.io.SAXReader.read(SAXReader.java:323)
at org.dom4j.io.SAXReader.read(SAXReader.java:24






-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
dom4j-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-user

Reply via email to