• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Ignoring DOCTYPE tag in java

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!, while parsing an xml file, I am getting error that it is not able to resolve a url
(eg: <!DOCTYPE RootElement SYSTEM "http://www.mywebsite.com:80/dtds/testdtd_200609.dtd">. When I googled, there were suggestions that I need to use EntityResolver. But it is not working. Here is the code that I have. Ant help is greatly appreciated.

Regards


DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
docBuilder.setEntityResolver(new EntityResolver() {
public InputSource resolveEntity(java.lang.String publicId,
java.lang.String systemId)
throws SAXException, java.io.IOException {
if (publicId.equals("--myDTDpublicID-"))
return new InputSource(new ByteArrayInputStream
("<?xml version='1.0' encoding='UTF-8'?>".getBytes()));
else return null;
}
});
 
Marshal
Posts: 28226
95
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
Is your EntityResolver being called? If so, what's the value of the publicId and systemId variables?
 
Paul Clapham
Marshal
Posts: 28226
95
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
Reddy Anoop, sending me a PM is not the right way to reply here. Scroll down and you will see the "Post Reply" button.
 
I have a knack for fixing things like this ... um ... sorry ... here is a consilitory tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic