xsdhandler.java

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

JAVA
1,320
字号
/* * The Apache Software License, Version 1.1 * * * Copyright (c) 1999-2004 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.xs.traversers;import java.io.IOException;import java.util.Hashtable;import java.util.Stack;import java.util.Vector;import javax.xml.transform.Source;import javax.xml.transform.Transformer;import javax.xml.transform.TransformerException;import javax.xml.transform.TransformerFactory;import javax.xml.transform.dom.DOMSource;import javax.xml.transform.sax.SAXSource;import javax.xml.transform.sax.SAXResult;import javax.xml.transform.stream.StreamSource;import com.sun.org.apache.xerces.internal.impl.Constants;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.xs.SchemaGrammar;import com.sun.org.apache.xerces.internal.impl.xs.SchemaNamespaceSupport;import com.sun.org.apache.xerces.internal.impl.xs.SchemaSymbols;import com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaException;import com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader;import com.sun.org.apache.xerces.internal.impl.xs.XSComplexTypeDecl;import com.sun.org.apache.xerces.internal.impl.xs.XSDDescription;import com.sun.org.apache.xerces.internal.impl.xs.XSDeclarationPool;import com.sun.org.apache.xerces.internal.impl.xs.XSElementDecl;import com.sun.org.apache.xerces.internal.impl.xs.XSGrammarBucket;import com.sun.org.apache.xerces.internal.impl.xs.XSGroupDecl;import com.sun.org.apache.xerces.internal.impl.xs.XSMessageFormatter;import com.sun.org.apache.xerces.internal.impl.xs.XSModelGroupImpl;import com.sun.org.apache.xerces.internal.impl.xs.XSParticleDecl;import com.sun.org.apache.xerces.internal.impl.xs.opti.ElementImpl;import com.sun.org.apache.xerces.internal.impl.xs.opti.SchemaDOM;import com.sun.org.apache.xerces.internal.impl.xs.opti.SchemaDOMParser;import com.sun.org.apache.xerces.internal.impl.xs.opti.SchemaParsingConfig;import com.sun.org.apache.xerces.internal.impl.xs.util.SimpleLocator;import com.sun.org.apache.xerces.internal.parsers.SAXParser;import com.sun.org.apache.xerces.internal.util.DOMUtil;import com.sun.org.apache.xerces.internal.util.SecurityManager;import com.sun.org.apache.xerces.internal.util.SAX2XNI;import com.sun.org.apache.xerces.internal.util.SymbolTable;import com.sun.org.apache.xerces.internal.util.XMLInputSourceAdaptor;import com.sun.org.apache.xerces.internal.util.XMLSymbols;import com.sun.org.apache.xerces.internal.xni.QName;import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarPool;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.XMLEntityResolver;import com.sun.org.apache.xerces.internal.xni.parser.XMLErrorHandler;import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource;import com.sun.org.apache.xerces.internal.xs.XSObject;import org.w3c.dom.Document;import org.w3c.dom.Element;import org.w3c.dom.Node;import org.xml.sax.XMLReader;import org.xml.sax.SAXException;/** * The purpose of this class is to co-ordinate the construction of a * grammar object corresponding to a schema.  To do this, it must be * prepared to parse several schema documents (for instance if the * schema document originally referred to contains <include> or * <redefined> information items).  If any of the schemas imports a * schema, other grammars may be constructed as a side-effect. * * @author Neil Graham, IBM * @author Pavani Mukthipudi, Sun Microsystems * @version $Id: XSDHandler.java,v 1.75 2004/02/03 17:27:45 sandygao Exp $ */public class XSDHandler {    /** Feature identifier:  allow java encodings */    protected static final String ALLOW_JAVA_ENCODINGS =        Constants.XERCES_FEATURE_PREFIX + Constants.ALLOW_JAVA_ENCODINGS_FEATURE;    /** Feature identifier:  continue after fatal error */    protected static final String CONTINUE_AFTER_FATAL_ERROR =        Constants.XERCES_FEATURE_PREFIX + Constants.CONTINUE_AFTER_FATAL_ERROR_FEATURE;    /** Feature identifier:  allow java encodings */    protected static final String STANDARD_URI_CONFORMANT_FEATURE =        Constants.XERCES_FEATURE_PREFIX + Constants.STANDARD_URI_CONFORMANT_FEATURE;            /** Feature: disallow doctype*/    protected static final String DISALLOW_DOCTYPE =         Constants.XERCES_FEATURE_PREFIX + Constants.DISALLOW_DOCTYPE_DECL_FEATURE;          /** Property identifier: error handler. */    protected static final String ERROR_HANDLER =        Constants.XERCES_PROPERTY_PREFIX + Constants.ERROR_HANDLER_PROPERTY;    /** Property identifier: JAXP schema source. */    protected static final String JAXP_SCHEMA_SOURCE =        Constants.JAXP_PROPERTY_PREFIX + Constants.SCHEMA_SOURCE;    /** Property identifier: entity resolver. */    public static final String ENTITY_RESOLVER =    Constants.XERCES_PROPERTY_PREFIX + Constants.ENTITY_RESOLVER_PROPERTY;        private static final String SECURE_PROCESSING =        Constants.XERCES_PROPERTY_PREFIX + Constants.SECURITY_MANAGER_PROPERTY;        /** Property identifier: entity manager. */    protected static final String ENTITY_MANAGER =            Constants.XERCES_PROPERTY_PREFIX + Constants.ENTITY_MANAGER_PROPERTY;         /** Property identifier: error reporter. */    public static final String ERROR_REPORTER =        Constants.XERCES_PROPERTY_PREFIX + Constants.ERROR_REPORTER_PROPERTY;            /** Property identifier: grammar pool. */    public static final String XMLGRAMMAR_POOL =        Constants.XERCES_PROPERTY_PREFIX + Constants.XMLGRAMMAR_POOL_PROPERTY;            /** Property identifier: symbol table. */    public static final String SYMBOL_TABLE =        Constants.XERCES_PROPERTY_PREFIX + Constants.SYMBOL_TABLE_PROPERTY;            protected static final String SECURITY_MANAGER =        Constants.XERCES_PROPERTY_PREFIX + Constants.SECURITY_MANAGER_PROPERTY;     /**     * Property identifier: security manager.     */    protected static final boolean DEBUG_NODE_POOL = false;                                  // Data    // different sorts of declarations; should make lookup and    // traverser calling more efficient/less bulky.    final static int ATTRIBUTE_TYPE          = 1;    final static int ATTRIBUTEGROUP_TYPE     = 2;    final static int ELEMENT_TYPE            = 3;    final static int GROUP_TYPE              = 4;    final static int IDENTITYCONSTRAINT_TYPE = 5;    final static int NOTATION_TYPE           = 6;    final static int TYPEDECL_TYPE           = 7;    // this string gets appended to redefined names; it's purpose is to be    // as unlikely as possible to cause collisions.    public final static String REDEF_IDENTIFIER = "_fn3dktizrknc9pi";    //    //protected data that can be accessable by any traverser    // stores <notation> decl    protected Hashtable fNotationRegistry = new Hashtable();    protected XSDeclarationPool fDeclPool = null;    // are java encodings allowed?    private boolean fAllowJavaEncodings = false;        // enforcing strict uri?    private boolean fStrictURI = false;        /**     * <p>Security manager in effect.</p>     *      * <p>Protected to allow access by any traverser.</p>     */    protected SecurityManager fSecureProcessing = null;    // These tables correspond to the symbol spaces defined in the    // spec.    // They are keyed with a QName (that is, String("URI,localpart) and    // their values are nodes corresponding to the given name's decl.    // By asking the node for its ownerDocument and looking in    // XSDocumentInfoRegistry we can easily get the corresponding    // XSDocumentInfo object.    private Hashtable fUnparsedAttributeRegistry = new Hashtable();    private Hashtable fUnparsedAttributeGroupRegistry = new Hashtable();    private Hashtable fUnparsedElementRegistry = new Hashtable();    private Hashtable fUnparsedGroupRegistry = new Hashtable();    private Hashtable fUnparsedIdentityConstraintRegistry = new Hashtable();    private Hashtable fUnparsedNotationRegistry = new Hashtable();    private Hashtable fUnparsedTypeRegistry = new Hashtable();    // this is keyed with a documentNode (or the schemaRoot nodes    // contained in the XSDocumentInfo objects) and its value is the    // XSDocumentInfo object corresponding to that document.    // Basically, the function of this registry is to be a link    // between the nodes we fetch from calls to the fUnparsed*    // arrays and the XSDocumentInfos they live in.    private Hashtable fXSDocumentInfoRegistry = new Hashtable();    // this hashtable is keyed on by XSDocumentInfo objects.  Its values    // are Vectors containing the XSDocumentInfo objects <include>d,    // <import>ed or <redefine>d by the key XSDocumentInfo.    private Hashtable fDependencyMap = new Hashtable();    // this hashtable is keyed on by a target namespace.  Its values    // are Vectors containing namespaces imported by schema documents    // with the key target namespace.    // if an imprted schema has absent namespace, the value "null" is stored.    private Hashtable fImportMap = new Hashtable();    // all namespaces that imports other namespaces    // if the importing schema has absent namespace, empty string is stored.    // (because the key of a hashtable can't be null.)    private Vector fAllTNSs = new Vector();    // stores instance document mappings between namespaces and schema hints    private Hashtable fLocationPairs = null;    // convenience methods    private String null2EmptyString(String ns) {        return ns == null ? XMLSymbols.EMPTY_STRING : ns;    }

⌨️ 快捷键说明

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