StandardParserConfigurationpublic class StandardParserConfiguration extends DTDConfiguration This is the "standard" parser configuration. It extends the DTD
configuration with the standard set of parser components.
The standard set of parser components include those needed
to parse and validate with DTD's, and those needed for XML
Schema.
In addition to the features and properties recognized by the base
parser configuration, this class recognizes these additional
features and properties:
- Features
- http://apache.org/xml/features/validation/schema
- http://apache.org/xml/features/validation/schema-full-checking
- http://apache.org/xml/features/validation/schema/normalized-value
- http://apache.org/xml/features/validation/schema/element-default
- Properties
- http://apache.org/xml/properties/internal/error-reporter
- http://apache.org/xml/properties/internal/entity-manager
- http://apache.org/xml/properties/internal/document-scanner
- http://apache.org/xml/properties/internal/dtd-scanner
- http://apache.org/xml/properties/internal/grammar-pool
- http://apache.org/xml/properties/internal/validator/dtd
- http://apache.org/xml/properties/internal/datatype-validator-factory
|
Fields Summary |
---|
protected static final String | NORMALIZE_DATAFeature identifier: expose schema normalized value | protected static final String | SCHEMA_ELEMENT_DEFAULTFeature identifier: send element default value via characters() | protected static final String | SCHEMA_AUGMENT_PSVIFeature identifier: augment PSVI | protected static final String | XMLSCHEMA_VALIDATIONfeature identifier: XML Schema validation | protected static final String | XMLSCHEMA_FULL_CHECKINGfeature identifier: XML Schema validation -- full checking | protected static final String | GENERATE_SYNTHETIC_ANNOTATIONSFeature: generate synthetic annotations | protected static final String | VALIDATE_ANNOTATIONSFeature identifier: validate annotations | protected static final String | HONOUR_ALL_SCHEMALOCATIONSFeature identifier: honour all schemaLocations | protected static final String | SCHEMA_VALIDATORProperty identifier: XML Schema validator. | protected static final String | SCHEMA_LOCATIONProperty identifier: schema location. | protected static final String | SCHEMA_NONS_LOCATIONProperty identifier: no namespace schema location. | protected XMLSchemaValidator | fSchemaValidatorXML Schema Validator. |
Constructors Summary |
---|
public StandardParserConfiguration()Default constructor.
//
// Constructors
//
this(null, null, null);
| public StandardParserConfiguration(SymbolTable symbolTable)Constructs a parser configuration using the specified symbol table.
this(symbolTable, null, null);
| public StandardParserConfiguration(SymbolTable symbolTable, XMLGrammarPool grammarPool)Constructs a parser configuration using the specified symbol table and
grammar pool.
REVISIT:
Grammar pool will be updated when the new validation engine is
implemented.
this(symbolTable, grammarPool, null);
| public StandardParserConfiguration(SymbolTable symbolTable, XMLGrammarPool grammarPool, XMLComponentManager parentSettings)Constructs a parser configuration using the specified symbol table,
grammar pool, and parent settings.
REVISIT:
Grammar pool will be updated when the new validation engine is
implemented.
super(symbolTable, grammarPool, parentSettings);
// add default recognized features
final String[] recognizedFeatures = {
NORMALIZE_DATA,
SCHEMA_ELEMENT_DEFAULT,
SCHEMA_AUGMENT_PSVI,
GENERATE_SYNTHETIC_ANNOTATIONS,
VALIDATE_ANNOTATIONS,
HONOUR_ALL_SCHEMALOCATIONS,
// NOTE: These shouldn't really be here but since the XML Schema
// validator is constructed dynamically, its recognized
// features might not have been set and it would cause a
// not-recognized exception to be thrown. -Ac
XMLSCHEMA_VALIDATION,
XMLSCHEMA_FULL_CHECKING,
};
addRecognizedFeatures(recognizedFeatures);
// set state for default features
setFeature(SCHEMA_ELEMENT_DEFAULT, true);
setFeature(NORMALIZE_DATA, true);
setFeature(SCHEMA_AUGMENT_PSVI, true);
setFeature(GENERATE_SYNTHETIC_ANNOTATIONS, false);
setFeature(VALIDATE_ANNOTATIONS, false);
setFeature(HONOUR_ALL_SCHEMALOCATIONS, false);
// add default recognized properties
final String[] recognizedProperties = {
// NOTE: These shouldn't really be here but since the XML Schema
// validator is constructed dynamically, its recognized
// properties might not have been set and it would cause a
// not-recognized exception to be thrown. -Ac
SCHEMA_LOCATION,
SCHEMA_NONS_LOCATION,
};
addRecognizedProperties(recognizedProperties);
|
Methods Summary |
---|
protected void | checkFeature(java.lang.String featureId)Check a feature. If feature is know and supported, this method simply
returns. Otherwise, the appropriate exception is thrown.
//
// Xerces Features
//
if (featureId.startsWith(Constants.XERCES_FEATURE_PREFIX)) {
final int suffixLength = featureId.length() - Constants.XERCES_FEATURE_PREFIX.length();
//
// http://apache.org/xml/features/validation/schema
// Lets the user turn Schema validation support on/off.
//
if (suffixLength == Constants.SCHEMA_VALIDATION_FEATURE.length() &&
featureId.endsWith(Constants.SCHEMA_VALIDATION_FEATURE)) {
return;
}
// activate full schema checking
if (suffixLength == Constants.SCHEMA_FULL_CHECKING.length() &&
featureId.endsWith(Constants.SCHEMA_FULL_CHECKING)) {
return;
}
// Feature identifier: expose schema normalized value
// http://apache.org/xml/features/validation/schema/normalized-value
if (suffixLength == Constants.SCHEMA_NORMALIZED_VALUE.length() &&
featureId.endsWith(Constants.SCHEMA_NORMALIZED_VALUE)) {
return;
}
// Feature identifier: send element default value via characters()
// http://apache.org/xml/features/validation/schema/element-default
if (suffixLength == Constants.SCHEMA_ELEMENT_DEFAULT.length() &&
featureId.endsWith(Constants.SCHEMA_ELEMENT_DEFAULT)) {
return;
}
}
//
// Not recognized
//
super.checkFeature(featureId);
| protected void | checkProperty(java.lang.String propertyId)Check a property. If the property is know and supported, this method
simply returns. Otherwise, the appropriate exception is thrown.
//
// Xerces Properties
//
if (propertyId.startsWith(Constants.XERCES_PROPERTY_PREFIX)) {
final int suffixLength = propertyId.length() - Constants.XERCES_PROPERTY_PREFIX.length();
if (suffixLength == Constants.SCHEMA_LOCATION.length() &&
propertyId.endsWith(Constants.SCHEMA_LOCATION)) {
return;
}
if (suffixLength == Constants.SCHEMA_NONS_LOCATION.length() &&
propertyId.endsWith(Constants.SCHEMA_NONS_LOCATION)) {
return;
}
}
if (propertyId.startsWith(Constants.JAXP_PROPERTY_PREFIX)) {
final int suffixLength = propertyId.length() - Constants.JAXP_PROPERTY_PREFIX.length();
if (suffixLength == Constants.SCHEMA_SOURCE.length() &&
propertyId.endsWith(Constants.SCHEMA_SOURCE)) {
return;
}
}
//
// Not recognized
//
super.checkProperty(propertyId);
| protected void | configurePipeline()Configures the pipeline.
super.configurePipeline();
if ( getFeature(XMLSCHEMA_VALIDATION )) {
// If schema validator was not in the pipeline insert it.
if (fSchemaValidator == null) {
fSchemaValidator = new XMLSchemaValidator();
// add schema component
fProperties.put(SCHEMA_VALIDATOR, fSchemaValidator);
addComponent(fSchemaValidator);
// add schema message formatter
if (fErrorReporter.getMessageFormatter(XSMessageFormatter.SCHEMA_DOMAIN) == null) {
XSMessageFormatter xmft = new XSMessageFormatter();
fErrorReporter.putMessageFormatter(XSMessageFormatter.SCHEMA_DOMAIN, xmft);
}
}
fLastComponent = fSchemaValidator;
fNamespaceBinder.setDocumentHandler(fSchemaValidator);
fSchemaValidator.setDocumentHandler(fDocumentHandler);
fSchemaValidator.setDocumentSource(fNamespaceBinder);
}
|
|