• 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

Parsing an XML document with an incorrect DTD

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I need to parse an XML document which refers a DTD that further refers to other DTDs. The issue is that one of those second step DTDs is ill-formed, but I don't have the rights to change it. How can I force the SAX reader to read the XML, ignoring the DTD issues?
Will the SAXON parser also give issues while transforming this XML? If yes,then how can I avoid that?
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you tried the javax.xml.parsers.SAXParserFactory setValidating( false ) approach?

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

an XML document which refers a DTD that further refers to other DTDs



Please explain how a XML DTD refers to other DTDs.
 
Marshal
Posts: 28193
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
My approach would be to get the malformed DTD fixed. Just because you personally don't have the authority to make the change, doesn't mean it can't be done.

And there's no such thing as "the SAXON parser". Saxon just uses whatever XML parser the JVM is configured to use.
 
Archana Mehta Datta
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@William- Yes, I tried that, but despite setting it to false, it kept on validating the DTD.

@Paul- Thanks for the correction Correcting the DTD is just not an option for me, I am way down the hierarchy.
 
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How about creating a copy of the XML document with the original DTD reference removed or changed to point to a correct one?

Bill
 
Paul Clapham
Marshal
Posts: 28193
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

Archana Mehta Datta wrote: Correcting the DTD is just not an option for me, I am way down the hierarchy.



What you have to do is to say "That XML couldn't be parsed because the DTD is incorrect". Keep saying it until somebody figures out that the DTD is incorrect.
 
Archana Mehta Datta
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Paul, I ended up doing just that and the issue was finally resolved

 
Paul Clapham
Marshal
Posts: 28193
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
Thanks for letting us know, Archana. It's nice to know that sometimes people will do the right thing.
 
Stinging nettles are edible. But I really want to see you try to eat this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic