• 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
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

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;
}
});
 
Sheriff
Posts: 28413
102
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
Sheriff
Posts: 28413
102
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic