| 
 | 
 | 
 | 
 | 
 */  | 
 | 
/*  | 
 | 
 * 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.XML11DTDScannerImpl;  | 
 | 
import com.sun.org.apache.xerces.internal.impl.XML11DocumentScannerImpl;  | 
 | 
import com.sun.org.apache.xerces.internal.impl.XML11NSDocumentScannerImpl;  | 
 | 
import com.sun.org.apache.xerces.internal.impl.XMLDTDScannerImpl;  | 
 | 
import com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl;  | 
 | 
import com.sun.org.apache.xerces.internal.impl.XMLEntityHandler;  | 
 | 
import com.sun.org.apache.xerces.internal.impl.XMLEntityManager;  | 
 | 
import com.sun.org.apache.xerces.internal.impl.XMLErrorReporter;  | 
 | 
import com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl;  | 
 | 
import com.sun.org.apache.xerces.internal.impl.XMLVersionDetector;  | 
 | 
import com.sun.org.apache.xerces.internal.impl.dtd.XML11DTDProcessor;  | 
 | 
import com.sun.org.apache.xerces.internal.impl.dtd.XML11DTDValidator;  | 
 | 
import com.sun.org.apache.xerces.internal.impl.dtd.XML11NSDTDValidator;  | 
 | 
import com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDProcessor;  | 
 | 
import com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator;  | 
 | 
import com.sun.org.apache.xerces.internal.impl.dtd.XMLNSDTDValidator;  | 
 | 
import com.sun.org.apache.xerces.internal.impl.dv.DTDDVFactory;  | 
 | 
import com.sun.org.apache.xerces.internal.impl.msg.XMLMessageFormatter;  | 
 | 
import com.sun.org.apache.xerces.internal.impl.validation.ValidationManager;  | 
 | 
import com.sun.org.apache.xerces.internal.util.FeatureState;  | 
 | 
import com.sun.org.apache.xerces.internal.util.ParserConfigurationSettings;  | 
 | 
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.XMLDTDContentModelHandler;  | 
 | 
import com.sun.org.apache.xerces.internal.xni.XMLDTDHandler;  | 
 | 
import com.sun.org.apache.xerces.internal.xni.XMLDocumentHandler;  | 
 | 
import com.sun.org.apache.xerces.internal.xni.XMLLocator;  | 
 | 
import com.sun.org.apache.xerces.internal.xni.XNIException;  | 
 | 
import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarPool;  | 
 | 
import com.sun.org.apache.xerces.internal.xni.parser.XMLComponent;  | 
 | 
import com.sun.org.apache.xerces.internal.xni.parser.XMLComponentManager;  | 
 | 
import com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException;  | 
 | 
import com.sun.org.apache.xerces.internal.xni.parser.XMLDTDScanner;  | 
 | 
import com.sun.org.apache.xerces.internal.xni.parser.XMLDocumentScanner;  | 
 | 
import com.sun.org.apache.xerces.internal.xni.parser.XMLDocumentSource;  | 
 | 
import com.sun.org.apache.xerces.internal.xni.parser.XMLEntityResolver;  | 
 | 
import com.sun.org.apache.xerces.internal.xni.parser.XMLErrorHandler;  | 
 | 
import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource;  | 
 | 
import com.sun.org.apache.xerces.internal.xni.parser.XMLPullParserConfiguration;  | 
 | 
import java.io.IOException;  | 
 | 
import java.util.ArrayList;  | 
 | 
import java.util.HashMap;  | 
 | 
import java.util.List;  | 
 | 
import java.util.Locale;  | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 */  | 
 | 
public class XML11DTDConfiguration extends ParserConfigurationSettings  | 
 | 
    implements XMLPullParserConfiguration, XML11Configurable { | 
 | 
 | 
 | 
    //  | 
 | 
    // Constants  | 
 | 
      | 
 | 
    protected final static String XML11_DATATYPE_VALIDATOR_FACTORY =  | 
 | 
        "com.sun.org.apache.xerces.internal.impl.dv.dtd.XML11DTDDVFactoryImpl";  | 
 | 
 | 
 | 
    // feature identifiers  | 
 | 
 | 
 | 
      | 
 | 
    protected static final String VALIDATION =  | 
 | 
        Constants.SAX_FEATURE_PREFIX + Constants.VALIDATION_FEATURE;  | 
 | 
 | 
 | 
      | 
 | 
    protected static final String NAMESPACES =  | 
 | 
        Constants.SAX_FEATURE_PREFIX + Constants.NAMESPACES_FEATURE;  | 
 | 
 | 
 | 
      | 
 | 
    protected static final String EXTERNAL_GENERAL_ENTITIES =  | 
 | 
        Constants.SAX_FEATURE_PREFIX + Constants.EXTERNAL_GENERAL_ENTITIES_FEATURE;  | 
 | 
 | 
 | 
      | 
 | 
    protected static final String EXTERNAL_PARAMETER_ENTITIES =  | 
 | 
        Constants.SAX_FEATURE_PREFIX + Constants.EXTERNAL_PARAMETER_ENTITIES_FEATURE;  | 
 | 
 | 
 | 
      | 
 | 
    protected static final String CONTINUE_AFTER_FATAL_ERROR =  | 
 | 
        Constants.XERCES_FEATURE_PREFIX + Constants.CONTINUE_AFTER_FATAL_ERROR_FEATURE;  | 
 | 
 | 
 | 
      | 
 | 
    protected static final String LOAD_EXTERNAL_DTD =  | 
 | 
        Constants.XERCES_FEATURE_PREFIX + Constants.LOAD_EXTERNAL_DTD_FEATURE;  | 
 | 
 | 
 | 
    // property identifiers  | 
 | 
 | 
 | 
          | 
 | 
        protected static final String XML_STRING =  | 
 | 
                Constants.SAX_PROPERTY_PREFIX + Constants.XML_STRING_PROPERTY;  | 
 | 
 | 
 | 
          | 
 | 
        protected static final String SYMBOL_TABLE =  | 
 | 
                Constants.XERCES_PROPERTY_PREFIX + Constants.SYMBOL_TABLE_PROPERTY;  | 
 | 
 | 
 | 
          | 
 | 
        protected static final String ERROR_HANDLER =  | 
 | 
                Constants.XERCES_PROPERTY_PREFIX + Constants.ERROR_HANDLER_PROPERTY;  | 
 | 
 | 
 | 
          | 
 | 
        protected static final String ENTITY_RESOLVER =  | 
 | 
                Constants.XERCES_PROPERTY_PREFIX + Constants.ENTITY_RESOLVER_PROPERTY;  | 
 | 
 | 
 | 
      | 
 | 
    protected static final String ERROR_REPORTER =  | 
 | 
        Constants.XERCES_PROPERTY_PREFIX + Constants.ERROR_REPORTER_PROPERTY;  | 
 | 
 | 
 | 
      | 
 | 
    protected static final String ENTITY_MANAGER =  | 
 | 
        Constants.XERCES_PROPERTY_PREFIX + Constants.ENTITY_MANAGER_PROPERTY;  | 
 | 
 | 
 | 
      | 
 | 
    protected static final String DOCUMENT_SCANNER =  | 
 | 
        Constants.XERCES_PROPERTY_PREFIX + Constants.DOCUMENT_SCANNER_PROPERTY;  | 
 | 
 | 
 | 
      | 
 | 
    protected static final String DTD_SCANNER =  | 
 | 
        Constants.XERCES_PROPERTY_PREFIX + Constants.DTD_SCANNER_PROPERTY;  | 
 | 
 | 
 | 
      | 
 | 
    protected static final String XMLGRAMMAR_POOL =  | 
 | 
        Constants.XERCES_PROPERTY_PREFIX + Constants.XMLGRAMMAR_POOL_PROPERTY;  | 
 | 
 | 
 | 
      | 
 | 
    protected static final String DTD_PROCESSOR =  | 
 | 
        Constants.XERCES_PROPERTY_PREFIX + Constants.DTD_PROCESSOR_PROPERTY;  | 
 | 
 | 
 | 
      | 
 | 
    protected static final String DTD_VALIDATOR =  | 
 | 
        Constants.XERCES_PROPERTY_PREFIX + Constants.DTD_VALIDATOR_PROPERTY;  | 
 | 
 | 
 | 
      | 
 | 
    protected static final String NAMESPACE_BINDER =  | 
 | 
        Constants.XERCES_PROPERTY_PREFIX + Constants.NAMESPACE_BINDER_PROPERTY;  | 
 | 
 | 
 | 
      | 
 | 
    protected static final String DATATYPE_VALIDATOR_FACTORY =  | 
 | 
        Constants.XERCES_PROPERTY_PREFIX + Constants.DATATYPE_VALIDATOR_FACTORY_PROPERTY;  | 
 | 
 | 
 | 
    protected static final String VALIDATION_MANAGER =  | 
 | 
        Constants.XERCES_PROPERTY_PREFIX + Constants.VALIDATION_MANAGER_PROPERTY;  | 
 | 
 | 
 | 
      | 
 | 
    protected static final String JAXP_SCHEMA_LANGUAGE =  | 
 | 
        Constants.JAXP_PROPERTY_PREFIX + Constants.SCHEMA_LANGUAGE;  | 
 | 
 | 
 | 
      | 
 | 
    protected static final String JAXP_SCHEMA_SOURCE =  | 
 | 
        Constants.JAXP_PROPERTY_PREFIX + Constants.SCHEMA_SOURCE;  | 
 | 
 | 
 | 
    // debugging  | 
 | 
 | 
 | 
      | 
 | 
    protected static final boolean PRINT_EXCEPTION_STACK_TRACE = false;  | 
 | 
 | 
 | 
    //  | 
 | 
    // Data  | 
 | 
      | 
 | 
    protected SymbolTable fSymbolTable;  | 
 | 
    protected XMLInputSource fInputSource;  | 
 | 
    protected ValidationManager fValidationManager;  | 
 | 
    protected XMLVersionDetector fVersionDetector;  | 
 | 
    protected XMLLocator fLocator;  | 
 | 
    protected Locale fLocale;  | 
 | 
 | 
 | 
      | 
 | 
    protected List<XMLComponent> fComponents;  | 
 | 
 | 
 | 
      | 
 | 
    protected List<XMLComponent> fXML11Components = null;  | 
 | 
 | 
 | 
      | 
 | 
    protected List<XMLComponent> fCommonComponents = null;  | 
 | 
 | 
 | 
      | 
 | 
    protected XMLDocumentHandler fDocumentHandler;  | 
 | 
 | 
 | 
      | 
 | 
    protected XMLDTDHandler fDTDHandler;  | 
 | 
 | 
 | 
      | 
 | 
    protected XMLDTDContentModelHandler fDTDContentModelHandler;  | 
 | 
 | 
 | 
      | 
 | 
    protected XMLDocumentSource fLastComponent;  | 
 | 
 | 
 | 
      | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
     */  | 
 | 
    protected boolean fParseInProgress = false;  | 
 | 
 | 
 | 
      | 
 | 
 | 
 | 
 | 
 | 
     */  | 
 | 
    protected boolean fConfigUpdated = false;  | 
 | 
 | 
 | 
    //  | 
 | 
    // XML 1.0 components  | 
 | 
    //  | 
 | 
 | 
 | 
      | 
 | 
    protected DTDDVFactory fDatatypeValidatorFactory;  | 
 | 
 | 
 | 
      | 
 | 
    protected XMLNSDocumentScannerImpl fNamespaceScanner;  | 
 | 
 | 
 | 
      | 
 | 
    protected XMLDocumentScannerImpl fNonNSScanner;  | 
 | 
 | 
 | 
      | 
 | 
    protected XMLDTDValidator fDTDValidator;  | 
 | 
 | 
 | 
      | 
 | 
    protected XMLDTDValidator fNonNSDTDValidator;  | 
 | 
 | 
 | 
      | 
 | 
    protected XMLDTDScanner fDTDScanner;  | 
 | 
 | 
 | 
      | 
 | 
    protected XMLDTDProcessor fDTDProcessor;  | 
 | 
 | 
 | 
    //  | 
 | 
    // XML 1.1 components  | 
 | 
    //  | 
 | 
 | 
 | 
      | 
 | 
    protected DTDDVFactory fXML11DatatypeFactory = null;  | 
 | 
 | 
 | 
      | 
 | 
    protected XML11NSDocumentScannerImpl fXML11NSDocScanner = null;  | 
 | 
 | 
 | 
      | 
 | 
    protected XML11DocumentScannerImpl fXML11DocScanner = null;  | 
 | 
 | 
 | 
      | 
 | 
    protected XML11NSDTDValidator fXML11NSDTDValidator = null;  | 
 | 
 | 
 | 
      | 
 | 
    protected XML11DTDValidator fXML11DTDValidator = null;  | 
 | 
 | 
 | 
      | 
 | 
    protected XML11DTDScannerImpl fXML11DTDScanner = null;  | 
 | 
 | 
 | 
      | 
 | 
    protected XML11DTDProcessor fXML11DTDProcessor = null;  | 
 | 
 | 
 | 
    //  | 
 | 
    // Common components  | 
 | 
    //  | 
 | 
 | 
 | 
      | 
 | 
    protected XMLGrammarPool fGrammarPool;  | 
 | 
 | 
 | 
      | 
 | 
    protected XMLErrorReporter fErrorReporter;  | 
 | 
 | 
 | 
      | 
 | 
    protected XMLEntityManager fEntityManager;  | 
 | 
 | 
 | 
      | 
 | 
    protected XMLDocumentScanner fCurrentScanner;  | 
 | 
 | 
 | 
      | 
 | 
    protected DTDDVFactory fCurrentDVFactory;  | 
 | 
 | 
 | 
      | 
 | 
    protected XMLDTDScanner fCurrentDTDScanner;  | 
 | 
 | 
 | 
      | 
 | 
    private boolean f11Initialized = false;  | 
 | 
 | 
 | 
    //  | 
 | 
    // Constructors  | 
 | 
    //  | 
 | 
 | 
 | 
      | 
 | 
    public XML11DTDConfiguration() { | 
 | 
        this(null, null, null);  | 
 | 
    } // <init>()  | 
 | 
 | 
 | 
      | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
     */  | 
 | 
    public XML11DTDConfiguration(SymbolTable symbolTable) { | 
 | 
        this(symbolTable, null, null);  | 
 | 
    } // <init>(SymbolTable)  | 
 | 
 | 
 | 
      | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
     */  | 
 | 
    public XML11DTDConfiguration(SymbolTable symbolTable, XMLGrammarPool grammarPool) { | 
 | 
        this(symbolTable, grammarPool, null);  | 
 | 
    } // <init>(SymbolTable,XMLGrammarPool)  | 
 | 
 | 
 | 
      | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
     */  | 
 | 
    public XML11DTDConfiguration(  | 
 | 
        SymbolTable symbolTable,  | 
 | 
        XMLGrammarPool grammarPool,  | 
 | 
        XMLComponentManager parentSettings) { | 
 | 
 | 
 | 
                super(parentSettings);  | 
 | 
 | 
 | 
                // create a vector to hold all the components in use  | 
 | 
                  | 
 | 
                fComponents = new ArrayList<>();  | 
 | 
                  | 
 | 
                fXML11Components = new ArrayList<>();  | 
 | 
                  | 
 | 
                fCommonComponents = new ArrayList<>();  | 
 | 
 | 
 | 
                  | 
 | 
                fFeatures = new HashMap<>();  | 
 | 
                fProperties = new HashMap<>();  | 
 | 
 | 
 | 
          | 
 | 
        final String[] recognizedFeatures =  | 
 | 
            { | 
 | 
                CONTINUE_AFTER_FATAL_ERROR, LOAD_EXTERNAL_DTD,   | 
 | 
                                VALIDATION,  | 
 | 
                                NAMESPACES,  | 
 | 
                                EXTERNAL_GENERAL_ENTITIES,  | 
 | 
                                EXTERNAL_PARAMETER_ENTITIES,  | 
 | 
                                PARSER_SETTINGS  | 
 | 
                        };  | 
 | 
        addRecognizedFeatures(recognizedFeatures);  | 
 | 
                  | 
 | 
                fFeatures.put(VALIDATION, Boolean.FALSE);  | 
 | 
                fFeatures.put(NAMESPACES, Boolean.TRUE);  | 
 | 
                fFeatures.put(EXTERNAL_GENERAL_ENTITIES, Boolean.TRUE);  | 
 | 
                fFeatures.put(EXTERNAL_PARAMETER_ENTITIES, Boolean.TRUE);  | 
 | 
                fFeatures.put(CONTINUE_AFTER_FATAL_ERROR, Boolean.FALSE);  | 
 | 
                fFeatures.put(LOAD_EXTERNAL_DTD, Boolean.TRUE);  | 
 | 
                fFeatures.put(PARSER_SETTINGS, Boolean.TRUE);  | 
 | 
 | 
 | 
          | 
 | 
        final String[] recognizedProperties =  | 
 | 
            { | 
 | 
                                SYMBOL_TABLE,  | 
 | 
                                ERROR_HANDLER,  | 
 | 
                                ENTITY_RESOLVER,  | 
 | 
                ERROR_REPORTER,  | 
 | 
                ENTITY_MANAGER,  | 
 | 
                DOCUMENT_SCANNER,  | 
 | 
                DTD_SCANNER,  | 
 | 
                DTD_PROCESSOR,  | 
 | 
                DTD_VALIDATOR,  | 
 | 
                                DATATYPE_VALIDATOR_FACTORY,  | 
 | 
                                VALIDATION_MANAGER,  | 
 | 
                                XML_STRING,  | 
 | 
                XMLGRAMMAR_POOL,  | 
 | 
                JAXP_SCHEMA_SOURCE,  | 
 | 
                JAXP_SCHEMA_LANGUAGE};  | 
 | 
        addRecognizedProperties(recognizedProperties);  | 
 | 
 | 
 | 
                if (symbolTable == null) { | 
 | 
                        symbolTable = new SymbolTable();  | 
 | 
                }  | 
 | 
                fSymbolTable = symbolTable;  | 
 | 
                fProperties.put(SYMBOL_TABLE, fSymbolTable);  | 
 | 
 | 
 | 
        fGrammarPool = grammarPool;  | 
 | 
        if (fGrammarPool != null) { | 
 | 
                        fProperties.put(XMLGRAMMAR_POOL, fGrammarPool);  | 
 | 
        }  | 
 | 
 | 
 | 
        fEntityManager = new XMLEntityManager();  | 
 | 
                fProperties.put(ENTITY_MANAGER, fEntityManager);  | 
 | 
        addCommonComponent(fEntityManager);  | 
 | 
 | 
 | 
        fErrorReporter = new XMLErrorReporter();  | 
 | 
        fErrorReporter.setDocumentLocator(fEntityManager.getEntityScanner());  | 
 | 
                fProperties.put(ERROR_REPORTER, fErrorReporter);  | 
 | 
        addCommonComponent(fErrorReporter);  | 
 | 
 | 
 | 
        fNamespaceScanner = new XMLNSDocumentScannerImpl();  | 
 | 
                fProperties.put(DOCUMENT_SCANNER, fNamespaceScanner);  | 
 | 
        addComponent((XMLComponent) fNamespaceScanner);  | 
 | 
 | 
 | 
        fDTDScanner = new XMLDTDScannerImpl();  | 
 | 
                fProperties.put(DTD_SCANNER, fDTDScanner);  | 
 | 
        addComponent((XMLComponent) fDTDScanner);  | 
 | 
 | 
 | 
        fDTDProcessor = new XMLDTDProcessor();  | 
 | 
                fProperties.put(DTD_PROCESSOR, fDTDProcessor);  | 
 | 
        addComponent((XMLComponent) fDTDProcessor);  | 
 | 
 | 
 | 
        fDTDValidator = new XMLNSDTDValidator();  | 
 | 
                fProperties.put(DTD_VALIDATOR, fDTDValidator);  | 
 | 
        addComponent(fDTDValidator);  | 
 | 
 | 
 | 
        fDatatypeValidatorFactory = DTDDVFactory.getInstance();  | 
 | 
                fProperties.put(DATATYPE_VALIDATOR_FACTORY, fDatatypeValidatorFactory);  | 
 | 
 | 
 | 
        fValidationManager = new ValidationManager();  | 
 | 
                fProperties.put(VALIDATION_MANAGER, fValidationManager);  | 
 | 
 | 
 | 
        fVersionDetector = new XMLVersionDetector();  | 
 | 
 | 
 | 
          | 
 | 
        if (fErrorReporter.getMessageFormatter(XMLMessageFormatter.XML_DOMAIN) == null) { | 
 | 
            XMLMessageFormatter xmft = new XMLMessageFormatter();  | 
 | 
            fErrorReporter.putMessageFormatter(XMLMessageFormatter.XML_DOMAIN, xmft);  | 
 | 
            fErrorReporter.putMessageFormatter(XMLMessageFormatter.XMLNS_DOMAIN, xmft);  | 
 | 
        }  | 
 | 
 | 
 | 
          | 
 | 
        try { | 
 | 
            setLocale(Locale.getDefault());  | 
 | 
        } catch (XNIException e) { | 
 | 
            // do nothing  | 
 | 
            // REVISIT: What is the right thing to do? -Ac  | 
 | 
        }  | 
 | 
 | 
 | 
                fConfigUpdated = false;  | 
 | 
 | 
 | 
    } // <init>(SymbolTable,XMLGrammarPool)  | 
 | 
 | 
 | 
    //  | 
 | 
    // Public methods  | 
 | 
    //  | 
 | 
      | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
     */  | 
 | 
    public void setInputSource(XMLInputSource inputSource)  | 
 | 
        throws XMLConfigurationException, IOException { | 
 | 
 | 
 | 
        // REVISIT: this method used to reset all the components and  | 
 | 
        //          construct the pipeline. Now reset() is called  | 
 | 
        //          in parse (boolean) just before we parse the document  | 
 | 
        //          Should this method still throw exceptions..?  | 
 | 
 | 
 | 
        fInputSource = inputSource;  | 
 | 
 | 
 | 
    } // setInputSource(XMLInputSource)  | 
 | 
 | 
 | 
      | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
     */  | 
 | 
    public void setLocale(Locale locale) throws XNIException { | 
 | 
        fLocale = locale;  | 
 | 
        fErrorReporter.setLocale(locale);  | 
 | 
    } // setLocale(Locale)  | 
 | 
 | 
 | 
          | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
         */  | 
 | 
        public void setDocumentHandler(XMLDocumentHandler documentHandler) { | 
 | 
                fDocumentHandler = documentHandler;  | 
 | 
                if (fLastComponent != null) { | 
 | 
                        fLastComponent.setDocumentHandler(fDocumentHandler);  | 
 | 
                        if (fDocumentHandler !=null){ | 
 | 
                                fDocumentHandler.setDocumentSource(fLastComponent);  | 
 | 
                        }  | 
 | 
                }  | 
 | 
        } // setDocumentHandler(XMLDocumentHandler)  | 
 | 
 | 
 | 
          | 
 | 
        public XMLDocumentHandler getDocumentHandler() { | 
 | 
                return fDocumentHandler;  | 
 | 
        } // getDocumentHandler():XMLDocumentHandler  | 
 | 
 | 
 | 
          | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
         */  | 
 | 
        public void setDTDHandler(XMLDTDHandler dtdHandler) { | 
 | 
                fDTDHandler = dtdHandler;  | 
 | 
        } // setDTDHandler(XMLDTDHandler)  | 
 | 
 | 
 | 
          | 
 | 
        public XMLDTDHandler getDTDHandler() { | 
 | 
                return fDTDHandler;  | 
 | 
        } // getDTDHandler():XMLDTDHandler  | 
 | 
 | 
 | 
          | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
         */  | 
 | 
        public void setDTDContentModelHandler(XMLDTDContentModelHandler handler) { | 
 | 
                fDTDContentModelHandler = handler;  | 
 | 
        } // setDTDContentModelHandler(XMLDTDContentModelHandler)  | 
 | 
 | 
 | 
          | 
 | 
        public XMLDTDContentModelHandler getDTDContentModelHandler() { | 
 | 
                return fDTDContentModelHandler;  | 
 | 
        } // getDTDContentModelHandler():XMLDTDContentModelHandler  | 
 | 
 | 
 | 
          | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
         */  | 
 | 
        public void setEntityResolver(XMLEntityResolver resolver) { | 
 | 
                fProperties.put(ENTITY_RESOLVER, resolver);  | 
 | 
        } // setEntityResolver(XMLEntityResolver)  | 
 | 
 | 
 | 
          | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
         */  | 
 | 
        public XMLEntityResolver getEntityResolver() { | 
 | 
                return (XMLEntityResolver)fProperties.get(ENTITY_RESOLVER);  | 
 | 
        } // getEntityResolver():XMLEntityResolver  | 
 | 
 | 
 | 
          | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
         */  | 
 | 
        public void setErrorHandler(XMLErrorHandler errorHandler) { | 
 | 
                fProperties.put(ERROR_HANDLER, errorHandler);  | 
 | 
        } // setErrorHandler(XMLErrorHandler)  | 
 | 
 | 
 | 
          | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
         */  | 
 | 
        public XMLErrorHandler getErrorHandler() { | 
 | 
                  | 
 | 
                return (XMLErrorHandler)fProperties.get(ERROR_HANDLER);  | 
 | 
        } // getErrorHandler():XMLErrorHandler  | 
 | 
 | 
 | 
 | 
 | 
      | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
     */  | 
 | 
    public void cleanup() { | 
 | 
        fEntityManager.closeReaders();  | 
 | 
    }  | 
 | 
 | 
 | 
      | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
     */  | 
 | 
    public void parse(XMLInputSource source) throws XNIException, IOException { | 
 | 
 | 
 | 
        if (fParseInProgress) { | 
 | 
              | 
 | 
            throw new XNIException("FWK005 parse may not be called while parsing."); | 
 | 
        }  | 
 | 
        fParseInProgress = true;  | 
 | 
 | 
 | 
        try { | 
 | 
            setInputSource(source);  | 
 | 
            parse(true);  | 
 | 
        } catch (XNIException ex) { | 
 | 
            if (PRINT_EXCEPTION_STACK_TRACE)  | 
 | 
                ex.printStackTrace();  | 
 | 
            throw ex;  | 
 | 
        } catch (IOException ex) { | 
 | 
            if (PRINT_EXCEPTION_STACK_TRACE)  | 
 | 
                ex.printStackTrace();  | 
 | 
            throw ex;  | 
 | 
        } catch (RuntimeException ex) { | 
 | 
            if (PRINT_EXCEPTION_STACK_TRACE)  | 
 | 
                ex.printStackTrace();  | 
 | 
            throw ex;  | 
 | 
        } catch (Exception ex) { | 
 | 
            if (PRINT_EXCEPTION_STACK_TRACE)  | 
 | 
                ex.printStackTrace();  | 
 | 
            throw new XNIException(ex);  | 
 | 
        } finally { | 
 | 
            fParseInProgress = false;  | 
 | 
              | 
 | 
            this.cleanup();  | 
 | 
        }  | 
 | 
 | 
 | 
    } // parse(InputSource)  | 
 | 
 | 
 | 
    public boolean parse(boolean complete) throws XNIException, IOException { | 
 | 
        //  | 
 | 
          | 
 | 
        if (fInputSource != null) { | 
 | 
            try { | 
 | 
                                fValidationManager.reset();  | 
 | 
                fVersionDetector.reset(this);  | 
 | 
                resetCommon();  | 
 | 
 | 
 | 
                short version = fVersionDetector.determineDocVersion(fInputSource);  | 
 | 
                if (version == Constants.XML_VERSION_1_1) { | 
 | 
                    initXML11Components();  | 
 | 
                    configureXML11Pipeline();  | 
 | 
                    resetXML11();  | 
 | 
                } else { | 
 | 
                    configurePipeline();  | 
 | 
                    reset();  | 
 | 
                }  | 
 | 
 | 
 | 
                  | 
 | 
                fConfigUpdated = false;  | 
 | 
 | 
 | 
                  | 
 | 
                fVersionDetector.startDocumentParsing((XMLEntityHandler) fCurrentScanner, version);  | 
 | 
                fInputSource = null;  | 
 | 
            } catch (XNIException ex) { | 
 | 
                if (PRINT_EXCEPTION_STACK_TRACE)  | 
 | 
                    ex.printStackTrace();  | 
 | 
                throw ex;  | 
 | 
            } catch (IOException ex) { | 
 | 
                if (PRINT_EXCEPTION_STACK_TRACE)  | 
 | 
                    ex.printStackTrace();  | 
 | 
                throw ex;  | 
 | 
            } catch (RuntimeException ex) { | 
 | 
                if (PRINT_EXCEPTION_STACK_TRACE)  | 
 | 
                    ex.printStackTrace();  | 
 | 
                throw ex;  | 
 | 
            } catch (Exception ex) { | 
 | 
                if (PRINT_EXCEPTION_STACK_TRACE)  | 
 | 
                    ex.printStackTrace();  | 
 | 
                throw new XNIException(ex);  | 
 | 
            }  | 
 | 
        }  | 
 | 
 | 
 | 
        try { | 
 | 
            return fCurrentScanner.scanDocument(complete);  | 
 | 
        } catch (XNIException ex) { | 
 | 
            if (PRINT_EXCEPTION_STACK_TRACE)  | 
 | 
                ex.printStackTrace();  | 
 | 
            throw ex;  | 
 | 
        } catch (IOException ex) { | 
 | 
            if (PRINT_EXCEPTION_STACK_TRACE)  | 
 | 
                ex.printStackTrace();  | 
 | 
            throw ex;  | 
 | 
        } catch (RuntimeException ex) { | 
 | 
            if (PRINT_EXCEPTION_STACK_TRACE)  | 
 | 
                ex.printStackTrace();  | 
 | 
            throw ex;  | 
 | 
        } catch (Exception ex) { | 
 | 
            if (PRINT_EXCEPTION_STACK_TRACE)  | 
 | 
                ex.printStackTrace();  | 
 | 
            throw new XNIException(ex);  | 
 | 
        }  | 
 | 
 | 
 | 
    } // parse(boolean):boolean  | 
 | 
 | 
 | 
          | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
         */  | 
 | 
        public FeatureState getFeatureState(String featureId)  | 
 | 
                throws XMLConfigurationException { | 
 | 
                          | 
 | 
        if (featureId.equals(PARSER_SETTINGS)){ | 
 | 
                return FeatureState.is(fConfigUpdated);  | 
 | 
        }  | 
 | 
        return super.getFeatureState(featureId);  | 
 | 
 | 
 | 
        } // getFeature(String):boolean  | 
 | 
 | 
 | 
          | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
         */  | 
 | 
        public void setFeature(String featureId, boolean state)  | 
 | 
                throws XMLConfigurationException { | 
 | 
                fConfigUpdated = true;  | 
 | 
                  | 
 | 
                for (XMLComponent c : fComponents) { | 
 | 
                    c.setFeature(featureId, state);  | 
 | 
                }  | 
 | 
                  | 
 | 
                for (XMLComponent c : fCommonComponents) { | 
 | 
                    c.setFeature(featureId, state);  | 
 | 
                }  | 
 | 
                  | 
 | 
                for (XMLComponent c : fXML11Components) { | 
 | 
                    try { | 
 | 
                        c.setFeature(featureId, state);  | 
 | 
                    }  | 
 | 
                    catch (Exception e){ | 
 | 
                        // no op  | 
 | 
                    }  | 
 | 
                }  | 
 | 
                  | 
 | 
                super.setFeature(featureId, state);  | 
 | 
 | 
 | 
        } // setFeature(String,boolean)  | 
 | 
 | 
 | 
          | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
         */  | 
 | 
        public void setProperty(String propertyId, Object value)  | 
 | 
                throws XMLConfigurationException { | 
 | 
                fConfigUpdated = true;  | 
 | 
                  | 
 | 
                for (XMLComponent c : fComponents) { | 
 | 
                    c.setProperty(propertyId, value);  | 
 | 
                }  | 
 | 
                  | 
 | 
                for (XMLComponent c : fCommonComponents) { | 
 | 
                    c.setProperty(propertyId, value);  | 
 | 
                }  | 
 | 
                  | 
 | 
                for (XMLComponent c : fXML11Components) { | 
 | 
                    try { | 
 | 
                        c.setProperty(propertyId, value);  | 
 | 
                    }  | 
 | 
                    catch (Exception e){ | 
 | 
                                // ignore it  | 
 | 
                    }  | 
 | 
                }  | 
 | 
 | 
 | 
                  | 
 | 
                super.setProperty(propertyId, value);  | 
 | 
 | 
 | 
        } // setProperty(String,Object)  | 
 | 
 | 
 | 
 | 
 | 
          | 
 | 
        public Locale getLocale() { | 
 | 
                return fLocale;  | 
 | 
        } // getLocale():Locale  | 
 | 
 | 
 | 
          | 
 | 
 | 
 | 
         */  | 
 | 
        protected void reset() throws XNIException { | 
 | 
            for (XMLComponent c : fComponents) { | 
 | 
                c.reset(this);  | 
 | 
            }  | 
 | 
        } // reset()  | 
 | 
 | 
 | 
          | 
 | 
 | 
 | 
         */  | 
 | 
        protected void resetCommon() throws XNIException { | 
 | 
              | 
 | 
            for (XMLComponent c : fCommonComponents) { | 
 | 
                c.reset(this);  | 
 | 
            }  | 
 | 
        } // resetCommon()  | 
 | 
 | 
 | 
          | 
 | 
 | 
 | 
         */  | 
 | 
        protected void resetXML11() throws XNIException { | 
 | 
              | 
 | 
            for (XMLComponent c : fXML11Components) { | 
 | 
                c.reset(this);  | 
 | 
            }  | 
 | 
        } // resetXML11()  | 
 | 
 | 
 | 
      | 
 | 
 | 
 | 
 | 
 | 
     */  | 
 | 
    protected void configureXML11Pipeline() { | 
 | 
        if (fCurrentDVFactory != fXML11DatatypeFactory) { | 
 | 
            fCurrentDVFactory = fXML11DatatypeFactory;  | 
 | 
            setProperty(DATATYPE_VALIDATOR_FACTORY, fCurrentDVFactory);  | 
 | 
        }  | 
 | 
        if (fCurrentDTDScanner != fXML11DTDScanner) { | 
 | 
            fCurrentDTDScanner = fXML11DTDScanner;  | 
 | 
            setProperty(DTD_SCANNER, fCurrentDTDScanner);  | 
 | 
                        setProperty(DTD_PROCESSOR, fXML11DTDProcessor);  | 
 | 
        }  | 
 | 
 | 
 | 
        fXML11DTDScanner.setDTDHandler(fXML11DTDProcessor);  | 
 | 
        fXML11DTDProcessor.setDTDSource(fXML11DTDScanner);  | 
 | 
        fXML11DTDProcessor.setDTDHandler(fDTDHandler);  | 
 | 
        if (fDTDHandler != null) { | 
 | 
            fDTDHandler.setDTDSource(fXML11DTDProcessor);  | 
 | 
        }  | 
 | 
 | 
 | 
        fXML11DTDScanner.setDTDContentModelHandler(fXML11DTDProcessor);  | 
 | 
        fXML11DTDProcessor.setDTDContentModelSource(fXML11DTDScanner);  | 
 | 
        fXML11DTDProcessor.setDTDContentModelHandler(fDTDContentModelHandler);  | 
 | 
        if (fDTDContentModelHandler != null) { | 
 | 
            fDTDContentModelHandler.setDTDContentModelSource(fXML11DTDProcessor);  | 
 | 
        }  | 
 | 
 | 
 | 
          | 
 | 
        if (fFeatures.get(NAMESPACES) == Boolean.TRUE) { | 
 | 
            if (fCurrentScanner != fXML11NSDocScanner) { | 
 | 
                fCurrentScanner = fXML11NSDocScanner;  | 
 | 
                setProperty(DOCUMENT_SCANNER, fXML11NSDocScanner);  | 
 | 
                setProperty(DTD_VALIDATOR, fXML11NSDTDValidator);  | 
 | 
            }  | 
 | 
 | 
 | 
            fXML11NSDocScanner.setDTDValidator(fXML11NSDTDValidator);  | 
 | 
            fXML11NSDocScanner.setDocumentHandler(fXML11NSDTDValidator);  | 
 | 
            fXML11NSDTDValidator.setDocumentSource(fXML11NSDocScanner);  | 
 | 
            fXML11NSDTDValidator.setDocumentHandler(fDocumentHandler);  | 
 | 
 | 
 | 
            if (fDocumentHandler != null) { | 
 | 
                fDocumentHandler.setDocumentSource(fXML11NSDTDValidator);  | 
 | 
            }  | 
 | 
            fLastComponent = fXML11NSDTDValidator;  | 
 | 
 | 
 | 
        } else { | 
 | 
                          | 
 | 
                          if (fXML11DocScanner == null) { | 
 | 
                                          | 
 | 
                                        fXML11DocScanner = new XML11DocumentScannerImpl();  | 
 | 
                                        addXML11Component(fXML11DocScanner);  | 
 | 
                                        fXML11DTDValidator = new XML11DTDValidator();  | 
 | 
                                        addXML11Component(fXML11DTDValidator);  | 
 | 
                          }  | 
 | 
            if (fCurrentScanner != fXML11DocScanner) { | 
 | 
                fCurrentScanner = fXML11DocScanner;  | 
 | 
                setProperty(DOCUMENT_SCANNER, fXML11DocScanner);  | 
 | 
                setProperty(DTD_VALIDATOR, fXML11DTDValidator);  | 
 | 
            }  | 
 | 
            fXML11DocScanner.setDocumentHandler(fXML11DTDValidator);  | 
 | 
            fXML11DTDValidator.setDocumentSource(fXML11DocScanner);  | 
 | 
            fXML11DTDValidator.setDocumentHandler(fDocumentHandler);  | 
 | 
 | 
 | 
            if (fDocumentHandler != null) { | 
 | 
                fDocumentHandler.setDocumentSource(fXML11DTDValidator);  | 
 | 
            }  | 
 | 
            fLastComponent = fXML11DTDValidator;  | 
 | 
        }  | 
 | 
 | 
 | 
    } // configureXML11Pipeline()  | 
 | 
 | 
 | 
      | 
 | 
    protected void configurePipeline() { | 
 | 
        if (fCurrentDVFactory != fDatatypeValidatorFactory) { | 
 | 
            fCurrentDVFactory = fDatatypeValidatorFactory;  | 
 | 
              | 
 | 
            setProperty(DATATYPE_VALIDATOR_FACTORY, fCurrentDVFactory);  | 
 | 
        }  | 
 | 
 | 
 | 
          | 
 | 
        if (fCurrentDTDScanner != fDTDScanner) { | 
 | 
            fCurrentDTDScanner = fDTDScanner;  | 
 | 
            setProperty(DTD_SCANNER, fCurrentDTDScanner);  | 
 | 
            setProperty(DTD_PROCESSOR, fDTDProcessor);  | 
 | 
        }  | 
 | 
        fDTDScanner.setDTDHandler(fDTDProcessor);  | 
 | 
        fDTDProcessor.setDTDSource(fDTDScanner);  | 
 | 
        fDTDProcessor.setDTDHandler(fDTDHandler);  | 
 | 
        if (fDTDHandler != null) { | 
 | 
            fDTDHandler.setDTDSource(fDTDProcessor);  | 
 | 
        }  | 
 | 
 | 
 | 
        fDTDScanner.setDTDContentModelHandler(fDTDProcessor);  | 
 | 
        fDTDProcessor.setDTDContentModelSource(fDTDScanner);  | 
 | 
        fDTDProcessor.setDTDContentModelHandler(fDTDContentModelHandler);  | 
 | 
        if (fDTDContentModelHandler != null) { | 
 | 
            fDTDContentModelHandler.setDTDContentModelSource(fDTDProcessor);  | 
 | 
        }  | 
 | 
 | 
 | 
          | 
 | 
        if (fFeatures.get(NAMESPACES) == Boolean.TRUE) { | 
 | 
            if (fCurrentScanner != fNamespaceScanner) { | 
 | 
                fCurrentScanner = fNamespaceScanner;  | 
 | 
                setProperty(DOCUMENT_SCANNER, fNamespaceScanner);  | 
 | 
                setProperty(DTD_VALIDATOR, fDTDValidator);  | 
 | 
            }  | 
 | 
            fNamespaceScanner.setDTDValidator(fDTDValidator);  | 
 | 
            fNamespaceScanner.setDocumentHandler(fDTDValidator);  | 
 | 
            fDTDValidator.setDocumentSource(fNamespaceScanner);  | 
 | 
            fDTDValidator.setDocumentHandler(fDocumentHandler);  | 
 | 
            if (fDocumentHandler != null) { | 
 | 
                fDocumentHandler.setDocumentSource(fDTDValidator);  | 
 | 
            }  | 
 | 
            fLastComponent = fDTDValidator;  | 
 | 
        } else { | 
 | 
              | 
 | 
            if (fNonNSScanner == null) { | 
 | 
                fNonNSScanner = new XMLDocumentScannerImpl();  | 
 | 
                fNonNSDTDValidator = new XMLDTDValidator();  | 
 | 
                  | 
 | 
                addComponent((XMLComponent) fNonNSScanner);  | 
 | 
                addComponent((XMLComponent) fNonNSDTDValidator);  | 
 | 
            }  | 
 | 
            if (fCurrentScanner != fNonNSScanner) { | 
 | 
                fCurrentScanner = fNonNSScanner;  | 
 | 
                setProperty(DOCUMENT_SCANNER, fNonNSScanner);  | 
 | 
                setProperty(DTD_VALIDATOR, fNonNSDTDValidator);  | 
 | 
            }  | 
 | 
 | 
 | 
            fNonNSScanner.setDocumentHandler(fNonNSDTDValidator);  | 
 | 
            fNonNSDTDValidator.setDocumentSource(fNonNSScanner);  | 
 | 
            fNonNSDTDValidator.setDocumentHandler(fDocumentHandler);  | 
 | 
            if (fDocumentHandler != null) { | 
 | 
                fDocumentHandler.setDocumentSource(fNonNSDTDValidator);  | 
 | 
            }  | 
 | 
            fLastComponent = fNonNSDTDValidator;  | 
 | 
        }  | 
 | 
 | 
 | 
    } // 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/dynamic  | 
 | 
            //   Allows the parser to validate a document only when it  | 
 | 
            //   contains a grammar. Validation is turned on/off based  | 
 | 
            //   on each document instance, automatically.  | 
 | 
              | 
 | 
            if (suffixLength == Constants.DYNAMIC_VALIDATION_FEATURE.length() &&  | 
 | 
                featureId.endsWith(Constants.DYNAMIC_VALIDATION_FEATURE)) { | 
 | 
                return FeatureState.RECOGNIZED;  | 
 | 
            }  | 
 | 
 | 
 | 
            //  | 
 | 
            // http://apache.org/xml/features/validation/default-attribute-values  | 
 | 
              | 
 | 
            if (suffixLength == Constants.DEFAULT_ATTRIBUTE_VALUES_FEATURE.length() &&  | 
 | 
                featureId.endsWith(Constants.DEFAULT_ATTRIBUTE_VALUES_FEATURE)) { | 
 | 
                  | 
 | 
                return FeatureState.NOT_SUPPORTED;  | 
 | 
            }  | 
 | 
            //  | 
 | 
            // http://apache.org/xml/features/validation/default-attribute-values  | 
 | 
              | 
 | 
            if (suffixLength == Constants.VALIDATE_CONTENT_MODELS_FEATURE.length() &&  | 
 | 
                featureId.endsWith(Constants.VALIDATE_CONTENT_MODELS_FEATURE)) { | 
 | 
                  | 
 | 
                return FeatureState.NOT_SUPPORTED;  | 
 | 
            }  | 
 | 
            //  | 
 | 
            // http://apache.org/xml/features/validation/nonvalidating/load-dtd-grammar  | 
 | 
              | 
 | 
            if (suffixLength == Constants.LOAD_DTD_GRAMMAR_FEATURE.length() &&  | 
 | 
                featureId.endsWith(Constants.LOAD_DTD_GRAMMAR_FEATURE)) { | 
 | 
                return FeatureState.RECOGNIZED;  | 
 | 
            }  | 
 | 
            //  | 
 | 
            // http://apache.org/xml/features/validation/nonvalidating/load-external-dtd  | 
 | 
              | 
 | 
            if (suffixLength == Constants.LOAD_EXTERNAL_DTD_FEATURE.length() &&  | 
 | 
                featureId.endsWith(Constants.LOAD_EXTERNAL_DTD_FEATURE)) { | 
 | 
                return FeatureState.RECOGNIZED;  | 
 | 
            }  | 
 | 
 | 
 | 
            //  | 
 | 
            // http://apache.org/xml/features/validation/default-attribute-values  | 
 | 
              | 
 | 
            if (suffixLength == Constants.VALIDATE_DATATYPES_FEATURE.length() &&  | 
 | 
                featureId.endsWith(Constants.VALIDATE_DATATYPES_FEATURE)) { | 
 | 
                return FeatureState.NOT_SUPPORTED;  | 
 | 
            }  | 
 | 
 | 
 | 
              | 
 | 
            if (suffixLength == Constants.PARSER_SETTINGS.length() &&  | 
 | 
                featureId.endsWith(Constants.PARSER_SETTINGS)) { | 
 | 
                return FeatureState.NOT_SUPPORTED;  | 
 | 
            }  | 
 | 
        }  | 
 | 
 | 
 | 
        //  | 
 | 
        // 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.DTD_SCANNER_PROPERTY.length() &&  | 
 | 
                propertyId.endsWith(Constants.DTD_SCANNER_PROPERTY)) { | 
 | 
                return PropertyState.RECOGNIZED;  | 
 | 
            }  | 
 | 
        }  | 
 | 
 | 
 | 
          | 
 | 
        if (propertyId.startsWith(Constants.SAX_PROPERTY_PREFIX)) { | 
 | 
            final int suffixLength = propertyId.length() - Constants.SAX_PROPERTY_PREFIX.length();  | 
 | 
 | 
 | 
            //  | 
 | 
            // http://xml.org/sax/properties/xml-string  | 
 | 
            // Value type: String  | 
 | 
            // Access: read-only  | 
 | 
            //   Get the literal string of characters associated with the  | 
 | 
            //   current event.  If the parser recognises and supports this  | 
 | 
            //   property but is not currently parsing text, it should return  | 
 | 
            //   null (this is a good way to check for availability before the  | 
 | 
            //   parse begins).  | 
 | 
              | 
 | 
            if (suffixLength == Constants.XML_STRING_PROPERTY.length() &&  | 
 | 
                propertyId.endsWith(Constants.XML_STRING_PROPERTY)) { | 
 | 
                // REVISIT - we should probably ask xml-dev for a precise  | 
 | 
                // definition of what this is actually supposed to return, and  | 
 | 
                  | 
 | 
                return PropertyState.NOT_SUPPORTED;  | 
 | 
            }  | 
 | 
        }  | 
 | 
 | 
 | 
        //  | 
 | 
        // Not recognized  | 
 | 
        //  | 
 | 
 | 
 | 
        return super.checkProperty(propertyId);  | 
 | 
 | 
 | 
    } // checkProperty(String)  | 
 | 
 | 
 | 
 | 
 | 
      | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
     */  | 
 | 
    protected void addComponent(XMLComponent component) { | 
 | 
 | 
 | 
          | 
 | 
        if (fComponents.contains(component)) { | 
 | 
            return;  | 
 | 
        }  | 
 | 
        fComponents.add(component);  | 
 | 
        addRecognizedParamsAndSetDefaults(component);  | 
 | 
 | 
 | 
    } // addComponent(XMLComponent)  | 
 | 
 | 
 | 
      | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
     */  | 
 | 
    protected void addCommonComponent(XMLComponent component) { | 
 | 
 | 
 | 
          | 
 | 
        if (fCommonComponents.contains(component)) { | 
 | 
            return;  | 
 | 
        }  | 
 | 
        fCommonComponents.add(component);  | 
 | 
        addRecognizedParamsAndSetDefaults(component);  | 
 | 
 | 
 | 
    } // addCommonComponent(XMLComponent)  | 
 | 
 | 
 | 
      | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
     */  | 
 | 
    protected void addXML11Component(XMLComponent component) { | 
 | 
 | 
 | 
          | 
 | 
        if (fXML11Components.contains(component)) { | 
 | 
            return;  | 
 | 
        }  | 
 | 
        fXML11Components.add(component);  | 
 | 
        addRecognizedParamsAndSetDefaults(component);  | 
 | 
 | 
 | 
    } // addXML11Component(XMLComponent)  | 
 | 
 | 
 | 
      | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
     */  | 
 | 
    protected void addRecognizedParamsAndSetDefaults(XMLComponent component) { | 
 | 
 | 
 | 
          | 
 | 
        String[] recognizedFeatures = component.getRecognizedFeatures();  | 
 | 
        addRecognizedFeatures(recognizedFeatures);  | 
 | 
 | 
 | 
          | 
 | 
        String[] recognizedProperties = component.getRecognizedProperties();  | 
 | 
        addRecognizedProperties(recognizedProperties);  | 
 | 
 | 
 | 
          | 
 | 
        if (recognizedFeatures != null) { | 
 | 
            for (int i = 0; i < recognizedFeatures.length; ++i) { | 
 | 
                String featureId = recognizedFeatures[i];  | 
 | 
                Boolean state = component.getFeatureDefault(featureId);  | 
 | 
                if (state != null) { | 
 | 
                      | 
 | 
                    if (!fFeatures.containsKey(featureId)) { | 
 | 
                        fFeatures.put(featureId, state);  | 
 | 
                        // For newly added components who recognize this feature  | 
 | 
                        // but did not offer a default value, we need to make  | 
 | 
                        // sure these components will get an opportunity to read  | 
 | 
                          | 
 | 
                        fConfigUpdated = true;  | 
 | 
                    }  | 
 | 
                }  | 
 | 
            }  | 
 | 
        }  | 
 | 
        if (recognizedProperties != null) { | 
 | 
            for (int i = 0; i < recognizedProperties.length; ++i) { | 
 | 
                String propertyId = recognizedProperties[i];  | 
 | 
                Object value = component.getPropertyDefault(propertyId);  | 
 | 
                if (value != null) { | 
 | 
                      | 
 | 
                    if (!fProperties.containsKey(propertyId)) { | 
 | 
                        fProperties.put(propertyId, value);  | 
 | 
                        // For newly added components who recognize this property  | 
 | 
                        // but did not offer a default value, we need to make  | 
 | 
                        // sure these components will get an opportunity to read  | 
 | 
                          | 
 | 
                        fConfigUpdated = true;  | 
 | 
                    }  | 
 | 
                }  | 
 | 
            }  | 
 | 
        }  | 
 | 
    }  | 
 | 
 | 
 | 
    private void initXML11Components() { | 
 | 
        if (!f11Initialized) { | 
 | 
 | 
 | 
              | 
 | 
            fXML11DatatypeFactory = DTDDVFactory.getInstance(XML11_DATATYPE_VALIDATOR_FACTORY);  | 
 | 
 | 
 | 
              | 
 | 
            fXML11DTDScanner = new XML11DTDScannerImpl();  | 
 | 
            addXML11Component(fXML11DTDScanner);  | 
 | 
            fXML11DTDProcessor = new XML11DTDProcessor();  | 
 | 
            addXML11Component(fXML11DTDProcessor);  | 
 | 
 | 
 | 
              | 
 | 
            fXML11NSDocScanner = new XML11NSDocumentScannerImpl();  | 
 | 
            addXML11Component(fXML11NSDocScanner);  | 
 | 
            fXML11NSDTDValidator = new XML11NSDTDValidator();  | 
 | 
            addXML11Component(fXML11NSDTDValidator);  | 
 | 
 | 
 | 
            f11Initialized = true;  | 
 | 
        }  | 
 | 
    }  | 
 | 
 | 
 | 
} // class XML11DTDConfiguration  |