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

📄 xmldtdprocessor.java

📁 java1.6众多例子参考
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
/* * The Apache Software License, Version 1.1 * * * Copyright (c) 1999-2002 The Apache Software Foundation.   * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright *    notice, this list of conditions and the following disclaimer.  * * 2. Redistributions in binary form must reproduce the above copyright *    notice, this list of conditions and the following disclaimer in *    the documentation and/or other materials provided with the *    distribution. * * 3. The end-user documentation included with the redistribution, *    if any, must include the following acknowledgment:   *       "This product includes software developed by the *        Apache Software Foundation (http://www.apache.org/)." *    Alternately, this acknowledgment may appear in the software itself, *    if and wherever such third-party acknowledgments normally appear. * * 4. The names "Xerces" and "Apache Software Foundation" must *    not be used to endorse or promote products derived from this *    software without prior written permission. For written  *    permission, please contact apache@apache.org. * * 5. Products derived from this software may not be called "Apache", *    nor may "Apache" appear in their name, without prior written *    permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation and was * originally based on software copyright (c) 1999, International * Business Machines, Inc., http://www.apache.org.  For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. */package com.sun.org.apache.xerces.internal.impl.dtd;import java.util.Enumeration;import java.util.Hashtable;import java.util.Locale;import java.util.StringTokenizer;import java.util.Vector;import com.sun.org.apache.xerces.internal.impl.Constants;import com.sun.org.apache.xerces.internal.impl.XMLErrorReporter;import com.sun.org.apache.xerces.internal.impl.msg.XMLMessageFormatter;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.XMLDTDContentModelHandler;import com.sun.org.apache.xerces.internal.xni.XMLDTDHandler;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.XMLDTDContentModelFilter;import com.sun.org.apache.xerces.internal.xni.parser.XMLDTDContentModelSource;import com.sun.org.apache.xerces.internal.xni.parser.XMLDTDFilter;import com.sun.org.apache.xerces.internal.xni.parser.XMLDTDSource;/** * The DTD processor. The processor implements a DTD * filter: receiving DTD events from the DTD scanner; validating * the content and structure; building a grammar, if applicable; * and notifying the DTDHandler of the information resulting from the * process. * <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://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 Neil Graham, IBM * * @version $Id: XMLDTDProcessor.java,v 1.1.2.1 2005/08/01 03:36:41 jeffsuttor Exp $ */public class XMLDTDProcessor        implements XMLComponent, XMLDTDFilter, XMLDTDContentModelFilter {    //    // Constants    //    /** Top level scope (-1). */    private static final int TOP_LEVEL_SCOPE = -1;    // feature identifiers    /** Feature identifier: validation. */    protected static final String VALIDATION =        Constants.SAX_FEATURE_PREFIX + Constants.VALIDATION_FEATURE;    /** Feature identifier: notify character references. */    protected static final String NOTIFY_CHAR_REFS =        Constants.XERCES_FEATURE_PREFIX + Constants.NOTIFY_CHAR_REFS_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: validator . */    protected static final String DTD_VALIDATOR =        Constants.XERCES_PROPERTY_PREFIX + Constants.DTD_VALIDATOR_PROPERTY;    // recognized features and properties    /** Recognized features. */    private static final String[] RECOGNIZED_FEATURES = {        VALIDATION,        WARN_ON_DUPLICATE_ATTDEF,        NOTIFY_CHAR_REFS,    };    /** Feature defaults. */    private static final Boolean[] FEATURE_DEFAULTS = {        null,        Boolean.FALSE,        null,    };    /** Recognized properties. */    private static final String[] RECOGNIZED_PROPERTIES = {        SYMBOL_TABLE,               ERROR_REPORTER,        GRAMMAR_POOL,               DTD_VALIDATOR,    };    /** Property defaults. */    private static final Object[] PROPERTY_DEFAULTS = {        null,        null,        null,        null,    };    // debugging    //            // Data    //    // features    /** Validation. */    protected boolean fValidation;    /** Validation against only DTD */    protected boolean fDTDValidation;    /** 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;    /** Grammar bucket. */    protected DTDGrammarBucket fGrammarBucket;    // the validator to which we look for our grammar bucket (the    // validator needs to hold the bucket so that it can initialize    // the grammar with details like whether it's for a standalone document...    protected XMLDTDValidator fValidator;    // the grammar pool we'll try to add the grammar to:    protected XMLGrammarPool fGrammarPool;    // what's our Locale?    protected Locale fLocale;    // handlers    /** DTD handler. */    protected XMLDTDHandler fDTDHandler;    /** DTD source. */    protected XMLDTDSource fDTDSource;    /** DTD content model handler. */    protected XMLDTDContentModelHandler fDTDContentModelHandler;    /** DTD content model source. */    protected XMLDTDContentModelSource fDTDContentModelSource;    // grammars    /** DTD Grammar. */    protected DTDGrammar fDTDGrammar;    // state    /** Perform validation. */    private boolean fPerformValidation;    /** True if in an ignore conditional section of the DTD. */    protected boolean fInDTDIgnore;    // information regarding the current element    // validation states    /** Mixed. */    private boolean fMixed;    // temporary variables    /** Temporary entity declaration. */    private XMLEntityDecl fEntityDecl = new XMLEntityDecl();    /** Notation declaration hash. */    private Hashtable fNDataDeclNotations = new Hashtable();    /** DTD element declaration name. */    private String fDTDElementDeclName = null;    /** Mixed element type "hash". */    private Vector fMixedElementTypes = new Vector();    /** Element declarations in DTD. */    private Vector fDTDElementDecls = new Vector();    // to check for duplicate ID or ANNOTATION attribute declare in    // ATTLIST, and misc VCs    /** ID attribute names. */    private Hashtable fTableOfIDAttributeNames;    /** NOTATION attribute names. */    private Hashtable fTableOfNOTATIONAttributeNames;    /** NOTATION enumeration values. */    private Hashtable fNotationEnumVals;    //    // Constructors    //    /** Default constructor. */    public XMLDTDProcessor() {        // initialize data    } // <init>()    //    // 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 {               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            reset();            return;        }        // sax features        try {            fValidation = componentManager.getFeature(VALIDATION);        } catch (XMLConfigurationException e) {            fValidation = false;

⌨️ 快捷键说明

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