xml11configuration.java
来自「JAVA的一些源码 JAVA2 STANDARD EDITION DEVELO」· Java 代码 · 共 1,528 行 · 第 1/5 页
JAVA
1,528 行
protected ArrayList fCommonComponents = null; /** The document handler. */ protected XMLDocumentHandler fDocumentHandler; /** The DTD handler. */ protected XMLDTDHandler fDTDHandler; /** The DTD content model handler. */ protected XMLDTDContentModelHandler fDTDContentModelHandler; /** Last component in the document pipeline */ protected XMLDocumentSource fLastComponent; /** * True if a parse is in progress. This state is needed because * some features/properties cannot be set while parsing (e.g. * validation and namespaces). */ protected boolean fParseInProgress = false; /** fConfigUpdated is set to true if there has been any change to the configuration settings, * i.e a feature or a property was changed. */ protected boolean fConfigUpdated = false; // // XML 1.0 components // /** The XML 1.0 Datatype validator factory. */ protected DTDDVFactory fDatatypeValidatorFactory; /** The XML 1.0 Document scanner that does namespace binding. */ protected XMLNSDocumentScannerImpl fNamespaceScanner; /** The XML 1.0 Non-namespace implementation of scanner */ protected XMLDocumentScannerImpl fNonNSScanner; /** The XML 1.0 DTD Validator: binds namespaces */ protected XMLDTDValidator fDTDValidator; /** The XML 1.0 DTD Validator that does not bind namespaces */ protected XMLDTDValidator fNonNSDTDValidator; /** The XML 1.0 DTD scanner. */ protected XMLDTDScanner fDTDScanner; /** The XML 1.0 DTD Processor . */ protected XMLDTDProcessor fDTDProcessor; // // XML 1.1 components // /** The XML 1.1 datatype factory. **/ protected DTDDVFactory fXML11DatatypeFactory = null; /** The XML 1.1 document scanner that does namespace binding. **/ protected XML11NSDocumentScannerImpl fXML11NSDocScanner = null; /** The XML 1.1 document scanner that does not do namespace binding. **/ protected XML11DocumentScannerImpl fXML11DocScanner = null; /** The XML 1.1 DTD validator that does namespace binding. **/ protected XML11NSDTDValidator fXML11NSDTDValidator = null; /** The XML 1.1 DTD validator that does not do namespace binding. **/ protected XML11DTDValidator fXML11DTDValidator = null; /** The XML 1.1 DTD scanner. **/ protected XML11DTDScannerImpl fXML11DTDScanner = null; /** The XML 1.1 DTD processor. **/ protected XML11DTDProcessor fXML11DTDProcessor = null; // // Common components // /** Grammar pool. */ protected XMLGrammarPool fGrammarPool; /** Error reporter. */ protected XMLErrorReporter fErrorReporter; /** Entity manager. */ protected XMLEntityManager fEntityManager; /** XML Schema Validator. */ protected XMLSchemaValidator fSchemaValidator; /** Current scanner */ protected XMLDocumentScanner fCurrentScanner; /** Current Datatype validator factory. */ protected DTDDVFactory fCurrentDVFactory; /** Current DTD scanner. */ protected XMLDTDScanner fCurrentDTDScanner; /** Flag indiciating whether XML11 components have been initialized. */ private boolean f11Initialized = false; // // Constructors // /** Default constructor. */ public XML11Configuration() { this(null, null, null); } // <init>() /** * Constructs a parser configuration using the specified symbol table. * * @param symbolTable The symbol table to use. */ public XML11Configuration(SymbolTable symbolTable) { this(symbolTable, null, null); } // <init>(SymbolTable) /** * Constructs a parser configuration using the specified symbol table and * grammar pool. * <p> * <strong>REVISIT:</strong> * 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 XML11Configuration(SymbolTable symbolTable, XMLGrammarPool grammarPool) { this(symbolTable, grammarPool, null); } // <init>(SymbolTable,XMLGrammarPool) /** * Constructs a parser configuration using the specified symbol table, * grammar pool, and parent settings. * <p> * <strong>REVISIT:</strong> * 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 XML11Configuration( SymbolTable symbolTable, XMLGrammarPool grammarPool, XMLComponentManager parentSettings) { super(parentSettings); // create a vector to hold all the components in use // XML 1.0 specialized components fComponents = new ArrayList(); // XML 1.1 specialized components fXML11Components = new ArrayList(); // Common components for XML 1.1. and XML 1.0 fCommonComponents = new ArrayList(); // create storage for recognized features and properties fRecognizedFeatures = new ArrayList(); fRecognizedProperties = new ArrayList(); // create table for features and properties fFeatures = new HashMap(); fProperties = new HashMap(); // add default recognized features final String[] recognizedFeatures = { CONTINUE_AFTER_FATAL_ERROR, LOAD_EXTERNAL_DTD, // from XMLDTDScannerImpl VALIDATION, NAMESPACES, NORMALIZE_DATA, SCHEMA_ELEMENT_DEFAULT, SCHEMA_AUGMENT_PSVI, // 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, EXTERNAL_GENERAL_ENTITIES, EXTERNAL_PARAMETER_ENTITIES, PARSER_SETTINGS, EXPAND_URIS, XML_VERSION_SUPPORT, NORMALIZAION_CHECKS }; addRecognizedFeatures(recognizedFeatures); // set state for default features 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(SCHEMA_ELEMENT_DEFAULT, Boolean.TRUE); fFeatures.put(NORMALIZE_DATA, Boolean.TRUE); fFeatures.put(SCHEMA_AUGMENT_PSVI, Boolean.TRUE); fFeatures.put(PARSER_SETTINGS, Boolean.TRUE); fFeatures.put(EXPAND_URIS, Boolean.TRUE); fFeatures.put(XML_VERSION_SUPPORT, Boolean.TRUE); fFeatures.put(NORMALIZAION_CHECKS, Boolean.FALSE); // add default recognized properties 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, SCHEMA_VALIDATOR, XML_STRING, XMLGRAMMAR_POOL, JAXP_SCHEMA_SOURCE, JAXP_SCHEMA_LANGUAGE, // 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); 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(); // 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 } fConfigUpdated = false; } // <init>(SymbolTable,XMLGrammarPool) // // Public methods // /** * Sets the input source for the document to parse. * * @param inputSource The document's input source. * * @exception XMLConfigurationException Thrown if there is a * configuration error when initializing the * parser. * @exception IOException Thrown on I/O error. * * @see #parse(boolean) */ 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
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?