org.apache.commons.digester.parser

Class XercesParser


public class XercesParser
extends java.lang.Object

Create a SAXParser based on the underlying Xerces version. Currently, Xerces 2.3 and up doesn't implement schema validation the same way 2.1 was. In other to support schema validation in a portable way between parser, some features/properties need to be set.
Since:
1.6

Field Summary

protected static String
JAXP_SCHEMA_LANGUAGE
The JAXP 1.2 property to set up the schemaLanguage used.
private static String
JAXP_SCHEMA_SOURCE
The JAXP 1.2 property required to set up the schema location.
protected static String
XERCES_DYNAMIC
Xerces dynamic validation property
protected static String
XERCES_SCHEMA
Xerces schema validation property
protected static Log
log
The Log to which all SAX event related logging calls will be made.
protected static float
version
A float representing the underlying Xerces version
protected static String
versionNumber
The current Xerces version.

Method Summary

private static void
configureOldXerces(SAXParser parser, Properties properties)
Configure schema validation as recommended by the JAXP 1.2 spec.
private static void
configureXerces(SAXParserFactory factory)
Configure schema validation as recommended by the Xerces spec.
private static String
getXercesVersion()
Return the current Xerces version.
static SAXParser
newSAXParser(Properties properties)
Create a SAXParser based on the underlying Xerces version.

Field Details

JAXP_SCHEMA_LANGUAGE

protected static String JAXP_SCHEMA_LANGUAGE
The JAXP 1.2 property to set up the schemaLanguage used.

JAXP_SCHEMA_SOURCE

private static final String JAXP_SCHEMA_SOURCE
The JAXP 1.2 property required to set up the schema location.

XERCES_DYNAMIC

protected static String XERCES_DYNAMIC
Xerces dynamic validation property

XERCES_SCHEMA

protected static String XERCES_SCHEMA
Xerces schema validation property

log

protected static Log log
The Log to which all SAX event related logging calls will be made.

version

protected static float version
A float representing the underlying Xerces version

versionNumber

protected static String versionNumber
The current Xerces version.

Method Details

configureOldXerces

private static void configureOldXerces(SAXParser parser,
                                       Properties properties)
            throws ParserConfigurationException,
                   SAXNotSupportedException
Configure schema validation as recommended by the JAXP 1.2 spec. The properties object may contains information about the schema local and language.
Parameters:
properties - parser optional info

configureXerces

private static void configureXerces(SAXParserFactory factory)
            throws ParserConfigurationException,
                   SAXNotRecognizedException,
                   SAXNotSupportedException
Configure schema validation as recommended by the Xerces spec. Both DTD and Schema validation will be enabled simultaneously.

NOTE: This method is broken. It is supposed to set up validation against the schema specified in property "schemaLocation", but it doesn't.

Parameters:
factory - SAXParserFactory to be configured

getXercesVersion

private static String getXercesVersion()
Return the current Xerces version.
Returns:
the current Xerces version.

newSAXParser

public static SAXParser newSAXParser(Properties properties)
            throws ParserConfigurationException,
                   SAXException,
                   SAXNotSupportedException
Create a SAXParser based on the underlying Xerces version.
Parameters:
properties - parser specific properties/features
Returns:
an XML Schema/DTD enabled SAXParser

Copyright 2001-2005 The Apache Software Foundation.