• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Trouble parsing a well-formed file with a defined entity reference

 
Ranch Hand
Posts: 436
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I'm using Java 6 and whatever the default XML parser that comes with that. Using htis code,



I'm parsing a well-formed document that begins with



but the parsing always dies with the following exception ...



I'm able to access the DTD URL in a web browser ("http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"). What else am I doing wrong? Thanks, - Dave
 
Sheriff
Posts: 28326
96
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The W3C has been refusing to serve that DTD for years now because it was disgusted by undisciplined applications (many written in Java) which didn't bother to cache it. Chances are that the error is occurring because of that.

So... where are you trying to get it from? Do you have an XML catalog configured, or something like that?
 
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The PUBLIC identifier of a DOCTYPE declaration is for informational purposes. I would removed the DOCTYPE declaration and confirm that the file is well-formed. You could used the XML parser of the Internet Explorer by simply navigating to the file. If the file is well-formed you will be able to view the markup and the contents. Or, you could parse the document using an XML parser such as XP.

XP - an XML Parser in Java
www.jclark.com/xml/xp/
 
Paul Clapham
Sheriff
Posts: 28326
96
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But removing the DOCTYPE would make any entities declared in that DTD (like   for example) become not well-formed, wouldn't it?
 
Dave Alvarado
Ranch Hand
Posts: 436
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Paul, I don't quite know how the parser works, but as far as I know, it is trying to get the DTD directly from the Internet, so your explanation about the W3C blocking access makes sense with what's happening. Is there a way to tell the parser to ignore resolving entities or some other work-around?

Jimmy, Using your suggestion, I confirmed that the document is well-formed. Would the parser you suggest overcome the problems that Paul mentioned? - Dave
 
Dave Alvarado
Ranch Hand
Posts: 436
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ah, I found out how to turn off DTD resolving, described here -- http://rubenlaguna.com/wp/2009/10/25/disable-dom-dtd-validation/index.html/ .

Now this problem is a laughable thing of the past, like RC Cola or the Simple Life. - Dave
 
Can you really tell me that we aren't dealing with suspicious baked goods? And then there is this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic