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

📄 xmldtdvalidator.java

📁 java1.6众多例子参考
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
    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    /**     * The start of the document.     *     * @param locator The system identifier of the entity if the entity     *                 is external, null otherwise.     * @param encoding The auto-detected IANA encoding name of the entity     *                 stream. This value will be null in those situations     *                 where the entity encoding is not auto-detected (e.g.     *                 internal entities or a document entity that is     *                 parsed from a java.io.Reader).     * @param namespaceContext     *                 The namespace context in effect at the     *                 start of this document.     *                 This object represents the current context.     *                 Implementors of this class are responsible     *                 for copying the namespace bindings from the     *                 the current context (and its parent contexts)     *                 if that information is important.     * @param augs   Additional information that may include infoset augmentations     *     * @throws XNIException Thrown by handler to signal an error.     */    public void startDocument(XMLLocator locator, String encoding,                               NamespaceContext namespaceContext, Augmentations augs)     throws XNIException {        // call handlers        // get initial grammars        if(fGrammarPool != null) {            Grammar [] grammars = fGrammarPool.retrieveInitialGrammarSet(XMLGrammarDescription.XML_DTD);            for(int i = 0; i<grammars.length; i++) {                fGrammarBucket.putGrammar((DTDGrammar)grammars[i]);            }        }        fDocLocation = locator;        fNamespaceContext = namespaceContext;

⌨️ 快捷键说明

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