src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDHandler.java
author joehw
Wed, 18 Oct 2017 13:25:49 -0700
changeset 47359 e1a6c0168741
parent 47312 d4f959806fe9
child 47477 115ed64c7822
permissions -rw-r--r--
8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked Reviewed-by: lancea, rriggs, mullan
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
     1
/*
45853
bfa06be36a17 8181154: Fix lint warnings in JAXP repo: deprecation
joehw
parents: 42247
diff changeset
     2
 * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
     3
 * @LastModified: Oct 2017
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
     4
 */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
     5
/*
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 25868
diff changeset
     6
 * Licensed to the Apache Software Foundation (ASF) under one or more
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 25868
diff changeset
     7
 * contributor license agreements.  See the NOTICE file distributed with
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 25868
diff changeset
     8
 * this work for additional information regarding copyright ownership.
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 25868
diff changeset
     9
 * The ASF licenses this file to You under the Apache License, Version 2.0
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 25868
diff changeset
    10
 * (the "License"); you may not use this file except in compliance with
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 25868
diff changeset
    11
 * the License.  You may obtain a copy of the License at
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    12
 *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    13
 *      http://www.apache.org/licenses/LICENSE-2.0
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    14
 *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    15
 * Unless required by applicable law or agreed to in writing, software
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    16
 * distributed under the License is distributed on an "AS IS" BASIS,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    17
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    18
 * See the License for the specific language governing permissions and
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    19
 * limitations under the License.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    20
 */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    21
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    22
package com.sun.org.apache.xerces.internal.impl.xs.traversers;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    23
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    24
import com.sun.org.apache.xerces.internal.impl.Constants;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    25
import com.sun.org.apache.xerces.internal.impl.XMLEntityManager;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    26
import com.sun.org.apache.xerces.internal.impl.XMLErrorReporter;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    27
import com.sun.org.apache.xerces.internal.impl.dv.SchemaDVFactory;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    28
import com.sun.org.apache.xerces.internal.impl.dv.xs.XSSimpleTypeDecl;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    29
import com.sun.org.apache.xerces.internal.impl.xs.SchemaGrammar;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    30
import com.sun.org.apache.xerces.internal.impl.xs.SchemaNamespaceSupport;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    31
import com.sun.org.apache.xerces.internal.impl.xs.SchemaSymbols;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    32
import com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaException;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    33
import com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    34
import com.sun.org.apache.xerces.internal.impl.xs.XSAttributeDecl;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    35
import com.sun.org.apache.xerces.internal.impl.xs.XSAttributeGroupDecl;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    36
import com.sun.org.apache.xerces.internal.impl.xs.XSComplexTypeDecl;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    37
import com.sun.org.apache.xerces.internal.impl.xs.XSDDescription;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    38
import com.sun.org.apache.xerces.internal.impl.xs.XSDeclarationPool;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    39
import com.sun.org.apache.xerces.internal.impl.xs.XSElementDecl;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    40
import com.sun.org.apache.xerces.internal.impl.xs.XSGrammarBucket;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    41
import com.sun.org.apache.xerces.internal.impl.xs.XSGroupDecl;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    42
import com.sun.org.apache.xerces.internal.impl.xs.XSMessageFormatter;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    43
import com.sun.org.apache.xerces.internal.impl.xs.XSModelGroupImpl;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    44
import com.sun.org.apache.xerces.internal.impl.xs.XSNotationDecl;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    45
import com.sun.org.apache.xerces.internal.impl.xs.XSParticleDecl;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    46
import com.sun.org.apache.xerces.internal.impl.xs.identity.IdentityConstraint;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    47
import com.sun.org.apache.xerces.internal.impl.xs.opti.ElementImpl;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    48
import com.sun.org.apache.xerces.internal.impl.xs.opti.SchemaDOMParser;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    49
import com.sun.org.apache.xerces.internal.impl.xs.opti.SchemaParsingConfig;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    50
import com.sun.org.apache.xerces.internal.impl.xs.util.SimpleLocator;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    51
import com.sun.org.apache.xerces.internal.impl.xs.util.XSInputSource;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    52
import com.sun.org.apache.xerces.internal.parsers.SAXParser;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    53
import com.sun.org.apache.xerces.internal.parsers.XML11Configuration;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    54
import com.sun.org.apache.xerces.internal.util.DOMInputSource;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    55
import com.sun.org.apache.xerces.internal.util.DOMUtil;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    56
import com.sun.org.apache.xerces.internal.util.DefaultErrorHandler;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    57
import com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    58
import com.sun.org.apache.xerces.internal.util.SAXInputSource;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    59
import com.sun.org.apache.xerces.internal.util.StAXInputSource;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    60
import com.sun.org.apache.xerces.internal.util.StAXLocationWrapper;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    61
import com.sun.org.apache.xerces.internal.util.SymbolHash;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    62
import com.sun.org.apache.xerces.internal.util.SymbolTable;
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 25868
diff changeset
    63
import com.sun.org.apache.xerces.internal.util.URI.MalformedURIException;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    64
import com.sun.org.apache.xerces.internal.util.XMLSymbols;
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 25868
diff changeset
    65
import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
18890
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 17534
diff changeset
    66
import com.sun.org.apache.xerces.internal.utils.XMLSecurityPropertyManager;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    67
import com.sun.org.apache.xerces.internal.xni.QName;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    68
import com.sun.org.apache.xerces.internal.xni.XNIException;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    69
import com.sun.org.apache.xerces.internal.xni.grammars.Grammar;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    70
import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarDescription;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    71
import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarPool;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    72
import com.sun.org.apache.xerces.internal.xni.grammars.XMLSchemaDescription;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    73
import com.sun.org.apache.xerces.internal.xni.parser.XMLComponentManager;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    74
import com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    75
import com.sun.org.apache.xerces.internal.xni.parser.XMLEntityResolver;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    76
import com.sun.org.apache.xerces.internal.xni.parser.XMLErrorHandler;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    77
import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    78
import com.sun.org.apache.xerces.internal.xni.parser.XMLParseException;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    79
import com.sun.org.apache.xerces.internal.xs.StringList;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    80
import com.sun.org.apache.xerces.internal.xs.XSAttributeDeclaration;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    81
import com.sun.org.apache.xerces.internal.xs.XSAttributeGroupDefinition;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    82
import com.sun.org.apache.xerces.internal.xs.XSAttributeUse;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    83
import com.sun.org.apache.xerces.internal.xs.XSConstants;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    84
import com.sun.org.apache.xerces.internal.xs.XSElementDeclaration;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    85
import com.sun.org.apache.xerces.internal.xs.XSModelGroup;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    86
import com.sun.org.apache.xerces.internal.xs.XSModelGroupDefinition;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    87
import com.sun.org.apache.xerces.internal.xs.XSNamedMap;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    88
import com.sun.org.apache.xerces.internal.xs.XSObject;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    89
import com.sun.org.apache.xerces.internal.xs.XSObjectList;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    90
import com.sun.org.apache.xerces.internal.xs.XSParticle;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    91
import com.sun.org.apache.xerces.internal.xs.XSSimpleTypeDefinition;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    92
import com.sun.org.apache.xerces.internal.xs.XSTerm;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    93
import com.sun.org.apache.xerces.internal.xs.XSTypeDefinition;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    94
import com.sun.org.apache.xerces.internal.xs.datatypes.ObjectList;
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 25868
diff changeset
    95
import java.io.IOException;
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 25868
diff changeset
    96
import java.io.StringReader;
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 25868
diff changeset
    97
import java.util.ArrayList;
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 25868
diff changeset
    98
import java.util.Collections;
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 25868
diff changeset
    99
import java.util.HashMap;
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
   100
import java.util.List;
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 25868
diff changeset
   101
import java.util.Locale;
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 25868
diff changeset
   102
import java.util.Map;
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 25868
diff changeset
   103
import java.util.Stack;
17534
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 12457
diff changeset
   104
import javax.xml.XMLConstants;
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 39080
diff changeset
   105
import javax.xml.catalog.CatalogFeatures;
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 25868
diff changeset
   106
import javax.xml.stream.XMLEventReader;
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 25868
diff changeset
   107
import javax.xml.stream.XMLStreamException;
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 25868
diff changeset
   108
import javax.xml.stream.XMLStreamReader;
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 39080
diff changeset
   109
import jdk.xml.internal.JdkXmlUtils;
47312
d4f959806fe9 8187593: Cleanup: removing SecuritySupport files
joehw
parents: 47216
diff changeset
   110
import jdk.xml.internal.SecuritySupport;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   111
import org.w3c.dom.Document;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   112
import org.w3c.dom.Element;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   113
import org.w3c.dom.Node;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   114
import org.xml.sax.InputSource;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   115
import org.xml.sax.SAXException;
18890
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 17534
diff changeset
   116
import org.xml.sax.SAXNotRecognizedException;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   117
import org.xml.sax.SAXParseException;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   118
import org.xml.sax.XMLReader;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   119
import org.xml.sax.helpers.XMLReaderFactory;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   120
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   121
/**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   122
 * The purpose of this class is to co-ordinate the construction of a
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   123
 * grammar object corresponding to a schema.  To do this, it must be
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   124
 * prepared to parse several schema documents (for instance if the
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   125
 * schema document originally referred to contains <include> or
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   126
 * <redefined> information items).  If any of the schemas imports a
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   127
 * schema, other grammars may be constructed as a side-effect.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   128
 *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   129
 * @xerces.internal
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   130
 *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   131
 * @author Neil Graham, IBM
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   132
 * @author Pavani Mukthipudi, Sun Microsystems
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   133
 *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   134
 */
45853
bfa06be36a17 8181154: Fix lint warnings in JAXP repo: deprecation
joehw
parents: 42247
diff changeset
   135
@SuppressWarnings("deprecation") //org.xml.sax.helpers.XMLReaderFactory
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   136
public class XSDHandler {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   137
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   138
    /** Feature identifier: validation. */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   139
    protected static final String VALIDATION =
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   140
        Constants.SAX_FEATURE_PREFIX + Constants.VALIDATION_FEATURE;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   141
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   142
    /** feature identifier: XML Schema validation */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   143
    protected static final String XMLSCHEMA_VALIDATION =
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   144
        Constants.XERCES_FEATURE_PREFIX + Constants.SCHEMA_VALIDATION_FEATURE;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   145
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   146
    /** Feature identifier:  allow java encodings */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   147
    protected static final String ALLOW_JAVA_ENCODINGS =
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   148
        Constants.XERCES_FEATURE_PREFIX + Constants.ALLOW_JAVA_ENCODINGS_FEATURE;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   149
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   150
    /** Feature identifier:  continue after fatal error */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   151
    protected static final String CONTINUE_AFTER_FATAL_ERROR =
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   152
        Constants.XERCES_FEATURE_PREFIX + Constants.CONTINUE_AFTER_FATAL_ERROR_FEATURE;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   153
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   154
    /** Feature identifier:  allow java encodings */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   155
    protected static final String STANDARD_URI_CONFORMANT_FEATURE =
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   156
        Constants.XERCES_FEATURE_PREFIX + Constants.STANDARD_URI_CONFORMANT_FEATURE;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   157
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   158
    /** Feature: disallow doctype*/
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   159
    protected static final String DISALLOW_DOCTYPE =
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   160
        Constants.XERCES_FEATURE_PREFIX + Constants.DISALLOW_DOCTYPE_DECL_FEATURE;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   161
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   162
    /** Feature: generate synthetic annotations */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   163
    protected static final String GENERATE_SYNTHETIC_ANNOTATIONS =
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   164
        Constants.XERCES_FEATURE_PREFIX + Constants.GENERATE_SYNTHETIC_ANNOTATIONS_FEATURE;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   165
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   166
    /** Feature identifier: validate annotations. */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   167
    protected static final String VALIDATE_ANNOTATIONS =
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   168
        Constants.XERCES_FEATURE_PREFIX + Constants.VALIDATE_ANNOTATIONS_FEATURE;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   169
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   170
    /** Feature identifier: honour all schemaLocations */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   171
    protected static final String HONOUR_ALL_SCHEMALOCATIONS =
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   172
      Constants.XERCES_FEATURE_PREFIX + Constants.HONOUR_ALL_SCHEMALOCATIONS_FEATURE;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   173
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   174
    /** Feature identifier: namespace growth */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   175
    protected static final String NAMESPACE_GROWTH =
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   176
      Constants.XERCES_FEATURE_PREFIX + Constants.NAMESPACE_GROWTH_FEATURE;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   177
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   178
    /** Feature identifier: tolerate duplicates */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   179
    protected static final String TOLERATE_DUPLICATES =
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   180
      Constants.XERCES_FEATURE_PREFIX + Constants.TOLERATE_DUPLICATES_FEATURE;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   181
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   182
    /** Feature identifier: namespace prefixes. */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   183
    private static final String NAMESPACE_PREFIXES =
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   184
        Constants.SAX_FEATURE_PREFIX + Constants.NAMESPACE_PREFIXES_FEATURE;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   185
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   186
    /** Feature identifier: string interning. */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   187
    protected static final String STRING_INTERNING =
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   188
        Constants.SAX_FEATURE_PREFIX + Constants.STRING_INTERNING_FEATURE;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   189
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   190
    /** Property identifier: error handler. */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   191
    protected static final String ERROR_HANDLER =
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   192
        Constants.XERCES_PROPERTY_PREFIX + Constants.ERROR_HANDLER_PROPERTY;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   193
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   194
    /** Property identifier: JAXP schema source. */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   195
    protected static final String JAXP_SCHEMA_SOURCE =
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   196
        Constants.JAXP_PROPERTY_PREFIX + Constants.SCHEMA_SOURCE;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   197
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   198
    /** Property identifier: entity resolver. */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   199
    public static final String ENTITY_RESOLVER =
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   200
        Constants.XERCES_PROPERTY_PREFIX + Constants.ENTITY_RESOLVER_PROPERTY;
36146
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
   201
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   202
    /** Property identifier: entity manager. */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   203
    protected static final String ENTITY_MANAGER =
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   204
        Constants.XERCES_PROPERTY_PREFIX + Constants.ENTITY_MANAGER_PROPERTY;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   205
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   206
    /** Property identifier: error reporter. */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   207
    public static final String ERROR_REPORTER =
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   208
        Constants.XERCES_PROPERTY_PREFIX + Constants.ERROR_REPORTER_PROPERTY;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   209
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   210
    /** Property identifier: grammar pool. */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   211
    public static final String XMLGRAMMAR_POOL =
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   212
        Constants.XERCES_PROPERTY_PREFIX + Constants.XMLGRAMMAR_POOL_PROPERTY;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   213
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   214
    /** Property identifier: symbol table. */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   215
    public static final String SYMBOL_TABLE =
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   216
        Constants.XERCES_PROPERTY_PREFIX + Constants.SYMBOL_TABLE_PROPERTY;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   217
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   218
    /** Property identifier: security manager. */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   219
    protected static final String SECURITY_MANAGER =
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   220
        Constants.XERCES_PROPERTY_PREFIX + Constants.SECURITY_MANAGER_PROPERTY;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   221
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   222
    /** Property identifier: locale. */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   223
    protected static final String LOCALE =
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   224
        Constants.XERCES_PROPERTY_PREFIX + Constants.LOCALE_PROPERTY;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   225
36146
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
   226
    /** Property identifier: Security property manager. */
18890
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 17534
diff changeset
   227
    private static final String XML_SECURITY_PROPERTY_MANAGER =
36146
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
   228
        Constants.XML_SECURITY_PROPERTY_MANAGER;
17534
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 12457
diff changeset
   229
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   230
    protected static final boolean DEBUG_NODE_POOL = false;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   231
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   232
    // Data
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   233
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   234
    // different sorts of declarations; should make lookup and
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   235
    // traverser calling more efficient/less bulky.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   236
    final static int ATTRIBUTE_TYPE          = 1;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   237
    final static int ATTRIBUTEGROUP_TYPE     = 2;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   238
    final static int ELEMENT_TYPE            = 3;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   239
    final static int GROUP_TYPE              = 4;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   240
    final static int IDENTITYCONSTRAINT_TYPE = 5;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   241
    final static int NOTATION_TYPE           = 6;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   242
    final static int TYPEDECL_TYPE           = 7;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   243
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   244
    // this string gets appended to redefined names; it's purpose is to be
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   245
    // as unlikely as possible to cause collisions.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   246
    public final static String REDEF_IDENTIFIER = "_fn3dktizrknc9pi";
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   247
36146
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
   248
    //protected data that can be accessible by any traverser
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   249
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   250
    protected XSDeclarationPool fDeclPool = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   251
36146
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
   252
    // the Security manager in effect.
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
   253
    protected XMLSecurityManager fSecurityManager = null;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   254
17534
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 12457
diff changeset
   255
    private String fAccessExternalSchema;
18890
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 17534
diff changeset
   256
    private String fAccessExternalDTD;
17534
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 12457
diff changeset
   257
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   258
    // These tables correspond to the symbol spaces defined in the
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   259
    // spec.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   260
    // They are keyed with a QName (that is, String("URI,localpart) and
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   261
    // their values are nodes corresponding to the given name's decl.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   262
    // By asking the node for its ownerDocument and looking in
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   263
    // XSDocumentInfoRegistry we can easily get the corresponding
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   264
    // XSDocumentInfo object.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   265
    private boolean registryEmpty = true;
36146
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
   266
    private Map<String, Element> fUnparsedAttributeRegistry = new HashMap<>();
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
   267
    private Map<String, Element> fUnparsedAttributeGroupRegistry =  new HashMap<>();
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
   268
    private Map<String, Element> fUnparsedElementRegistry =  new HashMap<>();
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
   269
    private Map<String, Element> fUnparsedGroupRegistry =  new HashMap<>();
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
   270
    private Map<String, Element> fUnparsedIdentityConstraintRegistry =  new HashMap<>();
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
   271
    private Map<String, Element> fUnparsedNotationRegistry =  new HashMap<>();
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
   272
    private Map<String, Element> fUnparsedTypeRegistry =  new HashMap<>();
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 25868
diff changeset
   273
    // Compensation for the above maps to locate XSDocumentInfo,
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   274
    // Since we may take Schema Element directly, so can not get the
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 25868
diff changeset
   275
    // corresponding XSDocumentInfo object just using above maps.
36146
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
   276
    private Map<String, XSDocumentInfo> fUnparsedAttributeRegistrySub =  new HashMap<>();
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
   277
    private Map<String, XSDocumentInfo> fUnparsedAttributeGroupRegistrySub =  new HashMap<>();
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
   278
    private Map<String, XSDocumentInfo> fUnparsedElementRegistrySub =  new HashMap<>();
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
   279
    private Map<String, XSDocumentInfo> fUnparsedGroupRegistrySub =  new HashMap<>();
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
   280
    private Map<String, XSDocumentInfo> fUnparsedIdentityConstraintRegistrySub =  new HashMap<>();
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
   281
    private Map<String, XSDocumentInfo> fUnparsedNotationRegistrySub =  new HashMap<>();
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
   282
    private Map<String, XSDocumentInfo> fUnparsedTypeRegistrySub =  new HashMap<>();
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   283
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   284
    // Stores XSDocumentInfo (keyed by component name), to check for duplicate
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   285
    // components declared within the same xsd document
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
   286
    @SuppressWarnings({"rawtypes", "unchecked"})
36146
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
   287
    private Map<String, XSDocumentInfo> fUnparsedRegistriesExt[] = new HashMap[] {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   288
        null,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   289
        null, // ATTRIBUTE_TYPE
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   290
        null, // ATTRIBUTEGROUP_TYPE
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   291
        null, // ELEMENT_TYPE
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   292
        null, // GROUP_TYPE
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   293
        null, // IDENTITYCONSTRAINT_TYPE
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   294
        null, // NOTATION_TYPE
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   295
        null, // TYPEDECL_TYPE
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   296
    };
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   297
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 25868
diff changeset
   298
    // this map is keyed on by XSDocumentInfo objects.  Its values
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   299
    // are Vectors containing the XSDocumentInfo objects <include>d,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   300
    // <import>ed or <redefine>d by the key XSDocumentInfo.
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
   301
    private Map<XSDocumentInfo, List<XSDocumentInfo>> fDependencyMap = new HashMap<>();
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   302
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 25868
diff changeset
   303
    // this map is keyed on by a target namespace.  Its values
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   304
    // are Vectors containing namespaces imported by schema documents
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   305
    // with the key target namespace.
36146
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
   306
    // if an imported schema has absent namespace, the value "null" is stored.
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
   307
    private Map<String, List<String>> fImportMap = new HashMap<> ();
36146
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
   308
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   309
    // all namespaces that imports other namespaces
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   310
    // if the importing schema has absent namespace, empty string is stored.
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 25868
diff changeset
   311
    // (because the key of a map can't be null.)
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
   312
    private List<String> fAllTNSs = new ArrayList<>();
36146
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
   313
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   314
    // stores instance document mappings between namespaces and schema hints
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 25868
diff changeset
   315
    private Map<String, XMLSchemaLoader.LocationArray> fLocationPairs = null;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   316
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   317
    // Records which nodes are hidden when the input is a DOMInputSource.
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 25868
diff changeset
   318
    Map<Node, String> fHiddenNodes = null;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   319
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   320
    // convenience methods
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   321
    private String null2EmptyString(String ns) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   322
        return ns == null ? XMLSymbols.EMPTY_STRING : ns;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   323
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   324
    private String emptyString2Null(String ns) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   325
        return ns == XMLSymbols.EMPTY_STRING ? null : ns;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   326
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   327
    // use Schema Element to lookup the SystemId.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   328
    private String doc2SystemId(Element ele) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   329
        String documentURI = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   330
        /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   331
         * REVISIT: Casting until DOM Level 3 interfaces are available. -- mrglavas
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   332
         */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   333
        if(ele.getOwnerDocument() instanceof com.sun.org.apache.xerces.internal.impl.xs.opti.SchemaDOM){
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   334
            documentURI = ((com.sun.org.apache.xerces.internal.impl.xs.opti.SchemaDOM) ele.getOwnerDocument()).getDocumentURI();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   335
        }
36146
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
   336
        return documentURI != null ? documentURI : fDoc2SystemId.get(ele);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   337
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   338
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   339
    // This vector stores strings which are combinations of the
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   340
    // publicId and systemId of the inputSource corresponding to a
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   341
    // schema document.  This combination is used so that the user's
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   342
    // EntityResolver can provide a consistent way of identifying a
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   343
    // schema document that is included in multiple other schemas.
36146
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
   344
    private Map<XSDKey, Element> fTraversed = new HashMap<>();
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   345
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 25868
diff changeset
   346
    // this map contains a mapping from Schema Element to its systemId
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   347
    // this is useful to resolve a uri relative to the referring document
36146
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
   348
    private Map<Element, String> fDoc2SystemId = new HashMap<>();
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   349
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   350
    // the primary XSDocumentInfo we were called to parse
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   351
    private XSDocumentInfo fRoot = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   352
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 25868
diff changeset
   353
    // This map's job is to act as a link between the Schema Element and its
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   354
    // XSDocumentInfo object.
42247
52fafb950d5a 8158619: Very large CDATA section in XML document causes OOME
joehw
parents: 39907
diff changeset
   355
    private Map<Element, XSDocumentInfo> fDoc2XSDocumentMap = new HashMap<>();
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   356
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   357
    // map between <redefine> elements and the XSDocumentInfo
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   358
    // objects that correspond to the documents being redefined.
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
   359
    private Map<Element, XSDocumentInfo> fRedefine2XSDMap = null;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   360
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   361
    // map between <redefine> elements and the namespace support
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
   362
    private Map<Element, SchemaNamespaceSupport> fRedefine2NSSupport = null;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   363
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   364
    // these objects store a mapping between the names of redefining
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   365
    // groups/attributeGroups and the groups/AttributeGroups which
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   366
    // they redefine by restriction (implicitly).  It is up to the
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   367
    // Group and AttributeGroup traversers to check these restrictions for
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   368
    // validity.
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
   369
    private final Map<String, String> fRedefinedRestrictedAttributeGroupRegistry = new HashMap<>();
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
   370
    private final Map<String, String> fRedefinedRestrictedGroupRegistry = new HashMap<>();
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   371
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   372
    // a variable storing whether the last schema document
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   373
    // processed (by getSchema) was a duplicate.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   374
    private boolean fLastSchemaWasDuplicate;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   375
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   376
    // validate annotations feature
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   377
    private boolean fValidateAnnotations = false;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   378
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   379
    //handle multiple import feature
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   380
    private boolean fHonourAllSchemaLocations = false;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   381
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   382
    //handle namespace growth feature
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   383
    boolean fNamespaceGrowth = false;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   384
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   385
    // handle tolerate duplicates feature
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   386
    boolean fTolerateDuplicates = false;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   387
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   388
    // the XMLErrorReporter
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   389
    private XMLErrorReporter fErrorReporter;
36146
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
   390
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
   391
    // the XMLErrorHandler
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
   392
    private XMLErrorHandler fErrorHandler;
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
   393
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
   394
    // the Locale
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
   395
    private Locale fLocale;
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
   396
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
   397
    // the XMLEntityManager
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 39080
diff changeset
   398
    private XMLEntityManager fEntityManager;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   399
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   400
    // the XSAttributeChecker
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   401
    private XSAttributeChecker fAttributeChecker;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   402
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   403
    // the symbol table
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   404
    private SymbolTable fSymbolTable;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   405
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   406
    // the GrammarResolver
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   407
    private XSGrammarBucket fGrammarBucket;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   408
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   409
    // the Grammar description
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   410
    private XSDDescription fSchemaGrammarDescription;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   411
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   412
    // the Grammar Pool
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   413
    private XMLGrammarPool fGrammarPool;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   414
36146
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
   415
    // the security property manager
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
   416
    private XMLSecurityPropertyManager fSecurityPropertyMgr = null;
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
   417
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 39080
diff changeset
   418
    /** indicate whether Catalog should be used for resolving external resources */
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 39080
diff changeset
   419
    private boolean fUseCatalog = true;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 39080
diff changeset
   420
    private String fCatalogFile;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 39080
diff changeset
   421
    private String fDefer;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 39080
diff changeset
   422
    private String fPrefer;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 39080
diff changeset
   423
    private String fResolve;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 39080
diff changeset
   424
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   425
    //************ Traversers **********
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   426
    XSDAttributeGroupTraverser fAttributeGroupTraverser;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   427
    XSDAttributeTraverser fAttributeTraverser;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   428
    XSDComplexTypeTraverser fComplexTypeTraverser;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   429
    XSDElementTraverser fElementTraverser;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   430
    XSDGroupTraverser fGroupTraverser;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   431
    XSDKeyrefTraverser fKeyrefTraverser;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   432
    XSDNotationTraverser fNotationTraverser;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   433
    XSDSimpleTypeTraverser fSimpleTypeTraverser;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   434
    XSDUniqueOrKeyTraverser fUniqueOrKeyTraverser;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   435
    XSDWildcardTraverser fWildCardTraverser;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   436
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   437
    SchemaDVFactory fDVFactory;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   438
    SchemaDOMParser fSchemaParser;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   439
    SchemaContentHandler fXSContentHandler;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   440
    StAXSchemaParser fStAXSchemaParser;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   441
    XML11Configuration fAnnotationValidator;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   442
    XSAnnotationGrammarPool fGrammarBucketAdapter;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   443
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   444
    // these data members are needed for the deferred traversal
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   445
    // of local elements.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   446
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   447
    // the initial size of the array to store deferred local elements
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   448
    private static final int INIT_STACK_SIZE = 30;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   449
    // the incremental size of the array to store deferred local elements
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   450
    private static final int INC_STACK_SIZE  = 10;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   451
    // current position of the array (# of deferred local elements)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   452
    private int fLocalElemStackPos = 0;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   453
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   454
    private XSParticleDecl[] fParticle = new XSParticleDecl[INIT_STACK_SIZE];
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   455
    private Element[] fLocalElementDecl = new Element[INIT_STACK_SIZE];
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   456
    private XSDocumentInfo[] fLocalElementDecl_schema = new XSDocumentInfo[INIT_STACK_SIZE]; //JACK
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   457
    private int[] fAllContext = new int[INIT_STACK_SIZE];
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   458
    private XSObject[] fParent = new XSObject[INIT_STACK_SIZE];
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   459
    private String [][] fLocalElemNamespaceContext = new String [INIT_STACK_SIZE][1];
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   460
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   461
    // these data members are needed for the deferred traversal
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   462
    // of keyrefs.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   463
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   464
    // the initial size of the array to store deferred keyrefs
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   465
    private static final int INIT_KEYREF_STACK = 2;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   466
    // the incremental size of the array to store deferred keyrefs
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   467
    private static final int INC_KEYREF_STACK_AMOUNT = 2;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   468
    // current position of the array (# of deferred keyrefs)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   469
    private int fKeyrefStackPos = 0;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   470
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   471
    private Element [] fKeyrefs = new Element[INIT_KEYREF_STACK];
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   472
    private XSDocumentInfo [] fKeyrefsMapXSDocumentInfo = new XSDocumentInfo[INIT_KEYREF_STACK];
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   473
    private XSElementDecl [] fKeyrefElems = new XSElementDecl [INIT_KEYREF_STACK];
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   474
    private String [][] fKeyrefNamespaceContext = new String[INIT_KEYREF_STACK][1];
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   475
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   476
    // global decls: map from decl name to decl object
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 25868
diff changeset
   477
    SymbolHash fGlobalAttrDecls = new SymbolHash(12);
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 25868
diff changeset
   478
    SymbolHash fGlobalAttrGrpDecls = new SymbolHash(5);
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 25868
diff changeset
   479
    SymbolHash fGlobalElemDecls = new SymbolHash(25);
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 25868
diff changeset
   480
    SymbolHash fGlobalGroupDecls = new SymbolHash(5);
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 25868
diff changeset
   481
    SymbolHash fGlobalNotationDecls = new SymbolHash(1);
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 25868
diff changeset
   482
    SymbolHash fGlobalIDConstraintDecls = new SymbolHash(3);
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 25868
diff changeset
   483
    SymbolHash fGlobalTypeDecls = new SymbolHash(25);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   484
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   485
    // Constructors
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   486
    public XSDHandler(){
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 25868
diff changeset
   487
        fHiddenNodes = new HashMap<>();
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   488
        fSchemaParser = new SchemaDOMParser(new SchemaParsingConfig());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   489
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   490
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   491
    // it should be possible to use the same XSDHandler to parse
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   492
    // multiple schema documents; this will allow one to be
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   493
    // constructed.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   494
    public XSDHandler (XSGrammarBucket gBucket) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   495
        this();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   496
        fGrammarBucket = gBucket;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   497
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   498
        // Note: don't use SchemaConfiguration internally
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   499
        //       we will get stack overflaw because
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   500
        //       XMLSchemaValidator will be instantiating XSDHandler...
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   501
        fSchemaGrammarDescription = new XSDDescription();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   502
    } // end constructor
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   503
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   504
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   505
     * This method initiates the parse of a schema.  It will likely be
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   506
     * called from the Validator and it will make the
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   507
     * resulting grammar available; it returns a reference to this object just
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   508
     * in case.  A reset(XMLComponentManager) must be called before this methods is called.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   509
     * @param is
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   510
     * @param desc
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   511
     * @param locationPairs
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   512
     * @return the SchemaGrammar
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   513
     * @throws IOException
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   514
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   515
    public SchemaGrammar parseSchema(XMLInputSource is, XSDDescription desc,
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 25868
diff changeset
   516
            Map<String, XMLSchemaLoader.LocationArray> locationPairs)
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   517
    throws IOException {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   518
        fLocationPairs = locationPairs;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   519
        fSchemaParser.resetNodePool();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   520
        SchemaGrammar grammar = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   521
        String schemaNamespace  = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   522
        short referType = desc.getContextType();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   523
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   524
        // if loading using JAXP schemaSource property, or using grammar caching loadGrammar
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   525
        // the desc.targetNamespace is always null.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   526
        // Therefore we should not attempt to find out if
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   527
        // the schema is already in the bucket, since in the case we have
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   528
        // no namespace schema in the bucket, findGrammar will always return the
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   529
        // no namespace schema.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   530
        if (referType != XSDDescription.CONTEXT_PREPARSE){
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   531
            // first try to find it in the bucket/pool, return if one is found
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   532
            if (fHonourAllSchemaLocations && referType == XSDDescription.CONTEXT_IMPORT && isExistingGrammar(desc, fNamespaceGrowth)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   533
                grammar = fGrammarBucket.getGrammar(desc.getTargetNamespace());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   534
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   535
            else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   536
                grammar = findGrammar(desc, fNamespaceGrowth);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   537
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   538
            if (grammar != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   539
                if (!fNamespaceGrowth) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   540
                    return grammar;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   541
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   542
                else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   543
                    try {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   544
                        if (grammar.getDocumentLocations().contains(XMLEntityManager.expandSystemId(is.getSystemId(), is.getBaseSystemId(), false))) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   545
                            return grammar;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   546
                        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   547
                    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   548
                    catch (MalformedURIException e) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   549
                        //REVISIT: return the grammar?
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   550
                    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   551
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   552
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   553
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   554
            schemaNamespace = desc.getTargetNamespace();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   555
            // handle empty string URI as null
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   556
            if (schemaNamespace != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   557
                schemaNamespace = fSymbolTable.addSymbol(schemaNamespace);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   558
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   559
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   560
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   561
        // before parsing a schema, need to clear registries associated with
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   562
        // parsing schemas
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   563
        prepareForParse();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   564
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   565
        Element schemaRoot = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   566
        // first phase:  construct trees.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   567
        if (is instanceof DOMInputSource) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   568
            schemaRoot = getSchemaDocument(schemaNamespace, (DOMInputSource) is,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   569
                    referType == XSDDescription.CONTEXT_PREPARSE,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   570
                    referType, null);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   571
        } // DOMInputSource
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   572
        else if (is instanceof SAXInputSource) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   573
                schemaRoot = getSchemaDocument(schemaNamespace, (SAXInputSource) is,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   574
                    referType == XSDDescription.CONTEXT_PREPARSE,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   575
                    referType, null);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   576
        } // SAXInputSource
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   577
        else if (is instanceof StAXInputSource) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   578
            schemaRoot = getSchemaDocument(schemaNamespace, (StAXInputSource) is,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   579
                    referType == XSDDescription.CONTEXT_PREPARSE,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   580
                    referType, null);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   581
        } // StAXInputSource
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   582
        else if (is instanceof XSInputSource) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   583
            schemaRoot = getSchemaDocument((XSInputSource) is, desc);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   584
        } // XSInputSource
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   585
        else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   586
                schemaRoot = getSchemaDocument(schemaNamespace, is,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   587
                  referType == XSDDescription.CONTEXT_PREPARSE,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   588
                  referType, null);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   589
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   590
        } //is instanceof XMLInputSource
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   591
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   592
        if (schemaRoot == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   593
            // something went wrong right off the hop
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   594
            if (is instanceof XSInputSource) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   595
                return fGrammarBucket.getGrammar(desc.getTargetNamespace());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   596
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   597
            return grammar;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   598
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   599
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   600
        if (referType == XSDDescription.CONTEXT_PREPARSE) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   601
                Element schemaElem = schemaRoot;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   602
            schemaNamespace = DOMUtil.getAttrValue(schemaElem, SchemaSymbols.ATT_TARGETNAMESPACE);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   603
            if(schemaNamespace != null && schemaNamespace.length() > 0) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   604
                // Since now we've discovered a namespace, we need to update xsd key
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   605
                // and store this schema in traversed schemas bucket
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   606
                schemaNamespace = fSymbolTable.addSymbol(schemaNamespace);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   607
                desc.setTargetNamespace(schemaNamespace);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   608
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   609
            else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   610
                schemaNamespace = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   611
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   612
            grammar = findGrammar(desc, fNamespaceGrowth);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   613
            String schemaId = XMLEntityManager.expandSystemId(is.getSystemId(), is.getBaseSystemId(), false);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   614
            if (grammar != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   615
                // When namespace growth is enabled and a null location is provided we cannot tell
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   616
                // whether we've loaded this schema document before so we must assume that we haven't.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   617
                if (!fNamespaceGrowth || (schemaId != null && grammar.getDocumentLocations().contains(schemaId))) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   618
                    return grammar;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   619
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   620
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   621
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   622
            XSDKey key = new XSDKey(schemaId, referType, schemaNamespace);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   623
            fTraversed.put(key, schemaRoot);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   624
            if (schemaId != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   625
                fDoc2SystemId.put(schemaRoot, schemaId);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   626
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   627
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   628
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   629
        // before constructing trees and traversing a schema, need to reset
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   630
        // all traversers and clear all registries
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   631
        prepareForTraverse();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   632
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   633
        fRoot = constructTrees(schemaRoot, is.getSystemId(), desc, grammar != null);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   634
        if (fRoot == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   635
            return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   636
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   637
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   638
        // second phase:  fill global registries.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   639
        buildGlobalNameRegistries();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   640
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   641
        // third phase:  call traversers
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
   642
        List<Object> annotationInfo = fValidateAnnotations ? new ArrayList<>() : null;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   643
        traverseSchemas(annotationInfo);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   644
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   645
        // fourth phase: handle local element decls
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   646
        traverseLocalElements();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   647
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   648
        // fifth phase:  handle Keyrefs
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   649
        resolveKeyRefs();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   650
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   651
        // sixth phase:  validate attribute of non-schema namespaces
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   652
        // REVISIT: skip this for now. we really don't want to do it.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   653
        //fAttributeChecker.checkNonSchemaAttributes(fGrammarBucket);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   654
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   655
        // seventh phase:  store imported grammars
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   656
        // for all grammars with <import>s
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   657
        for (int i = fAllTNSs.size() - 1; i >= 0; i--) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   658
            // get its target namespace
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
   659
            String tns = fAllTNSs.get(i);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   660
            // get all namespaces it imports
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
   661
            List<String> ins = fImportMap.get(tns);
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
   662
            List<SchemaGrammar> grammars = new ArrayList<>();
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   663
            // get the grammar
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   664
            SchemaGrammar sg = fGrammarBucket.getGrammar(emptyString2Null(tns));
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   665
            if (sg == null)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   666
                continue;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   667
            SchemaGrammar isg;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   668
            // for imported namespace
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   669
            int count = 0;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   670
            for (int j = 0; j < ins.size(); j++) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   671
                // get imported grammar
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
   672
                isg = fGrammarBucket.getGrammar(ins.get(j));
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   673
                // reuse the same vector
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
   674
                if (isg != null) {
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
   675
                    grammars.add(isg);
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
   676
                }
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   677
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   678
            // set the imported grammars
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
   679
            sg.setImportedGrammars(grammars);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   680
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   681
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   682
        /** validate annotations **/
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   683
        if (fValidateAnnotations && annotationInfo.size() > 0) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   684
            validateAnnotations(annotationInfo);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   685
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   686
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   687
        // and return.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   688
        return fGrammarBucket.getGrammar(fRoot.fTargetNamespace);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   689
    } // end parseSchema
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   690
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
   691
    private void validateAnnotations(List<Object> annotationInfo) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   692
        if (fAnnotationValidator == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   693
            createAnnotationValidator();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   694
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   695
        final int size = annotationInfo.size();
39080
57563e513b11 8158204: accessExternalSchema property handling is inconsistent and differs from spec.
joehw
parents: 36146
diff changeset
   696
        final XMLInputSource src = new XMLInputSource(null, null, null, false);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   697
        fGrammarBucketAdapter.refreshGrammars(fGrammarBucket);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   698
        for (int i = 0; i < size; i += 2) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   699
            src.setSystemId((String) annotationInfo.get(i));
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   700
            XSAnnotationInfo annotation = (XSAnnotationInfo) annotationInfo.get(i+1);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   701
            while (annotation != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   702
                src.setCharacterStream(new StringReader(annotation.fAnnotation));
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   703
                try {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   704
                    fAnnotationValidator.parse(src);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   705
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   706
                catch (IOException exc) {}
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   707
                annotation = annotation.next;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   708
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   709
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   710
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   711
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   712
    private void createAnnotationValidator() {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   713
        fAnnotationValidator = new XML11Configuration();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   714
        fGrammarBucketAdapter = new XSAnnotationGrammarPool();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   715
        fAnnotationValidator.setFeature(VALIDATION, true);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   716
        fAnnotationValidator.setFeature(XMLSCHEMA_VALIDATION, true);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   717
        fAnnotationValidator.setProperty(XMLGRAMMAR_POOL, fGrammarBucketAdapter);
36146
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
   718
        /** set security manager and XML Security Property Manager **/
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
   719
        fAnnotationValidator.setProperty(SECURITY_MANAGER, (fSecurityManager != null) ? fSecurityManager : new XMLSecurityManager(true));
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
   720
        fAnnotationValidator.setProperty(XML_SECURITY_PROPERTY_MANAGER, fSecurityPropertyMgr);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   721
        /** Set error handler. **/
36146
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
   722
        fAnnotationValidator.setProperty(ERROR_HANDLER, (fErrorHandler != null) ? fErrorHandler : new DefaultErrorHandler());
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   723
        /** Set locale. **/
36146
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
   724
        fAnnotationValidator.setProperty(LOCALE, fLocale);
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 39080
diff changeset
   725
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 39080
diff changeset
   726
        // Passing on the Catalog settings
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 39080
diff changeset
   727
        fAnnotationValidator.setFeature(XMLConstants.USE_CATALOG, fUseCatalog);
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 39080
diff changeset
   728
        fAnnotationValidator.setProperty(JdkXmlUtils.CATALOG_FILES, fCatalogFile);
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 39080
diff changeset
   729
        fAnnotationValidator.setProperty(JdkXmlUtils.CATALOG_DEFER, fDefer);
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 39080
diff changeset
   730
        fAnnotationValidator.setProperty(JdkXmlUtils.CATALOG_PREFER, fPrefer);
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 39080
diff changeset
   731
        fAnnotationValidator.setProperty(JdkXmlUtils.CATALOG_RESOLVE, fResolve);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   732
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   733
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   734
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   735
     * Pull the grammar out of the bucket simply using
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   736
     * its TNS as a key
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   737
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   738
    SchemaGrammar getGrammar(String tns) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   739
        return fGrammarBucket.getGrammar(tns);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   740
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   741
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   742
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   743
     * First try to find a grammar in the bucket, if failed, consult the
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   744
     * grammar pool. If a grammar is found in the pool, then add it (and all
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   745
     * imported ones) into the bucket.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   746
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   747
    protected SchemaGrammar findGrammar(XSDDescription desc, boolean ignoreConflict) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   748
        SchemaGrammar sg = fGrammarBucket.getGrammar(desc.getTargetNamespace());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   749
        if (sg == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   750
            if (fGrammarPool != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   751
                sg = (SchemaGrammar)fGrammarPool.retrieveGrammar(desc);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   752
                if (sg != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   753
                    // put this grammar into the bucket, along with grammars
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   754
                    // imported by it (directly or indirectly)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   755
                    if (!fGrammarBucket.putGrammar(sg, true, ignoreConflict)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   756
                        // REVISIT: a conflict between new grammar(s) and grammars
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   757
                        // in the bucket. What to do? A warning? An exception?
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   758
                        reportSchemaWarning("GrammarConflict", null, null);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   759
                        sg = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   760
                    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   761
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   762
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   763
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   764
        return sg;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   765
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   766
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   767
    // may wish to have setter methods for ErrorHandler,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   768
    // EntityResolver...
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   769
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   770
    private static final String[][] NS_ERROR_CODES = {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   771
            {"src-include.2.1", "src-include.2.1"},
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   772
            {"src-redefine.3.1", "src-redefine.3.1"},
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   773
            {"src-import.3.1", "src-import.3.2"},
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   774
            null,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   775
            {"TargetNamespace.1", "TargetNamespace.2"},
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   776
            {"TargetNamespace.1", "TargetNamespace.2"},
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   777
            {"TargetNamespace.1", "TargetNamespace.2"},
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   778
            {"TargetNamespace.1", "TargetNamespace.2"}
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   779
    };
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   780
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   781
    private static final String[] ELE_ERROR_CODES = {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   782
            "src-include.1", "src-redefine.2", "src-import.2", "schema_reference.4",
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   783
            "schema_reference.4", "schema_reference.4", "schema_reference.4", "schema_reference.4"
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   784
    };
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   785
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   786
    // This method does several things:
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   787
    // It constructs an instance of an XSDocumentInfo object using the
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   788
    // schemaRoot node.  Then, for each <include>,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   789
    // <redefine>, and <import> children, it attempts to resolve the
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   790
    // requested schema document, initiates a DOM parse, and calls
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   791
    // itself recursively on that document's root.  It also records in
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   792
    // the DependencyMap object what XSDocumentInfo objects its XSDocumentInfo
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   793
    // depends on.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   794
    // It also makes sure the targetNamespace of the schema it was
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   795
    // called to parse is correct.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   796
    protected XSDocumentInfo constructTrees(Element schemaRoot, String locationHint, XSDDescription desc, boolean nsCollision) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   797
        if (schemaRoot == null) return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   798
        String callerTNS = desc.getTargetNamespace();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   799
        short referType = desc.getContextType();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   800
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   801
        XSDocumentInfo currSchemaInfo = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   802
        try {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   803
            // note that attributes are freed at end of traverseSchemas()
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   804
            currSchemaInfo = new XSDocumentInfo(schemaRoot, fAttributeChecker, fSymbolTable);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   805
        } catch (XMLSchemaException se) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   806
            reportSchemaError(ELE_ERROR_CODES[referType],
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   807
                    new Object[]{locationHint},
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   808
                                          schemaRoot);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   809
            return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   810
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   811
        // targetNamespace="" is not valid, issue a warning, and ignore it
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   812
        if (currSchemaInfo.fTargetNamespace != null &&
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   813
                currSchemaInfo.fTargetNamespace.length() == 0) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   814
            reportSchemaWarning("EmptyTargetNamespace",
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   815
                    new Object[]{locationHint},
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   816
                                        schemaRoot);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   817
            currSchemaInfo.fTargetNamespace = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   818
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   819
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   820
        if (callerTNS != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   821
            // the second index to the NS_ERROR_CODES array
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   822
            // if the caller/expected NS is not absent, we use the first column
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   823
            int secondIdx = 0;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   824
            // for include and redefine
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   825
            if (referType == XSDDescription.CONTEXT_INCLUDE ||
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   826
                    referType == XSDDescription.CONTEXT_REDEFINE) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   827
                // if the referred document has no targetNamespace,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   828
                // it's a chameleon schema
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   829
                if (currSchemaInfo.fTargetNamespace == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   830
                    currSchemaInfo.fTargetNamespace = callerTNS;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   831
                    currSchemaInfo.fIsChameleonSchema = true;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   832
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   833
                // if the referred document has a target namespace differing
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   834
                // from the caller, it's an error
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   835
                else if (callerTNS != currSchemaInfo.fTargetNamespace) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   836
                    reportSchemaError(NS_ERROR_CODES[referType][secondIdx],
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   837
                            new Object [] {callerTNS, currSchemaInfo.fTargetNamespace},
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   838
                                                        schemaRoot);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   839
                    return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   840
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   841
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   842
            // for instance and import, the two NS's must be the same
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   843
            else if (referType != XSDDescription.CONTEXT_PREPARSE && callerTNS != currSchemaInfo.fTargetNamespace) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   844
                reportSchemaError(NS_ERROR_CODES[referType][secondIdx],
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   845
                        new Object [] {callerTNS, currSchemaInfo.fTargetNamespace},
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   846
                                                schemaRoot);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   847
                return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   848
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   849
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   850
        // now there is no caller/expected NS, it's an error for the referred
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   851
        // document to have a target namespace, unless we are preparsing a schema
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   852
        else if (currSchemaInfo.fTargetNamespace != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   853
            // set the target namespace of the description
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   854
            if (referType == XSDDescription.CONTEXT_PREPARSE) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   855
                desc.setTargetNamespace(currSchemaInfo.fTargetNamespace);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   856
                callerTNS = currSchemaInfo.fTargetNamespace;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   857
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   858
            else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   859
                // the second index to the NS_ERROR_CODES array
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   860
                // if the caller/expected NS is absent, we use the second column
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   861
                int secondIdx = 1;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   862
                reportSchemaError(NS_ERROR_CODES[referType][secondIdx],
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   863
                        new Object [] {callerTNS, currSchemaInfo.fTargetNamespace},
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   864
                                                schemaRoot);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   865
                return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   866
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   867
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   868
        // the other cases (callerTNS == currSchemaInfo.fTargetNamespce == null)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   869
        // are valid
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   870
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   871
        // a schema document can always access it's own target namespace
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   872
        currSchemaInfo.addAllowedNS(currSchemaInfo.fTargetNamespace);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   873
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   874
        SchemaGrammar sg = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   875
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   876
        // we have a namespace collision
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   877
        if (nsCollision) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   878
            SchemaGrammar sg2 = fGrammarBucket.getGrammar(currSchemaInfo.fTargetNamespace);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   879
            if (sg2.isImmutable()) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   880
                sg = new SchemaGrammar(sg2);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   881
                fGrammarBucket.putGrammar(sg);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   882
                // update all the grammars in the bucket to point to the new grammar.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   883
                updateImportListWith(sg);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   884
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   885
            else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   886
                sg = sg2;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   887
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   888
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   889
            // update import list of the new grammar
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   890
            updateImportListFor(sg);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   891
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   892
        else if (referType == XSDDescription.CONTEXT_INCLUDE ||
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   893
                referType == XSDDescription.CONTEXT_REDEFINE) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   894
            sg = fGrammarBucket.getGrammar(currSchemaInfo.fTargetNamespace);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   895
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   896
        else if(fHonourAllSchemaLocations && referType == XSDDescription.CONTEXT_IMPORT) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   897
            sg = findGrammar(desc, false);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   898
            if(sg == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   899
                sg = new SchemaGrammar(currSchemaInfo.fTargetNamespace, desc.makeClone(), fSymbolTable);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   900
                fGrammarBucket.putGrammar(sg);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   901
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   902
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   903
        else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   904
            sg = new SchemaGrammar(currSchemaInfo.fTargetNamespace, desc.makeClone(), fSymbolTable);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   905
            fGrammarBucket.putGrammar(sg);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   906
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   907
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   908
        // store the document and its location
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   909
        // REVISIT: don't expose the DOM tree
36146
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
   910
        sg.addDocument(null, fDoc2SystemId.get(currSchemaInfo.fSchemaElement));
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   911
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   912
        fDoc2XSDocumentMap.put(schemaRoot, currSchemaInfo);
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
   913
        List<XSDocumentInfo> dependencies = new ArrayList<>();
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   914
        Element rootNode = schemaRoot;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   915
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   916
        Element newSchemaRoot = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   917
        for (Element child = DOMUtil.getFirstChildElement(rootNode);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   918
        child != null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   919
        child = DOMUtil.getNextSiblingElement(child)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   920
            String schemaNamespace=null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   921
            String schemaHint=null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   922
            String localName = DOMUtil.getLocalName(child);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   923
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   924
            short refType = -1;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   925
            boolean importCollision = false;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   926
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   927
            if (localName.equals(SchemaSymbols.ELT_ANNOTATION))
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   928
                continue;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   929
            else if (localName.equals(SchemaSymbols.ELT_IMPORT)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   930
                refType = XSDDescription.CONTEXT_IMPORT;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   931
                // have to handle some validation here too!
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   932
                // call XSAttributeChecker to fill in attrs
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   933
                Object[] importAttrs = fAttributeChecker.checkAttributes(child, true, currSchemaInfo);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   934
                schemaHint = (String)importAttrs[XSAttributeChecker.ATTIDX_SCHEMALOCATION];
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   935
                schemaNamespace = (String)importAttrs[XSAttributeChecker.ATTIDX_NAMESPACE];
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   936
                if (schemaNamespace != null)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   937
                    schemaNamespace = fSymbolTable.addSymbol(schemaNamespace);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   938
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   939
                // check contents and process optional annotations
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   940
                Element importChild = DOMUtil.getFirstChildElement(child);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   941
                if(importChild != null ) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   942
                    String importComponentType = DOMUtil.getLocalName(importChild);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   943
                    if (importComponentType.equals(SchemaSymbols.ELT_ANNOTATION)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   944
                        // promoting annotations to parent component
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   945
                        sg.addAnnotation(
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   946
                                fElementTraverser.traverseAnnotationDecl(importChild, importAttrs, true, currSchemaInfo));
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   947
                    } else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   948
                        reportSchemaError("s4s-elt-must-match.1", new Object [] {localName, "annotation?", importComponentType}, child);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   949
                    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   950
                    if(DOMUtil.getNextSiblingElement(importChild) != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   951
                        reportSchemaError("s4s-elt-must-match.1", new Object [] {localName, "annotation?", DOMUtil.getLocalName(DOMUtil.getNextSiblingElement(importChild))}, child);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   952
                    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   953
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   954
                else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   955
                    String text = DOMUtil.getSyntheticAnnotation(child);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   956
                    if (text != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   957
                        sg.addAnnotation(fElementTraverser.traverseSyntheticAnnotation(child, text, importAttrs, true, currSchemaInfo));
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   958
                    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   959
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   960
                fAttributeChecker.returnAttrArray(importAttrs, currSchemaInfo);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   961
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   962
                // a document can't import another document with the same namespace
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   963
                if (schemaNamespace == currSchemaInfo.fTargetNamespace) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   964
                    reportSchemaError(schemaNamespace != null ?
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   965
                            "src-import.1.1" : "src-import.1.2", new Object [] {schemaNamespace}, child);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   966
                    continue;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   967
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   968
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   969
                // if this namespace has not been imported by this document,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   970
                //  then import if multiple imports support is enabled.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   971
                if(currSchemaInfo.isAllowedNS(schemaNamespace)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   972
                    if(!fHonourAllSchemaLocations && !fNamespaceGrowth)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   973
                        continue;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   974
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   975
                else  {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   976
                    currSchemaInfo.addAllowedNS(schemaNamespace);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   977
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   978
                // also record the fact that one namespace imports another one
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   979
                // convert null to ""
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   980
                String tns = null2EmptyString(currSchemaInfo.fTargetNamespace);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   981
                // get all namespaces imported by this one
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
   982
               List<String> ins = fImportMap.get(tns);
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
   983
                // if no namespace was imported, create new ArrayList<>
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   984
                if (ins == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   985
                    // record that this one imports other(s)
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
   986
                    fAllTNSs.add(tns);
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
   987
                    ins = new ArrayList<>();
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   988
                    fImportMap.put(tns, ins);
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
   989
                    ins.add(schemaNamespace);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   990
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   991
                else if (!ins.contains(schemaNamespace)){
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
   992
                    ins.add(schemaNamespace);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   993
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   994
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   995
                fSchemaGrammarDescription.reset();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   996
                fSchemaGrammarDescription.setContextType(XSDDescription.CONTEXT_IMPORT);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   997
                fSchemaGrammarDescription.setBaseSystemId(doc2SystemId(schemaRoot));
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   998
                fSchemaGrammarDescription.setLiteralSystemId(schemaHint);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   999
                fSchemaGrammarDescription.setLocationHints(new String[]{schemaHint});
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1000
                fSchemaGrammarDescription.setTargetNamespace(schemaNamespace);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1001
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1002
                // if a grammar with the same namespace and location exists (or being
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1003
                // built), ignore this one (don't traverse it).
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1004
                SchemaGrammar isg = findGrammar(fSchemaGrammarDescription, fNamespaceGrowth);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1005
                if (isg != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1006
                    if (fNamespaceGrowth) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1007
                        try {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1008
                            if (isg.getDocumentLocations().contains(XMLEntityManager.expandSystemId(schemaHint, fSchemaGrammarDescription.getBaseSystemId(), false))) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1009
                                continue;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1010
                            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1011
                            else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1012
                                importCollision = true;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1013
                            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1014
                        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1015
                        catch (MalformedURIException e) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1016
                        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1017
                    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1018
                    else if (!fHonourAllSchemaLocations || isExistingGrammar(fSchemaGrammarDescription, false)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1019
                        continue;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1020
                    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1021
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1022
                //if ((!fHonourAllSchemaLocations && findGrammar(fSchemaGrammarDescription) != null) || isExistingGrammar(fSchemaGrammarDescription))
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1023
                //    continue;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1024
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1025
                // If "findGrammar" returns a grammar, then this is not the
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1026
                // the first time we see a location for a given namespace.
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 25868
diff changeset
  1027
                // Don't consult the location pair map in this case,
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1028
                // otherwise the location will be ignored because it'll get
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1029
                // resolved to the same location as the first hint.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1030
                newSchemaRoot = resolveSchema(fSchemaGrammarDescription, false, child, isg == null);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1031
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1032
            else if ((localName.equals(SchemaSymbols.ELT_INCLUDE)) ||
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1033
                    (localName.equals(SchemaSymbols.ELT_REDEFINE))) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1034
                // validation for redefine/include will be the same here; just
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1035
                // make sure TNS is right (don't care about redef contents
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1036
                // yet).
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1037
                Object[] includeAttrs = fAttributeChecker.checkAttributes(child, true, currSchemaInfo);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1038
                schemaHint = (String)includeAttrs[XSAttributeChecker.ATTIDX_SCHEMALOCATION];
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1039
                // store the namespace decls of the redefine element
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1040
                if (localName.equals(SchemaSymbols.ELT_REDEFINE)) {
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  1041
                    if (fRedefine2NSSupport == null) fRedefine2NSSupport = new HashMap<>();
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1042
                    fRedefine2NSSupport.put(child, new SchemaNamespaceSupport(currSchemaInfo.fNamespaceSupport));
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1043
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1044
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1045
                // check annotations.  Must do this here to avoid having to
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1046
                // re-parse attributes later
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1047
                if(localName.equals(SchemaSymbols.ELT_INCLUDE)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1048
                    Element includeChild = DOMUtil.getFirstChildElement(child);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1049
                    if(includeChild != null ) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1050
                        String includeComponentType = DOMUtil.getLocalName(includeChild);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1051
                        if (includeComponentType.equals(SchemaSymbols.ELT_ANNOTATION)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1052
                            // promoting annotations to parent component
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1053
                            sg.addAnnotation(
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1054
                                    fElementTraverser.traverseAnnotationDecl(includeChild, includeAttrs, true, currSchemaInfo));
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1055
                        } else {
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  1056
                            reportSchemaError("s4s-elt-must-match.1",
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  1057
                                    new Object [] {localName, "annotation?", includeComponentType}, child);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1058
                        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1059
                        if(DOMUtil.getNextSiblingElement(includeChild) != null) {
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  1060
                            reportSchemaError("s4s-elt-must-match.1",
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  1061
                                    new Object [] {localName, "annotation?",
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  1062
                                        DOMUtil.getLocalName(DOMUtil.getNextSiblingElement(includeChild))}, child);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1063
                        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1064
                    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1065
                    else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1066
                        String text = DOMUtil.getSyntheticAnnotation(child);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1067
                        if (text != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1068
                            sg.addAnnotation(fElementTraverser.traverseSyntheticAnnotation(child, text, includeAttrs, true, currSchemaInfo));
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1069
                        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1070
                    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1071
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1072
                else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1073
                    for (Element redefinedChild = DOMUtil.getFirstChildElement(child);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1074
                    redefinedChild != null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1075
                    redefinedChild = DOMUtil.getNextSiblingElement(redefinedChild)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1076
                        String redefinedComponentType = DOMUtil.getLocalName(redefinedChild);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1077
                        if (redefinedComponentType.equals(SchemaSymbols.ELT_ANNOTATION)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1078
                            // promoting annotations to parent component
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1079
                            sg.addAnnotation(
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1080
                                    fElementTraverser.traverseAnnotationDecl(redefinedChild, includeAttrs, true, currSchemaInfo));
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1081
                            DOMUtil.setHidden(redefinedChild, fHiddenNodes);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1082
                        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1083
                        else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1084
                            String text = DOMUtil.getSyntheticAnnotation(child);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1085
                            if (text != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1086
                                sg.addAnnotation(fElementTraverser.traverseSyntheticAnnotation(child, text, includeAttrs, true, currSchemaInfo));
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1087
                            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1088
                        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1089
                        // catch all other content errors later
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1090
                    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1091
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1092
                fAttributeChecker.returnAttrArray(includeAttrs, currSchemaInfo);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1093
                // schemaLocation is required on <include> and <redefine>
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1094
                if (schemaHint == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1095
                    reportSchemaError("s4s-att-must-appear", new Object [] {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1096
                            "<include> or <redefine>", "schemaLocation"},
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1097
                            child);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1098
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1099
                // pass the systemId of the current document as the base systemId
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1100
                boolean mustResolve = false;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1101
                refType = XSDDescription.CONTEXT_INCLUDE;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1102
                if(localName.equals(SchemaSymbols.ELT_REDEFINE)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1103
                    mustResolve = nonAnnotationContent(child);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1104
                    refType = XSDDescription.CONTEXT_REDEFINE;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1105
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1106
                fSchemaGrammarDescription.reset();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1107
                fSchemaGrammarDescription.setContextType(refType);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1108
                fSchemaGrammarDescription.setBaseSystemId(doc2SystemId(schemaRoot));
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1109
                fSchemaGrammarDescription.setLocationHints(new String[]{schemaHint});
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1110
                fSchemaGrammarDescription.setTargetNamespace(callerTNS);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1111
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1112
                boolean alreadyTraversed = false;
42247
52fafb950d5a 8158619: Very large CDATA section in XML document causes OOME
joehw
parents: 39907
diff changeset
  1113
                XMLInputSource schemaSource =
52fafb950d5a 8158619: Very large CDATA section in XML document causes OOME
joehw
parents: 39907
diff changeset
  1114
                        resolveSchemaSource(fSchemaGrammarDescription, mustResolve, child, true);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1115
                if (fNamespaceGrowth && refType == XSDDescription.CONTEXT_INCLUDE) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1116
                    try {
42247
52fafb950d5a 8158619: Very large CDATA section in XML document causes OOME
joehw
parents: 39907
diff changeset
  1117
                        final String schemaId = XMLEntityManager.expandSystemId(
52fafb950d5a 8158619: Very large CDATA section in XML document causes OOME
joehw
parents: 39907
diff changeset
  1118
                                schemaSource.getSystemId(), schemaSource.getBaseSystemId(), false);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1119
                        alreadyTraversed = sg.getDocumentLocations().contains(schemaId);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1120
                    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1121
                    catch(MalformedURIException e) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1122
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1123
                    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1124
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1125
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1126
                if (!alreadyTraversed) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1127
                    newSchemaRoot = resolveSchema(schemaSource, fSchemaGrammarDescription, mustResolve, child);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1128
                    schemaNamespace = currSchemaInfo.fTargetNamespace;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1129
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1130
                else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1131
                    fLastSchemaWasDuplicate = true;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1132
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1133
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1134
            else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1135
                // no more possibility of schema references in well-formed
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1136
                // schema...
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1137
                break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1138
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1139
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1140
            // If the schema is duplicate, we needn't call constructTrees() again.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1141
            // To handle mutual <include>s
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1142
            XSDocumentInfo newSchemaInfo = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1143
            if (fLastSchemaWasDuplicate) {
42247
52fafb950d5a 8158619: Very large CDATA section in XML document causes OOME
joehw
parents: 39907
diff changeset
  1144
                newSchemaInfo = newSchemaRoot == null ? null : fDoc2XSDocumentMap.get(newSchemaRoot);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1145
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1146
            else {
42247
52fafb950d5a 8158619: Very large CDATA section in XML document causes OOME
joehw
parents: 39907
diff changeset
  1147
                newSchemaInfo = constructTrees(newSchemaRoot, schemaHint,
52fafb950d5a 8158619: Very large CDATA section in XML document causes OOME
joehw
parents: 39907
diff changeset
  1148
                        fSchemaGrammarDescription, importCollision);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1149
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1150
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1151
            if (localName.equals(SchemaSymbols.ELT_REDEFINE) &&
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1152
                    newSchemaInfo != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1153
                // must record which schema we're redefining so that we can
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1154
                // rename the right things later!
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  1155
                if (fRedefine2XSDMap == null) fRedefine2XSDMap = new HashMap<>();
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1156
                fRedefine2XSDMap.put(child, newSchemaInfo);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1157
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1158
            if (newSchemaRoot != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1159
                if (newSchemaInfo != null)
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  1160
                    dependencies.add(newSchemaInfo);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1161
                newSchemaRoot = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1162
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1163
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1164
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1165
        fDependencyMap.put(currSchemaInfo, dependencies);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1166
        return currSchemaInfo;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1167
    } // end constructTrees
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1168
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1169
    private boolean isExistingGrammar(XSDDescription desc, boolean ignoreConflict) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1170
        SchemaGrammar sg = fGrammarBucket.getGrammar(desc.getTargetNamespace());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1171
        if (sg == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1172
            return findGrammar(desc, ignoreConflict) != null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1173
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1174
        else if (sg.isImmutable()) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1175
            return true;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1176
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1177
        else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1178
            try {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1179
                return sg.getDocumentLocations().contains(XMLEntityManager.expandSystemId(desc.getLiteralSystemId(), desc.getBaseSystemId(), false));
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1180
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1181
            catch (MalformedURIException e) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1182
                return false;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1183
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1184
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1185
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1186
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1187
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1188
     * Namespace growth
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1189
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1190
     * Go through the import list of a given grammar and for each imported
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1191
     * grammar, check to see if the grammar bucket has a newer version.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1192
     * If a new instance is found, we update the import list with the
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1193
     * newer version.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1194
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1195
    private void updateImportListFor(SchemaGrammar grammar) {
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  1196
       List<SchemaGrammar> importedGrammars = grammar.getImportedGrammars();
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1197
        if (importedGrammars != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1198
            for (int i=0; i<importedGrammars.size(); i++) {
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  1199
                SchemaGrammar isg1 = importedGrammars.get(i);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1200
                SchemaGrammar isg2 = fGrammarBucket.getGrammar(isg1.getTargetNamespace());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1201
                if (isg2 != null && isg1 != isg2) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1202
                    importedGrammars.set(i, isg2);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1203
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1204
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1205
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1206
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1207
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1208
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1209
     * Namespace growth
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1210
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1211
     * Go throuth the grammar bucket, and for each grammar in the bucket
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1212
     * check the import list. If there exists a grammar in import list
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1213
     * that has the same namespace as newGrammar, but a different instance,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1214
     * then update the import list and replace the old grammar instance with
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1215
     * the new one
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1216
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1217
    private void updateImportListWith(SchemaGrammar newGrammar) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1218
        SchemaGrammar[] schemaGrammars = fGrammarBucket.getGrammars();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1219
        for (int i = 0; i < schemaGrammars.length; ++i) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1220
            SchemaGrammar sg = schemaGrammars[i];
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1221
            if (sg != newGrammar) {
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  1222
                List<SchemaGrammar> importedGrammars = sg.getImportedGrammars();
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1223
                if (importedGrammars != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1224
                    for (int j=0; j<importedGrammars.size(); j++) {
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  1225
                        SchemaGrammar isg = importedGrammars.get(j);
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  1226
                        if (null2EmptyString(isg.getTargetNamespace()).equals(
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  1227
                                null2EmptyString(newGrammar.getTargetNamespace()))) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1228
                            if (isg != newGrammar) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1229
                                importedGrammars.set(j, newGrammar);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1230
                            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1231
                            break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1232
                        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1233
                    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1234
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1235
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1236
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1237
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1238
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1239
    // This method builds registries for all globally-referenceable
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1240
    // names.  A registry will be built for each symbol space defined
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1241
    // by the spec.  It is also this method's job to rename redefined
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1242
    // components, and to record which components redefine others (so
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1243
    // that implicit redefinitions of groups and attributeGroups can be handled).
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1244
    protected void buildGlobalNameRegistries() {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1245
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1246
        registryEmpty = false;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1247
        // Starting with fRoot, we examine each child of the schema
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1248
        // element.  Skipping all imports and includes, we record the names
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1249
        // of all other global components (and children of <redefine>).  We
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1250
        // also put <redefine> names in a registry that we look through in
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1251
        // case something needs renaming.  Once we're done with a schema we
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1252
        // set its Document node to hidden so that we don't try to traverse
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1253
        // it again; then we look to its Dependency map entry.  We keep a
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1254
        // stack of schemas that we haven't yet finished processing; this
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1255
        // is a depth-first traversal.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1256
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  1257
        Stack<XSDocumentInfo> schemasToProcess = new Stack<>();
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1258
        schemasToProcess.push(fRoot);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1259
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1260
        while (!schemasToProcess.empty()) {
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  1261
            XSDocumentInfo currSchemaDoc = schemasToProcess.pop();
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1262
            Element currDoc = currSchemaDoc.fSchemaElement;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1263
            if(DOMUtil.isHidden(currDoc, fHiddenNodes)){
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1264
                // must have processed this already!
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1265
                continue;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1266
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1267
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1268
            Element currRoot = currDoc;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1269
            // process this schema's global decls
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1270
            boolean dependenciesCanOccur = true;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1271
            for (Element globalComp =
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1272
                DOMUtil.getFirstChildElement(currRoot);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1273
            globalComp != null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1274
            globalComp = DOMUtil.getNextSiblingElement(globalComp)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1275
                // this loop makes sure the <schema> element ordering is
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1276
                // also valid.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1277
                if (DOMUtil.getLocalName(globalComp).equals(SchemaSymbols.ELT_ANNOTATION)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1278
                    //skip it; traverse it later
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1279
                    continue;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1280
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1281
                else if (DOMUtil.getLocalName(globalComp).equals(SchemaSymbols.ELT_INCLUDE) ||
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1282
                        DOMUtil.getLocalName(globalComp).equals(SchemaSymbols.ELT_IMPORT)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1283
                    if (!dependenciesCanOccur) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1284
                        reportSchemaError("s4s-elt-invalid-content.3", new Object [] {DOMUtil.getLocalName(globalComp)}, globalComp);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1285
                    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1286
                    DOMUtil.setHidden(globalComp, fHiddenNodes);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1287
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1288
                else if (DOMUtil.getLocalName(globalComp).equals(SchemaSymbols.ELT_REDEFINE)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1289
                    if (!dependenciesCanOccur) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1290
                        reportSchemaError("s4s-elt-invalid-content.3", new Object [] {DOMUtil.getLocalName(globalComp)}, globalComp);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1291
                    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1292
                    for (Element redefineComp = DOMUtil.getFirstChildElement(globalComp);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1293
                    redefineComp != null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1294
                    redefineComp = DOMUtil.getNextSiblingElement(redefineComp)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1295
                        String lName = DOMUtil.getAttrValue(redefineComp, SchemaSymbols.ATT_NAME);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1296
                        if (lName.length() == 0) // an error we'll catch later
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1297
                            continue;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1298
                        String qName = currSchemaDoc.fTargetNamespace == null ?
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1299
                                ","+lName:
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1300
                                    currSchemaDoc.fTargetNamespace +","+lName;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1301
                        String componentType = DOMUtil.getLocalName(redefineComp);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1302
                        if (componentType.equals(SchemaSymbols.ELT_ATTRIBUTEGROUP)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1303
                            checkForDuplicateNames(qName, ATTRIBUTEGROUP_TYPE, fUnparsedAttributeGroupRegistry, fUnparsedAttributeGroupRegistrySub, redefineComp, currSchemaDoc);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1304
                            // the check will have changed our name;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1305
                            String targetLName = DOMUtil.getAttrValue(redefineComp, SchemaSymbols.ATT_NAME)+REDEF_IDENTIFIER;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1306
                            // and all we need to do is error-check+rename our kkids:
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1307
                            renameRedefiningComponents(currSchemaDoc, redefineComp, SchemaSymbols.ELT_ATTRIBUTEGROUP,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1308
                                    lName, targetLName);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1309
                        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1310
                        else if ((componentType.equals(SchemaSymbols.ELT_COMPLEXTYPE)) ||
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1311
                                (componentType.equals(SchemaSymbols.ELT_SIMPLETYPE))) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1312
                            checkForDuplicateNames(qName, TYPEDECL_TYPE, fUnparsedTypeRegistry, fUnparsedTypeRegistrySub, redefineComp, currSchemaDoc);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1313
                            // the check will have changed our name;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1314
                            String targetLName = DOMUtil.getAttrValue(redefineComp, SchemaSymbols.ATT_NAME) + REDEF_IDENTIFIER;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1315
                            // and all we need to do is error-check+rename our kkids:
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1316
                            if (componentType.equals(SchemaSymbols.ELT_COMPLEXTYPE)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1317
                                renameRedefiningComponents(currSchemaDoc, redefineComp, SchemaSymbols.ELT_COMPLEXTYPE,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1318
                                        lName, targetLName);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1319
                            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1320
                            else { // must be simpleType
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1321
                                renameRedefiningComponents(currSchemaDoc, redefineComp, SchemaSymbols.ELT_SIMPLETYPE,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1322
                                        lName, targetLName);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1323
                            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1324
                        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1325
                        else if (componentType.equals(SchemaSymbols.ELT_GROUP)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1326
                            checkForDuplicateNames(qName, GROUP_TYPE, fUnparsedGroupRegistry, fUnparsedGroupRegistrySub, redefineComp, currSchemaDoc);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1327
                            // the check will have changed our name;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1328
                            String targetLName = DOMUtil.getAttrValue(redefineComp, SchemaSymbols.ATT_NAME)+REDEF_IDENTIFIER;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1329
                            // and all we need to do is error-check+rename our kids:
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1330
                            renameRedefiningComponents(currSchemaDoc, redefineComp, SchemaSymbols.ELT_GROUP,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1331
                                    lName, targetLName);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1332
                        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1333
                    } // end march through <redefine> children
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1334
                    // and now set as traversed
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1335
                    //DOMUtil.setHidden(globalComp);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1336
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1337
                else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1338
                    dependenciesCanOccur = false;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1339
                    String lName = DOMUtil.getAttrValue(globalComp, SchemaSymbols.ATT_NAME);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1340
                    if (lName.length() == 0) // an error we'll catch later
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1341
                        continue;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1342
                    String qName = currSchemaDoc.fTargetNamespace == null?
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1343
                            ","+lName:
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1344
                                currSchemaDoc.fTargetNamespace +","+lName;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1345
                    String componentType = DOMUtil.getLocalName(globalComp);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1346
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1347
                    if (componentType.equals(SchemaSymbols.ELT_ATTRIBUTE)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1348
                        checkForDuplicateNames(qName, ATTRIBUTE_TYPE, fUnparsedAttributeRegistry, fUnparsedAttributeRegistrySub, globalComp, currSchemaDoc);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1349
                    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1350
                    else if (componentType.equals(SchemaSymbols.ELT_ATTRIBUTEGROUP)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1351
                        checkForDuplicateNames(qName, ATTRIBUTEGROUP_TYPE, fUnparsedAttributeGroupRegistry, fUnparsedAttributeGroupRegistrySub, globalComp, currSchemaDoc);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1352
                    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1353
                    else if ((componentType.equals(SchemaSymbols.ELT_COMPLEXTYPE)) ||
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1354
                            (componentType.equals(SchemaSymbols.ELT_SIMPLETYPE))) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1355
                        checkForDuplicateNames(qName, TYPEDECL_TYPE, fUnparsedTypeRegistry, fUnparsedTypeRegistrySub, globalComp, currSchemaDoc);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1356
                    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1357
                    else if (componentType.equals(SchemaSymbols.ELT_ELEMENT)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1358
                        checkForDuplicateNames(qName, ELEMENT_TYPE, fUnparsedElementRegistry, fUnparsedElementRegistrySub, globalComp, currSchemaDoc);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1359
                    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1360
                    else if (componentType.equals(SchemaSymbols.ELT_GROUP)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1361
                        checkForDuplicateNames(qName, GROUP_TYPE, fUnparsedGroupRegistry, fUnparsedGroupRegistrySub, globalComp, currSchemaDoc);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1362
                    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1363
                    else if (componentType.equals(SchemaSymbols.ELT_NOTATION)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1364
                        checkForDuplicateNames(qName, NOTATION_TYPE, fUnparsedNotationRegistry, fUnparsedNotationRegistrySub, globalComp, currSchemaDoc);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1365
                    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1366
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1367
            } // end for
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1368
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1369
            // now we're done with this one!
36146
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
  1370
            DOMUtil.setHidden(currDoc, fHiddenNodes);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1371
            // now add the schemas this guy depends on
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  1372
            List<XSDocumentInfo> currSchemaDepends = fDependencyMap.get(currSchemaDoc);
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  1373
            for (XSDocumentInfo currSchemaDepend : currSchemaDepends) {
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  1374
                schemasToProcess.push(currSchemaDepend);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1375
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1376
        } // while
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1377
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1378
    } // end buildGlobalNameRegistries
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1379
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1380
    // Beginning at the first schema processing was requested for
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1381
    // (fRoot), this method
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1382
    // examines each child (global schema information item) of each
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1383
    // schema document (and of each <redefine> element)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1384
    // corresponding to an XSDocumentInfo object.  If the
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1385
    // readOnly field on that node has not been set, it calls an
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1386
    // appropriate traverser to traverse it.  Once all global decls in
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1387
    // an XSDocumentInfo object have been traversed, it marks that object
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1388
    // as traversed (or hidden) in order to avoid infinite loops.  It completes
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1389
    // when it has visited all XSDocumentInfo objects in the
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1390
    // DependencyMap and marked them as traversed.
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  1391
    protected void traverseSchemas(List<Object> annotationInfo) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1392
        // the process here is very similar to that in
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1393
        // buildGlobalRegistries, except we can't set our schemas as
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1394
        // hidden for a second time; so make them all visible again
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1395
        // first!
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1396
        setSchemasVisible(fRoot);
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  1397
        Stack<XSDocumentInfo> schemasToProcess = new Stack<>();
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1398
        schemasToProcess.push(fRoot);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1399
        while (!schemasToProcess.empty()) {
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  1400
            XSDocumentInfo currSchemaDoc = schemasToProcess.pop();
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1401
            Element currDoc = currSchemaDoc.fSchemaElement;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1402
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1403
            SchemaGrammar currSG = fGrammarBucket.getGrammar(currSchemaDoc.fTargetNamespace);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1404
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1405
            if(DOMUtil.isHidden(currDoc, fHiddenNodes)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1406
                // must have processed this already!
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1407
                continue;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1408
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1409
            Element currRoot = currDoc;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1410
            boolean sawAnnotation = false;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1411
            // traverse this schema's global decls
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1412
            for (Element globalComp =
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1413
                DOMUtil.getFirstVisibleChildElement(currRoot, fHiddenNodes);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1414
            globalComp != null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1415
            globalComp = DOMUtil.getNextVisibleSiblingElement(globalComp, fHiddenNodes)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1416
                DOMUtil.setHidden(globalComp, fHiddenNodes);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1417
                String componentType = DOMUtil.getLocalName(globalComp);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1418
                // includes and imports will not show up here!
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1419
                if (DOMUtil.getLocalName(globalComp).equals(SchemaSymbols.ELT_REDEFINE)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1420
                    // use the namespace decls for the redefine, instead of for the parent <schema>
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  1421
                    currSchemaDoc.backupNSSupport((fRedefine2NSSupport!=null) ?
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  1422
                            fRedefine2NSSupport.get(globalComp) : null);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1423
                    for (Element redefinedComp = DOMUtil.getFirstVisibleChildElement(globalComp, fHiddenNodes);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1424
                    redefinedComp != null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1425
                    redefinedComp = DOMUtil.getNextVisibleSiblingElement(redefinedComp, fHiddenNodes)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1426
                        String redefinedComponentType = DOMUtil.getLocalName(redefinedComp);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1427
                        DOMUtil.setHidden(redefinedComp, fHiddenNodes);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1428
                        if (redefinedComponentType.equals(SchemaSymbols.ELT_ATTRIBUTEGROUP)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1429
                            fAttributeGroupTraverser.traverseGlobal(redefinedComp, currSchemaDoc, currSG);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1430
                        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1431
                        else if (redefinedComponentType.equals(SchemaSymbols.ELT_COMPLEXTYPE)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1432
                            fComplexTypeTraverser.traverseGlobal(redefinedComp, currSchemaDoc, currSG);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1433
                        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1434
                        else if (redefinedComponentType.equals(SchemaSymbols.ELT_GROUP)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1435
                            fGroupTraverser.traverseGlobal(redefinedComp, currSchemaDoc, currSG);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1436
                        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1437
                        else if (redefinedComponentType.equals(SchemaSymbols.ELT_SIMPLETYPE)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1438
                            fSimpleTypeTraverser.traverseGlobal(redefinedComp, currSchemaDoc, currSG);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1439
                        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1440
                        // annotations will have been processed already; this is now
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1441
                        // unnecessary
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1442
                        //else if (redefinedComponentType.equals(SchemaSymbols.ELT_ANNOTATION)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1443
                        //    fElementTraverser.traverseAnnotationDecl(redefinedComp, null, true, currSchemaDoc);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1444
                        //}
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1445
                        else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1446
                            reportSchemaError("s4s-elt-must-match.1", new Object [] {DOMUtil.getLocalName(globalComp), "(annotation | (simpleType | complexType | group | attributeGroup))*", redefinedComponentType}, redefinedComp);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1447
                        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1448
                    } // end march through <redefine> children
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1449
                    currSchemaDoc.restoreNSSupport();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1450
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1451
                else if (componentType.equals(SchemaSymbols.ELT_ATTRIBUTE)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1452
                    fAttributeTraverser.traverseGlobal(globalComp, currSchemaDoc, currSG);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1453
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1454
                else if (componentType.equals(SchemaSymbols.ELT_ATTRIBUTEGROUP)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1455
                    fAttributeGroupTraverser.traverseGlobal(globalComp, currSchemaDoc, currSG);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1456
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1457
                else if (componentType.equals(SchemaSymbols.ELT_COMPLEXTYPE)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1458
                    fComplexTypeTraverser.traverseGlobal(globalComp, currSchemaDoc, currSG);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1459
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1460
                else if (componentType.equals(SchemaSymbols.ELT_ELEMENT)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1461
                    fElementTraverser.traverseGlobal(globalComp, currSchemaDoc, currSG);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1462
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1463
                else if (componentType.equals(SchemaSymbols.ELT_GROUP)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1464
                    fGroupTraverser.traverseGlobal(globalComp, currSchemaDoc, currSG);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1465
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1466
                else if (componentType.equals(SchemaSymbols.ELT_NOTATION)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1467
                    fNotationTraverser.traverse(globalComp, currSchemaDoc, currSG);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1468
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1469
                else if (componentType.equals(SchemaSymbols.ELT_SIMPLETYPE)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1470
                    fSimpleTypeTraverser.traverseGlobal(globalComp, currSchemaDoc, currSG);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1471
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1472
                else if (componentType.equals(SchemaSymbols.ELT_ANNOTATION)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1473
                    currSG.addAnnotation(fElementTraverser.traverseAnnotationDecl(globalComp, currSchemaDoc.getSchemaAttrs(), true, currSchemaDoc));
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1474
                    sawAnnotation = true;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1475
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1476
                else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1477
                    reportSchemaError("s4s-elt-invalid-content.1", new Object [] {SchemaSymbols.ELT_SCHEMA, DOMUtil.getLocalName(globalComp)}, globalComp);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1478
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1479
            } // end for
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1480
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1481
            if (!sawAnnotation) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1482
                String text = DOMUtil.getSyntheticAnnotation(currRoot);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1483
                if (text != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1484
                    currSG.addAnnotation(fElementTraverser.traverseSyntheticAnnotation(currRoot, text, currSchemaDoc.getSchemaAttrs(), true, currSchemaDoc));
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1485
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1486
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1487
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1488
            /** Collect annotation information for validation. **/
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1489
            if (annotationInfo != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1490
                XSAnnotationInfo info = currSchemaDoc.getAnnotations();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1491
                /** Only add annotations to the list if there were any in this document. **/
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1492
                if (info != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1493
                    annotationInfo.add(doc2SystemId(currDoc));
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1494
                    annotationInfo.add(info);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1495
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1496
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1497
            // now we're done with this one!
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1498
            currSchemaDoc.returnSchemaAttrs();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1499
            DOMUtil.setHidden(currDoc, fHiddenNodes);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1500
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1501
            // now add the schemas this guy depends on
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  1502
            List<XSDocumentInfo> currSchemaDepends = fDependencyMap.get(currSchemaDoc);
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  1503
            for (XSDocumentInfo currSchemaDepend : currSchemaDepends) {
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  1504
                schemasToProcess.push(currSchemaDepend);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1505
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1506
        } // while
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1507
    } // end traverseSchemas
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1508
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1509
    // store whether we have reported an error about that no grammar
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1510
    // is found for the given namespace uri
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  1511
    private List<String> fReportedTNS = null;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1512
    // check whether we need to report an error against the given uri.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1513
    // if we have reported an error, then we don't need to report again;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1514
    // otherwise we reported the error, and remember this fact.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1515
    private final boolean needReportTNSError(String uri) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1516
        if (fReportedTNS == null)
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  1517
            fReportedTNS = new ArrayList<>();
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1518
        else if (fReportedTNS.contains(uri))
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1519
            return false;
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  1520
        fReportedTNS.add(uri);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1521
        return true;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1522
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1523
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1524
    private static final String[] COMP_TYPE = {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1525
            null,               // index 0
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1526
            "attribute declaration",
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1527
            "attribute group",
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1528
            "element declaration",
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1529
            "group",
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1530
            "identity constraint",
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1531
            "notation",
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1532
            "type definition",
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1533
    };
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1534
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1535
    private static final String[] CIRCULAR_CODES = {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1536
            "Internal-Error",
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1537
            "Internal-Error",
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1538
            "src-attribute_group.3",
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1539
            "e-props-correct.6",
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1540
            "mg-props-correct.2",
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1541
            "Internal-Error",
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1542
            "Internal-Error",
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1543
            "st-props-correct.2",       //or ct-props-correct.3
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1544
    };
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1545
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1546
    // add a global attribute decl from a current schema load (only if no existing decl is found)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1547
    void addGlobalAttributeDecl(XSAttributeDecl decl) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1548
        final String namespace = decl.getNamespace();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1549
        final String declKey = (namespace == null || namespace.length() == 0)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1550
            ? "," + decl.getName() : namespace + "," + decl.getName();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1551
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1552
        if (fGlobalAttrDecls.get(declKey) == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1553
            fGlobalAttrDecls.put(declKey, decl);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1554
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1555
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1556
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1557
    // add a global attribute group decl from a current schema load (only if no existing decl is found)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1558
    void addGlobalAttributeGroupDecl(XSAttributeGroupDecl decl) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1559
        final String namespace = decl.getNamespace();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1560
        final String declKey = (namespace == null || namespace.length() == 0)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1561
            ? "," + decl.getName() : namespace + "," + decl.getName();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1562
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1563
        if (fGlobalAttrGrpDecls.get(declKey) == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1564
            fGlobalAttrGrpDecls.put(declKey, decl);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1565
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1566
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1567
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1568
    // add a global element decl from a current schema load (only if no existing decl is found)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1569
    void addGlobalElementDecl(XSElementDecl decl) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1570
        final String namespace = decl.getNamespace();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1571
        final String declKey = (namespace == null || namespace.length() == 0)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1572
            ? "," + decl.getName() : namespace + "," + decl.getName();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1573
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1574
        if (fGlobalElemDecls.get(declKey) == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1575
            fGlobalElemDecls.put(declKey, decl);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1576
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1577
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1578
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1579
    // add a global group decl from a current schema load (only if no existing decl is found)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1580
    void addGlobalGroupDecl(XSGroupDecl decl) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1581
        final String namespace = decl.getNamespace();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1582
        final String declKey = (namespace == null || namespace.length() == 0)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1583
            ? "," + decl.getName() : namespace + "," + decl.getName();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1584
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1585
        if (fGlobalGroupDecls.get(declKey) == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1586
            fGlobalGroupDecls.put(declKey, decl);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1587
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1588
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1589
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1590
    // add a global notation decl from a current schema load (only if no existing decl is found)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1591
    void addGlobalNotationDecl(XSNotationDecl decl) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1592
        final String namespace = decl.getNamespace();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1593
        final String declKey = (namespace == null || namespace.length() == 0)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1594
            ? "," + decl.getName() : namespace + "," + decl.getName();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1595
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1596
        if (fGlobalNotationDecls.get(declKey) == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1597
            fGlobalNotationDecls.put(declKey, decl);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1598
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1599
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1600
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1601
    // add a global type decl from a current schema load (only if no existing decl is found)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1602
    void addGlobalTypeDecl(XSTypeDefinition decl) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1603
        final String namespace = decl.getNamespace();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1604
        final String declKey = (namespace == null || namespace.length() == 0)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1605
            ? "," + decl.getName() : namespace + "," + decl.getName();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1606
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1607
        if (fGlobalTypeDecls.get(declKey) == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1608
            fGlobalTypeDecls.put(declKey, decl);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1609
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1610
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1611
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1612
    // add a identity constraint decl from a current schema load (only if no existing decl is found)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1613
    void addIDConstraintDecl(IdentityConstraint decl) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1614
        final String namespace = decl.getNamespace();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1615
        final String declKey = (namespace == null || namespace.length() == 0)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1616
            ? "," + decl.getIdentityConstraintName() : namespace + "," + decl.getIdentityConstraintName();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1617
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1618
        if (fGlobalIDConstraintDecls.get(declKey) == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1619
            fGlobalIDConstraintDecls.put(declKey, decl);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1620
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1621
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1622
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1623
    private XSAttributeDecl getGlobalAttributeDecl(String declKey) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1624
        return (XSAttributeDecl)fGlobalAttrDecls.get(declKey);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1625
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1626
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1627
    private XSAttributeGroupDecl getGlobalAttributeGroupDecl(String declKey) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1628
        return (XSAttributeGroupDecl)fGlobalAttrGrpDecls.get(declKey);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1629
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1630
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1631
    private XSElementDecl getGlobalElementDecl(String declKey) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1632
        return (XSElementDecl)fGlobalElemDecls.get(declKey);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1633
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1634
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1635
    private XSGroupDecl getGlobalGroupDecl(String declKey) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1636
        return (XSGroupDecl)fGlobalGroupDecls.get(declKey);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1637
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1638
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1639
    private XSNotationDecl getGlobalNotationDecl(String declKey) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1640
        return (XSNotationDecl)fGlobalNotationDecls.get(declKey);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1641
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1642
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1643
    private XSTypeDefinition getGlobalTypeDecl(String declKey) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1644
        return (XSTypeDefinition)fGlobalTypeDecls.get(declKey);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1645
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1646
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1647
    private IdentityConstraint getIDConstraintDecl(String declKey) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1648
        return (IdentityConstraint)fGlobalIDConstraintDecls.get(declKey);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1649
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1650
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1651
    // since it is forbidden for traversers to talk to each other
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1652
    // directly (except wen a traverser encounters a local declaration),
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1653
    // this provides a generic means for a traverser to call
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1654
    // for the traversal of some declaration.  An XSDocumentInfo is
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1655
    // required because the XSDocumentInfo that the traverser is traversing
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1656
    // may bear no relation to the one the handler is operating on.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1657
    // This method will:
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1658
    // 1.  See if a global definition matching declToTraverse exists;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1659
    // 2. if so, determine if there is a path from currSchema to the
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1660
    // schema document where declToTraverse lives (i.e., do a lookup
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1661
    // in DependencyMap);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1662
    // 3. depending on declType (which will be relevant to step 1 as
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1663
    // well), call the appropriate traverser with the appropriate
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1664
    // XSDocumentInfo object.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1665
    // This method returns whatever the traverser it called returned;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1666
    // this will be an Object of some kind
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1667
    // that lives in the Grammar.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1668
    protected Object getGlobalDecl(XSDocumentInfo currSchema,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1669
            int declType,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1670
            QName declToTraverse,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1671
            Element elmNode) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1672
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1673
        if (DEBUG_NODE_POOL) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1674
            System.out.println("TRAVERSE_GL: "+declToTraverse.toString());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1675
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1676
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1677
        // from the schema spec, all built-in types are present in all schemas,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1678
        // so if the requested component is a type, and could be found in the
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1679
        // default schema grammar, we should return that type.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1680
        // otherwise (since we would support user-defined schema grammar) we'll
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1681
        // use the normal way to get the decl
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1682
        if (declToTraverse.uri != null &&
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1683
                declToTraverse.uri == SchemaSymbols.URI_SCHEMAFORSCHEMA) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1684
            if (declType == TYPEDECL_TYPE) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1685
                Object retObj = SchemaGrammar.SG_SchemaNS.getGlobalTypeDecl(declToTraverse.localpart);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1686
                if (retObj != null)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1687
                    return retObj;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1688
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1689
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1690
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1691
        // now check whether this document can access the requsted namespace
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1692
        if (!currSchema.isAllowedNS(declToTraverse.uri)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1693
            // cannot get to this schema from the one containing the requesting decl
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1694
            if (currSchema.needReportTNSError(declToTraverse.uri)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1695
                String code = declToTraverse.uri == null ? "src-resolve.4.1" : "src-resolve.4.2";
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1696
                reportSchemaError(code, new Object[]{fDoc2SystemId.get(currSchema.fSchemaElement), declToTraverse.uri, declToTraverse.rawname}, elmNode);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1697
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1698
            // Recover and continue to look for the component.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1699
            // return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1700
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1701
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1702
        // check whether there is grammar for the requested namespace
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1703
        SchemaGrammar sGrammar = fGrammarBucket.getGrammar(declToTraverse.uri);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1704
        if (sGrammar == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1705
            if (needReportTNSError(declToTraverse.uri))
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1706
                reportSchemaError("src-resolve", new Object[]{declToTraverse.rawname, COMP_TYPE[declType]}, elmNode);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1707
            return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1708
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1709
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1710
        // if there is such grammar, check whether the requested component is in the grammar
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1711
        Object retObj = getGlobalDeclFromGrammar(sGrammar, declType, declToTraverse.localpart);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1712
        String declKey = declToTraverse.uri == null? ","+declToTraverse.localpart:
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1713
            declToTraverse.uri+","+declToTraverse.localpart;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1714
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1715
        // if the component is parsed, return it
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1716
        if (!fTolerateDuplicates) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1717
            if (retObj != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1718
                return retObj;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1719
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1720
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1721
        else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1722
            Object retObj2 = getGlobalDecl(declKey, declType);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1723
            if (retObj2 != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1724
                return retObj2;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1725
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1726
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1727
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1728
        XSDocumentInfo schemaWithDecl = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1729
        Element decl = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1730
        XSDocumentInfo declDoc = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1731
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1732
        // the component is not parsed, try to find a DOM element for it
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1733
        switch (declType) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1734
        case ATTRIBUTE_TYPE :
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1735
            decl = getElementFromMap(fUnparsedAttributeRegistry, declKey);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1736
            declDoc = getDocInfoFromMap(fUnparsedAttributeRegistrySub, declKey);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1737
            break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1738
        case ATTRIBUTEGROUP_TYPE :
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1739
            decl = getElementFromMap(fUnparsedAttributeGroupRegistry, declKey);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1740
            declDoc = getDocInfoFromMap(fUnparsedAttributeGroupRegistrySub, declKey);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1741
            break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1742
        case ELEMENT_TYPE :
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1743
            decl = getElementFromMap(fUnparsedElementRegistry, declKey);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1744
            declDoc = getDocInfoFromMap(fUnparsedElementRegistrySub, declKey);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1745
            break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1746
        case GROUP_TYPE :
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1747
            decl = getElementFromMap(fUnparsedGroupRegistry, declKey);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1748
            declDoc = getDocInfoFromMap(fUnparsedGroupRegistrySub, declKey);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1749
            break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1750
        case IDENTITYCONSTRAINT_TYPE :
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1751
            decl = getElementFromMap(fUnparsedIdentityConstraintRegistry, declKey);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1752
            declDoc = getDocInfoFromMap(fUnparsedIdentityConstraintRegistrySub, declKey);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1753
            break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1754
        case NOTATION_TYPE :
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1755
            decl = getElementFromMap(fUnparsedNotationRegistry, declKey);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1756
            declDoc = getDocInfoFromMap(fUnparsedNotationRegistrySub, declKey);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1757
            break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1758
        case TYPEDECL_TYPE :
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1759
            decl = getElementFromMap(fUnparsedTypeRegistry, declKey);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1760
            declDoc = getDocInfoFromMap(fUnparsedTypeRegistrySub, declKey);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1761
            break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1762
        default:
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1763
            reportSchemaError("Internal-Error", new Object [] {"XSDHandler asked to locate component of type " + declType + "; it does not recognize this type!"}, elmNode);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1764
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1765
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1766
        // no DOM element found, so the component can't be located
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1767
        if (decl == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1768
            if (retObj == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1769
                reportSchemaError("src-resolve", new Object[]{declToTraverse.rawname, COMP_TYPE[declType]}, elmNode);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1770
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1771
            return retObj;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1772
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1773
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1774
        // get the schema doc containing the component to be parsed
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1775
        // it should always return non-null value, but since null-checking
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1776
        // comes for free, let's be safe and check again
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1777
        schemaWithDecl = findXSDocumentForDecl(currSchema, decl, declDoc);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1778
        if (schemaWithDecl == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1779
            // cannot get to this schema from the one containing the requesting decl
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1780
            if (retObj == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1781
                String code = declToTraverse.uri == null ? "src-resolve.4.1" : "src-resolve.4.2";
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1782
                reportSchemaError(code, new Object[]{fDoc2SystemId.get(currSchema.fSchemaElement), declToTraverse.uri, declToTraverse.rawname}, elmNode);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1783
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1784
            return retObj;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1785
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1786
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1787
        // a component is hidden, meaning either it's traversed, or being traversed.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1788
        // but we didn't find it in the grammar, so it's the latter case, and
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1789
        // a circular reference. error!
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1790
        if (DOMUtil.isHidden(decl, fHiddenNodes)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1791
            if (retObj == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1792
                String code = CIRCULAR_CODES[declType];
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1793
                if (declType == TYPEDECL_TYPE) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1794
                    if (SchemaSymbols.ELT_COMPLEXTYPE.equals(DOMUtil.getLocalName(decl))) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1795
                        code = "ct-props-correct.3";
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1796
                    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1797
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1798
                // decl must not be null if we're here...
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1799
                reportSchemaError(code, new Object [] {declToTraverse.prefix+":"+declToTraverse.localpart}, elmNode);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1800
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1801
            return retObj;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1802
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1803
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1804
        return traverseGlobalDecl(declType, decl, schemaWithDecl, sGrammar);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1805
    } // getGlobalDecl(XSDocumentInfo, int, QName):  Object
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1806
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1807
    // If we are tolerating duplicate declarations and allowing namespace growth
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1808
    // use the declaration from the current schema load (if it exists)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1809
    protected Object getGlobalDecl(String declKey, int declType) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1810
        Object retObj = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1811
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1812
        switch (declType) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1813
        case ATTRIBUTE_TYPE :
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1814
            retObj = getGlobalAttributeDecl(declKey);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1815
            break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1816
        case ATTRIBUTEGROUP_TYPE :
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1817
            retObj = getGlobalAttributeGroupDecl(declKey);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1818
            break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1819
        case ELEMENT_TYPE :
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1820
            retObj = getGlobalElementDecl(declKey);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1821
            break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1822
        case GROUP_TYPE :
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1823
            retObj = getGlobalGroupDecl(declKey);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1824
            break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1825
        case IDENTITYCONSTRAINT_TYPE :
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1826
            retObj = getIDConstraintDecl(declKey);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1827
            break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1828
        case NOTATION_TYPE :
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1829
            retObj = getGlobalNotationDecl(declKey);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1830
            break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1831
        case TYPEDECL_TYPE :
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1832
            retObj = getGlobalTypeDecl(declKey);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1833
            break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1834
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1835
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1836
        return retObj;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1837
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1838
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1839
    protected Object getGlobalDeclFromGrammar(SchemaGrammar sGrammar, int declType, String localpart) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1840
        Object retObj = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1841
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1842
        switch (declType) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1843
        case ATTRIBUTE_TYPE :
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1844
            retObj = sGrammar.getGlobalAttributeDecl(localpart);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1845
            break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1846
        case ATTRIBUTEGROUP_TYPE :
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1847
            retObj = sGrammar.getGlobalAttributeGroupDecl(localpart);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1848
            break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1849
        case ELEMENT_TYPE :
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1850
            retObj = sGrammar.getGlobalElementDecl(localpart);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1851
            break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1852
        case GROUP_TYPE :
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1853
            retObj = sGrammar.getGlobalGroupDecl(localpart);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1854
            break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1855
        case IDENTITYCONSTRAINT_TYPE :
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1856
            retObj = sGrammar.getIDConstraintDecl(localpart);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1857
            break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1858
        case NOTATION_TYPE :
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1859
            retObj = sGrammar.getGlobalNotationDecl(localpart);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1860
            break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1861
        case TYPEDECL_TYPE :
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1862
            retObj = sGrammar.getGlobalTypeDecl(localpart);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1863
            break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1864
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1865
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1866
        return retObj;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1867
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1868
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1869
    protected Object getGlobalDeclFromGrammar(SchemaGrammar sGrammar, int declType, String localpart, String schemaLoc) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1870
        Object retObj = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1871
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1872
        switch (declType) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1873
        case ATTRIBUTE_TYPE :
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1874
            retObj = sGrammar.getGlobalAttributeDecl(localpart, schemaLoc);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1875
            break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1876
        case ATTRIBUTEGROUP_TYPE :
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1877
            retObj = sGrammar.getGlobalAttributeGroupDecl(localpart, schemaLoc);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1878
            break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1879
        case ELEMENT_TYPE :
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1880
            retObj = sGrammar.getGlobalElementDecl(localpart, schemaLoc);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1881
            break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1882
        case GROUP_TYPE :
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1883
            retObj = sGrammar.getGlobalGroupDecl(localpart, schemaLoc);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1884
            break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1885
        case IDENTITYCONSTRAINT_TYPE :
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1886
            retObj = sGrammar.getIDConstraintDecl(localpart, schemaLoc);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1887
            break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1888
        case NOTATION_TYPE :
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1889
            retObj = sGrammar.getGlobalNotationDecl(localpart, schemaLoc);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1890
            break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1891
        case TYPEDECL_TYPE :
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1892
            retObj = sGrammar.getGlobalTypeDecl(localpart, schemaLoc);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1893
            break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1894
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1895
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1896
        return retObj;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1897
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1898
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  1899
    protected Object traverseGlobalDecl(int declType, Element decl,
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  1900
            XSDocumentInfo schemaDoc, SchemaGrammar grammar) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1901
        Object retObj = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1902
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1903
        DOMUtil.setHidden(decl, fHiddenNodes);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1904
        SchemaNamespaceSupport nsSupport = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1905
        // if the parent is <redefine> use the namespace delcs for it.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1906
        Element parent = DOMUtil.getParent(decl);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1907
        if (DOMUtil.getLocalName(parent).equals(SchemaSymbols.ELT_REDEFINE))
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  1908
            nsSupport = (fRedefine2NSSupport!=null) ? fRedefine2NSSupport.get(parent) : null;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1909
        // back up the current SchemaNamespaceSupport, because we need to provide
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1910
        // a fresh one to the traverseGlobal methods.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1911
        schemaDoc.backupNSSupport(nsSupport);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1912
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1913
        // traverse the referenced global component
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1914
        switch (declType) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1915
        case TYPEDECL_TYPE :
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1916
            if (DOMUtil.getLocalName(decl).equals(SchemaSymbols.ELT_COMPLEXTYPE)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1917
                retObj = fComplexTypeTraverser.traverseGlobal(decl, schemaDoc, grammar);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1918
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1919
            else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1920
                retObj = fSimpleTypeTraverser.traverseGlobal(decl, schemaDoc, grammar);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1921
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1922
            break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1923
        case ATTRIBUTE_TYPE :
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1924
            retObj = fAttributeTraverser.traverseGlobal(decl, schemaDoc, grammar);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1925
            break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1926
        case ELEMENT_TYPE :
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1927
            retObj = fElementTraverser.traverseGlobal(decl, schemaDoc, grammar);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1928
            break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1929
        case ATTRIBUTEGROUP_TYPE :
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1930
            retObj = fAttributeGroupTraverser.traverseGlobal(decl, schemaDoc, grammar);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1931
            break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1932
        case GROUP_TYPE :
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1933
            retObj = fGroupTraverser.traverseGlobal(decl, schemaDoc, grammar);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1934
            break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1935
        case NOTATION_TYPE :
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1936
            retObj = fNotationTraverser.traverse(decl, schemaDoc, grammar);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1937
            break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1938
        case IDENTITYCONSTRAINT_TYPE :
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1939
            // identity constraints should have been parsed already...
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1940
            // we should never get here
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1941
            break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1942
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1943
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1944
        // restore the previous SchemaNamespaceSupport, so that the caller can get
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1945
        // proper namespace binding.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1946
        schemaDoc.restoreNSSupport();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1947
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1948
        return retObj;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1949
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1950
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1951
    public String schemaDocument2SystemId(XSDocumentInfo schemaDoc) {
36146
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
  1952
        return fDoc2SystemId.get(schemaDoc.fSchemaElement);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1953
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1954
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1955
    // This method determines whether there is a group
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1956
    // (attributeGroup) which the given one has redefined by
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1957
    // restriction.  If so, it returns it; else it returns null.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1958
    // @param type:  whether what's been redefined is an
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1959
    // attributeGroup or a group;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1960
    // @param name:  the QName of the component doing the redefining.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1961
    // @param currSchema:  schema doc in which the redefining component lives.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1962
    // @return:  Object representing decl redefined if present, null
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1963
    // otherwise.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1964
    Object getGrpOrAttrGrpRedefinedByRestriction(int type, QName name, XSDocumentInfo currSchema, Element elmNode) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1965
        String realName = name.uri != null?name.uri+","+name.localpart:
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1966
            ","+name.localpart;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1967
        String nameToFind = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1968
        switch (type) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1969
        case ATTRIBUTEGROUP_TYPE:
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  1970
            nameToFind = fRedefinedRestrictedAttributeGroupRegistry.get(realName);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1971
            break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1972
        case GROUP_TYPE:
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  1973
            nameToFind = fRedefinedRestrictedGroupRegistry.get(realName);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1974
            break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1975
        default:
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1976
            return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1977
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1978
        if (nameToFind == null) return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1979
        int commaPos = nameToFind.indexOf(",");
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1980
        QName qNameToFind = new QName(XMLSymbols.EMPTY_STRING, nameToFind.substring(commaPos+1),
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1981
                nameToFind.substring(commaPos), (commaPos == 0)? null : nameToFind.substring(0, commaPos));
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1982
        Object retObj = getGlobalDecl(currSchema, type, qNameToFind, elmNode);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1983
        if(retObj == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1984
            switch (type) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1985
            case ATTRIBUTEGROUP_TYPE:
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1986
                reportSchemaError("src-redefine.7.2.1", new Object []{name.localpart}, elmNode);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1987
                break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1988
            case GROUP_TYPE:
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1989
                reportSchemaError("src-redefine.6.2.1", new Object []{name.localpart}, elmNode);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1990
                break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1991
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1992
            return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1993
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1994
        return retObj;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1995
    } // getGrpOrAttrGrpRedefinedByRestriction(int, QName, XSDocumentInfo):  Object
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1996
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1997
    // Since ID constraints can occur in local elements, unless we
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1998
    // wish to completely traverse all our DOM trees looking for ID
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1999
    // constraints while we're building our global name registries,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2000
    // which seems terribly inefficient, we need to resolve keyrefs
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2001
    // after all parsing is complete.  This we can simply do by running through
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2002
    // fIdentityConstraintRegistry and calling traverseKeyRef on all
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2003
    // of the KeyRef nodes.  This unfortunately removes this knowledge
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2004
    // from the elementTraverser class (which must ignore keyrefs),
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2005
    // but there seems to be no efficient way around this...
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2006
    protected void resolveKeyRefs() {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2007
        for (int i=0; i<fKeyrefStackPos; i++) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2008
            XSDocumentInfo keyrefSchemaDoc = fKeyrefsMapXSDocumentInfo[i];
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2009
            keyrefSchemaDoc.fNamespaceSupport.makeGlobal();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2010
            keyrefSchemaDoc.fNamespaceSupport.setEffectiveContext( fKeyrefNamespaceContext[i] );
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2011
            SchemaGrammar keyrefGrammar = fGrammarBucket.getGrammar(keyrefSchemaDoc.fTargetNamespace);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2012
            // need to set <keyref> to hidden before traversing it,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2013
            // because it has global scope
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2014
                DOMUtil.setHidden(fKeyrefs[i], fHiddenNodes);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2015
            fKeyrefTraverser.traverse(fKeyrefs[i], fKeyrefElems[i], keyrefSchemaDoc, keyrefGrammar);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2016
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2017
    } // end resolveKeyRefs
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2018
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2019
    // an accessor method.  Just makes sure callers
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2020
    // who want the Identity constraint registry vaguely know what they're about.
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  2021
    protected Map<String, Element> getIDRegistry() {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2022
        return fUnparsedIdentityConstraintRegistry;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2023
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2024
    // an accessor method.
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  2025
    protected Map<String, XSDocumentInfo> getIDRegistry_sub() {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2026
        return fUnparsedIdentityConstraintRegistrySub;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2027
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2028
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2029
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2030
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2031
    // This method squirrels away <keyref> declarations--along with the element
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2032
    // decls and namespace bindings they might find handy.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2033
    protected void storeKeyRef (Element keyrefToStore, XSDocumentInfo schemaDoc,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2034
            XSElementDecl currElemDecl) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2035
        String keyrefName = DOMUtil.getAttrValue(keyrefToStore, SchemaSymbols.ATT_NAME);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2036
        if (keyrefName.length() != 0) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2037
            String keyrefQName = schemaDoc.fTargetNamespace == null?
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2038
                    "," + keyrefName: schemaDoc.fTargetNamespace+","+keyrefName;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2039
            checkForDuplicateNames(keyrefQName, IDENTITYCONSTRAINT_TYPE, fUnparsedIdentityConstraintRegistry, fUnparsedIdentityConstraintRegistrySub, keyrefToStore, schemaDoc);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2040
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2041
        // now set up all the registries we'll need...
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2042
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2043
        // check array sizes
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2044
        if (fKeyrefStackPos == fKeyrefs.length) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2045
            Element [] elemArray = new Element [fKeyrefStackPos + INC_KEYREF_STACK_AMOUNT];
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2046
            System.arraycopy(fKeyrefs, 0, elemArray, 0, fKeyrefStackPos);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2047
            fKeyrefs = elemArray;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2048
            XSElementDecl [] declArray = new XSElementDecl [fKeyrefStackPos + INC_KEYREF_STACK_AMOUNT];
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2049
            System.arraycopy(fKeyrefElems, 0, declArray, 0, fKeyrefStackPos);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2050
            fKeyrefElems = declArray;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2051
            String[][] stringArray = new String [fKeyrefStackPos + INC_KEYREF_STACK_AMOUNT][];
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2052
            System.arraycopy(fKeyrefNamespaceContext, 0, stringArray, 0, fKeyrefStackPos);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2053
            fKeyrefNamespaceContext = stringArray;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2054
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2055
            XSDocumentInfo [] xsDocumentInfo = new XSDocumentInfo [fKeyrefStackPos + INC_KEYREF_STACK_AMOUNT];
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2056
            System.arraycopy(fKeyrefsMapXSDocumentInfo, 0, xsDocumentInfo, 0, fKeyrefStackPos);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2057
            fKeyrefsMapXSDocumentInfo = xsDocumentInfo;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2058
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2059
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2060
        fKeyrefs[fKeyrefStackPos] = keyrefToStore;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2061
        fKeyrefElems[fKeyrefStackPos] = currElemDecl;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2062
        fKeyrefNamespaceContext[fKeyrefStackPos] = schemaDoc.fNamespaceSupport.getEffectiveLocalContext();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2063
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2064
        fKeyrefsMapXSDocumentInfo[fKeyrefStackPos++] = schemaDoc;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2065
    } // storeKeyref (Element, XSDocumentInfo, XSElementDecl): void
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2066
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2067
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2068
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2069
     * resolveSchema method is responsible for resolving location of the schema (using XMLEntityResolver),
39080
57563e513b11 8158204: accessExternalSchema property handling is inconsistent and differs from spec.
joehw
parents: 36146
diff changeset
  2070
     * and if it was successfully resolved getting the schema Document.
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2071
     * @param desc
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2072
     * @param mustResolve
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2073
     * @param referElement
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2074
     * @return A schema Element or null.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2075
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2076
    private Element resolveSchema(XSDDescription desc, boolean mustResolve,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2077
                                  Element referElement, boolean usePairs) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2078
        XMLInputSource schemaSource = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2079
        try {
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 25868
diff changeset
  2080
            Map<String, XMLSchemaLoader.LocationArray> pairs = usePairs ? fLocationPairs : Collections.emptyMap();
36146
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
  2081
            schemaSource = XMLSchemaLoader.resolveDocument(desc, pairs, fEntityManager);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2082
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2083
        catch (IOException ex) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2084
            if (mustResolve) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2085
                reportSchemaError("schema_reference.4",
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2086
                        new Object[]{desc.getLocationHints()[0]},
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2087
                        referElement);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2088
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2089
            else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2090
                reportSchemaWarning("schema_reference.4",
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2091
                        new Object[]{desc.getLocationHints()[0]},
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2092
                        referElement);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2093
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2094
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2095
        if (schemaSource instanceof DOMInputSource) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2096
            return getSchemaDocument(desc.getTargetNamespace(), (DOMInputSource) schemaSource, mustResolve, desc.getContextType(), referElement);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2097
        } // DOMInputSource
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2098
        else if (schemaSource instanceof SAXInputSource) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2099
            return getSchemaDocument(desc.getTargetNamespace(), (SAXInputSource) schemaSource, mustResolve, desc.getContextType(), referElement);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2100
        } // SAXInputSource
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2101
        else if (schemaSource instanceof StAXInputSource) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2102
            return getSchemaDocument(desc.getTargetNamespace(), (StAXInputSource) schemaSource, mustResolve, desc.getContextType(), referElement);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2103
        } // StAXInputSource
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2104
        else if (schemaSource instanceof XSInputSource) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2105
            return getSchemaDocument((XSInputSource) schemaSource, desc);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2106
        } // XSInputSource
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2107
        return getSchemaDocument(desc.getTargetNamespace(), schemaSource, mustResolve, desc.getContextType(), referElement);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2108
    } // getSchema(String, String, String, boolean, short):  Document
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2109
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2110
    private Element resolveSchema(XMLInputSource schemaSource, XSDDescription desc,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2111
            boolean mustResolve, Element referElement) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2112
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2113
        if (schemaSource instanceof DOMInputSource) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2114
            return getSchemaDocument(desc.getTargetNamespace(), (DOMInputSource) schemaSource, mustResolve, desc.getContextType(), referElement);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2115
        } // DOMInputSource
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2116
        else if (schemaSource instanceof SAXInputSource) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2117
            return getSchemaDocument(desc.getTargetNamespace(), (SAXInputSource) schemaSource, mustResolve, desc.getContextType(), referElement);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2118
        } // SAXInputSource
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2119
        else if (schemaSource instanceof StAXInputSource) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2120
            return getSchemaDocument(desc.getTargetNamespace(), (StAXInputSource) schemaSource, mustResolve, desc.getContextType(), referElement);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2121
        } // StAXInputSource
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2122
        else if (schemaSource instanceof XSInputSource) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2123
            return getSchemaDocument((XSInputSource) schemaSource, desc);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2124
        } // XSInputSource
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2125
        return getSchemaDocument(desc.getTargetNamespace(), schemaSource, mustResolve, desc.getContextType(), referElement);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2126
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2127
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2128
    private XMLInputSource resolveSchemaSource(XSDDescription desc, boolean mustResolve,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2129
            Element referElement, boolean usePairs) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2130
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2131
        XMLInputSource schemaSource = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2132
        try {
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 25868
diff changeset
  2133
            Map<String, XMLSchemaLoader.LocationArray> pairs = usePairs ? fLocationPairs : Collections.emptyMap();
36146
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
  2134
            schemaSource = XMLSchemaLoader.resolveDocument(desc, pairs, fEntityManager);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2135
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2136
        catch (IOException ex) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2137
            if (mustResolve) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2138
                reportSchemaError("schema_reference.4",
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2139
                        new Object[]{desc.getLocationHints()[0]},
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2140
                        referElement);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2141
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2142
            else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2143
                reportSchemaWarning("schema_reference.4",
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2144
                        new Object[]{desc.getLocationHints()[0]},
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2145
                        referElement);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2146
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2147
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2148
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2149
        return schemaSource;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2150
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2151
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2152
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2153
     * getSchemaDocument method uses XMLInputSource to parse a schema document.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2154
     * @param schemaNamespace
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2155
     * @param schemaSource
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2156
     * @param mustResolve
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2157
     * @param referType
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2158
     * @param referElement
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2159
     * @return A schema Element.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2160
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2161
    private Element getSchemaDocument(String schemaNamespace, XMLInputSource schemaSource,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2162
            boolean mustResolve, short referType, Element referElement) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2163
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2164
        boolean hasInput = true;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2165
        IOException exception = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2166
        // contents of this method will depend on the system we adopt for entity resolution--i.e., XMLEntityHandler, EntityHandler, etc.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2167
        Element schemaElement = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2168
        try {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2169
            // when the system id and byte stream and character stream
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2170
            // of the input source are all null, it's
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2171
            // impossible to find the schema document. so we skip in
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2172
            // this case. otherwise we'll receive some NPE or
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2173
            // file not found errors. but schemaHint=="" is perfectly
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2174
            // legal for import.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2175
            if (schemaSource != null &&
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2176
                    (schemaSource.getSystemId() != null ||
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2177
                            schemaSource.getByteStream() != null ||
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2178
                            schemaSource.getCharacterStream() != null)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2179
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2180
                // When the system id of the input source is used, first try to
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2181
                // expand it, and check whether the same document has been
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2182
                // parsed before. If so, return the document corresponding to
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2183
                // that system id.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2184
                XSDKey key = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2185
                String schemaId = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2186
                if (referType != XSDDescription.CONTEXT_PREPARSE){
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2187
                    schemaId = XMLEntityManager.expandSystemId(schemaSource.getSystemId(), schemaSource.getBaseSystemId(), false);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2188
                    key = new XSDKey(schemaId, referType, schemaNamespace);
36146
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
  2189
                    if((schemaElement = fTraversed.get(key)) != null) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2190
                        fLastSchemaWasDuplicate = true;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2191
                        return schemaElement;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2192
                    }
39080
57563e513b11 8158204: accessExternalSchema property handling is inconsistent and differs from spec.
joehw
parents: 36146
diff changeset
  2193
                    if ((!schemaSource.isCreatedByResolver()) &&
57563e513b11 8158204: accessExternalSchema property handling is inconsistent and differs from spec.
joehw
parents: 36146
diff changeset
  2194
                            (referType == XSDDescription.CONTEXT_IMPORT || referType == XSDDescription.CONTEXT_INCLUDE
57563e513b11 8158204: accessExternalSchema property handling is inconsistent and differs from spec.
joehw
parents: 36146
diff changeset
  2195
                            || referType == XSDDescription.CONTEXT_REDEFINE)) {
17534
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 12457
diff changeset
  2196
                        String accessError = SecuritySupport.checkAccess(schemaId, fAccessExternalSchema, Constants.ACCESS_EXTERNAL_ALL);
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 12457
diff changeset
  2197
                        if (accessError != null) {
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 12457
diff changeset
  2198
                            reportSchemaFatalError("schema_reference.access",
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 12457
diff changeset
  2199
                                    new Object[] { SecuritySupport.sanitizePath(schemaId), accessError },
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 12457
diff changeset
  2200
                                    referElement);
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 12457
diff changeset
  2201
                        }
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 12457
diff changeset
  2202
                    }
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2203
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2204
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2205
                fSchemaParser.parse(schemaSource);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2206
                Document schemaDocument = fSchemaParser.getDocument();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2207
                schemaElement = schemaDocument != null ? DOMUtil.getRoot(schemaDocument) : null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2208
                return getSchemaDocument0(key, schemaId, schemaElement);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2209
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2210
            else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2211
                hasInput = false;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2212
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2213
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2214
        catch (IOException ex) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2215
            exception = ex;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2216
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2217
        return getSchemaDocument1(mustResolve, hasInput, schemaSource, referElement, exception);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2218
    } // getSchemaDocument(String, XMLInputSource, boolean, short, Element): Element
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2219
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2220
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2221
     * getSchemaDocument method uses SAXInputSource to parse a schema document.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2222
     * @param schemaNamespace
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2223
     * @param schemaSource
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2224
     * @param mustResolve
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2225
     * @param referType
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2226
     * @param referElement
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2227
     * @return A schema Element.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2228
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2229
    private Element getSchemaDocument(String schemaNamespace, SAXInputSource schemaSource,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2230
            boolean mustResolve, short referType, Element referElement) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2231
        XMLReader parser = schemaSource.getXMLReader();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2232
        InputSource inputSource = schemaSource.getInputSource();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2233
        boolean hasInput = true;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2234
        IOException exception = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2235
        Element schemaElement = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2236
        try {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2237
            if (inputSource != null &&
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2238
                    (inputSource.getSystemId() != null ||
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2239
                     inputSource.getByteStream() != null ||
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2240
                     inputSource.getCharacterStream() != null)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2241
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2242
                // check whether the same document has been parsed before.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2243
                // If so, return the document corresponding to that system id.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2244
                XSDKey key = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2245
                String schemaId = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2246
                if (referType != XSDDescription.CONTEXT_PREPARSE) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2247
                    schemaId = XMLEntityManager.expandSystemId(inputSource.getSystemId(), schemaSource.getBaseSystemId(), false);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2248
                    key = new XSDKey(schemaId, referType, schemaNamespace);
36146
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
  2249
                    if ((schemaElement = fTraversed.get(key)) != null) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2250
                        fLastSchemaWasDuplicate = true;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2251
                        return schemaElement;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2252
                    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2253
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2254
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2255
                boolean namespacePrefixes = false;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2256
                if (parser != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2257
                    try {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2258
                        namespacePrefixes = parser.getFeature(NAMESPACE_PREFIXES);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2259
                    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2260
                    catch (SAXException se) {}
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2261
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2262
                else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2263
                    try {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2264
                        parser = XMLReaderFactory.createXMLReader();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2265
                    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2266
                    // If something went wrong with the factory
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2267
                    // just use our own SAX parser.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2268
                    catch (SAXException se) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2269
                        parser = new SAXParser();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2270
                    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2271
                    try {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2272
                        parser.setFeature(NAMESPACE_PREFIXES, true);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2273
                        namespacePrefixes = true;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2274
                        // If this is a Xerces SAX parser set the security manager if there is one
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2275
                        if (parser instanceof SAXParser) {
36146
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
  2276
                            if (fSecurityManager != null) {
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
  2277
                                parser.setProperty(SECURITY_MANAGER, fSecurityManager);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2278
                            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2279
                        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2280
                    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2281
                    catch (SAXException se) {}
18890
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 17534
diff changeset
  2282
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 17534
diff changeset
  2283
                    try {
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 17534
diff changeset
  2284
                        parser.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, fAccessExternalDTD);
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 17534
diff changeset
  2285
                    } catch (SAXNotRecognizedException exc) {
35729
49f1515c5f5c 8144593: Suppress not recognized property/feature warning messages from SAXParser
aefimov
parents: 33349
diff changeset
  2286
                        XMLSecurityManager.printWarning(parser.getClass().getName(),
49f1515c5f5c 8144593: Suppress not recognized property/feature warning messages from SAXParser
aefimov
parents: 33349
diff changeset
  2287
                                XMLConstants.ACCESS_EXTERNAL_DTD, exc);
18890
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 17534
diff changeset
  2288
                    }
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2289
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2290
                // If XML names and Namespace URIs are already internalized we
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2291
                // can avoid running them through the SymbolTable.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2292
                boolean stringsInternalized = false;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2293
                try {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2294
                    stringsInternalized = parser.getFeature(STRING_INTERNING);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2295
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2296
                catch (SAXException exc) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2297
                    // The feature isn't recognized or getting it is not supported.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2298
                    // In either case, assume that strings are not internalized.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2299
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2300
                if (fXSContentHandler == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2301
                    fXSContentHandler = new SchemaContentHandler();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2302
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2303
                fXSContentHandler.reset(fSchemaParser, fSymbolTable,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2304
                        namespacePrefixes, stringsInternalized);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2305
                parser.setContentHandler(fXSContentHandler);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2306
                parser.setErrorHandler(fErrorReporter.getSAXErrorHandler());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2307
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2308
                parser.parse(inputSource);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2309
                // Disconnect the schema loader and other objects from the XMLReader
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2310
                try {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2311
                    parser.setContentHandler(null);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2312
                    parser.setErrorHandler(null);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2313
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2314
                // Ignore any exceptions thrown by the XMLReader. Old versions of SAX
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2315
                // required an XMLReader to throw a NullPointerException if an attempt
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2316
                // to set a handler to null was made.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2317
                catch (Exception e) {}
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2318
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2319
                Document schemaDocument = fXSContentHandler.getDocument();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2320
                schemaElement = schemaDocument != null ? DOMUtil.getRoot(schemaDocument) : null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2321
                return getSchemaDocument0(key, schemaId, schemaElement);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2322
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2323
            else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2324
                hasInput = false;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2325
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2326
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2327
        catch (SAXParseException spe) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2328
            throw SAX2XNIUtil.createXMLParseException0(spe);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2329
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2330
        catch (SAXException se) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2331
            throw SAX2XNIUtil.createXNIException0(se);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2332
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2333
        catch (IOException ioe) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2334
            exception = ioe;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2335
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2336
        return getSchemaDocument1(mustResolve, hasInput, schemaSource, referElement, exception);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2337
    } // getSchemaDocument(String, SAXInputSource, boolean, short, Element): Element
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2338
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2339
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2340
     * getSchemaDocument method uses DOMInputSource to parse a schema document.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2341
     * @param schemaNamespace
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2342
     * @param schemaSource
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2343
     * @param mustResolve
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2344
     * @param referType
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2345
     * @param referElement
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2346
     * @return A schema Element.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2347
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2348
    private Element getSchemaDocument(String schemaNamespace, DOMInputSource schemaSource,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2349
            boolean mustResolve, short referType, Element referElement) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2350
        boolean hasInput = true;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2351
        IOException exception = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2352
        Element schemaElement = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2353
        Element schemaRootElement = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2354
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2355
        final Node node = schemaSource.getNode();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2356
        short nodeType = -1;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2357
        if (node != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2358
            nodeType = node.getNodeType();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2359
            if (nodeType == Node.DOCUMENT_NODE) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2360
                schemaRootElement = DOMUtil.getRoot((Document) node);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2361
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2362
            else if (nodeType == Node.ELEMENT_NODE) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2363
                schemaRootElement = (Element) node;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2364
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2365
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2366
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2367
        try {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2368
            if (schemaRootElement != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2369
                // check whether the same document has been parsed before.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2370
                // If so, return the document corresponding to that system id.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2371
                XSDKey key = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2372
                String schemaId = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2373
                if (referType != XSDDescription.CONTEXT_PREPARSE) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2374
                    schemaId = XMLEntityManager.expandSystemId(schemaSource.getSystemId(), schemaSource.getBaseSystemId(), false);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2375
                    boolean isDocument = (nodeType == Node.DOCUMENT_NODE);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2376
                    if (!isDocument) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2377
                        Node parent = schemaRootElement.getParentNode();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2378
                        if (parent != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2379
                            isDocument = (parent.getNodeType() == Node.DOCUMENT_NODE);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2380
                        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2381
                    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2382
                    if (isDocument) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2383
                        key = new XSDKey(schemaId, referType, schemaNamespace);
36146
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
  2384
                        if ((schemaElement = fTraversed.get(key)) != null) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2385
                            fLastSchemaWasDuplicate = true;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2386
                            return schemaElement;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2387
                        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2388
                    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2389
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2390
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2391
                schemaElement = schemaRootElement;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2392
                return getSchemaDocument0(key, schemaId, schemaElement);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2393
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2394
            else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2395
                hasInput = false;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2396
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2397
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2398
        catch (IOException ioe) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2399
            exception = ioe;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2400
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2401
        return getSchemaDocument1(mustResolve, hasInput, schemaSource, referElement, exception);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2402
    } // getSchemaDocument(String, DOMInputSource, boolean, short, Element): Element
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2403
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2404
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2405
     * getSchemaDocument method uses StAXInputSource to parse a schema document.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2406
     * @param schemaNamespace
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2407
     * @param schemaSource
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2408
     * @param mustResolve
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2409
     * @param referType
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2410
     * @param referElement
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2411
     * @return A schema Element.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2412
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2413
    private Element getSchemaDocument(String schemaNamespace, StAXInputSource schemaSource,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2414
            boolean mustResolve, short referType, Element referElement) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2415
        IOException exception = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2416
        Element schemaElement = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2417
        try {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2418
            final boolean consumeRemainingContent = schemaSource.shouldConsumeRemainingContent();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2419
            final XMLStreamReader streamReader = schemaSource.getXMLStreamReader();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2420
            final XMLEventReader eventReader = schemaSource.getXMLEventReader();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2421
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2422
            // check whether the same document has been parsed before.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2423
            // If so, return the document corresponding to that system id.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2424
            XSDKey key = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2425
            String schemaId = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2426
            if (referType != XSDDescription.CONTEXT_PREPARSE) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2427
                schemaId = XMLEntityManager.expandSystemId(schemaSource.getSystemId(), schemaSource.getBaseSystemId(), false);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2428
                boolean isDocument = consumeRemainingContent;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2429
                if (!isDocument) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2430
                    if (streamReader != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2431
                        isDocument = (streamReader.getEventType() == XMLStreamReader.START_DOCUMENT);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2432
                    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2433
                    else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2434
                        isDocument = eventReader.peek().isStartDocument();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2435
                    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2436
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2437
                if (isDocument) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2438
                    key = new XSDKey(schemaId, referType, schemaNamespace);
36146
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
  2439
                    if ((schemaElement = fTraversed.get(key)) != null) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2440
                        fLastSchemaWasDuplicate = true;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2441
                        return schemaElement;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2442
                    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2443
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2444
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2445
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2446
            if (fStAXSchemaParser == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2447
                fStAXSchemaParser = new StAXSchemaParser();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2448
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2449
            fStAXSchemaParser.reset(fSchemaParser, fSymbolTable);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2450
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2451
            if (streamReader != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2452
                fStAXSchemaParser.parse(streamReader);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2453
                if (consumeRemainingContent) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2454
                    while (streamReader.hasNext()) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2455
                        streamReader.next();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2456
                    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2457
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2458
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2459
            else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2460
                fStAXSchemaParser.parse(eventReader);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2461
                if (consumeRemainingContent) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2462
                    while (eventReader.hasNext()) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2463
                        eventReader.nextEvent();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2464
                    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2465
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2466
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2467
            Document schemaDocument = fStAXSchemaParser.getDocument();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2468
            schemaElement = schemaDocument != null ? DOMUtil.getRoot(schemaDocument) : null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2469
            return getSchemaDocument0(key, schemaId, schemaElement);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2470
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2471
        catch (XMLStreamException e) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2472
            StAXLocationWrapper slw = new StAXLocationWrapper();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2473
            slw.setLocation(e.getLocation());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2474
            throw new XMLParseException(slw, e.getMessage(), e);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2475
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2476
        catch (IOException e) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2477
            exception = e;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2478
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2479
        return getSchemaDocument1(mustResolve, true, schemaSource, referElement, exception);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2480
    } // getSchemaDocument(String, StAXInputSource, boolean, short, Element): Element
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2481
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2482
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2483
     * Code shared between the various getSchemaDocument() methods which
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2484
     * stores mapping information for the document.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2485
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2486
    private Element getSchemaDocument0(XSDKey key, String schemaId, Element schemaElement) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2487
        // now we need to store the mapping information from system id
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2488
        // to the document. also from the document to the system id.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2489
        if (key != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2490
            fTraversed.put(key, schemaElement);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2491
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2492
        if (schemaId != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2493
            fDoc2SystemId.put(schemaElement, schemaId);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2494
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2495
        fLastSchemaWasDuplicate = false;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2496
        return schemaElement;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2497
    } // getSchemaDocument0(XSDKey, String, Element): Element
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2498
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2499
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2500
     * Error handling code shared between the various getSchemaDocument() methods.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2501
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2502
    private Element getSchemaDocument1(boolean mustResolve, boolean hasInput,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2503
            XMLInputSource schemaSource, Element referElement, IOException ioe) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2504
        // either an error occured (exception), or empty input source was
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2505
        // returned, we need to report an error or a warning
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2506
        if (mustResolve) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2507
            if (hasInput) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2508
                reportSchemaError("schema_reference.4",
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2509
                        new Object[]{schemaSource.getSystemId()},
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2510
                        referElement, ioe);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2511
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2512
            else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2513
                reportSchemaError("schema_reference.4",
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2514
                        new Object[]{schemaSource == null ? "" : schemaSource.getSystemId()},
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2515
                        referElement, ioe);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2516
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2517
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2518
        else if (hasInput) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2519
            reportSchemaWarning("schema_reference.4",
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2520
                    new Object[]{schemaSource.getSystemId()},
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2521
                    referElement, ioe);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2522
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2523
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2524
        fLastSchemaWasDuplicate = false;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2525
        return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2526
    } // getSchemaDocument1(boolean, boolean, XMLInputSource, Element): Element
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2527
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2528
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2529
     * getSchemaDocument method uses XMLInputSource to parse a schema document.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2530
     * @param schemaNamespace
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2531
     * @param schemaSource
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2532
     * @param mustResolve
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2533
     * @param referType
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2534
     * @param referElement
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2535
     * @return A schema Element.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2536
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2537
    private Element getSchemaDocument(XSInputSource schemaSource, XSDDescription desc) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2538
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2539
        SchemaGrammar[] grammars = schemaSource.getGrammars();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2540
        short referType = desc.getContextType();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2541
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2542
        if (grammars != null && grammars.length > 0) {
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  2543
           List<SchemaGrammar> expandedGrammars = expandGrammars(grammars);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2544
            // check for existing grammars in our bucket
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2545
            // and if there exist any, and namespace growth is
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2546
            // not enabled - we do nothing
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2547
            if (fNamespaceGrowth || !existingGrammars(expandedGrammars)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2548
                addGrammars(expandedGrammars);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2549
                if (referType == XSDDescription.CONTEXT_PREPARSE) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2550
                    desc.setTargetNamespace(grammars[0].getTargetNamespace());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2551
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2552
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2553
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2554
        else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2555
            XSObject[] components = schemaSource.getComponents();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2556
            if (components != null && components.length > 0) {
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  2557
                Map<String, List<String>> importDependencies = new HashMap<>();
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  2558
                List<XSObject> expandedComponents = expandComponents(components, importDependencies);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2559
                if (fNamespaceGrowth || canAddComponents(expandedComponents)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2560
                    addGlobalComponents(expandedComponents, importDependencies);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2561
                    if (referType == XSDDescription.CONTEXT_PREPARSE) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2562
                        desc.setTargetNamespace(components[0].getNamespace());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2563
                    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2564
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2565
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2566
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2567
        return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2568
    } // getSchemaDocument(String, XSInputSource, boolean, short, Element): Element
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2569
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  2570
    private List<SchemaGrammar> expandGrammars(SchemaGrammar[] grammars) {
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  2571
        List<SchemaGrammar> currGrammars = new ArrayList<>();
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2572
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2573
        for (int i=0; i<grammars.length; i++) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2574
            if (!currGrammars.contains(grammars[i])) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2575
                currGrammars.add(grammars[i]);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2576
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2577
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2578
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2579
        // for all (recursively) imported grammars
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2580
        SchemaGrammar sg1, sg2;
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  2581
        List<SchemaGrammar> gs;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2582
        for (int i = 0; i < currGrammars.size(); i++) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2583
            // get the grammar
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  2584
            sg1 = (SchemaGrammar)currGrammars.get(i);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2585
            // we need to add grammars imported by sg1 too
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2586
            gs = sg1.getImportedGrammars();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2587
            // for all grammars imported by sg2, but not in the vector
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2588
            // we add them to the vector
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2589
            if (gs == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2590
                continue;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2591
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2592
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2593
            for (int j = gs.size() - 1; j >= 0; j--) {
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  2594
                sg2 = (SchemaGrammar)gs.get(j);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2595
                if (!currGrammars.contains(sg2)) {
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  2596
                    currGrammars.add(sg2);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2597
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2598
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2599
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2600
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2601
        return currGrammars;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2602
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2603
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  2604
    private boolean existingGrammars(List<SchemaGrammar> grammars) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2605
        int length = grammars.size();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2606
        final XSDDescription desc = new XSDDescription();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2607
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2608
        for (int i=0; i < length; i++) {
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  2609
            final SchemaGrammar sg1 = (SchemaGrammar)grammars.get(i);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2610
            desc.setNamespace(sg1.getTargetNamespace());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2611
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2612
            final SchemaGrammar sg2 = findGrammar(desc, false);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2613
            if (sg2 != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2614
                return true;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2615
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2616
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2617
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2618
        return false;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2619
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2620
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  2621
    private boolean canAddComponents(List<XSObject> components) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2622
        final int size = components.size();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2623
        final XSDDescription desc = new XSDDescription();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2624
        for (int i=0; i<size; i++) {
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  2625
            XSObject component = (XSObject) components.get(i);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2626
            if (!canAddComponent(component, desc)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2627
                return false;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2628
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2629
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2630
        return true;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2631
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2632
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2633
    private boolean canAddComponent(XSObject component, XSDDescription desc) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2634
        desc.setNamespace(component.getNamespace());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2635
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2636
        final SchemaGrammar sg = findGrammar(desc, false);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2637
        if (sg == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2638
            return true;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2639
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2640
        else if (sg.isImmutable()) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2641
            return false;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2642
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2643
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2644
        short componentType = component.getType();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2645
        final String name = component.getName();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2646
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2647
        switch (componentType) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2648
        case XSConstants.TYPE_DEFINITION :
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2649
            if (sg.getGlobalTypeDecl(name) == component) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2650
                return true;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2651
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2652
            break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2653
        case XSConstants.ATTRIBUTE_DECLARATION :
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2654
            if (sg.getGlobalAttributeDecl(name) == component) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2655
                return true;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2656
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2657
            break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2658
        case XSConstants.ATTRIBUTE_GROUP :
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2659
            if (sg.getGlobalAttributeDecl(name) == component) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2660
                return true;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2661
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2662
            break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2663
        case XSConstants.ELEMENT_DECLARATION :
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2664
            if (sg.getGlobalElementDecl(name) == component) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2665
                return true;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2666
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2667
            break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2668
        case XSConstants.MODEL_GROUP_DEFINITION :
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2669
            if (sg.getGlobalGroupDecl(name) == component) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2670
                return true;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2671
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2672
            break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2673
        case XSConstants.NOTATION_DECLARATION :
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2674
            if (sg.getGlobalNotationDecl(name) == component) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2675
                return true;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2676
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2677
            break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2678
        case XSConstants.IDENTITY_CONSTRAINT :
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2679
        case XSConstants.ATTRIBUTE_USE :
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2680
        default :
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2681
            return true;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2682
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2683
        return false;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2684
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2685
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  2686
    private void addGrammars(List<SchemaGrammar> grammars) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2687
        int length = grammars.size();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2688
        XSDDescription desc = new XSDDescription();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2689
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2690
        for (int i=0; i < length; i++) {
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  2691
            final SchemaGrammar sg1 = grammars.get(i);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2692
            desc.setNamespace(sg1.getTargetNamespace());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2693
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2694
            final SchemaGrammar sg2 = findGrammar(desc, fNamespaceGrowth);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2695
            if (sg1 != sg2) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2696
                addGrammarComponents(sg1, sg2);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2697
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2698
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2699
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2700
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2701
    private void addGrammarComponents(SchemaGrammar srcGrammar, SchemaGrammar dstGrammar) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2702
        if (dstGrammar == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2703
            createGrammarFrom(srcGrammar);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2704
            return;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2705
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2706
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2707
        SchemaGrammar tmpGrammar = dstGrammar;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2708
        if (tmpGrammar.isImmutable()) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2709
            tmpGrammar = createGrammarFrom(dstGrammar);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2710
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2711
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2712
        // add any new locations
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2713
        addNewGrammarLocations(srcGrammar, tmpGrammar);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2714
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2715
        // add any new imported grammars
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2716
        addNewImportedGrammars(srcGrammar, tmpGrammar);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2717
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2718
        // add any new global components
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2719
        addNewGrammarComponents(srcGrammar, tmpGrammar);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2720
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2721
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2722
    private SchemaGrammar createGrammarFrom(SchemaGrammar grammar) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2723
        SchemaGrammar newGrammar = new SchemaGrammar(grammar);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2724
        fGrammarBucket.putGrammar(newGrammar);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2725
        // update all the grammars in the bucket to point to the new grammar.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2726
        updateImportListWith(newGrammar);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2727
        // update import list of the new grammar
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2728
        updateImportListFor(newGrammar);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2729
        return newGrammar;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2730
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2731
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2732
    private void addNewGrammarLocations(SchemaGrammar srcGrammar, SchemaGrammar dstGrammar) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2733
        final StringList locations = srcGrammar.getDocumentLocations();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2734
        final int locSize = locations.size();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2735
        final StringList locations2 = dstGrammar.getDocumentLocations();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2736
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2737
        for (int i=0; i<locSize; i++) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2738
            String loc = locations.item(i);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2739
            if (!locations2.contains(loc)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2740
                dstGrammar.addDocument(null, loc);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2741
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2742
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2743
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2744
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  2745
    @SuppressWarnings("unchecked")
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2746
    private void addNewImportedGrammars(SchemaGrammar srcGrammar, SchemaGrammar dstGrammar) {
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  2747
        final ArrayList<SchemaGrammar> igs1 = (ArrayList<SchemaGrammar>)srcGrammar.getImportedGrammars();
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2748
        if (igs1 != null) {
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  2749
           ArrayList<SchemaGrammar> igs2 = (ArrayList<SchemaGrammar>)dstGrammar.getImportedGrammars();
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2750
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2751
            if (igs2 == null) {
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  2752
                igs2 = (ArrayList<SchemaGrammar>)igs1.clone();
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2753
                dstGrammar.setImportedGrammars(igs2);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2754
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2755
            else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2756
                updateImportList(igs1, igs2);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2757
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2758
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2759
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2760
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  2761
    private void updateImportList(List<SchemaGrammar> importedSrc, List<SchemaGrammar> importedDst)
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2762
    {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2763
        final int size = importedSrc.size();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2764
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2765
        for (int i=0; i<size; i++) {
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  2766
            final SchemaGrammar sg = (SchemaGrammar) importedSrc.get(i);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2767
            if (!containedImportedGrammar(importedDst, sg)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2768
                importedDst.add(sg);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2769
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2770
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2771
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2772
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2773
    private void addNewGrammarComponents(SchemaGrammar srcGrammar, SchemaGrammar dstGrammar) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2774
        dstGrammar.resetComponents();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2775
        addGlobalElementDecls(srcGrammar, dstGrammar);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2776
        addGlobalAttributeDecls(srcGrammar, dstGrammar);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2777
        addGlobalAttributeGroupDecls(srcGrammar, dstGrammar);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2778
        addGlobalGroupDecls(srcGrammar, dstGrammar);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2779
        addGlobalTypeDecls(srcGrammar, dstGrammar);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2780
        addGlobalNotationDecls(srcGrammar, dstGrammar);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2781
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2782
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2783
    private void addGlobalElementDecls(SchemaGrammar srcGrammar, SchemaGrammar dstGrammar) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2784
        XSNamedMap components = srcGrammar.getComponents(XSConstants.ELEMENT_DECLARATION);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2785
        int len = components.getLength();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2786
        XSElementDecl srcDecl, dstDecl;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2787
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2788
        // add global components
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2789
        for (int i=0; i<len; i++) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2790
            srcDecl = (XSElementDecl) components.item(i);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2791
            dstDecl = dstGrammar.getGlobalElementDecl(srcDecl.getName());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2792
            if (dstDecl == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2793
                dstGrammar.addGlobalElementDecl(srcDecl);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2794
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2795
            else if (dstDecl != srcDecl){
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2796
                // TODO: if not tolerating duplicate, generate an error message
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2797
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2798
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2799
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2800
        // add any extended (duplicate) global components
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2801
        ObjectList componentsExt = srcGrammar.getComponentsExt(XSConstants.ELEMENT_DECLARATION);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2802
        len = componentsExt.getLength();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2803
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2804
        for (int i=0; i<len; i+= 2) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2805
            final String key = (String) componentsExt.item(i);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2806
            final int index = key.indexOf(',');
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2807
            final String location = key.substring(0, index);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2808
            final String name = key.substring(index + 1, key.length());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2809
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2810
            srcDecl = (XSElementDecl)componentsExt.item(i+1);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2811
            dstDecl = dstGrammar.getGlobalElementDecl(name, location);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2812
            if ( dstDecl == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2813
                dstGrammar.addGlobalElementDecl(srcDecl, location);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2814
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2815
            else if (dstDecl != srcDecl){
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2816
                // TODO: if not tolerating duplicate, generate an error message
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2817
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2818
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2819
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2820
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2821
    private void addGlobalAttributeDecls(SchemaGrammar srcGrammar, SchemaGrammar dstGrammar) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2822
        XSNamedMap components = srcGrammar.getComponents(XSConstants.ATTRIBUTE_DECLARATION);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2823
        int len = components.getLength();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2824
        XSAttributeDecl srcDecl, dstDecl;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2825
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2826
        // add global components
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2827
        for (int i=0; i<len; i++) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2828
            srcDecl = (XSAttributeDecl) components.item(i);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2829
            dstDecl = dstGrammar.getGlobalAttributeDecl(srcDecl.getName());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2830
            if (dstDecl == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2831
                dstGrammar.addGlobalAttributeDecl(srcDecl);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2832
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2833
            else if (dstDecl != srcDecl && !fTolerateDuplicates) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2834
                reportSharingError(srcDecl.getNamespace(), srcDecl.getName());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2835
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2836
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2837
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2838
        // add any extended (duplicate) global components
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2839
        ObjectList componentsExt = srcGrammar.getComponentsExt(XSConstants.ATTRIBUTE_DECLARATION);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2840
        len = componentsExt.getLength();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2841
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2842
        for (int i=0; i<len; i+= 2) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2843
            final String key = (String) componentsExt.item(i);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2844
            final int index = key.indexOf(',');
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2845
            final String location = key.substring(0, index);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2846
            final String name = key.substring(index + 1, key.length());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2847
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2848
            srcDecl = (XSAttributeDecl)componentsExt.item(i+1);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2849
            dstDecl = dstGrammar.getGlobalAttributeDecl(name, location);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2850
            if (dstDecl == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2851
                dstGrammar.addGlobalAttributeDecl(srcDecl, location);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2852
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2853
            // REVISIT - do we report an error?
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2854
            else if (dstDecl != srcDecl) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2855
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2856
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2857
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2858
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2859
    private void addGlobalAttributeGroupDecls(SchemaGrammar srcGrammar, SchemaGrammar dstGrammar) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2860
        XSNamedMap components = srcGrammar.getComponents(XSConstants.ATTRIBUTE_GROUP);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2861
        int len = components.getLength();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2862
        XSAttributeGroupDecl srcDecl, dstDecl;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2863
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2864
        // add global components
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2865
        for (int i=0; i<len; i++) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2866
            srcDecl = (XSAttributeGroupDecl) components.item(i);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2867
            dstDecl = dstGrammar.getGlobalAttributeGroupDecl(srcDecl.getName());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2868
            if (dstDecl == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2869
                dstGrammar.addGlobalAttributeGroupDecl(srcDecl);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2870
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2871
            else if (dstDecl != srcDecl && !fTolerateDuplicates) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2872
                reportSharingError(srcDecl.getNamespace(), srcDecl.getName());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2873
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2874
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2875
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2876
        // add any extended (duplicate) global components
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2877
        ObjectList componentsExt = srcGrammar.getComponentsExt(XSConstants.ATTRIBUTE_GROUP);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2878
        len = componentsExt.getLength();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2879
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2880
        for (int i=0; i<len; i+= 2) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2881
            final String key = (String) componentsExt.item(i);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2882
            final int index = key.indexOf(',');
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2883
            final String location = key.substring(0, index);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2884
            final String name = key.substring(index + 1, key.length());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2885
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2886
            srcDecl = (XSAttributeGroupDecl)componentsExt.item(i+1);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2887
            dstDecl = dstGrammar.getGlobalAttributeGroupDecl(name, location);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2888
            if (dstDecl == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2889
                dstGrammar.addGlobalAttributeGroupDecl(srcDecl, location);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2890
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2891
            // REVISIT - do we report an error?
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2892
            else if (dstDecl != srcDecl) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2893
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2894
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2895
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2896
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2897
    private void addGlobalNotationDecls(SchemaGrammar srcGrammar, SchemaGrammar dstGrammar) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2898
        XSNamedMap components = srcGrammar.getComponents(XSConstants.NOTATION_DECLARATION);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2899
        int len = components.getLength();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2900
        XSNotationDecl srcDecl, dstDecl;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2901
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2902
        // add global components
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2903
        for (int i=0; i<len; i++) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2904
            srcDecl = (XSNotationDecl) components.item(i);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2905
            dstDecl = dstGrammar.getGlobalNotationDecl(srcDecl.getName());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2906
            if (dstDecl == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2907
                dstGrammar.addGlobalNotationDecl(srcDecl);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2908
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2909
            else if (dstDecl != srcDecl && !fTolerateDuplicates) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2910
                reportSharingError(srcDecl.getNamespace(), srcDecl.getName());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2911
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2912
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2913
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2914
        // add any extended (duplicate) global components
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2915
        ObjectList componentsExt = srcGrammar.getComponentsExt(XSConstants.NOTATION_DECLARATION);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2916
        len = componentsExt.getLength();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2917
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2918
        for (int i=0; i<len; i+= 2) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2919
            final String key = (String) componentsExt.item(i);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2920
            final int index = key.indexOf(',');
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2921
            final String location = key.substring(0, index);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2922
            final String name = key.substring(index + 1, key.length());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2923
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2924
            srcDecl = (XSNotationDecl)componentsExt.item(i+1);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2925
            dstDecl = dstGrammar.getGlobalNotationDecl(name, location);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2926
            if (dstDecl == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2927
                dstGrammar.addGlobalNotationDecl(srcDecl, location);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2928
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2929
            // REVISIT - do we report an error?
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2930
            else if (dstDecl != srcDecl) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2931
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2932
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2933
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2934
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2935
    private void addGlobalGroupDecls(SchemaGrammar srcGrammar, SchemaGrammar dstGrammar) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2936
        XSNamedMap components = srcGrammar.getComponents(XSConstants.MODEL_GROUP_DEFINITION);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2937
        int len = components.getLength();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2938
        XSGroupDecl srcDecl, dstDecl;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2939
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2940
        // add global components
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2941
        for (int i=0; i<len; i++) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2942
            srcDecl = (XSGroupDecl) components.item(i);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2943
            dstDecl = dstGrammar.getGlobalGroupDecl(srcDecl.getName());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2944
            if (dstDecl == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2945
                dstGrammar.addGlobalGroupDecl(srcDecl);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2946
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2947
            else if (srcDecl != dstDecl && !fTolerateDuplicates) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2948
                reportSharingError(srcDecl.getNamespace(), srcDecl.getName());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2949
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2950
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2951
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2952
        // add any extended (duplicate) global components
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2953
        ObjectList componentsExt = srcGrammar.getComponentsExt(XSConstants.MODEL_GROUP_DEFINITION);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2954
        len = componentsExt.getLength();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2955
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2956
        for (int i=0; i<len; i+= 2) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2957
            final String key = (String) componentsExt.item(i);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2958
            final int index = key.indexOf(',');
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2959
            final String location = key.substring(0, index);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2960
            final String name = key.substring(index + 1, key.length());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2961
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2962
            srcDecl = (XSGroupDecl)componentsExt.item(i+1);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2963
            dstDecl = dstGrammar.getGlobalGroupDecl(name, location);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2964
            if (dstDecl == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2965
                dstGrammar.addGlobalGroupDecl(srcDecl, location);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2966
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2967
            // REVIST - do we report an error?
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2968
            else if (dstDecl != srcDecl) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2969
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2970
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2971
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2972
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2973
    private void addGlobalTypeDecls(SchemaGrammar srcGrammar, SchemaGrammar dstGrammar) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2974
        XSNamedMap components = srcGrammar.getComponents(XSConstants.TYPE_DEFINITION);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2975
        int len = components.getLength();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2976
        XSTypeDefinition srcDecl, dstDecl;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2977
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2978
        // add global components
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2979
        for (int i=0; i<len; i++) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2980
            srcDecl = (XSTypeDefinition) components.item(i);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2981
            dstDecl = dstGrammar.getGlobalTypeDecl(srcDecl.getName());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2982
            if (dstDecl == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2983
                dstGrammar.addGlobalTypeDecl(srcDecl);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2984
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2985
            else if (dstDecl != srcDecl && !fTolerateDuplicates) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2986
                reportSharingError(srcDecl.getNamespace(), srcDecl.getName());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2987
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2988
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2989
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2990
        // add any extended (duplicate) global components
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2991
        ObjectList componentsExt = srcGrammar.getComponentsExt(XSConstants.TYPE_DEFINITION);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2992
        len = componentsExt.getLength();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2993
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2994
        for (int i=0; i<len; i+= 2) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2995
            final String key = (String) componentsExt.item(i);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2996
            final int index = key.indexOf(',');
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2997
            final String location = key.substring(0, index);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2998
            final String name = key.substring(index + 1, key.length());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2999
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3000
            srcDecl = (XSTypeDefinition)componentsExt.item(i+1);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3001
            dstDecl = dstGrammar.getGlobalTypeDecl(name, location);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3002
            if (dstDecl == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3003
                dstGrammar.addGlobalTypeDecl(srcDecl, location);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3004
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3005
            // REVISIT - do we report an error?
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3006
            else if (dstDecl != srcDecl) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3007
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3008
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3009
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3010
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  3011
    private List<XSObject> expandComponents(XSObject[] components, Map<String, List<String>> dependencies) {
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  3012
        List<XSObject> newComponents = new ArrayList<>();
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3013
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3014
        for (int i=0; i<components.length; i++) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3015
            if (!newComponents.contains(components[i])) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3016
                newComponents.add(components[i]);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3017
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3018
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3019
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3020
        for (int i=0; i<newComponents.size(); i++) {
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  3021
            final XSObject component = newComponents.get(i);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3022
            expandRelatedComponents(component, newComponents, dependencies);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3023
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3024
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3025
        return newComponents;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3026
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3027
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  3028
    private void expandRelatedComponents(XSObject component,List<XSObject>componentList, Map<String, List<String>> dependencies) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3029
        short componentType = component.getType();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3030
        switch (componentType) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3031
        case XSConstants.TYPE_DEFINITION :
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3032
            expandRelatedTypeComponents((XSTypeDefinition) component, componentList, component.getNamespace(), dependencies);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3033
            break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3034
        case XSConstants.ATTRIBUTE_DECLARATION :
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3035
            expandRelatedAttributeComponents((XSAttributeDeclaration) component, componentList, component.getNamespace(), dependencies);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3036
            break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3037
        case XSConstants.ATTRIBUTE_GROUP :
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3038
            expandRelatedAttributeGroupComponents((XSAttributeGroupDefinition) component, componentList, component.getNamespace(), dependencies);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3039
        case XSConstants.ELEMENT_DECLARATION :
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3040
            expandRelatedElementComponents((XSElementDeclaration) component, componentList, component.getNamespace(), dependencies);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3041
            break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3042
        case XSConstants.MODEL_GROUP_DEFINITION :
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3043
            expandRelatedModelGroupDefinitionComponents((XSModelGroupDefinition) component, componentList, component.getNamespace(), dependencies);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3044
        case XSConstants.ATTRIBUTE_USE :
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3045
            //expandRelatedAttributeUseComponents((XSAttributeUse)component, componentList, dependencies);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3046
        case XSConstants.NOTATION_DECLARATION :
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3047
        case XSConstants.IDENTITY_CONSTRAINT :
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3048
        default :
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3049
            break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3050
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3051
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3052
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  3053
    private void expandRelatedAttributeComponents(XSAttributeDeclaration decl, List<XSObject> componentList, String namespace, Map<String, List<String>> dependencies) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3054
        addRelatedType(decl.getTypeDefinition(), componentList, namespace, dependencies);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3055
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3056
        /*final XSComplexTypeDefinition enclosingType = decl.getEnclosingCTDefinition();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3057
        if (enclosingType != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3058
            addRelatedType(enclosingType, componentList, namespace, dependencies);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3059
        }*/
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3060
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3061
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  3062
    private void expandRelatedElementComponents(XSElementDeclaration decl, List<XSObject> componentList, String namespace, Map<String, List<String>> dependencies) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3063
        addRelatedType(decl.getTypeDefinition(), componentList, namespace, dependencies);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3064
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3065
        /*final XSTypeDefinition enclosingType = decl.getEnclosingCTDefinition();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3066
        if (enclosingType != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3067
            addRelatedType(enclosingType, componentList, namespace, dependencies);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3068
        }*/
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3069
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3070
        final XSElementDeclaration subElemDecl = decl.getSubstitutionGroupAffiliation();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3071
        if (subElemDecl != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3072
            addRelatedElement(subElemDecl, componentList, namespace, dependencies);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3073
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3074
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3075
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  3076
    private void expandRelatedTypeComponents(XSTypeDefinition type, List<XSObject> componentList, String namespace, Map<String, List<String>> dependencies) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3077
        if (type instanceof XSComplexTypeDecl) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3078
            expandRelatedComplexTypeComponents((XSComplexTypeDecl) type, componentList, namespace, dependencies);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3079
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3080
        else if (type instanceof XSSimpleTypeDecl) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3081
            expandRelatedSimpleTypeComponents((XSSimpleTypeDefinition) type, componentList, namespace, dependencies);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3082
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3083
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3084
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  3085
    private void expandRelatedModelGroupDefinitionComponents(XSModelGroupDefinition modelGroupDef, List<XSObject>componentList,
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  3086
            String namespace, Map<String, List<String>> dependencies) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3087
        expandRelatedModelGroupComponents(modelGroupDef.getModelGroup(), componentList, namespace, dependencies);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3088
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3089
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  3090
    private void expandRelatedAttributeGroupComponents(XSAttributeGroupDefinition attrGroup, List<XSObject> componentList
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  3091
            , String namespace, Map<String, List<String>> dependencies) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3092
        expandRelatedAttributeUsesComponents(attrGroup.getAttributeUses(), componentList, namespace, dependencies);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3093
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3094
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  3095
    private void expandRelatedComplexTypeComponents(XSComplexTypeDecl type, List<XSObject> componentList, String namespace, Map<String, List<String>> dependencies) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3096
        addRelatedType(type.getBaseType(), componentList, namespace, dependencies);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3097
        expandRelatedAttributeUsesComponents(type.getAttributeUses(), componentList, namespace, dependencies);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3098
        final XSParticle particle = type.getParticle();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3099
        if (particle != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3100
            expandRelatedParticleComponents(particle, componentList, namespace, dependencies);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3101
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3102
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3103
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  3104
    private void expandRelatedSimpleTypeComponents(XSSimpleTypeDefinition type, List<XSObject> componentList, String namespace, Map<String, List<String>> dependencies) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3105
        final XSTypeDefinition baseType = type.getBaseType();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3106
        if (baseType != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3107
            addRelatedType(baseType, componentList, namespace, dependencies);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3108
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3109
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3110
        final XSTypeDefinition itemType = type.getItemType();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3111
        if (itemType != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3112
            addRelatedType(itemType, componentList, namespace, dependencies);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3113
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3114
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3115
        final XSTypeDefinition primitiveType = type.getPrimitiveType();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3116
        if (primitiveType != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3117
            addRelatedType(primitiveType, componentList, namespace, dependencies);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3118
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3119
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3120
        final XSObjectList memberTypes = type.getMemberTypes();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3121
        if (memberTypes.size() > 0) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3122
            for (int i=0; i<memberTypes.size(); i++) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3123
                addRelatedType((XSTypeDefinition)memberTypes.item(i), componentList, namespace, dependencies);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3124
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3125
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3126
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3127
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  3128
    private void expandRelatedAttributeUsesComponents(XSObjectList attrUses, List<XSObject> componentList,
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  3129
            String namespace, Map<String, List<String>> dependencies) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3130
        final int attrUseSize = (attrUses == null) ? 0 : attrUses.size();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3131
        for (int i=0; i<attrUseSize; i++) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3132
            expandRelatedAttributeUseComponents((XSAttributeUse)attrUses.item(i), componentList, namespace, dependencies);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3133
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3134
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3135
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  3136
    private void expandRelatedAttributeUseComponents(XSAttributeUse component, List<XSObject> componentList,
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  3137
            String namespace, Map<String, List<String>> dependencies) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3138
        addRelatedAttribute(component.getAttrDeclaration(), componentList, namespace, dependencies);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3139
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3140
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  3141
    private void expandRelatedParticleComponents(XSParticle component, List<XSObject> componentList,
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  3142
            String namespace, Map<String, List<String>> dependencies) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3143
        XSTerm term = component.getTerm();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3144
        switch (term.getType()) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3145
        case XSConstants.ELEMENT_DECLARATION :
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3146
            addRelatedElement((XSElementDeclaration) term, componentList, namespace, dependencies);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3147
            break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3148
        case XSConstants.MODEL_GROUP :
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3149
            expandRelatedModelGroupComponents((XSModelGroup) term, componentList, namespace, dependencies);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3150
            break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3151
        default:
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3152
            break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3153
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3154
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3155
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  3156
    private void expandRelatedModelGroupComponents(XSModelGroup modelGroup, List<XSObject> componentList,
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  3157
            String namespace, Map<String, List<String>> dependencies) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3158
        XSObjectList particles = modelGroup.getParticles();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3159
        final int length = (particles == null) ? 0 : particles.getLength();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3160
        for (int i=0; i<length; i++) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3161
            expandRelatedParticleComponents((XSParticle)particles.item(i), componentList, namespace, dependencies);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3162
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3163
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3164
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  3165
    private void addRelatedType(XSTypeDefinition type, List<XSObject> componentList, String namespace, Map<String, List<String>> dependencies) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3166
        if (!type.getAnonymous()) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3167
            if (!type.getNamespace().equals(SchemaSymbols.URI_SCHEMAFORSCHEMA)) { //REVISIT - do we use == instead
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3168
                if (!componentList.contains(type)) {
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  3169
                    final List<String> importedNamespaces = findDependentNamespaces(namespace, dependencies);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3170
                    addNamespaceDependency(namespace, type.getNamespace(), importedNamespaces);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3171
                    componentList.add(type);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3172
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3173
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3174
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3175
        else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3176
            expandRelatedTypeComponents(type, componentList, namespace, dependencies);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3177
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3178
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3179
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  3180
    private void addRelatedElement(XSElementDeclaration decl, List<XSObject> componentList, String namespace, Map<String, List<String>> dependencies) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3181
        if (decl.getScope() == XSConstants.SCOPE_GLOBAL) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3182
            if (!componentList.contains(decl)) {
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  3183
               List<String> importedNamespaces = findDependentNamespaces(namespace, dependencies);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3184
                addNamespaceDependency(namespace, decl.getNamespace(), importedNamespaces);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3185
                componentList.add(decl);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3186
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3187
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3188
        else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3189
            expandRelatedElementComponents(decl, componentList, namespace, dependencies);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3190
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3191
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3192
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  3193
    private void addRelatedAttribute(XSAttributeDeclaration decl, List<XSObject> componentList, String namespace, Map<String, List<String>> dependencies) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3194
        if (decl.getScope() == XSConstants.SCOPE_GLOBAL) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3195
            if (!componentList.contains(decl)) {
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  3196
                List<String> importedNamespaces = findDependentNamespaces(namespace, dependencies);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3197
                addNamespaceDependency(namespace, decl.getNamespace(), importedNamespaces);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3198
                componentList.add(decl);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3199
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3200
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3201
        else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3202
            expandRelatedAttributeComponents(decl, componentList, namespace, dependencies);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3203
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3204
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3205
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  3206
    private void addGlobalComponents(List<XSObject> components, Map<String, List<String>> importDependencies) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3207
        final XSDDescription desc = new XSDDescription();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3208
        final int size = components.size();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3209
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3210
        for (int i=0; i<size; i++) {
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  3211
            addGlobalComponent(components.get(i), desc);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3212
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3213
        updateImportDependencies(importDependencies);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3214
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3215
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3216
    private void addGlobalComponent(XSObject component, XSDDescription desc) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3217
        final String namespace = component.getNamespace();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3218
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3219
        desc.setNamespace(namespace);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3220
        final SchemaGrammar sg = getSchemaGrammar(desc);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3221
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3222
        short componentType = component.getType();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3223
        final String name = component.getName();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3224
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3225
        switch (componentType) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3226
        case XSConstants.TYPE_DEFINITION :
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3227
            if (!((XSTypeDefinition) component).getAnonymous()) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3228
                if (sg.getGlobalTypeDecl(name) == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3229
                    sg.addGlobalTypeDecl((XSTypeDefinition) component);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3230
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3231
                // store the declaration in the extended map, using an empty location
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3232
                if (sg.getGlobalTypeDecl(name, "") == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3233
                    sg.addGlobalTypeDecl((XSTypeDefinition) component, "");
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3234
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3235
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3236
            break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3237
        case XSConstants.ATTRIBUTE_DECLARATION :
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3238
            if (((XSAttributeDecl) component).getScope() == XSAttributeDecl.SCOPE_GLOBAL) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3239
                if (sg.getGlobalAttributeDecl(name) == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3240
                    sg.addGlobalAttributeDecl((XSAttributeDecl) component);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3241
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3242
                // store the declaration in the extended map, using an empty location
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3243
                if (sg.getGlobalAttributeDecl(name, "") == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3244
                    sg.addGlobalAttributeDecl((XSAttributeDecl) component, "");
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3245
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3246
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3247
            break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3248
        case XSConstants.ATTRIBUTE_GROUP :
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3249
            if (sg.getGlobalAttributeDecl(name) == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3250
                sg.addGlobalAttributeGroupDecl((XSAttributeGroupDecl) component);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3251
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3252
            // store the declaration in the extended map, using an empty location
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3253
            if (sg.getGlobalAttributeDecl(name, "") == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3254
                sg.addGlobalAttributeGroupDecl((XSAttributeGroupDecl) component, "");
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3255
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3256
            break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3257
        case XSConstants.ELEMENT_DECLARATION :
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3258
            if (((XSElementDecl) component).getScope() == XSElementDecl.SCOPE_GLOBAL) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3259
                sg.addGlobalElementDeclAll((XSElementDecl) component);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3260
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3261
                if (sg.getGlobalElementDecl(name) == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3262
                    sg.addGlobalElementDecl((XSElementDecl) component);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3263
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3264
                // store the declaration in the extended map, using an empty location
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3265
                if (sg.getGlobalElementDecl(name, "") == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3266
                    sg.addGlobalElementDecl((XSElementDecl) component, "");
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3267
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3268
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3269
            break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3270
        case XSConstants.MODEL_GROUP_DEFINITION :
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3271
            if (sg.getGlobalGroupDecl(name) == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3272
                sg.addGlobalGroupDecl((XSGroupDecl) component);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3273
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3274
            // store the declaration in the extended map, using an empty location
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3275
            if (sg.getGlobalGroupDecl(name, "") == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3276
                sg.addGlobalGroupDecl((XSGroupDecl) component, "");
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3277
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3278
            break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3279
        case XSConstants.NOTATION_DECLARATION :
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3280
            if (sg.getGlobalNotationDecl(name) == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3281
                sg.addGlobalNotationDecl((XSNotationDecl) component);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3282
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3283
            // store the declaration in the extended map, using an empty location
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3284
            if (sg.getGlobalNotationDecl(name, "") == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3285
                sg.addGlobalNotationDecl((XSNotationDecl) component, "");
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3286
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3287
            break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3288
        case XSConstants.IDENTITY_CONSTRAINT :
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3289
        case XSConstants.ATTRIBUTE_USE :
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3290
        default :
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3291
            break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3292
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3293
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3294
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  3295
    private void updateImportDependencies(Map<String, List<String>> table) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3296
        if (table == null) return;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3297
        String namespace;
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  3298
        List<String> importList;
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  3299
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  3300
        for(Map.Entry<String, List<String>> entry : table.entrySet()){
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3301
            namespace = entry.getKey();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3302
            importList = entry.getValue();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3303
            if (importList.size() > 0) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3304
                expandImportList(namespace, importList);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3305
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3306
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3307
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3308
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  3309
    private void expandImportList(String namespace, List<String> namespaceList) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3310
        SchemaGrammar sg = fGrammarBucket.getGrammar(namespace);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3311
        // shouldn't be null
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3312
        if (sg != null) {
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  3313
            List<SchemaGrammar> isgs = sg.getImportedGrammars();
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3314
            if (isgs == null) {
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  3315
                isgs = new ArrayList<>();
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3316
                addImportList(sg, isgs, namespaceList);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3317
                sg.setImportedGrammars(isgs);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3318
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3319
            else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3320
                updateImportList(sg, isgs, namespaceList);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3321
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3322
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3323
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3324
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  3325
    private void addImportList(SchemaGrammar sg, List<SchemaGrammar> importedGrammars, List<String> namespaceList) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3326
        final int size = namespaceList.size();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3327
        SchemaGrammar isg;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3328
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3329
        for (int i=0; i<size; i++) {
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  3330
            isg = fGrammarBucket.getGrammar(namespaceList.get(i));
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3331
            if (isg != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3332
                importedGrammars.add(isg);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3333
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3334
            else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3335
                //REVIST: report an error message
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3336
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3337
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3338
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3339
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  3340
    private void updateImportList(SchemaGrammar sg, List<SchemaGrammar> importedGrammars,
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  3341
            List<String> namespaceList) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3342
        final int size = namespaceList.size();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3343
        SchemaGrammar isg;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3344
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3345
        for (int i=0; i<size; i++) {
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  3346
            isg = fGrammarBucket.getGrammar(namespaceList.get(i));
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3347
            if (isg != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3348
                if (!containedImportedGrammar(importedGrammars, isg)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3349
                    importedGrammars.add(isg);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3350
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3351
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3352
            else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3353
                //REVIST: report an error message
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3354
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3355
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3356
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3357
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  3358
    private boolean containedImportedGrammar(List<SchemaGrammar> importedGrammar, SchemaGrammar grammar) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3359
        final int size = importedGrammar.size();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3360
        SchemaGrammar sg;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3361
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3362
        for (int i=0; i<size; i++) {
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  3363
            sg = (SchemaGrammar) importedGrammar.get(i);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3364
            if (null2EmptyString(sg.getTargetNamespace()).equals(null2EmptyString(grammar.getTargetNamespace()))) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3365
                return true;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3366
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3367
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3368
        return false;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3369
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3370
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3371
    // NOTE: always assuming that fNamespaceGrowth is enabled
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3372
    //       otherwise the grammar should have existed
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3373
    private SchemaGrammar getSchemaGrammar(XSDDescription desc) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3374
        SchemaGrammar sg = findGrammar(desc, fNamespaceGrowth);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3375
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3376
        if (sg == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3377
            sg = new SchemaGrammar(desc.getNamespace(), desc.makeClone(), fSymbolTable);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3378
            fGrammarBucket.putGrammar(sg);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3379
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3380
        else if (sg.isImmutable()){
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3381
            sg = createGrammarFrom(sg);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3382
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3383
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3384
        return sg;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3385
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3386
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  3387
    private List<String> findDependentNamespaces(String namespace,
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  3388
            Map<String, List<String>> table) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3389
        final String ns = null2EmptyString(namespace);
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  3390
        List<String> namespaceList = getFromMap(table, ns);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3391
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3392
        if (namespaceList == null) {
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  3393
            namespaceList = new ArrayList<>();
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3394
            table.put(ns, namespaceList);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3395
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3396
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3397
        return namespaceList;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3398
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3399
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  3400
    private void addNamespaceDependency(String namespace1, String namespace2, List<String> list) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3401
        final String ns1 = null2EmptyString(namespace1);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3402
        final String ns2 = null2EmptyString(namespace2);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3403
        if (!ns1.equals(ns2)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3404
            if (!list.contains(ns2)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3405
                list.add(ns2);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3406
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3407
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3408
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3409
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3410
    private void reportSharingError(String namespace, String name) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3411
        final String qName = (namespace == null)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3412
            ? "," + name : namespace + "," + name;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3413
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3414
        reportSchemaError("sch-props-correct.2", new Object [] {qName}, null);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3415
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3416
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3417
    // initialize all the traversers.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3418
    // this should only need to be called once during the construction
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3419
    // of this object; it creates the traversers that will be used to
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3420
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3421
    // construct schemaGrammars.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3422
    private void createTraversers() {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3423
        fAttributeChecker = new XSAttributeChecker(this);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3424
        fAttributeGroupTraverser = new XSDAttributeGroupTraverser(this, fAttributeChecker);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3425
        fAttributeTraverser = new XSDAttributeTraverser(this, fAttributeChecker);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3426
        fComplexTypeTraverser = new XSDComplexTypeTraverser(this, fAttributeChecker);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3427
        fElementTraverser = new XSDElementTraverser(this, fAttributeChecker);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3428
        fGroupTraverser = new XSDGroupTraverser(this, fAttributeChecker);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3429
        fKeyrefTraverser = new XSDKeyrefTraverser(this, fAttributeChecker);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3430
        fNotationTraverser = new XSDNotationTraverser(this, fAttributeChecker);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3431
        fSimpleTypeTraverser = new XSDSimpleTypeTraverser(this, fAttributeChecker);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3432
        fUniqueOrKeyTraverser = new XSDUniqueOrKeyTraverser(this, fAttributeChecker);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3433
        fWildCardTraverser = new XSDWildcardTraverser(this, fAttributeChecker);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3434
    } // createTraversers()
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3435
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3436
    // before parsing a schema, need to clear registries associated with
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3437
    // parsing schemas
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3438
    void prepareForParse() {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3439
        fTraversed.clear();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3440
        fDoc2SystemId.clear();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3441
        fHiddenNodes.clear();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3442
        fLastSchemaWasDuplicate = false;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3443
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3444
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3445
    // before traversing a schema's parse tree, need to reset all traversers and
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3446
    // clear all registries
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3447
    void prepareForTraverse() {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3448
        if (!registryEmpty) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3449
        fUnparsedAttributeRegistry.clear();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3450
        fUnparsedAttributeGroupRegistry.clear();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3451
        fUnparsedElementRegistry.clear();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3452
        fUnparsedGroupRegistry.clear();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3453
        fUnparsedIdentityConstraintRegistry.clear();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3454
        fUnparsedNotationRegistry.clear();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3455
        fUnparsedTypeRegistry.clear();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3456
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3457
        fUnparsedAttributeRegistrySub.clear();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3458
        fUnparsedAttributeGroupRegistrySub.clear();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3459
        fUnparsedElementRegistrySub.clear();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3460
        fUnparsedGroupRegistrySub.clear();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3461
        fUnparsedIdentityConstraintRegistrySub.clear();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3462
        fUnparsedNotationRegistrySub.clear();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3463
        fUnparsedTypeRegistrySub.clear();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3464
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3465
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3466
        for (int i=1; i<= TYPEDECL_TYPE; i++) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3467
            if (fUnparsedRegistriesExt[i] != null)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3468
                fUnparsedRegistriesExt[i].clear();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3469
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3470
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3471
        fDependencyMap.clear();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3472
        fDoc2XSDocumentMap.clear();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3473
        if (fRedefine2XSDMap != null) fRedefine2XSDMap.clear();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3474
        if (fRedefine2NSSupport != null) fRedefine2NSSupport.clear();
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  3475
        fAllTNSs.clear();
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3476
        fImportMap.clear();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3477
        fRoot = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3478
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3479
        // clear local element stack
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3480
        for (int i = 0; i < fLocalElemStackPos; i++) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3481
            fParticle[i] = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3482
            fLocalElementDecl[i] = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3483
            fLocalElementDecl_schema[i] = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3484
            fLocalElemNamespaceContext[i] = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3485
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3486
        fLocalElemStackPos = 0;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3487
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3488
        // and do same for keyrefs.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3489
        for (int i = 0; i < fKeyrefStackPos; i++) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3490
            fKeyrefs[i] = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3491
            fKeyrefElems[i] = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3492
            fKeyrefNamespaceContext[i] = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3493
            fKeyrefsMapXSDocumentInfo[i] = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3494
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3495
        fKeyrefStackPos = 0;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3496
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3497
        // create traversers if necessary
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3498
        if (fAttributeChecker == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3499
            createTraversers();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3500
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3501
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3502
        // reset traversers
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3503
        Locale locale = fErrorReporter.getLocale();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3504
        fAttributeChecker.reset(fSymbolTable);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3505
        fAttributeGroupTraverser.reset(fSymbolTable, fValidateAnnotations, locale);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3506
        fAttributeTraverser.reset(fSymbolTable, fValidateAnnotations, locale);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3507
        fComplexTypeTraverser.reset(fSymbolTable, fValidateAnnotations, locale);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3508
        fElementTraverser.reset(fSymbolTable, fValidateAnnotations, locale);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3509
        fGroupTraverser.reset(fSymbolTable, fValidateAnnotations, locale);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3510
        fKeyrefTraverser.reset(fSymbolTable, fValidateAnnotations, locale);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3511
        fNotationTraverser.reset(fSymbolTable, fValidateAnnotations, locale);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3512
        fSimpleTypeTraverser.reset(fSymbolTable, fValidateAnnotations, locale);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3513
        fUniqueOrKeyTraverser.reset(fSymbolTable, fValidateAnnotations, locale);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3514
        fWildCardTraverser.reset(fSymbolTable, fValidateAnnotations, locale);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3515
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3516
        fRedefinedRestrictedAttributeGroupRegistry.clear();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3517
        fRedefinedRestrictedGroupRegistry.clear();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3518
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3519
        fGlobalAttrDecls.clear();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3520
        fGlobalAttrGrpDecls.clear();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3521
        fGlobalElemDecls.clear();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3522
        fGlobalGroupDecls.clear();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3523
        fGlobalNotationDecls.clear();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3524
        fGlobalIDConstraintDecls.clear();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3525
        fGlobalTypeDecls.clear();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3526
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3527
    public void setDeclPool (XSDeclarationPool declPool){
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3528
        fDeclPool = declPool;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3529
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3530
    public void setDVFactory(SchemaDVFactory dvFactory){
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3531
        fDVFactory = dvFactory;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3532
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3533
    public SchemaDVFactory getDVFactory(){
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3534
        return fDVFactory;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3535
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3536
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3537
    public void reset(XMLComponentManager componentManager) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3538
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3539
        // set symbol table
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3540
        fSymbolTable = (SymbolTable) componentManager.getProperty(SYMBOL_TABLE);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3541
36146
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
  3542
        // set security manager
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
  3543
        fSecurityManager = (XMLSecurityManager) componentManager.getProperty(SECURITY_MANAGER, null);
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
  3544
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
  3545
        //set entity manager
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 39080
diff changeset
  3546
        fEntityManager = (XMLEntityManager) componentManager.getProperty(ENTITY_MANAGER);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3547
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3548
        //set entity resolver
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3549
        XMLEntityResolver er = (XMLEntityResolver)componentManager.getProperty(ENTITY_RESOLVER);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3550
        if (er != null)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3551
            fSchemaParser.setEntityResolver(er);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3552
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3553
        // set error reporter
36146
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
  3554
        fErrorReporter = (XMLErrorReporter) componentManager.getProperty(ERROR_REPORTER);
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
  3555
        fErrorHandler = fErrorReporter.getErrorHandler();
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
  3556
        fLocale = fErrorReporter.getLocale();
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3557
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3558
        fValidateAnnotations = componentManager.getFeature(VALIDATE_ANNOTATIONS, false);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3559
        fHonourAllSchemaLocations = componentManager.getFeature(HONOUR_ALL_SCHEMALOCATIONS, false);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3560
        fNamespaceGrowth = componentManager.getFeature(NAMESPACE_GROWTH, false);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3561
        fTolerateDuplicates = componentManager.getFeature(TOLERATE_DUPLICATES, false);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3562
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3563
        try {
36146
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
  3564
            // Setting a parser property can be much more expensive
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
  3565
            // than checking its value.  Don't set the ERROR_HANDLER
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
  3566
            // or LOCALE properties unless they've actually changed.
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
  3567
            if (fErrorHandler != fSchemaParser.getProperty(ERROR_HANDLER)) {
42247
52fafb950d5a 8158619: Very large CDATA section in XML document causes OOME
joehw
parents: 39907
diff changeset
  3568
                fSchemaParser.setProperty(ERROR_HANDLER,
52fafb950d5a 8158619: Very large CDATA section in XML document causes OOME
joehw
parents: 39907
diff changeset
  3569
                        (fErrorHandler != null) ? fErrorHandler : new DefaultErrorHandler());
36146
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
  3570
                if (fAnnotationValidator != null) {
42247
52fafb950d5a 8158619: Very large CDATA section in XML document causes OOME
joehw
parents: 39907
diff changeset
  3571
                    fAnnotationValidator.setProperty(ERROR_HANDLER,
52fafb950d5a 8158619: Very large CDATA section in XML document causes OOME
joehw
parents: 39907
diff changeset
  3572
                            (fErrorHandler != null) ? fErrorHandler : new DefaultErrorHandler());
36146
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
  3573
                }
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
  3574
            }
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
  3575
            if (fLocale != fSchemaParser.getProperty(LOCALE)) {
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
  3576
                fSchemaParser.setProperty(LOCALE, fLocale);
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
  3577
                if (fAnnotationValidator != null) {
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
  3578
                    fAnnotationValidator.setProperty(LOCALE, fLocale);
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
  3579
                }
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
  3580
            }
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3581
        }
36146
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
  3582
        catch (XMLConfigurationException e) {}
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
  3583
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
  3584
        try {
42247
52fafb950d5a 8158619: Very large CDATA section in XML document causes OOME
joehw
parents: 39907
diff changeset
  3585
            fSchemaParser.setFeature(CONTINUE_AFTER_FATAL_ERROR,
52fafb950d5a 8158619: Very large CDATA section in XML document causes OOME
joehw
parents: 39907
diff changeset
  3586
                    fErrorReporter.getFeature(CONTINUE_AFTER_FATAL_ERROR));
36146
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
  3587
        } catch (XMLConfigurationException e) {}
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3588
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3589
        try {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3590
            if (componentManager.getFeature(ALLOW_JAVA_ENCODINGS, false)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3591
                fSchemaParser.setFeature(ALLOW_JAVA_ENCODINGS, true);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3592
            }
36146
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
  3593
        } catch (XMLConfigurationException e) {}
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
  3594
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3595
        try {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3596
            if (componentManager.getFeature(STANDARD_URI_CONFORMANT_FEATURE, false)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3597
                fSchemaParser.setFeature(STANDARD_URI_CONFORMANT_FEATURE, true);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3598
            }
36146
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
  3599
        } catch (XMLConfigurationException e) {}
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3600
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3601
        try {
36146
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
  3602
            fGrammarPool = (XMLGrammarPool) componentManager.getProperty(XMLGRAMMAR_POOL);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3603
        } catch (XMLConfigurationException e) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3604
            fGrammarPool = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3605
        }
36146
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
  3606
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3607
        // security features
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3608
        try {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3609
            if (componentManager.getFeature(DISALLOW_DOCTYPE, false)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3610
                fSchemaParser.setFeature(DISALLOW_DOCTYPE, true);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3611
            }
36146
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
  3612
        } catch (XMLConfigurationException e) {}
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
  3613
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3614
        try {
36146
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
  3615
            if (fSecurityManager != null) {
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
  3616
                fSchemaParser.setProperty(SECURITY_MANAGER, fSecurityManager);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3617
            }
36146
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
  3618
        } catch (XMLConfigurationException e) {}
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
  3619
42247
52fafb950d5a 8158619: Very large CDATA section in XML document causes OOME
joehw
parents: 39907
diff changeset
  3620
        fSecurityPropertyMgr = (XMLSecurityPropertyManager)
52fafb950d5a 8158619: Very large CDATA section in XML document causes OOME
joehw
parents: 39907
diff changeset
  3621
                componentManager.getProperty(XML_SECURITY_PROPERTY_MANAGER);
36146
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
  3622
18890
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 17534
diff changeset
  3623
        //Passing on the setting to the parser
36146
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
  3624
        fSchemaParser.setProperty(XML_SECURITY_PROPERTY_MANAGER, fSecurityPropertyMgr);
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
  3625
42247
52fafb950d5a 8158619: Very large CDATA section in XML document causes OOME
joehw
parents: 39907
diff changeset
  3626
        fAccessExternalDTD = fSecurityPropertyMgr.getValue(
52fafb950d5a 8158619: Very large CDATA section in XML document causes OOME
joehw
parents: 39907
diff changeset
  3627
                XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_DTD);
52fafb950d5a 8158619: Very large CDATA section in XML document causes OOME
joehw
parents: 39907
diff changeset
  3628
        fAccessExternalSchema = fSecurityPropertyMgr.getValue(
52fafb950d5a 8158619: Very large CDATA section in XML document causes OOME
joehw
parents: 39907
diff changeset
  3629
                XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_SCHEMA);
18890
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 17534
diff changeset
  3630
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 39080
diff changeset
  3631
        // Passing the Catalog settings to the parser
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 39080
diff changeset
  3632
        fUseCatalog = componentManager.getFeature(XMLConstants.USE_CATALOG);
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 39080
diff changeset
  3633
        fSchemaParser.setFeature(XMLConstants.USE_CATALOG, fUseCatalog);
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 39080
diff changeset
  3634
        fEntityManager.setFeature(XMLConstants.USE_CATALOG, fUseCatalog);
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 39080
diff changeset
  3635
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 39080
diff changeset
  3636
        fCatalogFile = (String)componentManager.getProperty(JdkXmlUtils.CATALOG_FILES);
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 39080
diff changeset
  3637
        fDefer = (String)componentManager.getProperty(JdkXmlUtils.CATALOG_DEFER);
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 39080
diff changeset
  3638
        fPrefer = (String)componentManager.getProperty(JdkXmlUtils.CATALOG_PREFER);
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 39080
diff changeset
  3639
        fResolve = (String)componentManager.getProperty(JdkXmlUtils.CATALOG_RESOLVE);
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 39080
diff changeset
  3640
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 39080
diff changeset
  3641
        for( CatalogFeatures.Feature f : CatalogFeatures.Feature.values()) {
42247
52fafb950d5a 8158619: Very large CDATA section in XML document causes OOME
joehw
parents: 39907
diff changeset
  3642
            fSchemaParser.setProperty(f.getPropertyName(),
52fafb950d5a 8158619: Very large CDATA section in XML document causes OOME
joehw
parents: 39907
diff changeset
  3643
                    componentManager.getProperty(f.getPropertyName()));
52fafb950d5a 8158619: Very large CDATA section in XML document causes OOME
joehw
parents: 39907
diff changeset
  3644
            fEntityManager.setProperty(f.getPropertyName(),
52fafb950d5a 8158619: Very large CDATA section in XML document causes OOME
joehw
parents: 39907
diff changeset
  3645
                    componentManager.getProperty(f.getPropertyName()));
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 39080
diff changeset
  3646
        }
42247
52fafb950d5a 8158619: Very large CDATA section in XML document causes OOME
joehw
parents: 39907
diff changeset
  3647
52fafb950d5a 8158619: Very large CDATA section in XML document causes OOME
joehw
parents: 39907
diff changeset
  3648
        fSchemaParser.setProperty(JdkXmlUtils.CDATA_CHUNK_SIZE,
52fafb950d5a 8158619: Very large CDATA section in XML document causes OOME
joehw
parents: 39907
diff changeset
  3649
                componentManager.getProperty(JdkXmlUtils.CDATA_CHUNK_SIZE));
52fafb950d5a 8158619: Very large CDATA section in XML document causes OOME
joehw
parents: 39907
diff changeset
  3650
        fEntityManager.setProperty(JdkXmlUtils.CDATA_CHUNK_SIZE,
52fafb950d5a 8158619: Very large CDATA section in XML document causes OOME
joehw
parents: 39907
diff changeset
  3651
                componentManager.getProperty(JdkXmlUtils.CDATA_CHUNK_SIZE));
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3652
    } // reset(XMLComponentManager)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3653
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3654
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3655
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3656
     * Traverse all the deferred local elements. This method should be called
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3657
     * by traverseSchemas after we've done with all the global declarations.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3658
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3659
    void traverseLocalElements() {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3660
        fElementTraverser.fDeferTraversingLocalElements = false;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3661
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3662
        for (int i = 0; i < fLocalElemStackPos; i++) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3663
            Element currElem = fLocalElementDecl[i];
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3664
            XSDocumentInfo currSchema = fLocalElementDecl_schema[i];
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3665
            SchemaGrammar currGrammar = fGrammarBucket.getGrammar(currSchema.fTargetNamespace);
42247
52fafb950d5a 8158619: Very large CDATA section in XML document causes OOME
joehw
parents: 39907
diff changeset
  3666
            fElementTraverser.traverseLocal (fParticle[i], currElem, currSchema,
52fafb950d5a 8158619: Very large CDATA section in XML document causes OOME
joehw
parents: 39907
diff changeset
  3667
                    currGrammar, fAllContext[i], fParent[i], fLocalElemNamespaceContext[i]);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3668
            // If it's an empty particle, remove it from the containing component.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3669
            if (fParticle[i].fType == XSParticleDecl.PARTICLE_EMPTY) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3670
                XSModelGroupImpl group = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3671
                if (fParent[i] instanceof XSComplexTypeDecl) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3672
                    XSParticle p = ((XSComplexTypeDecl)fParent[i]).getParticle();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3673
                    if (p != null)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3674
                        group = (XSModelGroupImpl)p.getTerm();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3675
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3676
                else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3677
                    group = ((XSGroupDecl)fParent[i]).fModelGroup;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3678
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3679
                if (group != null)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3680
                    removeParticle(group, fParticle[i]);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3681
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3682
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3683
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3684
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3685
    private boolean removeParticle(XSModelGroupImpl group, XSParticleDecl particle) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3686
        XSParticleDecl member;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3687
        for (int i = 0; i < group.fParticleCount; i++) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3688
            member = group.fParticles[i];
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3689
            if (member == particle) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3690
                for (int j = i; j < group.fParticleCount-1; j++)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3691
                    group.fParticles[j] = group.fParticles[j+1];
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3692
                group.fParticleCount--;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3693
                return true;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3694
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3695
            if (member.fType == XSParticleDecl.PARTICLE_MODELGROUP) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3696
                if (removeParticle((XSModelGroupImpl)member.fValue, particle))
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3697
                    return true;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3698
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3699
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3700
        return false;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3701
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3702
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3703
    // the purpose of this method is to keep up-to-date structures
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3704
    // we'll need for the feferred traversal of local elements.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3705
    void fillInLocalElemInfo(Element elmDecl,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3706
            XSDocumentInfo schemaDoc,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3707
            int allContextFlags,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3708
            XSObject parent,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3709
            XSParticleDecl particle) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3710
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3711
        // if the stack is full, increase the size
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3712
        if (fParticle.length == fLocalElemStackPos) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3713
            // increase size
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3714
            XSParticleDecl[] newStackP = new XSParticleDecl[fLocalElemStackPos+INC_STACK_SIZE];
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3715
            System.arraycopy(fParticle, 0, newStackP, 0, fLocalElemStackPos);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3716
            fParticle = newStackP;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3717
            Element[] newStackE = new Element[fLocalElemStackPos+INC_STACK_SIZE];
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3718
            System.arraycopy(fLocalElementDecl, 0, newStackE, 0, fLocalElemStackPos);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3719
            fLocalElementDecl = newStackE;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3720
            XSDocumentInfo [] newStackE_schema = new XSDocumentInfo[fLocalElemStackPos+INC_STACK_SIZE];
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3721
            System.arraycopy(fLocalElementDecl_schema, 0, newStackE_schema, 0, fLocalElemStackPos);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3722
            fLocalElementDecl_schema = newStackE_schema;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3723
            int[] newStackI = new int[fLocalElemStackPos+INC_STACK_SIZE];
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3724
            System.arraycopy(fAllContext, 0, newStackI, 0, fLocalElemStackPos);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3725
            fAllContext = newStackI;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3726
            XSObject[] newStackC = new XSObject[fLocalElemStackPos+INC_STACK_SIZE];
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3727
            System.arraycopy(fParent, 0, newStackC, 0, fLocalElemStackPos);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3728
            fParent = newStackC;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3729
            String [][] newStackN = new String [fLocalElemStackPos+INC_STACK_SIZE][];
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3730
            System.arraycopy(fLocalElemNamespaceContext, 0, newStackN, 0, fLocalElemStackPos);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3731
            fLocalElemNamespaceContext = newStackN;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3732
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3733
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3734
        fParticle[fLocalElemStackPos] = particle;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3735
        fLocalElementDecl[fLocalElemStackPos] = elmDecl;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3736
        fLocalElementDecl_schema[fLocalElemStackPos] = schemaDoc;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3737
        fAllContext[fLocalElemStackPos] = allContextFlags;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3738
        fParent[fLocalElemStackPos] = parent;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3739
        fLocalElemNamespaceContext[fLocalElemStackPos++] = schemaDoc.fNamespaceSupport.getEffectiveLocalContext();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3740
    } // end fillInLocalElemInfo(...)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3741
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3742
    /** This method makes sure that
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3743
     * if this component is being redefined that it lives in the
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3744
     * right schema.  It then renames the component correctly.  If it
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3745
     * detects a collision--a duplicate definition--then it complains.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3746
     * Note that redefines must be handled carefully:  if there
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3747
     * is a collision, it may be because we're redefining something we know about
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3748
     * or because we've found the thing we're redefining.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3749
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3750
    void checkForDuplicateNames(String qName, int declType,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3751
            Map<String,Element> registry, Map<String,XSDocumentInfo> registry_sub, Element currComp,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3752
            XSDocumentInfo currSchema) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3753
        Object objElem = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3754
        // REVISIT:  when we add derivation checking, we'll have to make
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3755
        // sure that ID constraint collisions don't necessarily result in error messages.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3756
        if ((objElem = registry.get(qName)) == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3757
            // need to check whether we have a global declaration in the corresponding
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3758
            // grammar
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3759
            if (fNamespaceGrowth && !fTolerateDuplicates) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3760
                checkForDuplicateNames(qName, declType, currComp);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3761
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3762
            // just add it in!
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3763
            registry.put(qName, currComp);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3764
            registry_sub.put(qName, currSchema);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3765
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3766
        else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3767
            Element collidingElem = (Element)objElem;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3768
            XSDocumentInfo collidingElemSchema = (XSDocumentInfo)registry_sub.get(qName);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3769
            if (collidingElem == currComp) return;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3770
            Element elemParent = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3771
            XSDocumentInfo redefinedSchema = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3772
            // case where we've collided with a redefining element
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3773
            // (the parent of the colliding element is a redefine)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3774
            boolean collidedWithRedefine = true;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3775
            if ((DOMUtil.getLocalName((elemParent = DOMUtil.getParent(collidingElem))).equals(SchemaSymbols.ELT_REDEFINE))) {
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  3776
                redefinedSchema = (fRedefine2XSDMap != null)? fRedefine2XSDMap.get(elemParent) : null;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3777
                // case where we're a redefining element.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3778
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3779
            else if ((DOMUtil.getLocalName(DOMUtil.getParent(currComp)).equals(SchemaSymbols.ELT_REDEFINE))) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3780
                redefinedSchema = collidingElemSchema;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3781
                collidedWithRedefine = false;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3782
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3783
            if (redefinedSchema != null) { //redefinition involved somehow
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3784
                // If both components belong to the same document then
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3785
                // report an error and return.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3786
                if(collidingElemSchema == currSchema){
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3787
                    reportSchemaError("sch-props-correct.2", new Object[]{qName}, currComp);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3788
                    return;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3789
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3790
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3791
                String newName = qName.substring(qName.lastIndexOf(',')+1)+REDEF_IDENTIFIER;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3792
                if (redefinedSchema == currSchema) { // object comp. okay here
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3793
                    // now have to do some renaming...
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3794
                    currComp.setAttribute(SchemaSymbols.ATT_NAME, newName);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3795
                    if (currSchema.fTargetNamespace == null){
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3796
                        registry.put(","+newName, currComp);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3797
                        registry_sub.put(","+newName, currSchema);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3798
                    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3799
                    else{
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3800
                        registry.put(currSchema.fTargetNamespace+","+newName, currComp);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3801
                        registry_sub.put(currSchema.fTargetNamespace+","+newName, currSchema);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3802
                    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3803
                    // and take care of nested redefines by calling recursively:
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3804
                    if (currSchema.fTargetNamespace == null)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3805
                        checkForDuplicateNames(","+newName, declType, registry, registry_sub, currComp, currSchema);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3806
                    else
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3807
                        checkForDuplicateNames(currSchema.fTargetNamespace+","+newName, declType, registry, registry_sub, currComp, currSchema);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3808
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3809
                else { // we may be redefining the wrong schema
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3810
                    if (collidedWithRedefine) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3811
                        if (currSchema.fTargetNamespace == null)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3812
                            checkForDuplicateNames(","+newName, declType, registry, registry_sub, currComp, currSchema);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3813
                        else
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3814
                            checkForDuplicateNames(currSchema.fTargetNamespace+","+newName, declType, registry, registry_sub, currComp, currSchema);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3815
                    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3816
                    else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3817
                        // error that redefined element in wrong schema
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3818
                        reportSchemaError("sch-props-correct.2", new Object [] {qName}, currComp);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3819
                    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3820
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3821
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3822
            else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3823
                // we've just got a flat-out collision (we tolerate duplicate
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3824
                // declarations, only if they are defined in different schema
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3825
                // documents)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3826
                if (!fTolerateDuplicates) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3827
                    reportSchemaError("sch-props-correct.2", new Object []{qName}, currComp);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3828
                } else if (fUnparsedRegistriesExt[declType] != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3829
                    if (fUnparsedRegistriesExt[declType].get(qName) == currSchema) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3830
                        reportSchemaError("sch-props-correct.2", new Object []{qName}, currComp);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3831
                    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3832
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3833
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3834
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3835
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3836
        // store the lastest current document info
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3837
        if (fTolerateDuplicates) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3838
            if (fUnparsedRegistriesExt[declType] == null)
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  3839
                fUnparsedRegistriesExt[declType] = new HashMap<>();
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3840
            fUnparsedRegistriesExt[declType].put(qName, currSchema);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3841
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3842
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 25868
diff changeset
  3843
    } // checkForDuplicateNames(String, Map, Element, XSDocumentInfo):void
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3844
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3845
    void checkForDuplicateNames(String qName, int declType, Element currComp) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3846
        int namespaceEnd = qName.indexOf(',');
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3847
        String namespace = qName.substring(0, namespaceEnd);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3848
        SchemaGrammar grammar = fGrammarBucket.getGrammar(emptyString2Null(namespace));
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3849
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3850
        if (grammar != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3851
            Object obj = getGlobalDeclFromGrammar(grammar, declType, qName.substring(namespaceEnd + 1));
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3852
            if (obj != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3853
                reportSchemaError("sch-props-correct.2", new Object []{qName}, currComp);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3854
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3855
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3856
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3857
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3858
    // the purpose of this method is to take the component of the
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3859
    // specified type and rename references to itself so that they
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3860
    // refer to the object being redefined.  It takes special care of
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3861
    // <group>s and <attributeGroup>s to ensure that information
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3862
    // relating to implicit restrictions is preserved for those
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3863
    // traversers.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3864
    private void renameRedefiningComponents(XSDocumentInfo currSchema,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3865
            Element child, String componentType,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3866
            String oldName, String newName) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3867
        if (componentType.equals(SchemaSymbols.ELT_SIMPLETYPE)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3868
            Element grandKid = DOMUtil.getFirstChildElement(child);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3869
            if (grandKid == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3870
                reportSchemaError("src-redefine.5.a.a", null, child);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3871
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3872
            else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3873
                String grandKidName = DOMUtil.getLocalName(grandKid);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3874
                if (grandKidName.equals(SchemaSymbols.ELT_ANNOTATION)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3875
                    grandKid = DOMUtil.getNextSiblingElement(grandKid);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3876
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3877
                if (grandKid == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3878
                    reportSchemaError("src-redefine.5.a.a", null, child);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3879
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3880
                else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3881
                    grandKidName = DOMUtil.getLocalName(grandKid);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3882
                    if (!grandKidName.equals(SchemaSymbols.ELT_RESTRICTION)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3883
                        reportSchemaError("src-redefine.5.a.b", new Object[]{grandKidName}, child);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3884
                    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3885
                    else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3886
                        Object[] attrs = fAttributeChecker.checkAttributes(grandKid, false, currSchema);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3887
                        QName derivedBase = (QName)attrs[XSAttributeChecker.ATTIDX_BASE];
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3888
                        if (derivedBase == null ||
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3889
                                derivedBase.uri != currSchema.fTargetNamespace ||
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3890
                                !derivedBase.localpart.equals(oldName)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3891
                            reportSchemaError("src-redefine.5.a.c",
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3892
                                    new Object[]{grandKidName,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3893
                                    (currSchema.fTargetNamespace==null?"":currSchema.fTargetNamespace)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3894
                                    + "," + oldName},
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3895
                                    child);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3896
                        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3897
                        else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3898
                            // now we have to do the renaming...
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3899
                            if (derivedBase.prefix != null && derivedBase.prefix.length() > 0)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3900
                                grandKid.setAttribute( SchemaSymbols.ATT_BASE,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3901
                                        derivedBase.prefix + ":" + newName );
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3902
                            else
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3903
                                grandKid.setAttribute( SchemaSymbols.ATT_BASE, newName );
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3904
                            //                            return true;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3905
                        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3906
                        fAttributeChecker.returnAttrArray(attrs, currSchema);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3907
                    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3908
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3909
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3910
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3911
        else if (componentType.equals(SchemaSymbols.ELT_COMPLEXTYPE)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3912
            Element grandKid = DOMUtil.getFirstChildElement(child);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3913
            if (grandKid == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3914
                reportSchemaError("src-redefine.5.b.a", null, child);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3915
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3916
            else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3917
                if (DOMUtil.getLocalName(grandKid).equals(SchemaSymbols.ELT_ANNOTATION)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3918
                    grandKid = DOMUtil.getNextSiblingElement(grandKid);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3919
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3920
                if (grandKid == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3921
                    reportSchemaError("src-redefine.5.b.a", null, child);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3922
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3923
                else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3924
                    // have to go one more level down; let another pass worry whether complexType is valid.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3925
                    Element greatGrandKid = DOMUtil.getFirstChildElement(grandKid);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3926
                    if (greatGrandKid == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3927
                        reportSchemaError("src-redefine.5.b.b", null, grandKid);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3928
                    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3929
                    else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3930
                        String greatGrandKidName = DOMUtil.getLocalName(greatGrandKid);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3931
                        if (greatGrandKidName.equals(SchemaSymbols.ELT_ANNOTATION)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3932
                            greatGrandKid = DOMUtil.getNextSiblingElement(greatGrandKid);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3933
                        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3934
                        if (greatGrandKid == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3935
                            reportSchemaError("src-redefine.5.b.b", null, grandKid);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3936
                        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3937
                        else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3938
                            greatGrandKidName = DOMUtil.getLocalName(greatGrandKid);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3939
                            if (!greatGrandKidName.equals(SchemaSymbols.ELT_RESTRICTION) &&
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3940
                                    !greatGrandKidName.equals(SchemaSymbols.ELT_EXTENSION)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3941
                                reportSchemaError("src-redefine.5.b.c", new Object[]{greatGrandKidName}, greatGrandKid);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3942
                            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3943
                            else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3944
                                Object[] attrs = fAttributeChecker.checkAttributes(greatGrandKid, false, currSchema);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3945
                                QName derivedBase = (QName)attrs[XSAttributeChecker.ATTIDX_BASE];
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3946
                                if (derivedBase == null ||
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3947
                                        derivedBase.uri != currSchema.fTargetNamespace ||
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3948
                                        !derivedBase.localpart.equals(oldName)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3949
                                    reportSchemaError("src-redefine.5.b.d",
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3950
                                            new Object[]{greatGrandKidName,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3951
                                            (currSchema.fTargetNamespace==null?"":currSchema.fTargetNamespace)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3952
                                            + "," + oldName},
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3953
                                            greatGrandKid);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3954
                                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3955
                                else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3956
                                    // now we have to do the renaming...
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3957
                                    if (derivedBase.prefix != null && derivedBase.prefix.length() > 0)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3958
                                        greatGrandKid.setAttribute( SchemaSymbols.ATT_BASE,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3959
                                                derivedBase.prefix + ":" + newName );
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3960
                                    else
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3961
                                        greatGrandKid.setAttribute( SchemaSymbols.ATT_BASE,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3962
                                                newName );
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3963
                                    //                                    return true;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3964
                                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3965
                            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3966
                        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3967
                    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3968
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3969
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3970
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3971
        else if (componentType.equals(SchemaSymbols.ELT_ATTRIBUTEGROUP)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3972
            String processedBaseName = (currSchema.fTargetNamespace == null)?
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3973
                    ","+oldName:currSchema.fTargetNamespace+","+oldName;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3974
            int attGroupRefsCount = changeRedefineGroup(processedBaseName, componentType, newName, child, currSchema);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3975
            if (attGroupRefsCount > 1) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3976
                reportSchemaError("src-redefine.7.1", new Object []{new Integer(attGroupRefsCount)}, child);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3977
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3978
            else if (attGroupRefsCount == 1) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3979
                //                return true;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3980
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3981
            else
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3982
                if (currSchema.fTargetNamespace == null)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3983
                    fRedefinedRestrictedAttributeGroupRegistry.put(processedBaseName, ","+newName);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3984
                else
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3985
                    fRedefinedRestrictedAttributeGroupRegistry.put(processedBaseName, currSchema.fTargetNamespace+","+newName);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3986
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3987
        else if (componentType.equals(SchemaSymbols.ELT_GROUP)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3988
            String processedBaseName = (currSchema.fTargetNamespace == null)?
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3989
                    ","+oldName:currSchema.fTargetNamespace+","+oldName;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3990
            int groupRefsCount = changeRedefineGroup(processedBaseName, componentType, newName, child, currSchema);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3991
            if (groupRefsCount > 1) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3992
                reportSchemaError("src-redefine.6.1.1", new Object []{new Integer(groupRefsCount)}, child);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3993
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3994
            else if (groupRefsCount == 1) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3995
                //                return true;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3996
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3997
            else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3998
                if (currSchema.fTargetNamespace == null)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  3999
                    fRedefinedRestrictedGroupRegistry.put(processedBaseName, ","+newName);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4000
                else
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4001
                    fRedefinedRestrictedGroupRegistry.put(processedBaseName, currSchema.fTargetNamespace+","+newName);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4002
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4003
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4004
        else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4005
            reportSchemaError("Internal-Error", new Object [] {"could not handle this particular <redefine>; please submit your schemas and instance document in a bug report!"}, child);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4006
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4007
        // if we get here then we must have reported an error and failed somewhere...
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4008
        //        return false;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4009
    } // renameRedefiningComponents(XSDocumentInfo, Element, String, String, String):void
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4010
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4011
    // this method takes a name of the form a:b, determines the URI mapped
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4012
    // to by a in the current SchemaNamespaceSupport object, and returns this
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4013
    // information in the form (nsURI,b) suitable for lookups in the global
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 25868
diff changeset
  4014
    // decl maps.
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4015
    // REVISIT: should have it return QName, instead of String. this would
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4016
    //          save lots of string concatenation time. we can use
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4017
    //          QName#equals() to compare two QNames, and use QName directly
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4018
    //          as a key to the SymbolHash.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4019
    //          And when the DV's are ready to return compiled values from
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4020
    //          validate() method, we should just call QNameDV.validate()
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4021
    //          in this method.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4022
    private String findQName(String name, XSDocumentInfo schemaDoc) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4023
        SchemaNamespaceSupport currNSMap = schemaDoc.fNamespaceSupport;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4024
        int colonPtr = name.indexOf(':');
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4025
        String prefix = XMLSymbols.EMPTY_STRING;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4026
        if (colonPtr > 0)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4027
            prefix = name.substring(0, colonPtr);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4028
        String uri = currNSMap.getURI(fSymbolTable.addSymbol(prefix));
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4029
        String localpart = (colonPtr == 0)?name:name.substring(colonPtr+1);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4030
        if (prefix == XMLSymbols.EMPTY_STRING && uri == null && schemaDoc.fIsChameleonSchema)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4031
            uri = schemaDoc.fTargetNamespace;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4032
        if (uri == null)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4033
            return ","+localpart;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4034
        return uri+","+localpart;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4035
    } // findQName(String, XSDocumentInfo):  String
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4036
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4037
    // This function looks among the children of curr for an element of type elementSought.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4038
    // If it finds one, it evaluates whether its ref attribute contains a reference
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4039
    // to originalQName.  If it does, it returns 1 + the value returned by
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4040
    // calls to itself on all other children.  In all other cases it returns 0 plus
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4041
    // the sum of the values returned by calls to itself on curr's children.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4042
    // It also resets the value of ref so that it will refer to the renamed type from the schema
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4043
    // being redefined.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4044
    private int changeRedefineGroup(String originalQName, String elementSought,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4045
            String newName, Element curr, XSDocumentInfo schemaDoc) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4046
        int result = 0;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4047
        for (Element child = DOMUtil.getFirstChildElement(curr);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4048
        child != null; child = DOMUtil.getNextSiblingElement(child)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4049
            String name = DOMUtil.getLocalName(child);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4050
            if (!name.equals(elementSought))
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4051
                result += changeRedefineGroup(originalQName, elementSought, newName, child, schemaDoc);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4052
            else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4053
                String ref = child.getAttribute( SchemaSymbols.ATT_REF );
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4054
                if (ref.length() != 0) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4055
                    String processedRef = findQName(ref, schemaDoc);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4056
                    if (originalQName.equals(processedRef)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4057
                        String prefix = XMLSymbols.EMPTY_STRING;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4058
                        int colonptr = ref.indexOf(":");
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4059
                        if (colonptr > 0) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4060
                            prefix = ref.substring(0,colonptr);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4061
                            child.setAttribute(SchemaSymbols.ATT_REF, prefix + ":" + newName);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4062
                        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4063
                        else
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4064
                            child.setAttribute(SchemaSymbols.ATT_REF, newName);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4065
                        result++;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4066
                        if (elementSought.equals(SchemaSymbols.ELT_GROUP)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4067
                            String minOccurs = child.getAttribute( SchemaSymbols.ATT_MINOCCURS );
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4068
                            String maxOccurs = child.getAttribute( SchemaSymbols.ATT_MAXOCCURS );
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4069
                            if (!((maxOccurs.length() == 0 || maxOccurs.equals("1"))
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4070
                                    && (minOccurs.length() == 0 || minOccurs.equals("1")))) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4071
                                reportSchemaError("src-redefine.6.1.2", new Object [] {ref}, child);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4072
                            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4073
                        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4074
                    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4075
                } // if ref was null some other stage of processing will flag the error
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4076
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4077
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4078
        return result;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4079
    } // changeRedefineGroup
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4080
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4081
    // this method returns the XSDocumentInfo object that contains the
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4082
    // component corresponding to decl.  If components from this
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4083
    // document cannot be referred to from those of currSchema, this
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4084
    // method returns null; it's up to the caller to throw an error.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4085
    // @param:  currSchema:  the XSDocumentInfo object containing the
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4086
    // decl ref'ing us.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4087
    // @param:  decl:  the declaration being ref'd.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4088
    // this method is superficial now. ---Jack
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4089
    private XSDocumentInfo findXSDocumentForDecl(XSDocumentInfo currSchema,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4090
            Element decl, XSDocumentInfo decl_Doc) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4091
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4092
        if (DEBUG_NODE_POOL) {
42247
52fafb950d5a 8158619: Very large CDATA section in XML document causes OOME
joehw
parents: 39907
diff changeset
  4093
            System.out.println("DOCUMENT NS:" + currSchema.fTargetNamespace + " hashcode:" +
52fafb950d5a 8158619: Very large CDATA section in XML document causes OOME
joehw
parents: 39907
diff changeset
  4094
                    ((Object)currSchema.fSchemaElement).hashCode());
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4095
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4096
        Object temp = decl_Doc;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4097
        if (temp == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4098
            // something went badly wrong; we don't know this doc?
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4099
            return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4100
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4101
        XSDocumentInfo declDocInfo = (XSDocumentInfo)temp;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4102
        return declDocInfo;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4103
        /*********
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4104
         Logic here is unnecessary after schema WG's recent decision to allow
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4105
         schema components from one document to refer to components of any other,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4106
         so long as there's some include/import/redefine path amongst them.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4107
         If they rver reverse this decision the code's right here though...  - neilg
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4108
         // now look in fDependencyMap to see if this is reachable
36146
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
  4109
          if((fDependencyMap.get(currSchema)).contains(declDocInfo)) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4110
          return declDocInfo;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4111
          }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4112
          // obviously the requesting doc didn't include, redefine or
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4113
           // import the one containing decl...
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4114
            return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4115
            **********/
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4116
    } // findXSDocumentForDecl(XSDocumentInfo, Element):  XSDocumentInfo
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4117
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4118
    // returns whether more than <annotation>s occur in children of elem
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4119
    private boolean nonAnnotationContent(Element elem) {
42247
52fafb950d5a 8158619: Very large CDATA section in XML document causes OOME
joehw
parents: 39907
diff changeset
  4120
        for(Element child = DOMUtil.getFirstChildElement(elem); child != null;
52fafb950d5a 8158619: Very large CDATA section in XML document causes OOME
joehw
parents: 39907
diff changeset
  4121
                child = DOMUtil.getNextSiblingElement(child)) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4122
            if(!(DOMUtil.getLocalName(child).equals(SchemaSymbols.ELT_ANNOTATION))) return true;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4123
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4124
        return false;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4125
    } // nonAnnotationContent(Element):  boolean
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4126
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4127
    private void setSchemasVisible(XSDocumentInfo startSchema) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4128
        if (DOMUtil.isHidden(startSchema.fSchemaElement, fHiddenNodes)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4129
            // make it visible
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4130
            DOMUtil.setVisible(startSchema.fSchemaElement, fHiddenNodes);
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  4131
            List<XSDocumentInfo> dependingSchemas = fDependencyMap.get(startSchema);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4132
            for (int i = 0; i < dependingSchemas.size(); i++) {
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  4133
                setSchemasVisible(dependingSchemas.get(i));
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4134
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4135
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4136
        // if it's visible already than so must be its children
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4137
    } // setSchemasVisible(XSDocumentInfo): void
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4138
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4139
    private SimpleLocator xl = new SimpleLocator();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4140
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4141
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4142
     * Extract location information from an Element node, and create a
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4143
     * new SimpleLocator object from such information. Returning null means
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4144
     * no information can be retrieved from the element.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4145
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4146
    public SimpleLocator element2Locator(Element e) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4147
        if (!( e instanceof ElementImpl))
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4148
            return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4149
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4150
        SimpleLocator l = new SimpleLocator();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4151
        return element2Locator(e, l) ? l : null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4152
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4153
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4154
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4155
     * Extract location information from an Element node, store such
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4156
     * information in the passed-in SimpleLocator object, then return
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4157
     * true. Returning false means can't extract or store such information.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4158
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4159
    public boolean element2Locator(Element e, SimpleLocator l) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4160
        if (l == null)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4161
            return false;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4162
        if (e instanceof ElementImpl) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4163
            ElementImpl ele = (ElementImpl)e;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4164
            // get system id from document object
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4165
            Document doc = ele.getOwnerDocument();
36146
eca249f3c768 8149915: enabling validate-annotations feature for xsd schema with annotation causes NPE
joehw
parents: 35729
diff changeset
  4166
            String sid = fDoc2SystemId.get(DOMUtil.getRoot(doc));
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4167
            // line/column numbers are stored in the element node
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4168
            int line = ele.getLineNumber();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4169
            int column = ele.getColumnNumber();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4170
            l.setValues(sid, sid, line, column, ele.getCharacterOffset());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4171
            return true;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4172
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4173
        return false;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4174
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4175
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4176
    private Element getElementFromMap(Map<String, Element> registry, String declKey) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4177
        if (registry == null) return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4178
        return registry.get(declKey);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4179
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4180
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4181
    private XSDocumentInfo getDocInfoFromMap(Map<String, XSDocumentInfo> registry, String declKey) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4182
        if (registry == null) return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4183
        return registry.get(declKey);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4184
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4185
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  4186
    private List<String> getFromMap(Map<String, List<String>> registry, String key) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4187
        if (registry == null) return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4188
        return registry.get(key);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4189
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4190
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4191
    void reportSchemaFatalError(String key, Object[] args, Element ele) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4192
        reportSchemaErr(key, args, ele, XMLErrorReporter.SEVERITY_FATAL_ERROR, null);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4193
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4194
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4195
    void reportSchemaError(String key, Object[] args, Element ele) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4196
        reportSchemaErr(key, args, ele, XMLErrorReporter.SEVERITY_ERROR, null);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4197
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4198
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4199
    void reportSchemaError(String key, Object[] args, Element ele, Exception exception) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4200
        reportSchemaErr(key, args, ele, XMLErrorReporter.SEVERITY_ERROR, exception);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4201
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4202
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4203
    void reportSchemaWarning(String key, Object[] args, Element ele) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4204
        reportSchemaErr(key, args, ele, XMLErrorReporter.SEVERITY_WARNING, null);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4205
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4206
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4207
    void reportSchemaWarning(String key, Object[] args, Element ele, Exception exception) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4208
        reportSchemaErr(key, args, ele, XMLErrorReporter.SEVERITY_WARNING, exception);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4209
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4210
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4211
    void reportSchemaErr(String key, Object[] args, Element ele, short type, Exception exception) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4212
        if (element2Locator(ele, xl)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4213
            fErrorReporter.reportError(xl, XSMessageFormatter.SCHEMA_DOMAIN,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4214
                    key, args, type, exception);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4215
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4216
        else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4217
            fErrorReporter.reportError(XSMessageFormatter.SCHEMA_DOMAIN,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4218
                    key, args, type, exception);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4219
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4220
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4221
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4222
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4223
     * Grammar pool used for validating annotations. This will return all of the
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4224
     * grammars from the grammar bucket. It will also return an object for the
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4225
     * schema for schemas which will contain at least the relevant declarations
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4226
     * for annotations.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4227
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4228
    private static class XSAnnotationGrammarPool implements XMLGrammarPool {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4229
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4230
        private XSGrammarBucket fGrammarBucket;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4231
        private Grammar [] fInitialGrammarSet;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4232
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4233
        public Grammar[] retrieveInitialGrammarSet(String grammarType) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4234
            if (grammarType == XMLGrammarDescription.XML_SCHEMA) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4235
                if (fInitialGrammarSet == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4236
                    if (fGrammarBucket == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4237
                        fInitialGrammarSet = new Grammar [] {SchemaGrammar.Schema4Annotations.INSTANCE};
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4238
                    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4239
                    else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4240
                        SchemaGrammar [] schemaGrammars = fGrammarBucket.getGrammars();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4241
                        /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4242
                         * If the grammar bucket already contains the schema for schemas
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4243
                         * then we already have the definitions for the parts relevant
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4244
                         * to annotations.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4245
                         */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4246
                        for (int i = 0; i < schemaGrammars.length; ++i) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4247
                            if (SchemaSymbols.URI_SCHEMAFORSCHEMA.equals(schemaGrammars[i].getTargetNamespace())) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4248
                                fInitialGrammarSet = schemaGrammars;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4249
                                return fInitialGrammarSet;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4250
                            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4251
                        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4252
                        Grammar [] grammars = new Grammar[schemaGrammars.length + 1];
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4253
                        System.arraycopy(schemaGrammars, 0, grammars, 0, schemaGrammars.length);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4254
                        grammars[grammars.length - 1] = SchemaGrammar.Schema4Annotations.INSTANCE;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4255
                        fInitialGrammarSet = grammars;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4256
                    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4257
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4258
                return fInitialGrammarSet;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4259
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4260
            return new Grammar[0];
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4261
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4262
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4263
        public void cacheGrammars(String grammarType, Grammar[] grammars) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4264
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4265
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4266
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4267
        public Grammar retrieveGrammar(XMLGrammarDescription desc) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4268
            if (desc.getGrammarType() == XMLGrammarDescription.XML_SCHEMA) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4269
                final String tns = ((XMLSchemaDescription) desc).getTargetNamespace();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4270
                if (fGrammarBucket != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4271
                    Grammar grammar = fGrammarBucket.getGrammar(tns);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4272
                    if (grammar != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4273
                        return grammar;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4274
                    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4275
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4276
                if (SchemaSymbols.URI_SCHEMAFORSCHEMA.equals(tns)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4277
                    return SchemaGrammar.Schema4Annotations.INSTANCE;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4278
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4279
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4280
            return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4281
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4282
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4283
        public void refreshGrammars(XSGrammarBucket gBucket) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4284
            fGrammarBucket = gBucket;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4285
            fInitialGrammarSet = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4286
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4287
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4288
        public void lockPool() {}
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4289
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4290
        public void unlockPool() {}
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4291
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4292
        public void clear() {}
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4293
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4294
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4295
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4296
     * used to identify a reference to a schema document
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4297
     * if the same document is referenced twice with the same key, then
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4298
     * we only need to parse it once.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4299
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4300
     * When 2 XSDKey's are compared, the following table can be used to
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4301
     * determine whether they are equal:
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4302
     *      inc     red     imp     pre     ins
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4303
     * inc  N/L      ?      N/L     N/L     N/L
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4304
     * red   ?      N/L      ?       ?       ?
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4305
     * imp  N/L      ?      N/P     N/P     N/P
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4306
     * pre  N/L      ?      N/P     N/P     N/P
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4307
     * ins  N/L      ?      N/P     N/P     N/P
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4308
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4309
     * Where: N/L: duplicate when they have the same namespace and location.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4310
     *         ? : not clear from the spec.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4311
     *             REVISIT: to simplify the process, also considering
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4312
     *             it's very rare, we treat them as not duplicate.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4313
     *        N/P: not possible. imp/pre/ins are referenced by namespace.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4314
     *             when the first time we encounter a schema document for a
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4315
     *             namespace, we create a grammar and store it in the grammar
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4316
     *             bucket. when we see another reference to the same namespace,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4317
     *             we first check whether a grammar with the same namespace is
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4318
     *             already in the bucket, which is true in this case, so we
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4319
     *             won't create another XSDKey.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4320
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4321
     * Conclusion from the table: two XSDKey's are duplicate only when all of
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4322
     * the following are true:
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4323
     * 1. They are both "redefine", or neither is "redefine";
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4324
     * 2. They have the same namespace;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4325
     * 3. They have the same non-null location.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4326
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4327
     * About 3: if neither has a non-null location, then it's the case where
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4328
     * 2 input streams are provided, but no system ID is provided. We can't tell
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4329
     * whether the 2 streams have the same content, so we treat them as not
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4330
     * duplicate.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4331
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4332
    private static class XSDKey {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4333
        String systemId;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4334
        short  referType;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4335
        // for inclue/redefine, this is the enclosing namespace
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4336
        // for import/preparse/instance, this is the target namespace
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4337
        String referNS;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4338
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4339
        XSDKey(String systemId, short referType, String referNS) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4340
            this.systemId = systemId;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4341
            this.referType = referType;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4342
            this.referNS = referNS;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4343
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4344
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4345
        public int hashCode() {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4346
            // according to the description at the beginning of this class,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4347
            // we use the hashcode of the namespace as the hashcoe of this key.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4348
            return referNS == null ? 0 : referNS.hashCode();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4349
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4350
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4351
        public boolean equals(Object obj) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4352
            if (!(obj instanceof XSDKey)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4353
                return false;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4354
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4355
            XSDKey key = (XSDKey)obj;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4356
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4357
            // condition 1: both are redefine
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4358
            /** if (referType == XSDDescription.CONTEXT_REDEFINE ||
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4359
                    key.referType == XSDDescription.CONTEXT_REDEFINE) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4360
                if (referType != key.referType)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4361
                    return false;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4362
            }**/
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4363
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4364
            // condition 2: same namespace
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4365
            if (referNS != key.referNS)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4366
                return false;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4367
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4368
            // condition 3: same non-null location
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4369
            if (systemId == null || !systemId.equals(key.systemId)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4370
                return false;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4371
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4372
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4373
            return true;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4374
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4375
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4376
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4377
    private static final class SAX2XNIUtil extends ErrorHandlerWrapper {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4378
        public static XMLParseException createXMLParseException0(SAXParseException exception) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4379
            return createXMLParseException(exception);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4380
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4381
        public static XNIException createXNIException0(SAXException exception) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4382
            return createXNIException(exception);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4383
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4384
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4385
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4386
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4387
     * @param state
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4388
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4389
    public void setGenerateSyntheticAnnotations(boolean state) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4390
        fSchemaParser.setFeature(GENERATE_SYNTHETIC_ANNOTATIONS, state);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4391
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4392
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  4393
} // XSDHandler