• 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
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

URGENT - Setting feature for SAX Parser in Xerces.

 
Greenhorn
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.setContentHandler(checker);
parser.setErrorHandler(checker);
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/dynamic",true);
parser.setFeature( "http://apache.org/xml/features/validation/schema-full-checking", true);
--------------
PROBLEM AREA:
(1) First of all the following exception is thrown -
org.xml.sax.SAXNotRecognizedException: http://apache.org/xml/features/validation
/schema-full-checking
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.
Regards.
 
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
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
"http://xml.org/sax/features/validation",
"http://xml.org/sax/features/external-general-entities",
"http://xml.org/sax/features/external-parameter-entities",
"http://xml.org/sax/features/namespaces",
// Xerces
"http://apache.org/xml/features/validation/schema",
"http://apache.org/xml/features/validation/dynamic",
"http://apache.org/xml/features/validation/default-attribute-values",
"http://apache.org/xml/features/validation/validate-content-models",
"http://apache.org/xml/features/validation/validate-datatypes",
"http://apache.org/xml/features/validation/warn-on-duplicate-attdef",
"http://apache.org/xml/features/validation/warn-on-undeclared-elemdef",
"http://apache.org/xml/features/allow-java-encodings",
"http://apache.org/xml/features/continue-after-fatal-error",
"http://apache.org/xml/features/nonvalidating/load-dtd-grammar",
"http://apache.org/xml/features/nonvalidating/load-external-dtd"
};
------
I suggest you look at the source code for your version and see if the "schema-full-checking" type is there.
Bill

------------------
author of:
 
We don't have time to be charming! Quick, read this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic