xmldtdvalidator.java

来自「JAVA的一些源码 JAVA2 STANDARD EDITION DEVELO」· Java 代码 · 共 1,655 行 · 第 1/5 页

JAVA
1,655
字号
     * <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. */    private XMLEntityDecl fEntityDecl = new XMLEntityDecl();    /** Temporary qualified name. */    private QName fTempQName = new QName();    /** Temporary string buffers. */    private StringBuffer fBuffer = new StringBuffer();    // symbols: general    // attribute validators    /** Datatype validator: ID. */    protected DatatypeValidator fValID;    /** Datatype validator: IDREF. */    protected DatatypeValidator fValIDRef;    /** Datatype validator: IDREFS. */    protected DatatypeValidator fValIDRefs;    /** Datatype validator: ENTITY. */    protected DatatypeValidator fValENTITY;    /** Datatype validator: ENTITIES. */    protected DatatypeValidator fValENTITIES;    /** Datatype validator: NMTOKEN. */    protected DatatypeValidator fValNMTOKEN;    /** Datatype validator: NMTOKENS. */    protected DatatypeValidator fValNMTOKENS;    /** Datatype validator: NOTATION. */    protected DatatypeValidator fValNOTATION;    // to check for duplicate ID or ANNOTATION attribute declare in    // ATTLIST, and misc VCs    //    // Constructors    //    /** Default constructor. */    public XMLDTDValidator() {        // initialize data        for (int i = 0; i < fElementQNamePartsStack.length; i++) {            fElementQNamePartsStack[i] = new QName();        }        fGrammarBucket = new DTDGrammarBucket();    } // <init>()    DTDGrammarBucket getGrammarBucket() {        return fGrammarBucket;    } // getGrammarBucket():  DTDGrammarBucket    //    // XMLComponent methods    //    /*     * Resets the component. The component can query the component manager     * about any features and properties that affect the operation of the     * component.     *      * @param componentManager The component manager.     *     * @throws SAXException Thrown by component on finitialization error.     *                      For example, if a feature or property is     *                      required for the operation of the component, the     *                      component manager may throw a      *                      SAXNotRecognizedException or a     *                      SAXNotSupportedException.     */    public void reset(XMLComponentManager componentManager)    throws XMLConfigurationException {        // clear grammars        fDTDGrammar = null;        fSeenDoctypeDecl = false;        fInCDATASection = false;        // initialize state        fSeenRootElement = false;        fInElementContent = false;        fCurrentElementIndex = -1;        fCurrentContentSpecType = -1;        fRootElement.clear();		fValidationState.resetIDTables();				fGrammarBucket.clear();		fElementDepth = -1;                      		fElementChildrenLength = 0;                boolean parser_settings;        try {        	parser_settings = componentManager.getFeature(PARSER_SETTINGS);  	        }        catch (XMLConfigurationException e){        	parser_settings = true;        }                if (!parser_settings){        	// parser settings have not been changed			fValidationManager.addValidationState(fValidationState);        	return;        }        // sax features        try {            fNamespaces = componentManager.getFeature(NAMESPACES);        }        catch (XMLConfigurationException e) {            fNamespaces = true;        }        try {            fValidation = componentManager.getFeature(VALIDATION);        }        catch (XMLConfigurationException e) {            fValidation = false;        }        try {            fDTDValidation = !(componentManager.getFeature(Constants.XERCES_FEATURE_PREFIX + Constants.SCHEMA_VALIDATION_FEATURE));        }        catch (XMLConfigurationException e) {            // must be in a schema-less configuration!            fDTDValidation = true;        }        // Xerces features        try {            fDynamicValidation = componentManager.getFeature(DYNAMIC_VALIDATION);        }        catch (XMLConfigurationException e) {            fDynamicValidation = false;        }                try {            fWarnDuplicateAttdef = componentManager.getFeature(WARN_ON_DUPLICATE_ATTDEF);        }        catch (XMLConfigurationException e) {            fWarnDuplicateAttdef = false;        }                try {            fSchemaType = (String)componentManager.getProperty (Constants.JAXP_PROPERTY_PREFIX             + Constants.SCHEMA_LANGUAGE);                   }        catch (XMLConfigurationException e){            fSchemaType = null;        }        fValidationManager= (ValidationManager)componentManager.getProperty(VALIDATION_MANAGER);        fValidationManager.addValidationState(fValidationState);              fValidationState.setUsingNamespaces(fNamespaces);                // get needed components        fErrorReporter = (XMLErrorReporter)componentManager.getProperty(Constants.XERCES_PROPERTY_PREFIX+Constants.ERROR_REPORTER_PROPERTY);        fSymbolTable = (SymbolTable)componentManager.getProperty(Constants.XERCES_PROPERTY_PREFIX+Constants.SYMBOL_TABLE_PROPERTY);        try {            fGrammarPool= (XMLGrammarPool)componentManager.getProperty(GRAMMAR_POOL);        } catch (XMLConfigurationException e) {            fGrammarPool = null;        }        fDatatypeValidatorFactory = (DTDDVFactory)componentManager.getProperty(Constants.XERCES_PROPERTY_PREFIX + Constants.DATATYPE_VALIDATOR_FACTORY_PROPERTY);		init();    } // reset(XMLComponentManager)    /**     * Returns a list of feature identifiers that are recognized by     * this component. This method may return null if no features     * are recognized by this component.     */    public String[] getRecognizedFeatures() {        return (String[])(RECOGNIZED_FEATURES.clone());    } // getRecognizedFeatures():String[]    /**     * Sets the state of a feature. This method is called by the component     * manager any time after reset when a feature changes state.      * <p>     * <strong>Note:</strong> Components should silently ignore features     * that do not affect the operation of the component.     *      * @param featureId The feature identifier.     * @param state     The state of the feature.     *     * @throws SAXNotRecognizedException The component should not throw     *                                   this exception.     * @throws SAXNotSupportedException The component should not throw     *                                  this exception.     */    public void setFeature(String featureId, boolean state)    throws XMLConfigurationException {    } // setFeature(String,boolean)    /**     * Returns a list of property identifiers that are recognized by     * this component. This method may return null if no properties     * are recognized by this component.     */    public String[] getRecognizedProperties() {        return (String[])(RECOGNIZED_PROPERTIES.clone());    } // getRecognizedProperties():String[]    /**     * Sets the value of a property. This method is called by the component     * manager any time after reset when a property changes value.      * <p>     * <strong>Note:</strong> Components should silently ignore properties     * that do not affect the operation of the component.     *      * @param propertyId The property identifier.     * @param value      The value of the property.     *     * @throws SAXNotRecognizedException The component should not throw     *                                   this exception.     * @throws SAXNotSupportedException The component should not throw     *                                  this exception.     */    public void setProperty(String propertyId, Object value)    throws XMLConfigurationException {    } // setProperty(String,Object)    /**      * Returns the default state for a feature, or null if this     * component does not want to report a default value for this     * feature.     *     * @param featureId The feature identifier.     *     * @since Xerces 2.2.0     */    public Boolean getFeatureDefault(String featureId) {        for (int i = 0; i < RECOGNIZED_FEATURES.length; i++) {            if (RECOGNIZED_FEATURES[i].equals(featureId)) {                return FEATURE_DEFAULTS[i];            }        }        return null;    } // getFeatureDefault(String):Boolean    /**      * Returns the default state for a property, or null if this     * component does not want to report a default value for this     * property.      *     * @param propertyId The property identifier.     *     * @since Xerces 2.2.0     */    public Object getPropertyDefault(String propertyId) {        for (int i = 0; i < RECOGNIZED_PROPERTIES.length; i++) {            if (RECOGNIZED_PROPERTIES[i].equals(propertyId)) {                return PROPERTY_DEFAULTS[i];            }        }        return null;    } // getPropertyDefault(String):Object    //    // XMLDocumentSource methods    //    /** Sets the document handler to receive information about the document. */    public void setDocumentHandler(XMLDocumentHandler documentHandler) {        fDocumentHandler = documentHandler;    } // setDocumentHandler(XMLDocumentHandler)    /** Returns the document handler */    public XMLDocumentHandler getDocumentHandler() {        return fDocumentHandler;    } // getDocumentHandler():  XMLDocumentHandler    //    // XMLDocumentHandler methods    //    /** Sets the document source */    public void setDocumentSource(XMLDocumentSource source){        fDocumentSource = source;    } // setDocumentSource    /** Returns the document source */    public XMLDocumentSource getDocumentSource (){        return fDocumentSource;    } // getDocumentSource

⌨️ 快捷键说明

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