FileDocCategorySizeDatePackage
StandardParserConfiguration.javaAPI DocApache Xerces 3.0.115756Fri Sep 14 20:33:52 BST 2007org.apache.xerces.parsers

StandardParserConfiguration

public 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
author
Arnaud Le Hors, IBM
author
Andy Clark, IBM
version
$Id: StandardParserConfiguration.java 447239 2006-09-18 05:08:26Z mrglavas $

Fields Summary
protected static final String
NORMALIZE_DATA
Feature identifier: expose schema normalized value
protected static final String
SCHEMA_ELEMENT_DEFAULT
Feature identifier: send element default value via characters()
protected static final String
SCHEMA_AUGMENT_PSVI
Feature identifier: augment PSVI
protected static final String
XMLSCHEMA_VALIDATION
feature identifier: XML Schema validation
protected static final String
XMLSCHEMA_FULL_CHECKING
feature identifier: XML Schema validation -- full checking
protected static final String
GENERATE_SYNTHETIC_ANNOTATIONS
Feature: generate synthetic annotations
protected static final String
VALIDATE_ANNOTATIONS
Feature identifier: validate annotations
protected static final String
HONOUR_ALL_SCHEMALOCATIONS
Feature identifier: honour all schemaLocations
protected static final String
IGNORE_XSI_TYPE
Feature identifier: whether to ignore xsi:type attributes until a global element declaration is encountered
protected static final String
ID_IDREF_CHECKING
Feature identifier: whether to ignore ID/IDREF errors
protected static final String
UNPARSED_ENTITY_CHECKING
Feature identifier: whether to ignore unparsed entity errors
protected static final String
IDENTITY_CONSTRAINT_CHECKING
Feature identifier: whether to ignore identity constraint errors
protected static final String
SCHEMA_VALIDATOR
Property identifier: XML Schema validator.
protected static final String
SCHEMA_LOCATION
Property identifier: schema location.
protected static final String
SCHEMA_NONS_LOCATION
Property identifier: no namespace schema location.
protected static final String
ROOT_TYPE_DEF
Property identifier: root type definition.
protected org.apache.xerces.impl.xs.XMLSchemaValidator
fSchemaValidator
XML Schema Validator.
Constructors Summary
public StandardParserConfiguration()
Default constructor.


    //
    // Constructors
    //

       
      
        this(null, null, null);
    
public StandardParserConfiguration(org.apache.xerces.util.SymbolTable symbolTable)
Constructs a parser configuration using the specified symbol table.

param
symbolTable The symbol table to use.

        this(symbolTable, null, null);
    
public StandardParserConfiguration(org.apache.xerces.util.SymbolTable symbolTable, org.apache.xerces.xni.grammars.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.

param
symbolTable The symbol table to use.
param
grammarPool The grammar pool to use.

        this(symbolTable, grammarPool, null);
    
public StandardParserConfiguration(org.apache.xerces.util.SymbolTable symbolTable, org.apache.xerces.xni.grammars.XMLGrammarPool grammarPool, org.apache.xerces.xni.parser.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.

param
symbolTable The symbol table to use.
param
grammarPool The grammar pool to use.
param
parentSettings The parent settings.

        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,
            IGNORE_XSI_TYPE,
            ID_IDREF_CHECKING,
            IDENTITY_CONSTRAINT_CHECKING,
            UNPARSED_ENTITY_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);
        
        setFeature(IGNORE_XSI_TYPE, false);
        setFeature(ID_IDREF_CHECKING, true);
        setFeature(IDENTITY_CONSTRAINT_CHECKING, true);
        setFeature(UNPARSED_ENTITY_CHECKING, true);

        // 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,
            ROOT_TYPE_DEF,
        };
        
        addRecognizedProperties(recognizedProperties);
    
Methods Summary
protected voidcheckFeature(java.lang.String featureId)
Check a feature. If feature is know and supported, this method simply returns. Otherwise, the appropriate exception is thrown.

param
featureId The unique identifier (URI) of the feature.
throws
XMLConfigurationException Thrown for configuration error. In general, components should only throw this exception if it is really a critical error.


        //
        // 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 voidcheckProperty(java.lang.String propertyId)
Check a property. If the property is know and supported, this method simply returns. Otherwise, the appropriate exception is thrown.

param
propertyId The unique identifier (URI) of the property being set.
throws
XMLConfigurationException Thrown for configuration error. In general, components should only throw this exception if it is really a critical error.


        //
        // 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 voidconfigurePipeline()
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);
        }