• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

How to make setFeature work?

 
Ranch Hand
Posts: 1953
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

or

Both does not throw SAXException even I parsed an invalid xml file (well formed).
However, if I use JDOM, JDOMException will be caught.
The URI http://xml.org/sax/features/validation actually does not exist, could that be the reason for failing validation?
If it is, then what is the new working one?
If it is not, why it does not work? It is all over the internet, and I saw other people's complain on it too.
Please Help!
Thanks in advance!
Roseanne
[This message has been edited by Roseanne Zhang (edited August 16, 2001).]
 
Roseanne Zhang
Ranch Hand
Posts: 1953
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The strange thing is JDOM using the same statement inside their code:
parser.setFeature("http://xml.org/sax/features/validation", true);
and it works! Why? I saw the same question posted on Apache and JGuru, no answer yet.
If you made this work, please help!!!
Thanks!
Roseanne
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In JAXP anyway, it looks to me like you have to set the feature on the SAXParserFactory before you get the parser or the parser you get is not guaranteed to support the feature.
The URI is just there as a String constant, not a real resource.
Bill
 
Roseanne Zhang
Ranch Hand
Posts: 1953
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bill!
If I turn it on at the factory level, it works always. But it is hard to do that.
All I need is a concrete class which implements ErrorHandler. If you fake it by using DefaultHandler, it will not work, even DefaultHandler implements ErrorHandler.
Problem solved. See http://www-106.ibm.com/developerworks/xml/library/x-tipeh.html
Roseanne
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!