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

📄 xsdhandler.java

📁 java1.6众多例子参考
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
/* * Copyright 1999-2005 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * *      http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package com.sun.org.apache.xerces.internal.impl.xs.traversers;import java.io.IOException;import java.io.StringReader;import java.util.ArrayList;import java.util.Hashtable;import java.util.Stack;import java.util.Vector;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.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.util.DOMUtil;import com.sun.org.apache.xerces.internal.parsers.SAXParser;import com.sun.org.apache.xerces.internal.parsers.XML11Configuration;import com.sun.org.apache.xerces.internal.util.DOMInputSource;import com.sun.org.apache.xerces.internal.util.DefaultErrorHandler;import com.sun.org.apache.xerces.internal.util.SAXInputSource;import com.sun.org.apache.xerces.internal.util.SecurityManager;import com.sun.org.apache.xerces.internal.util.SymbolTable;import com.sun.org.apache.xerces.internal.util.XMLSymbols;import com.sun.org.apache.xerces.internal.util.URI.MalformedURIException;import com.sun.org.apache.xerces.internal.xni.QName;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.grammars.XMLSchemaDescription;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 com.sun.org.apache.xerces.internal.xs.XSParticle;import org.w3c.dom.Document;import org.w3c.dom.Element;import org.w3c.dom.Node;import org.xml.sax.InputSource;import org.xml.sax.SAXException;import org.xml.sax.XMLReader;import org.xml.sax.helpers.XMLReaderFactory;/** * 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. * * @xerces.internal  * * @author Neil Graham, IBM * @author Pavani Mukthipudi, Sun Microsystems *  * @version $Id: XSDHandler.java,v 1.3.2.2 2007/10/20 17:56:44 joehw Exp $ */public class XSDHandler {        /** Feature identifier: validation. */    protected static final String VALIDATION =        Constants.SAX_FEATURE_PREFIX + Constants.VALIDATION_FEATURE;        /** feature identifier: XML Schema validation */    protected static final String XMLSCHEMA_VALIDATION =        Constants.XERCES_FEATURE_PREFIX + Constants.SCHEMA_VALIDATION_FEATURE;        /** 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;        /** Feature: generate synthetic annotations */    protected static final String GENERATE_SYNTHETIC_ANNOTATIONS =         Constants.XERCES_FEATURE_PREFIX + Constants.GENERATE_SYNTHETIC_ANNOTATIONS_FEATURE;        /** Feature identifier: validate annotations. */    protected static final String VALIDATE_ANNOTATIONS =        Constants.XERCES_FEATURE_PREFIX + Constants.VALIDATE_ANNOTATIONS_FEATURE;        /** Feature identifier: honour all schemaLocations */    protected static final String HONOUR_ALL_SCHEMALOCATIONS =       Constants.XERCES_FEATURE_PREFIX + Constants.HONOUR_ALL_SCHEMALOCATIONS_FEATURE;        /** Feature identifier: namespace prefixes. */    private static final String NAMESPACE_PREFIXES =        Constants.SAX_FEATURE_PREFIX + Constants.NAMESPACE_PREFIXES_FEATURE;        /** Feature identifier: string interning. */    protected static final String STRING_INTERNING =        Constants.SAX_FEATURE_PREFIX + Constants.STRING_INTERNING_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;    /** 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;        /** Property identifier: security manager. */    protected static final String SECURITY_MANAGER =        Constants.XERCES_PROPERTY_PREFIX + Constants.SECURITY_MANAGER_PROPERTY;        private static final String SECURE_PROCESSING =        Constants.XERCES_PROPERTY_PREFIX + Constants.SECURITY_MANAGER_PROPERTY;       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;       /**     * <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();    // Compensation for the above hashtables to locate XSDocumentInfo,     // Since we may take Schema Element directly, so can not get the    // corresponding XSDocumentInfo object just using above hashtables.    private Hashtable fUnparsedAttributeRegistrySub = new Hashtable();    private Hashtable fUnparsedAttributeGroupRegistrySub = new Hashtable();    private Hashtable fUnparsedElementRegistrySub = new Hashtable();    private Hashtable fUnparsedGroupRegistrySub = new Hashtable();    private Hashtable fUnparsedIdentityConstraintRegistrySub = new Hashtable();    private Hashtable fUnparsedNotationRegistrySub = new Hashtable();    private Hashtable fUnparsedTypeRegistrySub = 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;        //this hashtable is keyded on by DOM node objects.     //The table stores the hidden nodes    private Hashtable fHiddenNodes = null;        // convenience methods    private String null2EmptyString(String ns) {

⌨️ 快捷键说明

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