Support Requests item #1012187, was opened at 2004-08-19 15:39
Message generated for change (Comment added) made by polx
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=216035&aid=1012187&group_id=16035

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Priority: 5
Submitted By: Larry Cryderman (lcryderm)
Assigned to: Maarten Coene (maartenc)
Summary: DOM4J reading local file DTD

Initial Comment:
My inbound XML documents reference a file dtd such 
as '<!DOCTYPE Foo SYSTEM "Foo.dtd">....I can't obtain 
a Document object from the SAXReader because it can't 
resolve the URI. I've tried using an EntityResolver, but 
it's never even referenced. Help plz!

----------------------------------------------------------------------

Comment By: Paul Libbrecht (polx)
Date: 2006-06-19 23:16

Message:
Logged In: YES 
user_id=647450

have you try using new SAXReader().read(file.toURL()) ?
I suspect this would solve your issues.
paul

----------------------------------------------------------------------

Comment By: Maarten Coene (maartenc)
Date: 2004-08-22 14:40

Message:
Logged In: YES 
user_id=178745

Hi Larry,

1. The reason the SAXReader can't resolve the URI is that 
you didn't specify a systemID in your InputSource. If you use 
dom4j, you don't have to create the InputSource yourself, 
but you can use one of these methods below which create 
the InputSource for you:

org.dom4j.io.SAXReader.read(File)
org.dom4j.io.SAXReader.read(InputStream, String)
org.dom4j.io.SAXReader.read(Reader, String)
org.dom4j.io.SAXReader.read(URL)

Please use one of these methods for creating your Document. 
If you use the read(File) or read(URL) method, the DTD has 
to be located in the same directory as your XML document. If 
you use the other methods, you'll have to provide the 
systemID yourself.

2. The reason that your EntityResolver is not used is hard to 
say if you don't provide your source code. However, some 
SAX Parser don't use the EntityResolver in some situations, 
even if you have specified one. Perhaps you can try to use 
the Xerces XML parser, which is behaving correctly in this 
situation. You can do this like this:
org.dom4j.io.SAXReader reader = new org.dom4j.io.SAXReader
("org.apache.xerces.parsers.SAXParser");

Did this solve your problems?

regards,
Maarten

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=216035&aid=1012187&group_id=16035


_______________________________________________
dom4j-dev mailing list
dom4j-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dom4j-dev

Reply via email to