• 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 ...
  • Campbell Ritchie
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown

URGENT - Setting feature for SAX Parser in Xerces.

Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Friends,
I am writing an application in Java for parsing an XML document against a schema using Xerces 1.4.1. I am giving a snippet of my code in which I have set some features.
XMLReader parser = (XMLReader)Class.forName(PARSER_NAME).newInstance();
parser.setFeature( "http://xml.org/sax/features/validation", true);
parser.setFeature( "http://xml.org/sax/features/namespaces", true);
parser.setFeature( "http://apache.org/xml/features/validation/schema", true);
parser.setFeature( "http://apache.org/xml/features/validation/schema-full-checking", true);
(1) First of all the following exception is thrown -
org.xml.sax.SAXNotRecognizedException: http://apache.org/xml/features/validation
at org.apache.xerces.framework.XMLParser.setFeature(XMLParser.java:1169)
at org.apache.xerces.parsers.SAXParser.setFeature(SAXParser.java:573)
at SchemaChecker.main(SchemaChecker.java:57)
(2) When I commented the line
parser.setFeature( "http://apache.org/xml/features/validation/schema-full-checking", true);
It says that parsing has been done successfully. But it doesn't as I specifically made mistakes in the XML and the parser could not find that.
Please help me out for parsing XML against Schema using Xerces.
Hope to get an immediate response.
Author and all-around good cowpoke
Posts: 13078
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am looking at Xerces 1.3.1 - source code for XMLParser.java
in the org.apache.xerces.framework package. I find the following array of String:
/** Features recognized by this parser. */
private static final String RECOGNIZED_FEATURES[] = {
// SAX2 core
// Xerces
I suggest you look at the source code for your version and see if the "schema-full-checking" type is there.

author of:
money grubbing section goes here:
a bit of art, as a gift, that will fit in a stocking
    Bookmark Topic Watch Topic
  • New Topic