You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Steven Gollery <sg...@cadrc.calpoly.edu> on 2002/03/09 02:31:26 UTC

problems parsing file with DTD

(XercesJ 1.4.4)

When I try to read a file that is on my local machine and has a PUBLIC
DTD, I get a java.net.socket exception when I use the file path (eg,
D:\whatever.xml) or an unknown host exception when I use file://D/
whatever.xml.

The DTD declaration looks like this:

<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">

I've seen some solutions to similar problems, but they all involve
deriving a class from EntityResolver to handle a specific DTD that is
known in advance, and are usually presented as a way to deal with SYSTEM
dtds, not PUBLIC. Further, Batik has no problem dealing with this file:
it's only when I try to parse it using Xerces that I have problems. When
I remove the DOCTYPE declaration, Xerces can load it without
difficulties

I'm using sample code from the XercesJ 1.4.4. distribution to do these
tests. DOMCount.java, for instance.

What do I need to do in order to parse files with PUBLIC DOCTYPE
declarations?

Thanks in advance,

Steven Gollery



---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Re: problems parsing file with DTD

Posted by Steven Gollery <sg...@cadrc.calpoly.edu>.
I get the same result with Xerces 2.0.1, using the dom.Count example. Using
Crimson 1.1.3 (running the DOMEcho example) , I get different errors, but it
still doesn't work.

Can anyone point me to an example of using Xerces to parse a file containing
a DOCTYPE that references a PUBLIC DTD?

Thanks,

Steven Gollery


Steven Gollery wrote:

> (XercesJ 1.4.4)
>
> When I try to read a file that is on my local machine and has a PUBLIC
> DTD, I get a java.net.socket exception when I use the file path (eg,
> D:\whatever.xml) or an unknown host exception when I use file://D/
> whatever.xml.
>
> The DTD declaration looks like this:
>
> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"
> "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
>
> I've seen some solutions to similar problems, but they all involve
> deriving a class from EntityResolver to handle a specific DTD that is
> known in advance, and are usually presented as a way to deal with SYSTEM
> dtds, not PUBLIC. Further, Batik has no problem dealing with this file:
> it's only when I try to parse it using Xerces that I have problems. When
> I remove the DOCTYPE declaration, Xerces can load it without
> difficulties
>
> I'm using sample code from the XercesJ 1.4.4. distribution to do these
> tests. DOMCount.java, for instance.
>
> What do I need to do in order to parse files with PUBLIC DOCTYPE
> declarations?
>
> Thanks in advance,
>
> Steven Gollery
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-user-help@xml.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Re: problems parsing file with DTD

Posted by Steven Gollery <sg...@cadrc.calpoly.edu>.
Elena,

Yes, it turned out to be a firewall problem. Once I set up the code to go
through the proxy, everything started to work. I assumed it had to be
something that I was overlooking (because obviously this is a pretty basic
function for any XML parser), but it took me a while to think of it.

Thanks for the help,

Steven Gollery

Elena Litani wrote:

> Steven,
>
> Steven Gollery wrote:
> > When I try to read a file that is on my local machine and has a PUBLIC
> > DTD, I get a java.net.socket exception when I use the file path (eg,
> > D:\whatever.xml) or an unknown host exception when I use file://D/
> > whatever.xml.
> > The DTD declaration looks like this:
> > <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"
> > "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
> >
>
> Xerces behaves correctly. All it is trying to do is load svg10.dtd which
> is located on the web.
> You local machine does not have an access to the resources on the
> internet, thus you get socket or unknown host exceptions.
> --
> Elena Litani / IBM Toronto
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-user-help@xml.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Re: problems parsing file with DTD

Posted by Elena Litani <el...@ca.ibm.com>.
Steven,

Steven Gollery wrote:
> When I try to read a file that is on my local machine and has a PUBLIC
> DTD, I get a java.net.socket exception when I use the file path (eg,
> D:\whatever.xml) or an unknown host exception when I use file://D/
> whatever.xml. 
> The DTD declaration looks like this:
> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"
> "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
> 

Xerces behaves correctly. All it is trying to do is load svg10.dtd which
is located on the web. 
You local machine does not have an access to the resources on the
internet, thus you get socket or unknown host exceptions.
-- 
Elena Litani / IBM Toronto

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org