| 
 | 
 | 
 | 
 | 
 */  | 
 | 
/*  | 
 | 
 * Licensed to the Apache Software Foundation (ASF) under one or more  | 
 | 
 * contributor license agreements.  See the NOTICE file distributed with  | 
 | 
 * this work for additional information regarding copyright ownership.  | 
 | 
 * The ASF licenses this file to You under the Apache License, Version 2.0  | 
 | 
 * (the "License"); you may not use this file except in compliance with  | 
 | 
 * the License.  You may obtain a copy of the License at  | 
 | 
 *  | 
 | 
 *      http://www.apache.org/licenses/LICENSE-2.0  | 
 | 
 *  | 
 | 
 * Unless required by applicable law or agreed to in writing, software  | 
 | 
 * distributed under the License is distributed on an "AS IS" BASIS,  | 
 | 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  | 
 | 
 * See the License for the specific language governing permissions and  | 
 | 
 * limitations under the License.  | 
 | 
 */  | 
 | 
 | 
 | 
package com.sun.org.apache.xerces.internal.parsers;  | 
 | 
 | 
 | 
import com.sun.org.apache.xerces.internal.impl.Constants;  | 
 | 
import com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator;  | 
 | 
import com.sun.org.apache.xerces.internal.impl.xs.XSMessageFormatter;  | 
 | 
import com.sun.org.apache.xerces.internal.util.FeatureState;  | 
 | 
import com.sun.org.apache.xerces.internal.util.PropertyState;  | 
 | 
import com.sun.org.apache.xerces.internal.util.Status;  | 
 | 
import com.sun.org.apache.xerces.internal.util.SymbolTable;  | 
 | 
import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarPool;  | 
 | 
import com.sun.org.apache.xerces.internal.xni.parser.XMLComponentManager;  | 
 | 
import com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException;  | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 */  | 
 | 
public class StandardParserConfiguration  | 
 | 
    extends DTDConfiguration { | 
 | 
 | 
 | 
    //  | 
 | 
    // Constants  | 
 | 
    //  | 
 | 
 | 
 | 
    // feature identifiers  | 
 | 
 | 
 | 
      | 
 | 
    protected static final String NORMALIZE_DATA =  | 
 | 
    Constants.XERCES_FEATURE_PREFIX + Constants.SCHEMA_NORMALIZED_VALUE;  | 
 | 
 | 
 | 
 | 
 | 
      | 
 | 
    protected static final String SCHEMA_ELEMENT_DEFAULT =  | 
 | 
    Constants.XERCES_FEATURE_PREFIX + Constants.SCHEMA_ELEMENT_DEFAULT;  | 
 | 
 | 
 | 
 | 
 | 
      | 
 | 
    protected static final String SCHEMA_AUGMENT_PSVI =  | 
 | 
    Constants.XERCES_FEATURE_PREFIX + Constants.SCHEMA_AUGMENT_PSVI;  | 
 | 
 | 
 | 
 | 
 | 
      | 
 | 
    protected static final String XMLSCHEMA_VALIDATION =  | 
 | 
    Constants.XERCES_FEATURE_PREFIX + Constants.SCHEMA_VALIDATION_FEATURE;  | 
 | 
 | 
 | 
      | 
 | 
    protected static final String XMLSCHEMA_FULL_CHECKING =  | 
 | 
    Constants.XERCES_FEATURE_PREFIX + Constants.SCHEMA_FULL_CHECKING;  | 
 | 
 | 
 | 
      | 
 | 
    protected static final String GENERATE_SYNTHETIC_ANNOTATIONS =  | 
 | 
        Constants.XERCES_FEATURE_PREFIX + Constants.GENERATE_SYNTHETIC_ANNOTATIONS_FEATURE;  | 
 | 
 | 
 | 
      | 
 | 
    protected static final String VALIDATE_ANNOTATIONS =  | 
 | 
        Constants.XERCES_FEATURE_PREFIX + Constants.VALIDATE_ANNOTATIONS_FEATURE;  | 
 | 
 | 
 | 
      | 
 | 
    protected static final String HONOUR_ALL_SCHEMALOCATIONS =  | 
 | 
        Constants.XERCES_FEATURE_PREFIX + Constants.HONOUR_ALL_SCHEMALOCATIONS_FEATURE;  | 
 | 
 | 
 | 
      | 
 | 
    protected static final String IGNORE_XSI_TYPE =  | 
 | 
        Constants.XERCES_FEATURE_PREFIX + Constants.IGNORE_XSI_TYPE_FEATURE;  | 
 | 
 | 
 | 
      | 
 | 
    protected static final String ID_IDREF_CHECKING =  | 
 | 
        Constants.XERCES_FEATURE_PREFIX + Constants.ID_IDREF_CHECKING_FEATURE;  | 
 | 
 | 
 | 
      | 
 | 
    protected static final String UNPARSED_ENTITY_CHECKING =  | 
 | 
        Constants.XERCES_FEATURE_PREFIX + Constants.UNPARSED_ENTITY_CHECKING_FEATURE;  | 
 | 
 | 
 | 
      | 
 | 
    protected static final String IDENTITY_CONSTRAINT_CHECKING =  | 
 | 
        Constants.XERCES_FEATURE_PREFIX + Constants.IDC_CHECKING_FEATURE;  | 
 | 
 | 
 | 
      | 
 | 
    protected static final String NAMESPACE_GROWTH =  | 
 | 
        Constants.XERCES_FEATURE_PREFIX + Constants.NAMESPACE_GROWTH_FEATURE;  | 
 | 
 | 
 | 
      | 
 | 
    protected static final String TOLERATE_DUPLICATES =  | 
 | 
        Constants.XERCES_FEATURE_PREFIX + Constants.TOLERATE_DUPLICATES_FEATURE;  | 
 | 
 | 
 | 
    // property identifiers  | 
 | 
 | 
 | 
      | 
 | 
    protected static final String SCHEMA_VALIDATOR =  | 
 | 
        Constants.XERCES_PROPERTY_PREFIX + Constants.SCHEMA_VALIDATOR_PROPERTY;  | 
 | 
 | 
 | 
      | 
 | 
    protected static final String SCHEMA_LOCATION =  | 
 | 
    Constants.XERCES_PROPERTY_PREFIX + Constants.SCHEMA_LOCATION;  | 
 | 
 | 
 | 
      | 
 | 
    protected static final String SCHEMA_NONS_LOCATION =  | 
 | 
    Constants.XERCES_PROPERTY_PREFIX + Constants.SCHEMA_NONS_LOCATION;  | 
 | 
 | 
 | 
      | 
 | 
    protected static final String SCHEMA_DV_FACTORY =  | 
 | 
        Constants.XERCES_PROPERTY_PREFIX + Constants.SCHEMA_DV_FACTORY_PROPERTY;  | 
 | 
 | 
 | 
      | 
 | 
    protected static final String ROOT_TYPE_DEF =  | 
 | 
        Constants.XERCES_PROPERTY_PREFIX + Constants.ROOT_TYPE_DEFINITION_PROPERTY;  | 
 | 
 | 
 | 
      | 
 | 
    protected static final String ROOT_ELEMENT_DECL =  | 
 | 
        Constants.XERCES_PROPERTY_PREFIX + Constants.ROOT_ELEMENT_DECLARATION_PROPERTY;  | 
 | 
 | 
 | 
    //  | 
 | 
    // Data  | 
 | 
    //  | 
 | 
 | 
 | 
    // components (non-configurable)  | 
 | 
 | 
 | 
      | 
 | 
    protected XMLSchemaValidator fSchemaValidator;  | 
 | 
 | 
 | 
    //  | 
 | 
    // Constructors  | 
 | 
    //  | 
 | 
 | 
 | 
      | 
 | 
    public StandardParserConfiguration() { | 
 | 
        this(null, null, null);  | 
 | 
    } // <init>()  | 
 | 
 | 
 | 
      | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
     */  | 
 | 
    public StandardParserConfiguration(SymbolTable symbolTable) { | 
 | 
        this(symbolTable, null, null);  | 
 | 
    } // <init>(SymbolTable)  | 
 | 
 | 
 | 
      | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
     */  | 
 | 
    public StandardParserConfiguration(SymbolTable symbolTable,  | 
 | 
                                       XMLGrammarPool grammarPool) { | 
 | 
        this(symbolTable, grammarPool, null);  | 
 | 
    } // <init>(SymbolTable,XMLGrammarPool)  | 
 | 
 | 
 | 
      | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
     */  | 
 | 
    public StandardParserConfiguration(SymbolTable symbolTable,  | 
 | 
                                       XMLGrammarPool grammarPool,  | 
 | 
                                       XMLComponentManager parentSettings) { | 
 | 
        super(symbolTable, grammarPool, parentSettings);  | 
 | 
 | 
 | 
          | 
 | 
        final String[] recognizedFeatures = { | 
 | 
            NORMALIZE_DATA,  | 
 | 
            SCHEMA_ELEMENT_DEFAULT,  | 
 | 
            SCHEMA_AUGMENT_PSVI,  | 
 | 
            GENERATE_SYNTHETIC_ANNOTATIONS,  | 
 | 
            VALIDATE_ANNOTATIONS,  | 
 | 
            HONOUR_ALL_SCHEMALOCATIONS,  | 
 | 
            NAMESPACE_GROWTH,  | 
 | 
            TOLERATE_DUPLICATES,  | 
 | 
            // 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  | 
 | 
              | 
 | 
            XMLSCHEMA_VALIDATION,  | 
 | 
            XMLSCHEMA_FULL_CHECKING,  | 
 | 
            IGNORE_XSI_TYPE,  | 
 | 
            ID_IDREF_CHECKING,  | 
 | 
            IDENTITY_CONSTRAINT_CHECKING,  | 
 | 
            UNPARSED_ENTITY_CHECKING,  | 
 | 
        };  | 
 | 
        addRecognizedFeatures(recognizedFeatures);  | 
 | 
 | 
 | 
          | 
 | 
        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);  | 
 | 
        setFeature(NAMESPACE_GROWTH, false);  | 
 | 
        setFeature(TOLERATE_DUPLICATES, 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  | 
 | 
              | 
 | 
            SCHEMA_LOCATION,  | 
 | 
            SCHEMA_NONS_LOCATION,  | 
 | 
            ROOT_TYPE_DEF,  | 
 | 
            ROOT_ELEMENT_DECL,  | 
 | 
            SCHEMA_DV_FACTORY,  | 
 | 
        };  | 
 | 
 | 
 | 
        addRecognizedProperties(recognizedProperties);  | 
 | 
    } // <init>(SymbolTable,XMLGrammarPool)  | 
 | 
 | 
 | 
    //  | 
 | 
    // Public methods  | 
 | 
    //  | 
 | 
 | 
 | 
      | 
 | 
    protected void configurePipeline() { | 
 | 
        super.configurePipeline();  | 
 | 
        if ( getFeature(XMLSCHEMA_VALIDATION )) { | 
 | 
              | 
 | 
            if (fSchemaValidator == null) { | 
 | 
                fSchemaValidator = new XMLSchemaValidator();  | 
 | 
 | 
 | 
                  | 
 | 
                fProperties.put(SCHEMA_VALIDATOR, fSchemaValidator);  | 
 | 
                addComponent(fSchemaValidator);  | 
 | 
                   | 
 | 
                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);  | 
 | 
        }  | 
 | 
 | 
 | 
 | 
 | 
    } // configurePipeline()  | 
 | 
 | 
 | 
    // features and properties  | 
 | 
 | 
 | 
      | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
     */  | 
 | 
    protected FeatureState checkFeature(String featureId)  | 
 | 
        throws XMLConfigurationException { | 
 | 
 | 
 | 
        //  | 
 | 
        // 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 FeatureState.RECOGNIZED;  | 
 | 
            }  | 
 | 
              | 
 | 
            if (suffixLength == Constants.SCHEMA_FULL_CHECKING.length() &&  | 
 | 
                featureId.endsWith(Constants.SCHEMA_FULL_CHECKING)) { | 
 | 
                return FeatureState.RECOGNIZED;  | 
 | 
            }  | 
 | 
            // Feature identifier: expose schema normalized value  | 
 | 
              | 
 | 
            if (suffixLength == Constants.SCHEMA_NORMALIZED_VALUE.length() &&  | 
 | 
                featureId.endsWith(Constants.SCHEMA_NORMALIZED_VALUE)) { | 
 | 
                return FeatureState.RECOGNIZED;  | 
 | 
            }  | 
 | 
            // Feature identifier: send element default value via characters()  | 
 | 
              | 
 | 
            if (suffixLength == Constants.SCHEMA_ELEMENT_DEFAULT.length() &&  | 
 | 
                featureId.endsWith(Constants.SCHEMA_ELEMENT_DEFAULT)) { | 
 | 
                return FeatureState.RECOGNIZED;  | 
 | 
            }  | 
 | 
        }  | 
 | 
 | 
 | 
        //  | 
 | 
        // Not recognized  | 
 | 
        //  | 
 | 
 | 
 | 
        return super.checkFeature(featureId);  | 
 | 
 | 
 | 
    } // checkFeature(String)  | 
 | 
 | 
 | 
      | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
     */  | 
 | 
    protected PropertyState checkProperty(String propertyId)  | 
 | 
        throws XMLConfigurationException { | 
 | 
 | 
 | 
        //  | 
 | 
        // 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 PropertyState.RECOGNIZED;  | 
 | 
            }  | 
 | 
            if (suffixLength == Constants.SCHEMA_NONS_LOCATION.length() &&  | 
 | 
                propertyId.endsWith(Constants.SCHEMA_NONS_LOCATION)) { | 
 | 
                return PropertyState.RECOGNIZED;  | 
 | 
            }  | 
 | 
        }  | 
 | 
 | 
 | 
        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 PropertyState.RECOGNIZED;  | 
 | 
            }  | 
 | 
        }  | 
 | 
 | 
 | 
        //  | 
 | 
        // Not recognized  | 
 | 
        //  | 
 | 
 | 
 | 
        return super.checkProperty(propertyId);  | 
 | 
 | 
 | 
    } // checkProperty(String)  | 
 | 
 | 
 | 
} // class StandardParserConfiguration  |