Class XercesParser
- java.lang.Object
-
- org.apache.commons.digester.parser.XercesParser
-
public class XercesParser extends java.lang.ObjectCreate aSAXParserbased 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
Fields Modifier and Type Field Description protected static java.lang.StringJAXP_SCHEMA_LANGUAGEThe JAXP 1.2 property to set up the schemaLanguage used.private static java.lang.StringJAXP_SCHEMA_SOURCEThe JAXP 1.2 property required to set up the schema location.protected static LoglogThe Log to which all SAX event related logging calls will be made.protected static floatversionAfloatrepresenting the underlying Xerces versionprotected static java.lang.StringversionNumberThe current Xerces version.protected static java.lang.StringXERCES_DYNAMICXerces dynamic validation propertyprotected static java.lang.StringXERCES_SCHEMAXerces schema validation property
-
Constructor Summary
Constructors Constructor Description XercesParser()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static voidconfigureOldXerces(javax.xml.parsers.SAXParser parser, java.util.Properties properties)Configure schema validation as recommended by the JAXP 1.2 spec.private static voidconfigureXerces(javax.xml.parsers.SAXParserFactory factory)Configure schema validation as recommended by the Xerces spec.private static java.lang.StringgetXercesVersion()Return the current Xerces version.static javax.xml.parsers.SAXParsernewSAXParser(java.util.Properties properties)Create aSAXParserbased on the underlyingXercesversion.
-
-
-
Field Detail
-
log
protected static Log log
The Log to which all SAX event related logging calls will be made.
-
JAXP_SCHEMA_SOURCE
private static final java.lang.String JAXP_SCHEMA_SOURCE
The JAXP 1.2 property required to set up the schema location.- See Also:
- Constant Field Values
-
JAXP_SCHEMA_LANGUAGE
protected static java.lang.String JAXP_SCHEMA_LANGUAGE
The JAXP 1.2 property to set up the schemaLanguage used.
-
XERCES_DYNAMIC
protected static java.lang.String XERCES_DYNAMIC
Xerces dynamic validation property
-
XERCES_SCHEMA
protected static java.lang.String XERCES_SCHEMA
Xerces schema validation property
-
version
protected static float version
Afloatrepresenting the underlying Xerces version
-
versionNumber
protected static java.lang.String versionNumber
The current Xerces version.
-
-
Method Detail
-
getXercesVersion
private static java.lang.String getXercesVersion()
Return the current Xerces version.- Returns:
- the current Xerces version.
-
newSAXParser
public static javax.xml.parsers.SAXParser newSAXParser(java.util.Properties properties) throws javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException, org.xml.sax.SAXNotSupportedExceptionCreate aSAXParserbased on the underlyingXercesversion.- Parameters:
properties- parser specific properties/features- Returns:
- an XML Schema/DTD enabled
SAXParser - Throws:
javax.xml.parsers.ParserConfigurationExceptionorg.xml.sax.SAXExceptionorg.xml.sax.SAXNotSupportedException
-
configureOldXerces
private static void configureOldXerces(javax.xml.parsers.SAXParser parser, java.util.Properties properties) throws javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXNotSupportedExceptionConfigure schema validation as recommended by the JAXP 1.2 spec. Thepropertiesobject may contains information about the schema local and language.- Parameters:
properties- parser optional info- Throws:
javax.xml.parsers.ParserConfigurationExceptionorg.xml.sax.SAXNotSupportedException
-
configureXerces
private static void configureXerces(javax.xml.parsers.SAXParserFactory factory) throws javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXNotRecognizedException, org.xml.sax.SAXNotSupportedExceptionConfigure 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- Throws:
javax.xml.parsers.ParserConfigurationExceptionorg.xml.sax.SAXNotRecognizedExceptionorg.xml.sax.SAXNotSupportedException
-
-