⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xmldtdvalidator.java

📁 java1.6众多例子参考
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
/* * Copyright 1999-2005 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.impl.dtd;import com.sun.org.apache.xerces.internal.impl.Constants;import com.sun.org.apache.xerces.internal.impl.RevalidationHandler;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.dtd.models.ContentModelValidator;import com.sun.org.apache.xerces.internal.impl.dv.DTDDVFactory;import com.sun.org.apache.xerces.internal.impl.dv.DatatypeValidator;import com.sun.org.apache.xerces.internal.impl.dv.InvalidDatatypeValueException;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.impl.validation.ValidationState;import com.sun.org.apache.xerces.internal.util.SymbolTable;import com.sun.org.apache.xerces.internal.util.XMLChar;import com.sun.org.apache.xerces.internal.util.XMLSymbols;import com.sun.org.apache.xerces.internal.xni.Augmentations;import com.sun.org.apache.xerces.internal.xni.NamespaceContext;import com.sun.org.apache.xerces.internal.xni.QName;import com.sun.org.apache.xerces.internal.xni.XMLAttributes;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.XMLResourceIdentifier;import com.sun.org.apache.xerces.internal.xni.XMLString;import com.sun.org.apache.xerces.internal.xni.XNIException;import com.sun.org.apache.xerces.internal.xni.grammars.Grammar;import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarDescription;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.XMLDocumentFilter;import com.sun.org.apache.xerces.internal.xni.parser.XMLDocumentSource;/** * The DTD validator. The validator implements a document * filter: receiving document events from the scanner; validating * the content and structure; augmenting the InfoSet, if applicable; * and notifying the parser of the information resulting from the * validation process. * <p> Formerly, this component also handled DTD events and grammar construction. * To facilitate the development of a meaningful DTD grammar caching/preparsing * framework, this functionality has been moved into the XMLDTDLoader * class.  Therefore, this class no longer implements the DTDFilter * or DTDContentModelFilter interfaces. * <p> * This component requires the following features and properties from the * component manager that uses it: * <ul> *  <li>http://xml.org/sax/features/namespaces</li> *  <li>http://xml.org/sax/features/validation</li> *  <li>http://apache.org/xml/features/validation/dynamic</li> *  <li>http://apache.org/xml/properties/internal/symbol-table</li> *  <li>http://apache.org/xml/properties/internal/error-reporter</li> *  <li>http://apache.org/xml/properties/internal/grammar-pool</li> *  <li>http://apache.org/xml/properties/internal/datatype-validator-factory</li> * </ul> *  * @xerces.internal * * @author Eric Ye, IBM * @author Andy Clark, IBM * @author Jeffrey Rodriguez IBM * @author Neil Graham, IBM * * @version $Id: XMLDTDValidator.java,v 1.3 2005/09/26 13:02:18 sunithareddy Exp $ */public class XMLDTDValidator        implements XMLComponent, XMLDocumentFilter, XMLDTDValidatorFilter, RevalidationHandler {    //    // Constants    //    /** Symbol: "&lt;&lt;datatypes>>". */    /** Top level scope (-1). */    private static final int TOP_LEVEL_SCOPE = -1;    // feature identifiers    /** Feature identifier: namespaces. */    protected static final String NAMESPACES =    Constants.SAX_FEATURE_PREFIX + Constants.NAMESPACES_FEATURE;    /** Feature identifier: validation. */    protected static final String VALIDATION =    Constants.SAX_FEATURE_PREFIX + Constants.VALIDATION_FEATURE;    /** Feature identifier: dynamic validation. */    protected static final String DYNAMIC_VALIDATION =     Constants.XERCES_FEATURE_PREFIX + Constants.DYNAMIC_VALIDATION_FEATURE;    /** Feature identifier: warn on duplicate attdef */    protected static final String WARN_ON_DUPLICATE_ATTDEF =     Constants.XERCES_FEATURE_PREFIX +Constants.WARN_ON_DUPLICATE_ATTDEF_FEATURE;     	protected static final String PARSER_SETTINGS = 		Constants.XERCES_FEATURE_PREFIX + Constants.PARSER_SETTINGS;	    // property identifiers    /** Property identifier: symbol table. */    protected static final String SYMBOL_TABLE =        Constants.XERCES_PROPERTY_PREFIX + Constants.SYMBOL_TABLE_PROPERTY;    /** Property identifier: error reporter. */    protected static final String ERROR_REPORTER =        Constants.XERCES_PROPERTY_PREFIX + Constants.ERROR_REPORTER_PROPERTY;    /** Property identifier: grammar pool. */    protected static final String GRAMMAR_POOL =        Constants.XERCES_PROPERTY_PREFIX + Constants.XMLGRAMMAR_POOL_PROPERTY;    /** Property identifier: datatype validator factory. */    protected static final String DATATYPE_VALIDATOR_FACTORY =        Constants.XERCES_PROPERTY_PREFIX + Constants.DATATYPE_VALIDATOR_FACTORY_PROPERTY;    // property identifier:  ValidationManager    protected static final String VALIDATION_MANAGER =        Constants.XERCES_PROPERTY_PREFIX + Constants.VALIDATION_MANAGER_PROPERTY;    // recognized features and properties    /** Recognized features. */    private static final String[] RECOGNIZED_FEATURES = {        NAMESPACES,        VALIDATION,        DYNAMIC_VALIDATION    };    /** Feature defaults. */    private static final Boolean[] FEATURE_DEFAULTS = {        null,        null,        Boolean.FALSE,    };    /** Recognized properties. */    private static final String[] RECOGNIZED_PROPERTIES = {        SYMBOL_TABLE,               ERROR_REPORTER,        GRAMMAR_POOL,        DATATYPE_VALIDATOR_FACTORY,        VALIDATION_MANAGER    };    /** Property defaults. */    private static final Object[] PROPERTY_DEFAULTS = {        null,        null,        null,        null,        null,    };    // debugging    /** Compile to true to debug attributes. */    private static final boolean DEBUG_ATTRIBUTES = false;    /** Compile to true to debug element children. */    private static final boolean DEBUG_ELEMENT_CHILDREN = false;    //            // Data    //    // updated during reset    protected ValidationManager fValidationManager = null;        // validation state    protected ValidationState   fValidationState   = new ValidationState();    // features    /** Namespaces. */    protected boolean fNamespaces;    /** Validation. */    protected boolean fValidation;    /** Validation against only DTD */    protected boolean fDTDValidation;    /**      * Dynamic validation. This state of this feature is only useful when     * the validation feature is set to <code>true</code>.     */    protected boolean fDynamicValidation;    /** warn on duplicate attribute definition, this feature works only when validation is true */    protected boolean fWarnDuplicateAttdef;            // properties    /** Symbol table. */    protected SymbolTable fSymbolTable;    /** Error reporter. */    protected XMLErrorReporter fErrorReporter;    // the grammar pool    protected XMLGrammarPool fGrammarPool;    /** Grammar bucket. */    protected DTDGrammarBucket fGrammarBucket;    /* location of the document as passed in from startDocument call */    protected XMLLocator fDocLocation;    /** Namespace support. */    protected NamespaceContext fNamespaceContext = null;    /** Datatype validator factory. */    protected DTDDVFactory fDatatypeValidatorFactory;    // handlers    /** Document handler. */    protected XMLDocumentHandler fDocumentHandler;    protected XMLDocumentSource fDocumentSource;    // grammars    /** DTD Grammar. */    protected DTDGrammar fDTDGrammar;    // state    /** True if seen DOCTYPE declaration. */    protected boolean fSeenDoctypeDecl = false;    /** Perform validation. */    private boolean fPerformValidation;        /** Schema type: None, DTD, Schema */    private String fSchemaType;    // information regarding the current element    /** Current element name. */    private final QName fCurrentElement = new QName();    /** Current element index. */    private int fCurrentElementIndex = -1;    /** Current content spec type. */    private int fCurrentContentSpecType = -1;    /** The root element name. */    private final QName fRootElement = new QName();    private boolean fInCDATASection = false;    // element stack    /** Element index stack. */    private int[] fElementIndexStack = new int[8];    /** Content spec type stack. */    private int[] fContentSpecTypeStack = new int[8];    /** Element name stack. */    private QName[] fElementQNamePartsStack = new QName[8];    // children list and offset stack    /**      * Element children. This data structure is a growing stack that     * holds the children of elements from the root to the current     * element depth. This structure never gets "deeper" than the     * deepest element. Space is re-used once each element is closed.     * <p>     * <strong>Note:</strong> This is much more efficient use of memory     * than creating new arrays for each element depth.     * <p>     * <strong>Note:</strong> The use of this data structure is for     * validation "on the way out". If the validation model changes to     * "on the way in", then this data structure is not needed.     */    private QName[] fElementChildren = new QName[32];    /** Element children count. */    private int fElementChildrenLength = 0;    /**      * Element children offset stack. This stack refers to offsets     * into the <code>fElementChildren</code> array.     * @see #fElementChildren     */    private int[] fElementChildrenOffsetStack = new int[32];    /** Element depth. */    private int fElementDepth = -1;    // validation states    /** True if seen the root element. */    private boolean fSeenRootElement = false;    /** True if inside of element content. */    private boolean fInElementContent = false;    // temporary variables    /** Temporary element declaration. */    private XMLElementDecl fTempElementDecl = new XMLElementDecl();    /** Temporary atribute declaration. */    private XMLAttributeDecl fTempAttDecl = new XMLAttributeDecl();    /** Temporary entity declaration. */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -