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

📄 xmldtdloader.java

📁 java1.6众多例子参考
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* * The Apache Software License, Version 1.1 * * * Copyright (c) 1999-2003 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 com.sun.org.apache.xerces.internal.impl.Constants;import com.sun.org.apache.xerces.internal.impl.XMLDTDScannerImpl;import com.sun.org.apache.xerces.internal.impl.XMLErrorReporter;import com.sun.org.apache.xerces.internal.impl.XMLEntityManager;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.DefaultErrorHandler;import com.sun.org.apache.xerces.internal.xni.XNIException;import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarPool;import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarLoader;import com.sun.org.apache.xerces.internal.xni.grammars.Grammar;import com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException;import com.sun.org.apache.xerces.internal.xni.parser.XMLErrorHandler;import com.sun.org.apache.xerces.internal.xni.parser.XMLEntityResolver;import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource;import java.util.Locale;import java.io.IOException;import java.io.EOFException;/** * The DTD loader. The loader knows how to build grammars from XMLInputSources. * It extends the DTD processor in order to do this; it's * a separate class because DTD processors don't need to know how * to talk to the outside world in their role as instance-document * helpers. * <p> * This component requires the following features and properties.  It * know ho to set them if no one else does:from the * <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: XMLDTDLoader.java,v 1.1.2.1 2005/08/01 03:36:42 jeffsuttor Exp $ */public class XMLDTDLoader        extends XMLDTDProcessor         implements XMLGrammarLoader {    //    // Constants    //    // feature identifiers    /** Feature identifier: standard uri conformant feature. */    protected static final String STANDARD_URI_CONFORMANT_FEATURE =        Constants.XERCES_FEATURE_PREFIX + Constants.STANDARD_URI_CONFORMANT_FEATURE;    // recognized features:    private static final String[] RECOGNIZED_FEATURES = {        VALIDATION,        WARN_ON_DUPLICATE_ATTDEF,        NOTIFY_CHAR_REFS,        STANDARD_URI_CONFORMANT_FEATURE    };    // property identifiers    /** Property identifier: error handler. */    protected static final String ERROR_HANDLER =        Constants.XERCES_PROPERTY_PREFIX + Constants.ERROR_HANDLER_PROPERTY;    /** Property identifier: entity resolver. */    public static final String ENTITY_RESOLVER =        Constants.XERCES_PROPERTY_PREFIX + Constants.ENTITY_RESOLVER_PROPERTY;    /** Recognized properties. */    private static final String[] LOADER_RECOGNIZED_PROPERTIES = {        SYMBOL_TABLE,               ERROR_REPORTER,        ERROR_HANDLER,        ENTITY_RESOLVER,        GRAMMAR_POOL,               DTD_VALIDATOR,    };    // enforcing strict uri?    private boolean fStrictURI = false;    /** Entity resolver . */    protected XMLEntityResolver fEntityResolver;    // the scanner we use to actually read the DTD    protected XMLDTDScannerImpl fDTDScanner;    // the entity manager the scanner needs.      protected XMLEntityManager fEntityManager;    // what's our Locale?    protected Locale fLocale;    //    // Constructors    //    /** Deny default construction; we need a SymtolTable! */    public XMLDTDLoader() {        this(new SymbolTable());    } // <init>()    public XMLDTDLoader(SymbolTable symbolTable) {        this(symbolTable, null);    } // init(SymbolTable)    public XMLDTDLoader(SymbolTable symbolTable,                XMLGrammarPool grammarPool) {        this(symbolTable, grammarPool, null, new XMLEntityManager());    } // init(SymbolTable, XMLGrammarPool)    XMLDTDLoader(SymbolTable symbolTable,                XMLGrammarPool grammarPool, XMLErrorReporter errorReporter,                 XMLEntityResolver entityResolver) {        fSymbolTable = symbolTable;        fGrammarPool = grammarPool;        if(errorReporter == null) {            errorReporter = new XMLErrorReporter();            errorReporter.setProperty(ERROR_HANDLER, new DefaultErrorHandler());        }        fErrorReporter = errorReporter;        // Add XML message formatter if there isn't one.        if (fErrorReporter.getMessageFormatter(XMLMessageFormatter.XML_DOMAIN) == null) {            XMLMessageFormatter xmft = new XMLMessageFormatter();            fErrorReporter.putMessageFormatter(XMLMessageFormatter.XML_DOMAIN, xmft);            fErrorReporter.putMessageFormatter(XMLMessageFormatter.XMLNS_DOMAIN, xmft);        }        fEntityResolver = entityResolver;        if(fEntityResolver instanceof XMLEntityManager) {            fEntityManager = (XMLEntityManager)fEntityResolver;        } else {            fEntityManager = new XMLEntityManager();        }        fEntityManager.setProperty(Constants.XERCES_PROPERTY_PREFIX + Constants.ERROR_REPORTER_PROPERTY, errorReporter);        fDTDScanner = new XMLDTDScannerImpl(fSymbolTable, fErrorReporter, fEntityManager);        fDTDScanner.setDTDHandler(this);        fDTDScanner.setDTDContentModelHandler(this);        reset();    } // init(SymbolTable, XMLGrammarPool, XMLErrorReporter, XMLEntityResolver)    // XMLGrammarLoader methods    /**     * 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

⌨️ 快捷键说明

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