/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed 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 java.io.IOException;
import java.util.Locale;
import com.sun.org.apache.xerces.internal.impl.Constants;
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.XMLEntityManager;
import com.sun.org.apache.xerces.internal.impl.XMLErrorReporter;
import com.sun.org.apache.xerces.internal.impl.XMLNamespaceBinder;
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.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.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.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.XMLInputSource;
import com.sun.org.apache.xerces.internal.xni.parser.XMLPullParserConfiguration;
/**
* This is the DTD-only parser configuration. It extends the basic
* configuration with a standard set of parser components appropriate
* to DTD-centric validation. Since
* the Xerces2 reference implementation document and DTD scanner
* implementations are capable of acting as pull parsers, this
* configuration implements the
* XMLPullParserConfiguration
interface.
*
* In addition to the features and properties recognized by the base * parser configuration, this class recognizes these additional * features and properties: *
* 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.
*/
public DTDConfiguration(SymbolTable symbolTable,
XMLGrammarPool grammarPool) {
this(symbolTable, grammarPool, null);
} //
* 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.
*/
public DTDConfiguration(SymbolTable symbolTable,
XMLGrammarPool grammarPool,
XMLComponentManager parentSettings) {
super(symbolTable, parentSettings);
// add default recognized features
final String[] recognizedFeatures = {
//WARN_ON_DUPLICATE_ATTDEF, // from XMLDTDScannerImpl
//WARN_ON_UNDECLARED_ELEMDEF, // from XMLDTDScannerImpl
//ALLOW_JAVA_ENCODINGS, // from XMLEntityManager
CONTINUE_AFTER_FATAL_ERROR,
LOAD_EXTERNAL_DTD, // from XMLDTDScannerImpl
//NOTIFY_BUILTIN_REFS, // from XMLDocumentFragmentScannerImpl
//NOTIFY_CHAR_REFS, // from XMLDocumentFragmentScannerImpl
//WARN_ON_DUPLICATE_ENTITYDEF, // from XMLEntityManager
};
addRecognizedFeatures(recognizedFeatures);
// set state for default features
//setFeature(WARN_ON_DUPLICATE_ATTDEF, false); // from XMLDTDScannerImpl
//setFeature(WARN_ON_UNDECLARED_ELEMDEF, false); // from XMLDTDScannerImpl
//setFeature(ALLOW_JAVA_ENCODINGS, false); // from XMLEntityManager
setFeature(CONTINUE_AFTER_FATAL_ERROR, false);
setFeature(LOAD_EXTERNAL_DTD, true); // from XMLDTDScannerImpl
//setFeature(NOTIFY_BUILTIN_REFS, false); // from XMLDocumentFragmentScannerImpl
//setFeature(NOTIFY_CHAR_REFS, false); // from XMLDocumentFragmentScannerImpl
//setFeature(WARN_ON_DUPLICATE_ENTITYDEF, false); // from XMLEntityManager
// add default recognized properties
final String[] recognizedProperties = {
ERROR_REPORTER,
ENTITY_MANAGER,
DOCUMENT_SCANNER,
DTD_SCANNER,
DTD_PROCESSOR,
DTD_VALIDATOR,
NAMESPACE_BINDER,
XMLGRAMMAR_POOL,
DATATYPE_VALIDATOR_FACTORY,
VALIDATION_MANAGER,
JAXP_SCHEMA_SOURCE,
JAXP_SCHEMA_LANGUAGE,
LOCALE
};
addRecognizedProperties(recognizedProperties);
fGrammarPool = grammarPool;
if(fGrammarPool != null){
setProperty(XMLGRAMMAR_POOL, fGrammarPool);
}
fEntityManager = createEntityManager();
setProperty(ENTITY_MANAGER, fEntityManager);
addComponent(fEntityManager);
fErrorReporter = createErrorReporter();
fErrorReporter.setDocumentLocator(fEntityManager.getEntityScanner());
setProperty(ERROR_REPORTER, fErrorReporter);
addComponent(fErrorReporter);
fScanner = createDocumentScanner();
setProperty(DOCUMENT_SCANNER, fScanner);
if (fScanner instanceof XMLComponent) {
addComponent((XMLComponent)fScanner);
}
fDTDScanner = createDTDScanner();
if (fDTDScanner != null) {
setProperty(DTD_SCANNER, fDTDScanner);
if (fDTDScanner instanceof XMLComponent) {
addComponent((XMLComponent)fDTDScanner);
}
}
fDTDProcessor = createDTDProcessor();
if (fDTDProcessor != null) {
setProperty(DTD_PROCESSOR, fDTDProcessor);
if (fDTDProcessor instanceof XMLComponent) {
addComponent((XMLComponent)fDTDProcessor);
}
}
fDTDValidator = createDTDValidator();
if (fDTDValidator != null) {
setProperty(DTD_VALIDATOR, fDTDValidator);
addComponent(fDTDValidator);
}
fNamespaceBinder = createNamespaceBinder();
if (fNamespaceBinder != null) {
setProperty(NAMESPACE_BINDER, fNamespaceBinder);
addComponent(fNamespaceBinder);
}
fDatatypeValidatorFactory = createDatatypeValidatorFactory();
if (fDatatypeValidatorFactory != null) {
setProperty(DATATYPE_VALIDATOR_FACTORY,
fDatatypeValidatorFactory);
}
fValidationManager = createValidationManager();
if (fValidationManager != null) {
setProperty (VALIDATION_MANAGER, fValidationManager);
}
// add message formatters
if (fErrorReporter.getMessageFormatter(XMLMessageFormatter.XML_DOMAIN) == null) {
XMLMessageFormatter xmft = new XMLMessageFormatter();
fErrorReporter.putMessageFormatter(XMLMessageFormatter.XML_DOMAIN, xmft);
fErrorReporter.putMessageFormatter(XMLMessageFormatter.XMLNS_DOMAIN, xmft);
}
// set locale
try {
setLocale(Locale.getDefault());
}
catch (XNIException e) {
// do nothing
// REVISIT: What is the right thing to do? -Ac
}
} //