• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

XML Parsing error

 
Anuranjan Arya
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI

I want to parse XML file
if XML file contains DTD tag then it is unable to parse the file
And of it does not contain any DTD them my prgram is easily able to parse the XML file.

Can any 1 tell me how can I resolve this problem?



if XML file contains DTD then my program throws Exception at Line 11
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13064
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I will never understand why people say "throws Exception" and then leave out the actual exception. My crystal ball is in the shop for the 10,000 vision checkup so I cant read your screen. The whole idea of Java exceptions is to communicate as much as possible what went wrong.

 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

My ESPN is out.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13064
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wow, that even looks like me - except I need to get a hat like that!
 
Anuranjan Arya
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Following exception is being thrwon
 
Rob Spoor
Sheriff
Pie
Posts: 20546
57
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check your Internet connection. Your system cannot find the IP address for www.jboss.org. If in doubt, contact your system administrator or ISP.
 
Anuranjan Arya
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is there any way i can skip this DTD validation during parsing
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That probably depends on the parser--but you shouldn't *want* to skip it, it's important. Are you sure it's the correct DTD? Do you have a local library with the DTD in it?
 
Anuranjan Arya
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is the problem I dont have the DTD in my local system and url from i can download the DTD is not working.
That is why i just want to skip the DTD validation.

Actually I am writing a program which parses a JBoss Server login-config.xml file installed on any platform.
So it possible that the server may not be connected to Internet or may not have the DTD locally, at that time when I try to parse the XML file then i am getting the above exception.
 
Rob Spoor
Sheriff
Pie
Posts: 20546
57
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you already tried calling DocumentBuilderFactory's setValidating(boolean) method?
 
Anuranjan Arya
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried it doesnt work
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13064
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One outrageous hack would be to write a custom java.io.InputStream extension which just removes the DTD reference before the parser sees it.

The beauty of Java IO is the ease with which you can do this sort of thing.


Bill
 
Paul Clapham
Sheriff
Posts: 21119
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anuranjan Arya wrote:That is the problem I dont have the DTD in my local system and url from i can download the DTD is not working.
That is why i just want to skip the DTD validation.

Actually I am writing a program which parses a JBoss Server login-config.xml file installed on any platform.
So it possible that the server may not be connected to Internet or may not have the DTD locally, at that time when I try to parse the XML file then i am getting the above exception.


You seem to have forgotten that a DTD is not only for validation. A DTD can specify entities which may then be used in the document, and it has some other features as well.

I would say your best approach would be to attach an EntityResolver to your parser, and have it return an InputSource containing a local copy of the DTD.
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually I am writing a program which parses a JBoss Server login-config.xml file installed on any platform.


That is why i just want to skip the DTD validation.


If you are "not" parsing the XML file with its DTD, what are you trying to do? You can't parse without the DTD. You can open the file and read it, but to programatically understand as an XML file, you need the DTD.
 
Anuranjan Arya
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am parsing the xml with document builder and later i am getting its content with the help of nodes and child nodes.
And I am successfully able to do that.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13064
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Presumably, JBoss servers use that DTD to ensure against configuration errors, so just parsing to a DOM is not sufficient to ensure no errors.

Where do JBoss servers get a copy of that DTD?

A google search for "jboss dtd login config xml" turned up hits dated 2004-2005

Is this even the current JBoss usage?

Bill
 
Paul Clapham
Sheriff
Posts: 21119
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
William Brogden wrote:Where do JBoss servers get a copy of that DTD?


I can't speak for JBoss, but I was just reading the Hibernate documentation the other day. Hibernate XML config documents also use a DTD; Hibernate keeps a copy of that DTD in its jar and uses an EntityResolver to resolve references to it. This avoids the hassle of having to go out to an external site to get it and possibly failing to get it.

I wouldn't be surprised to find that JBoss does the same thing. It's a perfectly sensible thing to do and that's why I suggested it in my post a couple of days ago.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic