286N/A/*
286N/A * reserved comment block
286N/A * DO NOT REMOVE OR ALTER!
286N/A */
286N/A/*
286N/A * Copyright 2001-2004 The Apache Software Foundation.
286N/A *
286N/A * Licensed under the Apache License, Version 2.0 (the "License");
286N/A * you may not use this file except in compliance with the License.
286N/A * You may obtain a copy of the License at
286N/A *
286N/A * http://www.apache.org/licenses/LICENSE-2.0
286N/A *
286N/A * Unless required by applicable law or agreed to in writing, software
286N/A * distributed under the License is distributed on an "AS IS" BASIS,
286N/A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
286N/A * See the License for the specific language governing permissions and
286N/A * limitations under the License.
286N/A */
286N/A
286N/Apackage com.sun.org.apache.xerces.internal.impl.xs;
286N/A
286N/Aimport java.lang.ref.SoftReference;
286N/Aimport java.util.Vector;
286N/A
286N/Aimport com.sun.org.apache.xerces.internal.impl.Constants;
286N/Aimport com.sun.org.apache.xerces.internal.impl.dv.SchemaDVFactory;
286N/Aimport com.sun.org.apache.xerces.internal.impl.dv.ValidatedInfo;
286N/Aimport com.sun.org.apache.xerces.internal.impl.dv.XSSimpleType;
286N/Aimport com.sun.org.apache.xerces.internal.impl.dv.xs.XSSimpleTypeDecl;
286N/Aimport com.sun.org.apache.xerces.internal.impl.xs.identity.IdentityConstraint;
286N/Aimport com.sun.org.apache.xerces.internal.impl.xs.util.ObjectListImpl;
286N/Aimport com.sun.org.apache.xerces.internal.impl.xs.util.SimpleLocator;
286N/Aimport com.sun.org.apache.xerces.internal.impl.xs.util.StringListImpl;
286N/Aimport com.sun.org.apache.xerces.internal.impl.xs.util.XSNamedMap4Types;
286N/Aimport com.sun.org.apache.xerces.internal.impl.xs.util.XSNamedMapImpl;
286N/Aimport com.sun.org.apache.xerces.internal.impl.xs.util.XSObjectListImpl;
286N/Aimport com.sun.org.apache.xerces.internal.parsers.DOMParser;
286N/Aimport com.sun.org.apache.xerces.internal.parsers.SAXParser;
286N/Aimport com.sun.org.apache.xerces.internal.parsers.XML11Configuration;
286N/Aimport com.sun.org.apache.xerces.internal.util.SymbolHash;
286N/Aimport com.sun.org.apache.xerces.internal.util.SymbolTable;
286N/Aimport com.sun.org.apache.xerces.internal.xni.NamespaceContext;
286N/Aimport com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarDescription;
286N/Aimport com.sun.org.apache.xerces.internal.xni.grammars.XSGrammar;
286N/Aimport com.sun.org.apache.xerces.internal.xs.StringList;
286N/Aimport com.sun.org.apache.xerces.internal.xs.XSAnnotation;
286N/Aimport com.sun.org.apache.xerces.internal.xs.XSAttributeDeclaration;
286N/Aimport com.sun.org.apache.xerces.internal.xs.XSAttributeGroupDefinition;
286N/Aimport com.sun.org.apache.xerces.internal.xs.XSConstants;
286N/Aimport com.sun.org.apache.xerces.internal.xs.XSElementDeclaration;
286N/Aimport com.sun.org.apache.xerces.internal.xs.XSModel;
286N/Aimport com.sun.org.apache.xerces.internal.xs.XSModelGroupDefinition;
286N/Aimport com.sun.org.apache.xerces.internal.xs.XSNamedMap;
286N/Aimport com.sun.org.apache.xerces.internal.xs.XSNamespaceItem;
286N/Aimport com.sun.org.apache.xerces.internal.xs.XSNotationDeclaration;
286N/Aimport com.sun.org.apache.xerces.internal.xs.XSObjectList;
286N/Aimport com.sun.org.apache.xerces.internal.xs.XSParticle;
286N/Aimport com.sun.org.apache.xerces.internal.xs.XSTypeDefinition;
286N/Aimport com.sun.org.apache.xerces.internal.xs.XSWildcard;
286N/Aimport com.sun.org.apache.xerces.internal.xs.datatypes.ObjectList;
286N/Aimport org.xml.sax.SAXException;
286N/A
286N/A/**
286N/A * This class is to hold all schema component declaration that are declared
286N/A * within one namespace.
286N/A *
286N/A * The Grammar class this class extends contains what little
286N/A * commonality there is between XML Schema and DTD grammars. It's
286N/A * useful to distinguish grammar objects from other kinds of object
286N/A * when they exist in pools or caches.
286N/A *
286N/A * @xerces.internal
286N/A *
286N/A * @author Sandy Gao, IBM
286N/A * @author Elena Litani, IBM
286N/A *
286N/A * @version $Id: SchemaGrammar.java,v 1.7 2010-11-01 04:39:55 joehw Exp $
286N/A */
286N/A
286N/Apublic class SchemaGrammar implements XSGrammar, XSNamespaceItem {
286N/A
286N/A // the target namespace of grammar
286N/A String fTargetNamespace;
286N/A
286N/A // global decls: map from decl name to decl object
286N/A SymbolHash fGlobalAttrDecls;
286N/A SymbolHash fGlobalAttrGrpDecls;
286N/A SymbolHash fGlobalElemDecls;
286N/A SymbolHash fGlobalGroupDecls;
286N/A SymbolHash fGlobalNotationDecls;
286N/A SymbolHash fGlobalIDConstraintDecls;
286N/A SymbolHash fGlobalTypeDecls;
286N/A
286N/A // extended global decls: map from schema location + decl name to decl object
286N/A // key is location,name
286N/A SymbolHash fGlobalAttrDeclsExt;
286N/A SymbolHash fGlobalAttrGrpDeclsExt;
286N/A SymbolHash fGlobalElemDeclsExt;
286N/A SymbolHash fGlobalGroupDeclsExt;
286N/A SymbolHash fGlobalNotationDeclsExt;
286N/A SymbolHash fGlobalIDConstraintDeclsExt;
286N/A SymbolHash fGlobalTypeDeclsExt;
286N/A
286N/A // A global map of all global element declarations - used for substitution group computation
286N/A // (handy when sharing components by reference, since we might end up with duplicate components
286N/A // that are not added to either of the global element declarations above)
286N/A SymbolHash fAllGlobalElemDecls;
286N/A
286N/A // the XMLGrammarDescription member
286N/A XSDDescription fGrammarDescription = null;
286N/A
286N/A // annotations associated with the "root" schema of this targetNamespace
286N/A XSAnnotationImpl [] fAnnotations = null;
286N/A
286N/A // number of annotations declared
286N/A int fNumAnnotations;
286N/A
286N/A // symbol table for constructing parsers (annotation support)
286N/A private SymbolTable fSymbolTable = null;
286N/A // parsers for annotation support
286N/A private SoftReference fSAXParser = null;
286N/A private SoftReference fDOMParser = null;
286N/A
286N/A // is this grammar immutable? (fully constructed and not changeable)
286N/A private boolean fIsImmutable = false;
286N/A
286N/A //
286N/A // Constructors
286N/A //
286N/A
286N/A // needed to make BuiltinSchemaGrammar work.
286N/A protected SchemaGrammar() {}
286N/A
286N/A /**
286N/A * Default constructor.
286N/A *
286N/A * @param targetNamespace
286N/A * @param grammarDesc the XMLGrammarDescription corresponding to this objec
286N/A * at the least a systemId should always be known.
286N/A * @param symbolTable needed for annotation support
286N/A */
286N/A public SchemaGrammar(String targetNamespace, XSDDescription grammarDesc,
286N/A SymbolTable symbolTable) {
286N/A fTargetNamespace = targetNamespace;
286N/A fGrammarDescription = grammarDesc;
286N/A fSymbolTable = symbolTable;
286N/A
286N/A // REVISIT: do we know the numbers of the following global decls
286N/A // when creating this grammar? If so, we can pass the numbers in,
286N/A // and use that number to initialize the following hashtables.
286N/A fGlobalAttrDecls = new SymbolHash();
286N/A fGlobalAttrGrpDecls = new SymbolHash();
286N/A fGlobalElemDecls = new SymbolHash();
286N/A fGlobalGroupDecls = new SymbolHash();
286N/A fGlobalNotationDecls = new SymbolHash();
286N/A fGlobalIDConstraintDecls = new SymbolHash();
286N/A
286N/A // Extended tables
286N/A fGlobalAttrDeclsExt = new SymbolHash();
286N/A fGlobalAttrGrpDeclsExt = new SymbolHash();
286N/A fGlobalElemDeclsExt = new SymbolHash();
286N/A fGlobalGroupDeclsExt = new SymbolHash();
286N/A fGlobalNotationDeclsExt = new SymbolHash();
286N/A fGlobalIDConstraintDeclsExt = new SymbolHash();
286N/A fGlobalTypeDeclsExt = new SymbolHash();
286N/A
286N/A // All global elements table
286N/A fAllGlobalElemDecls = new SymbolHash();
286N/A
286N/A // if we are parsing S4S, put built-in types in first
286N/A // they might get overwritten by the types from S4S, but that's
286N/A // considered what the application wants to do.
286N/A if (fTargetNamespace == SchemaSymbols.URI_SCHEMAFORSCHEMA)
286N/A fGlobalTypeDecls = SG_SchemaNS.fGlobalTypeDecls.makeClone();
286N/A else
286N/A fGlobalTypeDecls = new SymbolHash();
286N/A } // <init>(String, XSDDescription)
286N/A
286N/A // Clone an existing schema grammar
286N/A public SchemaGrammar(SchemaGrammar grammar) {
286N/A fTargetNamespace = grammar.fTargetNamespace;
286N/A fGrammarDescription = grammar.fGrammarDescription.makeClone();
286N/A //fGrammarDescription.fContextType |= XSDDescription.CONTEXT_COLLISION; // REVISIT
286N/A fSymbolTable = grammar.fSymbolTable; // REVISIT
286N/A
286N/A fGlobalAttrDecls = grammar.fGlobalAttrDecls.makeClone();
286N/A fGlobalAttrGrpDecls = grammar.fGlobalAttrGrpDecls.makeClone();
286N/A fGlobalElemDecls = grammar.fGlobalElemDecls.makeClone();
286N/A fGlobalGroupDecls = grammar.fGlobalGroupDecls.makeClone();
286N/A fGlobalNotationDecls = grammar.fGlobalNotationDecls.makeClone();
286N/A fGlobalIDConstraintDecls = grammar.fGlobalIDConstraintDecls.makeClone();
286N/A fGlobalTypeDecls = grammar.fGlobalTypeDecls.makeClone();
286N/A
286N/A // Extended tables
286N/A fGlobalAttrDeclsExt = grammar.fGlobalAttrDeclsExt.makeClone();
286N/A fGlobalAttrGrpDeclsExt = grammar.fGlobalAttrGrpDeclsExt.makeClone();
286N/A fGlobalElemDeclsExt = grammar.fGlobalElemDeclsExt.makeClone();
286N/A fGlobalGroupDeclsExt = grammar.fGlobalGroupDeclsExt.makeClone();
286N/A fGlobalNotationDeclsExt = grammar.fGlobalNotationDeclsExt.makeClone();
286N/A fGlobalIDConstraintDeclsExt = grammar.fGlobalIDConstraintDeclsExt.makeClone();
286N/A fGlobalTypeDeclsExt = grammar.fGlobalTypeDeclsExt.makeClone();
286N/A
286N/A // All global elements table
286N/A fAllGlobalElemDecls = grammar.fAllGlobalElemDecls.makeClone();
286N/A
286N/A // Annotations associated with the "root" schema of this targetNamespace
286N/A fNumAnnotations = grammar.fNumAnnotations;
286N/A if (fNumAnnotations > 0) {
286N/A fAnnotations = new XSAnnotationImpl[grammar.fAnnotations.length];
286N/A System.arraycopy(grammar.fAnnotations, 0, fAnnotations, 0, fNumAnnotations);
286N/A }
286N/A
286N/A // All substitution group information declared in this namespace
286N/A fSubGroupCount = grammar.fSubGroupCount;
286N/A if (fSubGroupCount > 0) {
286N/A fSubGroups = new XSElementDecl[grammar.fSubGroups.length];
286N/A System.arraycopy(grammar.fSubGroups, 0, fSubGroups, 0, fSubGroupCount);
286N/A }
286N/A
286N/A // Array to store complex type decls for constraint checking
286N/A fCTCount = grammar.fCTCount;
286N/A if (fCTCount > 0) {
286N/A fComplexTypeDecls = new XSComplexTypeDecl[grammar.fComplexTypeDecls.length];
286N/A fCTLocators = new SimpleLocator[grammar.fCTLocators.length];
286N/A System.arraycopy(grammar.fComplexTypeDecls, 0, fComplexTypeDecls, 0, fCTCount);
286N/A System.arraycopy(grammar.fCTLocators, 0, fCTLocators, 0, fCTCount);
286N/A }
286N/A
286N/A // Groups being redefined by restriction
286N/A fRGCount = grammar.fRGCount;
286N/A if (fRGCount > 0) {
286N/A fRedefinedGroupDecls = new XSGroupDecl[grammar.fRedefinedGroupDecls.length];
286N/A fRGLocators = new SimpleLocator[grammar.fRGLocators.length];
286N/A System.arraycopy(grammar.fRedefinedGroupDecls, 0, fRedefinedGroupDecls, 0, fRGCount);
286N/A System.arraycopy(grammar.fRGLocators, 0, fRGLocators, 0, fRGCount);
286N/A }
286N/A
286N/A // List of imported grammars
286N/A if (grammar.fImported != null) {
286N/A fImported = new Vector();
286N/A for (int i=0; i<grammar.fImported.size(); i++) {
286N/A fImported.add(grammar.fImported.elementAt(i));
286N/A }
286N/A }
286N/A
286N/A // Locations
286N/A if (grammar.fLocations != null) {
286N/A for (int k=0; k<grammar.fLocations.size(); k++) {
286N/A addDocument(null, (String)grammar.fLocations.elementAt(k));
286N/A }
286N/A }
286N/A
286N/A } // <init>(String, XSDDescription)
286N/A
286N/A // number of built-in XSTypes we need to create for base and full
286N/A // datatype set
286N/A private static final int BASICSET_COUNT = 29;
286N/A private static final int FULLSET_COUNT = 46;
286N/A
286N/A private static final int GRAMMAR_XS = 1;
286N/A private static final int GRAMMAR_XSI = 2;
286N/A
286N/A // this class makes sure the static, built-in schema grammars
286N/A // are immutable.
286N/A public static class BuiltinSchemaGrammar extends SchemaGrammar {
286N/A
286N/A private static final String EXTENDED_SCHEMA_FACTORY_CLASS = "com.sun.org.apache.xerces.internal.impl.dv.xs.ExtendedSchemaDVFactoryImpl";
286N/A
286N/A /**
286N/A * Special constructor to create the grammars for the schema namespaces
286N/A *
286N/A * @param grammar
286N/A */
286N/A public BuiltinSchemaGrammar(int grammar, short schemaVersion) {
286N/A SchemaDVFactory schemaFactory;
286N/A if (schemaVersion == Constants.SCHEMA_VERSION_1_0) {
286N/A schemaFactory = SchemaDVFactory.getInstance();
286N/A }
286N/A else {
286N/A schemaFactory = SchemaDVFactory.getInstance(EXTENDED_SCHEMA_FACTORY_CLASS);
286N/A }
286N/A
286N/A if (grammar == GRAMMAR_XS) {
286N/A // target namespace
286N/A fTargetNamespace = SchemaSymbols.URI_SCHEMAFORSCHEMA;
286N/A
286N/A // grammar description
286N/A fGrammarDescription = new XSDDescription();
286N/A fGrammarDescription.fContextType = XSDDescription.CONTEXT_PREPARSE;
286N/A fGrammarDescription.setNamespace(SchemaSymbols.URI_SCHEMAFORSCHEMA);
286N/A
286N/A // no global decls other than types
286N/A fGlobalAttrDecls = new SymbolHash(1);
286N/A fGlobalAttrGrpDecls = new SymbolHash(1);
286N/A fGlobalElemDecls = new SymbolHash(1);
286N/A fGlobalGroupDecls = new SymbolHash(1);
286N/A fGlobalNotationDecls = new SymbolHash(1);
286N/A fGlobalIDConstraintDecls = new SymbolHash(1);
286N/A
286N/A // no extended global decls
286N/A fGlobalAttrDeclsExt = new SymbolHash(1);
286N/A fGlobalAttrGrpDeclsExt = new SymbolHash(1);
286N/A fGlobalElemDeclsExt = new SymbolHash(1);
286N/A fGlobalGroupDeclsExt = new SymbolHash(1);
286N/A fGlobalNotationDeclsExt = new SymbolHash(1);
286N/A fGlobalIDConstraintDeclsExt = new SymbolHash(1);
286N/A fGlobalTypeDeclsExt = new SymbolHash(1);
286N/A
286N/A // all global element decls table
286N/A fAllGlobalElemDecls = new SymbolHash(1);
286N/A
286N/A // get all built-in types
286N/A fGlobalTypeDecls = schemaFactory.getBuiltInTypes();
286N/A
286N/A // assign the built-in schema grammar as the XSNamespaceItem
286N/A // for each of the built-in simple type definitions.
286N/A int length = fGlobalTypeDecls.getLength();
286N/A XSTypeDefinition [] typeDefinitions = new XSTypeDefinition[length];
286N/A fGlobalTypeDecls.getValues(typeDefinitions, 0);
286N/A for (int i = 0; i < length; ++i) {
286N/A XSTypeDefinition xtd = typeDefinitions[i];
286N/A if (xtd instanceof XSSimpleTypeDecl) {
286N/A ((XSSimpleTypeDecl) xtd).setNamespaceItem(this);
286N/A }
286N/A }
286N/A
286N/A // add anyType
286N/A fGlobalTypeDecls.put(fAnyType.getName(), fAnyType);
286N/A }
286N/A else if (grammar == GRAMMAR_XSI) {
286N/A // target namespace
286N/A fTargetNamespace = SchemaSymbols.URI_XSI;
286N/A // grammar description
286N/A fGrammarDescription = new XSDDescription();
286N/A fGrammarDescription.fContextType = XSDDescription.CONTEXT_PREPARSE;
286N/A fGrammarDescription.setNamespace(SchemaSymbols.URI_XSI);
286N/A
286N/A // no global decls other than attributes
286N/A fGlobalAttrGrpDecls = new SymbolHash(1);
286N/A fGlobalElemDecls = new SymbolHash(1);
286N/A fGlobalGroupDecls = new SymbolHash(1);
286N/A fGlobalNotationDecls = new SymbolHash(1);
286N/A fGlobalIDConstraintDecls = new SymbolHash(1);
286N/A fGlobalTypeDecls = new SymbolHash(1);
286N/A
286N/A // no extended global decls
286N/A fGlobalAttrDeclsExt = new SymbolHash(1);
286N/A fGlobalAttrGrpDeclsExt = new SymbolHash(1);
286N/A fGlobalElemDeclsExt = new SymbolHash(1);
286N/A fGlobalGroupDeclsExt = new SymbolHash(1);
286N/A fGlobalNotationDeclsExt = new SymbolHash(1);
286N/A fGlobalIDConstraintDeclsExt = new SymbolHash(1);
286N/A fGlobalTypeDeclsExt = new SymbolHash(1);
286N/A
286N/A // no all global element decls
286N/A fAllGlobalElemDecls = new SymbolHash(1);
286N/A
286N/A // 4 attributes, so initialize the size as 4*2 = 8
286N/A fGlobalAttrDecls = new SymbolHash(8);
286N/A String name = null;
286N/A String tns = null;
286N/A XSSimpleType type = null;
286N/A short scope = XSConstants.SCOPE_GLOBAL;
286N/A
286N/A // xsi:type
286N/A name = SchemaSymbols.XSI_TYPE;
286N/A tns = SchemaSymbols.URI_XSI;
286N/A type = schemaFactory.getBuiltInType(SchemaSymbols.ATTVAL_QNAME);
286N/A fGlobalAttrDecls.put(name, new BuiltinAttrDecl(name, tns, type, scope));
286N/A
286N/A // xsi:nil
286N/A name = SchemaSymbols.XSI_NIL;
286N/A tns = SchemaSymbols.URI_XSI;
286N/A type = schemaFactory.getBuiltInType(SchemaSymbols.ATTVAL_BOOLEAN);
286N/A fGlobalAttrDecls.put(name, new BuiltinAttrDecl(name, tns, type, scope));
286N/A
286N/A XSSimpleType anyURI = schemaFactory.getBuiltInType(SchemaSymbols.ATTVAL_ANYURI);
286N/A
286N/A // xsi:schemaLocation
286N/A name = SchemaSymbols.XSI_SCHEMALOCATION;
286N/A tns = SchemaSymbols.URI_XSI;
286N/A type = schemaFactory.createTypeList("#AnonType_schemaLocation", SchemaSymbols.URI_XSI, (short)0, anyURI, null);
286N/A if (type instanceof XSSimpleTypeDecl) {
286N/A ((XSSimpleTypeDecl)type).setAnonymous(true);
286N/A }
286N/A fGlobalAttrDecls.put(name, new BuiltinAttrDecl(name, tns, type, scope));
286N/A
286N/A // xsi:noNamespaceSchemaLocation
286N/A name = SchemaSymbols.XSI_NONAMESPACESCHEMALOCATION;
286N/A tns = SchemaSymbols.URI_XSI;
286N/A type = anyURI;
286N/A fGlobalAttrDecls.put(name, new BuiltinAttrDecl(name, tns, type, scope));
286N/A }
286N/A } // <init>(int)
286N/A
286N/A // return the XMLGrammarDescription corresponding to this
286N/A // object
286N/A public XMLGrammarDescription getGrammarDescription() {
286N/A return fGrammarDescription.makeClone();
286N/A } // getGrammarDescription(): XMLGrammarDescription
286N/A
286N/A // override these methods solely so that these
286N/A // objects cannot be modified once they're created.
286N/A public void setImportedGrammars(Vector importedGrammars) {
286N/A // ignore
286N/A }
286N/A public void addGlobalAttributeDecl(XSAttributeDecl decl) {
286N/A // ignore
286N/A }
286N/A public void addGlobalAttributeDecl(XSAttributeDecl decl, String location) {
286N/A // ignore
286N/A }
286N/A public void addGlobalAttributeGroupDecl(XSAttributeGroupDecl decl) {
286N/A // ignore
286N/A }
286N/A public void addGlobalAttributeGroupDecl(XSAttributeGroupDecl decl, String location) {
286N/A // ignore
286N/A }
286N/A public void addGlobalElementDecl(XSElementDecl decl) {
286N/A // ignore
286N/A }
286N/A public void addGlobalElementDecl(XSElementDecl decl, String location) {
286N/A // ignore
286N/A }
286N/A public void addGlobalElementDeclAll(XSElementDecl decl) {
286N/A // ignore
286N/A }
286N/A public void addGlobalGroupDecl(XSGroupDecl decl) {
286N/A // ignore
286N/A }
286N/A public void addGlobalGroupDecl(XSGroupDecl decl, String location) {
286N/A // ignore
286N/A }
286N/A public void addGlobalNotationDecl(XSNotationDecl decl) {
286N/A // ignore
286N/A }
286N/A public void addGlobalNotationDecl(XSNotationDecl decl, String location) {
286N/A // ignore
286N/A }
286N/A public void addGlobalTypeDecl(XSTypeDefinition decl) {
286N/A // ignore
286N/A }
286N/A public void addGlobalTypeDecl(XSTypeDefinition decl, String location) {
286N/A // ignore
286N/A }
286N/A public void addGlobalComplexTypeDecl(XSComplexTypeDecl decl) {
286N/A // ignore
286N/A }
286N/A public void addGlobalComplexTypeDecl(XSComplexTypeDecl decl, String location) {
286N/A // ignore
286N/A }
286N/A public void addGlobalSimpleTypeDecl(XSSimpleType decl) {
286N/A // ignore
286N/A }
286N/A public void addGlobalSimpleTypeDecl(XSSimpleType decl, String location) {
286N/A // ignore
286N/A }
286N/A public void addComplexTypeDecl(XSComplexTypeDecl decl, SimpleLocator locator) {
286N/A // ignore
286N/A }
286N/A public void addRedefinedGroupDecl(XSGroupDecl derived, XSGroupDecl base, SimpleLocator locator) {
286N/A // ignore
286N/A }
286N/A public synchronized void addDocument(Object document, String location) {
286N/A // ignore
286N/A }
286N/A
286N/A // annotation support
286N/A synchronized DOMParser getDOMParser() {
286N/A return null;
286N/A }
286N/A synchronized SAXParser getSAXParser() {
286N/A return null;
286N/A }
286N/A }
286N/A
286N/A /**
286N/A * <p>A partial schema for schemas for validating annotations.</p>
286N/A *
286N/A * @xerces.internal
286N/A *
286N/A * @author Michael Glavassevich, IBM
286N/A */
286N/A public static final class Schema4Annotations extends SchemaGrammar {
286N/A
286N/A /**
286N/A * Singleton instance.
286N/A */
286N/A public static final Schema4Annotations INSTANCE = new Schema4Annotations();
286N/A
286N/A /**
286N/A * Special constructor to create a schema
286N/A * capable of validating annotations.
286N/A */
286N/A private Schema4Annotations() {
286N/A
286N/A // target namespace
286N/A fTargetNamespace = SchemaSymbols.URI_SCHEMAFORSCHEMA;
286N/A
286N/A // grammar description
286N/A fGrammarDescription = new XSDDescription();
286N/A fGrammarDescription.fContextType = XSDDescription.CONTEXT_PREPARSE;
286N/A fGrammarDescription.setNamespace(SchemaSymbols.URI_SCHEMAFORSCHEMA);
286N/A
286N/A // no global decls other than types and
286N/A // element declarations for <annotation>, <documentation> and <appinfo>.
286N/A fGlobalAttrDecls = new SymbolHash(1);
286N/A fGlobalAttrGrpDecls = new SymbolHash(1);
286N/A fGlobalElemDecls = new SymbolHash(6);
286N/A fGlobalGroupDecls = new SymbolHash(1);
286N/A fGlobalNotationDecls = new SymbolHash(1);
286N/A fGlobalIDConstraintDecls = new SymbolHash(1);
286N/A
286N/A // no extended global decls
286N/A fGlobalAttrDeclsExt = new SymbolHash(1);
286N/A fGlobalAttrGrpDeclsExt = new SymbolHash(1);
286N/A fGlobalElemDeclsExt = new SymbolHash(6);
286N/A fGlobalGroupDeclsExt = new SymbolHash(1);
286N/A fGlobalNotationDeclsExt = new SymbolHash(1);
286N/A fGlobalIDConstraintDeclsExt = new SymbolHash(1);
286N/A fGlobalTypeDeclsExt = new SymbolHash(1);
286N/A
286N/A // all global element declarations
286N/A fAllGlobalElemDecls = new SymbolHash(6);
286N/A
286N/A // get all built-in types
286N/A fGlobalTypeDecls = SG_SchemaNS.fGlobalTypeDecls;
286N/A
286N/A // create element declarations for <annotation>, <documentation> and <appinfo>
286N/A XSElementDecl annotationDecl = createAnnotationElementDecl(SchemaSymbols.ELT_ANNOTATION);
286N/A XSElementDecl documentationDecl = createAnnotationElementDecl(SchemaSymbols.ELT_DOCUMENTATION);
286N/A XSElementDecl appinfoDecl = createAnnotationElementDecl(SchemaSymbols.ELT_APPINFO);
286N/A
286N/A // add global element declarations
286N/A fGlobalElemDecls.put(annotationDecl.fName, annotationDecl);
286N/A fGlobalElemDecls.put(documentationDecl.fName, documentationDecl);
286N/A fGlobalElemDecls.put(appinfoDecl.fName, appinfoDecl);
286N/A
286N/A fGlobalElemDeclsExt.put(","+annotationDecl.fName, annotationDecl);
286N/A fGlobalElemDeclsExt.put(","+documentationDecl.fName, documentationDecl);
286N/A fGlobalElemDeclsExt.put(","+appinfoDecl.fName, appinfoDecl);
286N/A
286N/A fAllGlobalElemDecls.put(annotationDecl, annotationDecl);
286N/A fAllGlobalElemDecls.put(documentationDecl, documentationDecl);
286N/A fAllGlobalElemDecls.put(appinfoDecl, appinfoDecl);
286N/A
286N/A // create complex type declarations for <annotation>, <documentation> and <appinfo>
286N/A XSComplexTypeDecl annotationType = new XSComplexTypeDecl();
286N/A XSComplexTypeDecl documentationType = new XSComplexTypeDecl();
286N/A XSComplexTypeDecl appinfoType = new XSComplexTypeDecl();
286N/A
286N/A // set the types on their element declarations
286N/A annotationDecl.fType = annotationType;
286N/A documentationDecl.fType = documentationType;
286N/A appinfoDecl.fType = appinfoType;
286N/A
286N/A // create attribute groups for <annotation>, <documentation> and <appinfo>
286N/A XSAttributeGroupDecl annotationAttrs = new XSAttributeGroupDecl();
286N/A XSAttributeGroupDecl documentationAttrs = new XSAttributeGroupDecl();
286N/A XSAttributeGroupDecl appinfoAttrs = new XSAttributeGroupDecl();
286N/A
286N/A // fill in attribute groups
286N/A {
286N/A // create and fill attribute uses for <annotation>, <documentation> and <appinfo>
286N/A XSAttributeUseImpl annotationIDAttr = new XSAttributeUseImpl();
286N/A annotationIDAttr.fAttrDecl = new XSAttributeDecl();
286N/A annotationIDAttr.fAttrDecl.setValues(SchemaSymbols.ATT_ID, null, (XSSimpleType) fGlobalTypeDecls.get(SchemaSymbols.ATTVAL_ID),
286N/A XSConstants.VC_NONE, XSConstants.SCOPE_LOCAL, null, annotationType, null);
286N/A annotationIDAttr.fUse = SchemaSymbols.USE_OPTIONAL;
286N/A annotationIDAttr.fConstraintType = XSConstants.VC_NONE;
286N/A
286N/A XSAttributeUseImpl documentationSourceAttr = new XSAttributeUseImpl();
286N/A documentationSourceAttr.fAttrDecl = new XSAttributeDecl();
286N/A documentationSourceAttr.fAttrDecl.setValues(SchemaSymbols.ATT_SOURCE, null, (XSSimpleType) fGlobalTypeDecls.get(SchemaSymbols.ATTVAL_ANYURI),
286N/A XSConstants.VC_NONE, XSConstants.SCOPE_LOCAL, null, documentationType, null);
286N/A documentationSourceAttr.fUse = SchemaSymbols.USE_OPTIONAL;
286N/A documentationSourceAttr.fConstraintType = XSConstants.VC_NONE;
286N/A
286N/A XSAttributeUseImpl documentationLangAttr = new XSAttributeUseImpl();
286N/A documentationLangAttr.fAttrDecl = new XSAttributeDecl();
286N/A documentationLangAttr.fAttrDecl.setValues("lang".intern(), NamespaceContext.XML_URI, (XSSimpleType) fGlobalTypeDecls.get(SchemaSymbols.ATTVAL_LANGUAGE),
286N/A XSConstants.VC_NONE, XSConstants.SCOPE_LOCAL, null, documentationType, null);
286N/A documentationLangAttr.fUse = SchemaSymbols.USE_OPTIONAL;
286N/A documentationLangAttr.fConstraintType = XSConstants.VC_NONE;
286N/A
286N/A XSAttributeUseImpl appinfoSourceAttr = new XSAttributeUseImpl();
286N/A appinfoSourceAttr.fAttrDecl = new XSAttributeDecl();
286N/A appinfoSourceAttr.fAttrDecl.setValues(SchemaSymbols.ATT_SOURCE, null, (XSSimpleType) fGlobalTypeDecls.get(SchemaSymbols.ATTVAL_ANYURI),
286N/A XSConstants.VC_NONE, XSConstants.SCOPE_LOCAL, null, appinfoType, null);
286N/A appinfoSourceAttr.fUse = SchemaSymbols.USE_OPTIONAL;
286N/A appinfoSourceAttr.fConstraintType = XSConstants.VC_NONE;
286N/A
286N/A // create lax attribute wildcard for <annotation>, <documentation> and <appinfo>
286N/A XSWildcardDecl otherAttrs = new XSWildcardDecl();
286N/A otherAttrs.fNamespaceList = new String [] {fTargetNamespace, null};
286N/A otherAttrs.fType = XSWildcard.NSCONSTRAINT_NOT;
286N/A otherAttrs.fProcessContents = XSWildcard.PC_LAX;
286N/A
286N/A // add attribute uses and wildcards to attribute groups for <annotation>, <documentation> and <appinfo>
286N/A annotationAttrs.addAttributeUse(annotationIDAttr);
286N/A annotationAttrs.fAttributeWC = otherAttrs;
286N/A
286N/A documentationAttrs.addAttributeUse(documentationSourceAttr);
286N/A documentationAttrs.addAttributeUse(documentationLangAttr);
286N/A documentationAttrs.fAttributeWC = otherAttrs;
286N/A
286N/A appinfoAttrs.addAttributeUse(appinfoSourceAttr);
286N/A appinfoAttrs.fAttributeWC = otherAttrs;
286N/A }
286N/A
286N/A // create particles for <annotation>
286N/A XSParticleDecl annotationParticle = createUnboundedModelGroupParticle();
286N/A {
286N/A XSModelGroupImpl annotationChoice = new XSModelGroupImpl();
286N/A annotationChoice.fCompositor = XSModelGroupImpl.MODELGROUP_CHOICE;
286N/A annotationChoice.fParticleCount = 2;
286N/A annotationChoice.fParticles = new XSParticleDecl[2];
286N/A annotationChoice.fParticles[0] = createChoiceElementParticle(appinfoDecl);
286N/A annotationChoice.fParticles[1] = createChoiceElementParticle(documentationDecl);
286N/A annotationParticle.fValue = annotationChoice;
286N/A }
286N/A
286N/A // create wildcard particle for <documentation> and <appinfo>
286N/A XSParticleDecl anyWCSequenceParticle = createUnboundedAnyWildcardSequenceParticle();
286N/A
286N/A // fill complex types
286N/A annotationType.setValues("#AnonType_" + SchemaSymbols.ELT_ANNOTATION, fTargetNamespace, SchemaGrammar.fAnyType,
286N/A XSConstants.DERIVATION_RESTRICTION, XSConstants.DERIVATION_NONE, (short) (XSConstants.DERIVATION_EXTENSION | XSConstants.DERIVATION_RESTRICTION),
286N/A XSComplexTypeDecl.CONTENTTYPE_ELEMENT, false, annotationAttrs, null, annotationParticle, new XSObjectListImpl(null, 0));
286N/A annotationType.setName("#AnonType_" + SchemaSymbols.ELT_ANNOTATION);
286N/A annotationType.setIsAnonymous();
286N/A
286N/A documentationType.setValues("#AnonType_" + SchemaSymbols.ELT_DOCUMENTATION, fTargetNamespace, SchemaGrammar.fAnyType,
286N/A XSConstants.DERIVATION_RESTRICTION, XSConstants.DERIVATION_NONE, (short) (XSConstants.DERIVATION_EXTENSION | XSConstants.DERIVATION_RESTRICTION),
286N/A XSComplexTypeDecl.CONTENTTYPE_MIXED, false, documentationAttrs, null, anyWCSequenceParticle, new XSObjectListImpl(null, 0));
286N/A documentationType.setName("#AnonType_" + SchemaSymbols.ELT_DOCUMENTATION);
286N/A documentationType.setIsAnonymous();
286N/A
286N/A appinfoType.setValues("#AnonType_" + SchemaSymbols.ELT_APPINFO, fTargetNamespace, SchemaGrammar.fAnyType,
286N/A XSConstants.DERIVATION_RESTRICTION, XSConstants.DERIVATION_NONE, (short) (XSConstants.DERIVATION_EXTENSION | XSConstants.DERIVATION_RESTRICTION),
286N/A XSComplexTypeDecl.CONTENTTYPE_MIXED, false, appinfoAttrs, null, anyWCSequenceParticle, new XSObjectListImpl(null, 0));
286N/A appinfoType.setName("#AnonType_" + SchemaSymbols.ELT_APPINFO);
286N/A appinfoType.setIsAnonymous();
286N/A
286N/A } // <init>(int)
286N/A
286N/A // return the XMLGrammarDescription corresponding to this
286N/A // object
286N/A public XMLGrammarDescription getGrammarDescription() {
286N/A return fGrammarDescription.makeClone();
286N/A } // getGrammarDescription(): XMLGrammarDescription
286N/A
286N/A // override these methods solely so that these
286N/A // objects cannot be modified once they're created.
286N/A public void setImportedGrammars(Vector importedGrammars) {
286N/A // ignore
286N/A }
286N/A public void addGlobalAttributeDecl(XSAttributeDecl decl) {
286N/A // ignore
286N/A }
286N/A public void addGlobalAttributeDecl(XSAttributeGroupDecl decl, String location) {
286N/A // ignore
286N/A }
286N/A public void addGlobalAttributeGroupDecl(XSAttributeGroupDecl decl) {
286N/A // ignore
286N/A }
286N/A public void addGlobalAttributeGroupDecl(XSAttributeGroupDecl decl, String location) {
286N/A // ignore
286N/A }
286N/A public void addGlobalElementDecl(XSElementDecl decl) {
286N/A // ignore
286N/A }
286N/A public void addGlobalElementDecl(XSElementDecl decl, String location) {
286N/A // ignore
286N/A }
286N/A public void addGlobalElementDeclAll(XSElementDecl decl) {
286N/A // ignore
286N/A }
286N/A public void addGlobalGroupDecl(XSGroupDecl decl) {
286N/A // ignore
286N/A }
286N/A public void addGlobalGroupDecl(XSGroupDecl decl, String location) {
286N/A // ignore
286N/A }
286N/A public void addGlobalNotationDecl(XSNotationDecl decl) {
286N/A // ignore
286N/A }
286N/A public void addGlobalNotationDecl(XSNotationDecl decl, String location) {
286N/A // ignore
286N/A }
286N/A public void addGlobalTypeDecl(XSTypeDefinition decl) {
286N/A // ignore
286N/A }
286N/A public void addGlobalTypeDecl(XSTypeDefinition decl, String location) {
286N/A // ignore
286N/A }
286N/A public void addGlobalComplexTypeDecl(XSComplexTypeDecl decl) {
286N/A // ignore
286N/A }
286N/A public void addGlobalComplexTypeDecl(XSComplexTypeDecl decl, String location) {
286N/A // ignore
286N/A }
286N/A public void addGlobalSimpleTypeDecl(XSSimpleType decl) {
286N/A // ignore
286N/A }
286N/A public void addGlobalSimpleTypeDecl(XSSimpleType decl, String location) {
286N/A // ignore
286N/A }
286N/A public void addComplexTypeDecl(XSComplexTypeDecl decl, SimpleLocator locator) {
286N/A // ignore
286N/A }
286N/A public void addRedefinedGroupDecl(XSGroupDecl derived, XSGroupDecl base, SimpleLocator locator) {
286N/A // ignore
286N/A }
286N/A public synchronized void addDocument(Object document, String location) {
286N/A // ignore
286N/A }
286N/A
286N/A // annotation support
286N/A synchronized DOMParser getDOMParser() {
286N/A return null;
286N/A }
286N/A synchronized SAXParser getSAXParser() {
286N/A return null;
286N/A }
286N/A
286N/A //
286N/A // private helper methods
286N/A //
286N/A
286N/A private XSElementDecl createAnnotationElementDecl(String localName) {
286N/A XSElementDecl eDecl = new XSElementDecl();
286N/A eDecl.fName = localName;
286N/A eDecl.fTargetNamespace = fTargetNamespace;
286N/A eDecl.setIsGlobal();
286N/A eDecl.fBlock = (XSConstants.DERIVATION_EXTENSION |
286N/A XSConstants.DERIVATION_RESTRICTION | XSConstants.DERIVATION_SUBSTITUTION);
286N/A eDecl.setConstraintType(XSConstants.VC_NONE);
286N/A return eDecl;
286N/A }
286N/A
286N/A private XSParticleDecl createUnboundedModelGroupParticle() {
286N/A XSParticleDecl particle = new XSParticleDecl();
286N/A particle.fMinOccurs = 0;
286N/A particle.fMaxOccurs = SchemaSymbols.OCCURRENCE_UNBOUNDED;
286N/A particle.fType = XSParticleDecl.PARTICLE_MODELGROUP;
286N/A return particle;
286N/A }
286N/A
286N/A private XSParticleDecl createChoiceElementParticle(XSElementDecl ref) {
286N/A XSParticleDecl particle = new XSParticleDecl();
286N/A particle.fMinOccurs = 1;
286N/A particle.fMaxOccurs = 1;
286N/A particle.fType = XSParticleDecl.PARTICLE_ELEMENT;
286N/A particle.fValue = ref;
286N/A return particle;
286N/A }
286N/A
286N/A private XSParticleDecl createUnboundedAnyWildcardSequenceParticle() {
286N/A XSParticleDecl particle = createUnboundedModelGroupParticle();
286N/A XSModelGroupImpl sequence = new XSModelGroupImpl();
286N/A sequence.fCompositor = XSModelGroupImpl.MODELGROUP_SEQUENCE;
286N/A sequence.fParticleCount = 1;
286N/A sequence.fParticles = new XSParticleDecl[1];
286N/A sequence.fParticles[0] = createAnyLaxWildcardParticle();
286N/A particle.fValue = sequence;
286N/A return particle;
286N/A }
286N/A
286N/A private XSParticleDecl createAnyLaxWildcardParticle() {
286N/A XSParticleDecl particle = new XSParticleDecl();
286N/A particle.fMinOccurs = 1;
286N/A particle.fMaxOccurs = 1;
286N/A particle.fType = XSParticleDecl.PARTICLE_WILDCARD;
286N/A
286N/A XSWildcardDecl anyWC = new XSWildcardDecl();
286N/A anyWC.fNamespaceList = null;
286N/A anyWC.fType = XSWildcard.NSCONSTRAINT_ANY;
286N/A anyWC.fProcessContents = XSWildcard.PC_LAX;
286N/A
286N/A particle.fValue = anyWC;
286N/A return particle;
286N/A }
286N/A }
286N/A
286N/A // Grammar methods
286N/A
286N/A // return the XMLGrammarDescription corresponding to this
286N/A // object
286N/A public XMLGrammarDescription getGrammarDescription() {
286N/A return fGrammarDescription;
286N/A } // getGrammarDescription(): XMLGrammarDescription
286N/A
286N/A // DTDGrammar methods
286N/A public boolean isNamespaceAware () {
286N/A return true;
286N/A } // isNamespaceAware():boolean
286N/A
286N/A Vector fImported = null;
286N/A
286N/A public void setImportedGrammars(Vector importedGrammars) {
286N/A fImported = importedGrammars;
286N/A }
286N/A
286N/A public Vector getImportedGrammars() {
286N/A return fImported;
286N/A }
286N/A
286N/A /**
286N/A * Returns this grammar's target namespace.
286N/A */
286N/A public final String getTargetNamespace() {
286N/A return fTargetNamespace;
286N/A } // getTargetNamespace():String
286N/A
286N/A /**
286N/A * register one global attribute
286N/A */
286N/A public void addGlobalAttributeDecl(XSAttributeDecl decl) {
286N/A fGlobalAttrDecls.put(decl.fName, decl);
286N/A decl.setNamespaceItem(this);
286N/A }
286N/A
286N/A public void addGlobalAttributeDecl(XSAttributeDecl decl, String location) {
286N/A fGlobalAttrDeclsExt.put(((location!=null) ? location : "") + "," + decl.fName, decl);
286N/A if (decl.getNamespaceItem() == null) {
286N/A decl.setNamespaceItem(this);
286N/A }
286N/A }
286N/A
286N/A /**
286N/A * register one global attribute group
286N/A */
286N/A public void addGlobalAttributeGroupDecl(XSAttributeGroupDecl decl) {
286N/A fGlobalAttrGrpDecls.put(decl.fName, decl);
286N/A decl.setNamespaceItem(this);
286N/A }
286N/A
286N/A public void addGlobalAttributeGroupDecl(XSAttributeGroupDecl decl, String location) {
286N/A fGlobalAttrGrpDeclsExt.put(((location!=null) ? location : "") + "," + decl.fName, decl);
286N/A if (decl.getNamespaceItem() == null) {
286N/A decl.setNamespaceItem(this);
286N/A }
286N/A }
286N/A
286N/A /**
286N/A * register one global element
286N/A */
286N/A public void addGlobalElementDeclAll(XSElementDecl decl) {
286N/A if (fAllGlobalElemDecls.get(decl) == null) {
286N/A fAllGlobalElemDecls.put(decl, decl);
286N/A // if there is a substitution group affiliation, store in an array,
286N/A // for further constraint checking: UPA, PD, EDC
286N/A if (decl.fSubGroup != null) {
286N/A if (fSubGroupCount == fSubGroups.length)
286N/A fSubGroups = resize(fSubGroups, fSubGroupCount+INC_SIZE);
286N/A fSubGroups[fSubGroupCount++] = decl;
286N/A }
286N/A }
286N/A }
286N/A
286N/A public void addGlobalElementDecl(XSElementDecl decl) {
286N/A fGlobalElemDecls.put(decl.fName, decl);
286N/A decl.setNamespaceItem(this);
286N/A }
286N/A
286N/A public void addGlobalElementDecl(XSElementDecl decl, String location) {
286N/A fGlobalElemDeclsExt.put(((location != null) ? location : "") + "," + decl.fName, decl);
286N/A if (decl.getNamespaceItem() == null) {
286N/A decl.setNamespaceItem(this);
286N/A }
286N/A }
286N/A
286N/A /**
286N/A * register one global group
286N/A */
286N/A public void addGlobalGroupDecl(XSGroupDecl decl) {
286N/A fGlobalGroupDecls.put(decl.fName, decl);
286N/A decl.setNamespaceItem(this);
286N/A }
286N/A
286N/A public void addGlobalGroupDecl(XSGroupDecl decl, String location) {
286N/A fGlobalGroupDeclsExt.put(((location!=null) ? location : "") + "," + decl.fName, decl);
286N/A if (decl.getNamespaceItem() == null) {
286N/A decl.setNamespaceItem(this);
286N/A }
286N/A }
286N/A
286N/A /**
286N/A * register one global notation
286N/A */
286N/A public void addGlobalNotationDecl(XSNotationDecl decl) {
286N/A fGlobalNotationDecls.put(decl.fName, decl);
286N/A decl.setNamespaceItem(this);
286N/A }
286N/A
286N/A public void addGlobalNotationDecl(XSNotationDecl decl, String location) {
286N/A fGlobalNotationDeclsExt.put(((location!=null) ? location : "") + "," +decl.fName, decl);
286N/A if (decl.getNamespaceItem() == null) {
286N/A decl.setNamespaceItem(this);
286N/A }
286N/A }
286N/A
286N/A /**
286N/A * register one global type
286N/A */
286N/A public void addGlobalTypeDecl(XSTypeDefinition decl) {
286N/A fGlobalTypeDecls.put(decl.getName(), decl);
286N/A if (decl instanceof XSComplexTypeDecl) {
286N/A ((XSComplexTypeDecl) decl).setNamespaceItem(this);
286N/A }
286N/A else if (decl instanceof XSSimpleTypeDecl) {
286N/A ((XSSimpleTypeDecl) decl).setNamespaceItem(this);
286N/A }
286N/A }
286N/A
286N/A public void addGlobalTypeDecl(XSTypeDefinition decl, String location) {
286N/A fGlobalTypeDeclsExt.put(((location!=null) ? location : "") + "," + decl.getName(), decl);
286N/A if (decl.getNamespaceItem() == null) {
286N/A if (decl instanceof XSComplexTypeDecl) {
286N/A ((XSComplexTypeDecl) decl).setNamespaceItem(this);
286N/A }
286N/A else if (decl instanceof XSSimpleTypeDecl) {
286N/A ((XSSimpleTypeDecl) decl).setNamespaceItem(this);
286N/A }
286N/A }
286N/A }
286N/A
286N/A /**
286N/A * register one global complex type
286N/A */
286N/A public void addGlobalComplexTypeDecl(XSComplexTypeDecl decl) {
286N/A fGlobalTypeDecls.put(decl.getName(), decl);
286N/A decl.setNamespaceItem(this);
286N/A }
286N/A
286N/A public void addGlobalComplexTypeDecl(XSComplexTypeDecl decl, String location) {
286N/A fGlobalTypeDeclsExt.put(((location!=null) ? location : "") + "," + decl.getName(), decl);
286N/A if (decl.getNamespaceItem() == null) {
286N/A decl.setNamespaceItem(this);
286N/A }
286N/A }
286N/A
286N/A /**
286N/A * register one global simple type
286N/A */
286N/A public void addGlobalSimpleTypeDecl(XSSimpleType decl) {
286N/A fGlobalTypeDecls.put(decl.getName(), decl);
286N/A if (decl instanceof XSSimpleTypeDecl) {
286N/A ((XSSimpleTypeDecl) decl).setNamespaceItem(this);
286N/A }
286N/A }
286N/A
286N/A public void addGlobalSimpleTypeDecl(XSSimpleType decl, String location) {
286N/A fGlobalTypeDeclsExt.put(((location != null) ? location : "") + "," + decl.getName(), decl);
286N/A if (decl.getNamespaceItem() == null && decl instanceof XSSimpleTypeDecl) {
286N/A ((XSSimpleTypeDecl) decl).setNamespaceItem(this);
286N/A }
286N/A }
286N/A
286N/A /**
286N/A * register one identity constraint
286N/A */
286N/A public final void addIDConstraintDecl(XSElementDecl elmDecl, IdentityConstraint decl) {
286N/A elmDecl.addIDConstraint(decl);
286N/A fGlobalIDConstraintDecls.put(decl.getIdentityConstraintName(), decl);
286N/A }
286N/A
286N/A public final void addIDConstraintDecl(XSElementDecl elmDecl, IdentityConstraint decl, String location) {
286N/A fGlobalIDConstraintDeclsExt.put(((location != null) ? location : "") + "," + decl.getIdentityConstraintName(), decl);
286N/A }
286N/A
286N/A /**
286N/A * get one global attribute
286N/A */
286N/A public final XSAttributeDecl getGlobalAttributeDecl(String declName) {
286N/A return(XSAttributeDecl)fGlobalAttrDecls.get(declName);
286N/A }
286N/A
286N/A public final XSAttributeDecl getGlobalAttributeDecl(String declName, String location) {
286N/A return(XSAttributeDecl)fGlobalAttrDeclsExt.get(((location != null) ? location : "") + "," + declName);
286N/A }
286N/A
286N/A /**
286N/A * get one global attribute group
286N/A */
286N/A public final XSAttributeGroupDecl getGlobalAttributeGroupDecl(String declName) {
286N/A return(XSAttributeGroupDecl)fGlobalAttrGrpDecls.get(declName);
286N/A }
286N/A
286N/A public final XSAttributeGroupDecl getGlobalAttributeGroupDecl(String declName, String location) {
286N/A return(XSAttributeGroupDecl)fGlobalAttrGrpDeclsExt.get(((location != null) ? location : "") + "," + declName);
286N/A }
286N/A
286N/A /**
286N/A * get one global element
286N/A */
286N/A public final XSElementDecl getGlobalElementDecl(String declName) {
286N/A return(XSElementDecl)fGlobalElemDecls.get(declName);
286N/A }
286N/A
286N/A public final XSElementDecl getGlobalElementDecl(String declName, String location) {
286N/A return(XSElementDecl)fGlobalElemDeclsExt.get(((location != null) ? location : "") + "," + declName);
286N/A }
286N/A
286N/A /**
286N/A * get one global group
286N/A */
286N/A public final XSGroupDecl getGlobalGroupDecl(String declName) {
286N/A return(XSGroupDecl)fGlobalGroupDecls.get(declName);
286N/A }
286N/A
286N/A public final XSGroupDecl getGlobalGroupDecl(String declName, String location) {
286N/A return(XSGroupDecl)fGlobalGroupDeclsExt.get(((location != null) ? location : "") + "," + declName);
286N/A }
286N/A
286N/A /**
286N/A * get one global notation
286N/A */
286N/A public final XSNotationDecl getGlobalNotationDecl(String declName) {
286N/A return(XSNotationDecl)fGlobalNotationDecls.get(declName);
286N/A }
286N/A
286N/A public final XSNotationDecl getGlobalNotationDecl(String declName, String location) {
286N/A return(XSNotationDecl)fGlobalNotationDeclsExt.get(((location != null) ? location : "") + "," + declName);
286N/A }
286N/A
286N/A /**
286N/A * get one global type
286N/A */
286N/A public final XSTypeDefinition getGlobalTypeDecl(String declName) {
286N/A return(XSTypeDefinition)fGlobalTypeDecls.get(declName);
286N/A }
286N/A
286N/A public final XSTypeDefinition getGlobalTypeDecl(String declName, String location) {
286N/A return(XSTypeDefinition)fGlobalTypeDeclsExt.get(((location != null) ? location : "") + "," + declName);
286N/A }
286N/A
286N/A /**
286N/A * get one identity constraint
286N/A */
286N/A public final IdentityConstraint getIDConstraintDecl(String declName) {
286N/A return(IdentityConstraint)fGlobalIDConstraintDecls.get(declName);
286N/A }
286N/A
286N/A public final IdentityConstraint getIDConstraintDecl(String declName, String location) {
286N/A return(IdentityConstraint)fGlobalIDConstraintDeclsExt.get(((location != null) ? location : "") + "," + declName);
286N/A }
286N/A
286N/A /**
286N/A * get one identity constraint
286N/A */
286N/A public final boolean hasIDConstraints() {
286N/A return fGlobalIDConstraintDecls.getLength() > 0;
286N/A }
286N/A
286N/A // array to store complex type decls
286N/A private static final int INITIAL_SIZE = 16;
286N/A private static final int INC_SIZE = 16;
286N/A
286N/A private int fCTCount = 0;
286N/A private XSComplexTypeDecl[] fComplexTypeDecls = new XSComplexTypeDecl[INITIAL_SIZE];
286N/A private SimpleLocator[] fCTLocators = new SimpleLocator[INITIAL_SIZE];
286N/A
286N/A // an array to store groups being redefined by restriction
286N/A // even-numbered elements are the derived groups, odd-numbered ones their bases
286N/A private static final int REDEFINED_GROUP_INIT_SIZE = 2;
286N/A private int fRGCount = 0;
286N/A private XSGroupDecl[] fRedefinedGroupDecls = new XSGroupDecl[REDEFINED_GROUP_INIT_SIZE];
286N/A private SimpleLocator[] fRGLocators = new SimpleLocator[REDEFINED_GROUP_INIT_SIZE/2];
286N/A
286N/A // a flag to indicate whether we have checked the 3 constraints on this
286N/A // grammar.
286N/A boolean fFullChecked = false;
286N/A
286N/A /**
286N/A * add one complex type decl: for later constraint checking
286N/A */
286N/A public void addComplexTypeDecl(XSComplexTypeDecl decl, SimpleLocator locator) {
286N/A if (fCTCount == fComplexTypeDecls.length) {
286N/A fComplexTypeDecls = resize(fComplexTypeDecls, fCTCount+INC_SIZE);
286N/A fCTLocators = resize(fCTLocators, fCTCount+INC_SIZE);
286N/A }
286N/A fCTLocators[fCTCount] = locator;
286N/A fComplexTypeDecls[fCTCount++] = decl;
286N/A }
286N/A
286N/A /**
286N/A * add a group redefined by restriction: for later constraint checking
286N/A */
286N/A public void addRedefinedGroupDecl(XSGroupDecl derived, XSGroupDecl base, SimpleLocator locator) {
286N/A if (fRGCount == fRedefinedGroupDecls.length) {
286N/A // double array size each time.
286N/A fRedefinedGroupDecls = resize(fRedefinedGroupDecls, fRGCount << 1);
286N/A fRGLocators = resize(fRGLocators, fRGCount);
286N/A }
286N/A fRGLocators[fRGCount/2] = locator;
286N/A fRedefinedGroupDecls[fRGCount++] = derived;
286N/A fRedefinedGroupDecls[fRGCount++] = base;
286N/A }
286N/A
286N/A /**
286N/A * get all complex type decls: for later constraint checking
286N/A */
286N/A final XSComplexTypeDecl[] getUncheckedComplexTypeDecls() {
286N/A if (fCTCount < fComplexTypeDecls.length) {
286N/A fComplexTypeDecls = resize(fComplexTypeDecls, fCTCount);
286N/A fCTLocators = resize(fCTLocators, fCTCount);
286N/A }
286N/A return fComplexTypeDecls;
286N/A }
286N/A
286N/A /**
286N/A * get the error locator of all complex type decls
286N/A */
286N/A final SimpleLocator[] getUncheckedCTLocators() {
286N/A if (fCTCount < fCTLocators.length) {
286N/A fComplexTypeDecls = resize(fComplexTypeDecls, fCTCount);
286N/A fCTLocators = resize(fCTLocators, fCTCount);
286N/A }
286N/A return fCTLocators;
286N/A }
286N/A
286N/A /**
286N/A * get all redefined groups: for later constraint checking
286N/A */
286N/A final XSGroupDecl[] getRedefinedGroupDecls() {
286N/A if (fRGCount < fRedefinedGroupDecls.length) {
286N/A fRedefinedGroupDecls = resize(fRedefinedGroupDecls, fRGCount);
286N/A fRGLocators = resize(fRGLocators, fRGCount/2);
286N/A }
286N/A return fRedefinedGroupDecls;
286N/A }
286N/A
286N/A /**
286N/A * get the error locator of all redefined groups
286N/A */
286N/A final SimpleLocator[] getRGLocators() {
286N/A if (fRGCount < fRedefinedGroupDecls.length) {
286N/A fRedefinedGroupDecls = resize(fRedefinedGroupDecls, fRGCount);
286N/A fRGLocators = resize(fRGLocators, fRGCount/2);
286N/A }
286N/A return fRGLocators;
286N/A }
286N/A
286N/A /**
286N/A * after the first-round checking, some types don't need to be checked
286N/A * against UPA again. here we trim the array to the proper size.
286N/A */
286N/A final void setUncheckedTypeNum(int newSize) {
286N/A fCTCount = newSize;
286N/A fComplexTypeDecls = resize(fComplexTypeDecls, fCTCount);
286N/A fCTLocators = resize(fCTLocators, fCTCount);
286N/A }
286N/A
286N/A // used to store all substitution group information declared in
286N/A // this namespace
286N/A private int fSubGroupCount = 0;
286N/A private XSElementDecl[] fSubGroups = new XSElementDecl[INITIAL_SIZE];
286N/A
286N/A /**
286N/A * get all substitution group information: for the 3 constraint checking
286N/A */
286N/A final XSElementDecl[] getSubstitutionGroups() {
286N/A if (fSubGroupCount < fSubGroups.length)
286N/A fSubGroups = resize(fSubGroups, fSubGroupCount);
286N/A return fSubGroups;
286N/A }
286N/A
286N/A // anyType and anySimpleType: because there are so many places where
286N/A // we need direct access to these two types
286N/A public final static XSComplexTypeDecl fAnyType = new XSAnyType();
286N/A private static class XSAnyType extends XSComplexTypeDecl {
286N/A public XSAnyType () {
286N/A fName = SchemaSymbols.ATTVAL_ANYTYPE;
286N/A super.fTargetNamespace = SchemaSymbols.URI_SCHEMAFORSCHEMA;
286N/A fBaseType = this;
286N/A fDerivedBy = XSConstants.DERIVATION_RESTRICTION;
286N/A fContentType = XSComplexTypeDecl.CONTENTTYPE_MIXED;
286N/A
286N/A fParticle = null;
286N/A fAttrGrp = null;
286N/A }
286N/A
286N/A // overridden methods
286N/A public void setValues(String name, String targetNamespace,
286N/A XSTypeDefinition baseType, short derivedBy, short schemaFinal,
286N/A short block, short contentType,
286N/A boolean isAbstract, XSAttributeGroupDecl attrGrp,
286N/A XSSimpleType simpleType, XSParticleDecl particle) {
286N/A // don't allow this.
286N/A }
286N/A
286N/A public void setName(String name){
286N/A // don't allow this.
286N/A }
286N/A
286N/A public void setIsAbstractType() {
286N/A // null implementation
286N/A }
286N/A
286N/A public void setContainsTypeID() {
286N/A // null implementation
286N/A }
286N/A
286N/A public void setIsAnonymous() {
286N/A // null implementation
286N/A }
286N/A
286N/A public void reset() {
286N/A // null implementation
286N/A }
286N/A
286N/A public XSObjectList getAttributeUses() {
286N/A return XSObjectListImpl.EMPTY_LIST;
286N/A }
286N/A
286N/A public XSAttributeGroupDecl getAttrGrp() {
286N/A XSWildcardDecl wildcard = new XSWildcardDecl();
286N/A wildcard.fProcessContents = XSWildcardDecl.PC_LAX;
286N/A XSAttributeGroupDecl attrGrp = new XSAttributeGroupDecl();
286N/A attrGrp.fAttributeWC = wildcard;
286N/A return attrGrp;
286N/A }
286N/A
286N/A public XSWildcard getAttributeWildcard() {
286N/A XSWildcardDecl wildcard = new XSWildcardDecl();
286N/A wildcard.fProcessContents = XSWildcardDecl.PC_LAX;
286N/A return wildcard;
286N/A }
286N/A
286N/A public XSParticle getParticle() {
286N/A // the wildcard used in anyType (content and attribute)
286N/A // the spec will change strict to skip for anyType
286N/A XSWildcardDecl wildcard = new XSWildcardDecl();
286N/A wildcard.fProcessContents = XSWildcardDecl.PC_LAX;
286N/A // the particle for the content wildcard
286N/A XSParticleDecl particleW = new XSParticleDecl();
286N/A particleW.fMinOccurs = 0;
286N/A particleW.fMaxOccurs = SchemaSymbols.OCCURRENCE_UNBOUNDED;
286N/A particleW.fType = XSParticleDecl.PARTICLE_WILDCARD;
286N/A particleW.fValue = wildcard;
286N/A // the model group of a sequence of the above particle
286N/A XSModelGroupImpl group = new XSModelGroupImpl();
286N/A group.fCompositor = XSModelGroupImpl.MODELGROUP_SEQUENCE;
286N/A group.fParticleCount = 1;
286N/A group.fParticles = new XSParticleDecl[1];
286N/A group.fParticles[0] = particleW;
286N/A // the content of anyType: particle of the above model group
286N/A XSParticleDecl particleG = new XSParticleDecl();
286N/A particleG.fType = XSParticleDecl.PARTICLE_MODELGROUP;
286N/A particleG.fValue = group;
286N/A
286N/A return particleG;
286N/A }
286N/A
286N/A public XSObjectList getAnnotations() {
286N/A return XSObjectListImpl.EMPTY_LIST;
286N/A }
286N/A
286N/A public XSNamespaceItem getNamespaceItem() {
286N/A return SG_SchemaNS;
286N/A }
286N/A }
286N/A private static class BuiltinAttrDecl extends XSAttributeDecl {
286N/A public BuiltinAttrDecl(String name, String tns,
286N/A XSSimpleType type, short scope) {
286N/A fName = name;
286N/A super.fTargetNamespace = tns;
286N/A fType = type;
286N/A fScope = scope;
286N/A }
286N/A
286N/A public void setValues(String name, String targetNamespace,
286N/A XSSimpleType simpleType, short constraintType, short scope,
286N/A ValidatedInfo valInfo, XSComplexTypeDecl enclosingCT) {
286N/A // ignore this call.
286N/A }
286N/A
286N/A public void reset () {
286N/A // also ignore this call.
286N/A }
286N/A
286N/A public XSAnnotation getAnnotation() {
286N/A return null;
286N/A }
286N/A
286N/A public XSNamespaceItem getNamespaceItem() {
286N/A return SG_XSI;
286N/A }
286N/A
286N/A } // class BuiltinAttrDecl
286N/A
286N/A // the grammars to hold components of the schema namespace
286N/A public final static BuiltinSchemaGrammar SG_SchemaNS = new BuiltinSchemaGrammar(GRAMMAR_XS, Constants.SCHEMA_VERSION_1_0);
286N/A private final static BuiltinSchemaGrammar SG_SchemaNSExtended = new BuiltinSchemaGrammar(GRAMMAR_XS, Constants.SCHEMA_VERSION_1_0_EXTENDED);
286N/A
286N/A public final static XSSimpleType fAnySimpleType = (XSSimpleType)SG_SchemaNS.getGlobalTypeDecl(SchemaSymbols.ATTVAL_ANYSIMPLETYPE);
286N/A
286N/A // the grammars to hold components of the schema-instance namespace
286N/A public final static BuiltinSchemaGrammar SG_XSI = new BuiltinSchemaGrammar(GRAMMAR_XSI, Constants.SCHEMA_VERSION_1_0);
286N/A
286N/A public static SchemaGrammar getS4SGrammar(short schemaVersion) {
286N/A if (schemaVersion == Constants.SCHEMA_VERSION_1_0) {
286N/A return SG_SchemaNS;
286N/A }
286N/A else {
286N/A return SG_SchemaNSExtended;
286N/A }
286N/A }
286N/A
286N/A static final XSComplexTypeDecl[] resize(XSComplexTypeDecl[] oldArray, int newSize) {
286N/A XSComplexTypeDecl[] newArray = new XSComplexTypeDecl[newSize];
286N/A System.arraycopy(oldArray, 0, newArray, 0, Math.min(oldArray.length, newSize));
286N/A return newArray;
286N/A }
286N/A
286N/A static final XSGroupDecl[] resize(XSGroupDecl[] oldArray, int newSize) {
286N/A XSGroupDecl[] newArray = new XSGroupDecl[newSize];
286N/A System.arraycopy(oldArray, 0, newArray, 0, Math.min(oldArray.length, newSize));
286N/A return newArray;
286N/A }
286N/A
286N/A static final XSElementDecl[] resize(XSElementDecl[] oldArray, int newSize) {
286N/A XSElementDecl[] newArray = new XSElementDecl[newSize];
286N/A System.arraycopy(oldArray, 0, newArray, 0, Math.min(oldArray.length, newSize));
286N/A return newArray;
286N/A }
286N/A
286N/A static final SimpleLocator[] resize(SimpleLocator[] oldArray, int newSize) {
286N/A SimpleLocator[] newArray = new SimpleLocator[newSize];
286N/A System.arraycopy(oldArray, 0, newArray, 0, Math.min(oldArray.length, newSize));
286N/A return newArray;
286N/A }
286N/A
286N/A // XSNamespaceItem methods
286N/A
286N/A // the max index / the max value of XSObject type
286N/A private static final short MAX_COMP_IDX = XSTypeDefinition.SIMPLE_TYPE;
286N/A private static final boolean[] GLOBAL_COMP = {false, // null
286N/A true, // attribute
286N/A true, // element
286N/A true, // type
286N/A false, // attribute use
286N/A true, // attribute group
286N/A true, // group
286N/A false, // model group
286N/A false, // particle
286N/A false, // wildcard
286N/A false, // idc
286N/A true, // notation
286N/A false, // annotation
286N/A false, // facet
286N/A false, // multi value facet
286N/A true, // complex type
286N/A true // simple type
286N/A };
286N/A
286N/A // store a certain kind of components from all namespaces
286N/A private XSNamedMap[] fComponents = null;
286N/A private ObjectList[] fComponentsExt = null;
286N/A
286N/A // store the documents and their locations contributing to this namespace
286N/A // REVISIT: use StringList and XSObjectList for there fields.
286N/A private Vector fDocuments = null;
286N/A private Vector fLocations = null;
286N/A
286N/A public synchronized void addDocument(Object document, String location) {
286N/A if (fDocuments == null) {
286N/A fDocuments = new Vector();
286N/A fLocations = new Vector();
286N/A }
286N/A fDocuments.addElement(document);
286N/A fLocations.addElement(location);
286N/A }
286N/A
286N/A public synchronized void removeDocument(int index) {
286N/A if (fDocuments != null &&
286N/A index >= 0 &&
286N/A index < fDocuments.size()) {
286N/A fDocuments.removeElementAt(index);
286N/A fLocations.removeElementAt(index);
286N/A }
286N/A }
286N/A
286N/A /**
286N/A * [schema namespace]
286N/A * @see <a href="http://www.w3.org/TR/xmlschema-1/#nsi-schema_namespace">[schema namespace]</a>
286N/A * @return The target namespace of this item.
286N/A */
286N/A public String getSchemaNamespace() {
286N/A return fTargetNamespace;
286N/A }
286N/A
286N/A // annotation support
286N/A synchronized DOMParser getDOMParser() {
286N/A if (fDOMParser != null) {
286N/A DOMParser parser = (DOMParser) fDOMParser.get();
286N/A if (parser != null) {
286N/A return parser;
286N/A }
286N/A }
286N/A // REVISIT: when schema handles XML 1.1, will need to
286N/A // revisit this (and the practice of not prepending an XML decl to the annotation string
286N/A XML11Configuration config = new XML11Configuration(fSymbolTable);
286N/A // note that this should never produce errors or require
286N/A // entity resolution, so just a barebones configuration with
286N/A // a couple of feature set will do fine
286N/A config.setFeature(Constants.SAX_FEATURE_PREFIX + Constants.NAMESPACES_FEATURE, true);
286N/A config.setFeature(Constants.SAX_FEATURE_PREFIX + Constants.VALIDATION_FEATURE, false);
286N/A
286N/A DOMParser parser = new DOMParser(config);
286N/A try {
286N/A parser.setFeature(Constants.XERCES_FEATURE_PREFIX + Constants.DEFER_NODE_EXPANSION_FEATURE, false);
286N/A }
286N/A catch (SAXException exc) {}
286N/A fDOMParser = new SoftReference(parser);
286N/A return parser;
286N/A }
286N/A
286N/A synchronized SAXParser getSAXParser() {
286N/A if (fSAXParser != null) {
286N/A SAXParser parser = (SAXParser) fSAXParser.get();
286N/A if (parser != null) {
286N/A return parser;
286N/A }
286N/A }
286N/A // REVISIT: when schema handles XML 1.1, will need to
286N/A // revisit this (and the practice of not prepending an XML decl to the annotation string
286N/A XML11Configuration config = new XML11Configuration(fSymbolTable);
286N/A // note that this should never produce errors or require
286N/A // entity resolution, so just a barebones configuration with
286N/A // a couple of feature set will do fine
286N/A config.setFeature(Constants.SAX_FEATURE_PREFIX + Constants.NAMESPACES_FEATURE, true);
286N/A config.setFeature(Constants.SAX_FEATURE_PREFIX + Constants.VALIDATION_FEATURE, false);
286N/A SAXParser parser = new SAXParser(config);
286N/A fSAXParser = new SoftReference(parser);
286N/A return parser;
286N/A }
286N/A
286N/A /**
286N/A * [schema components]: a list of top-level components, i.e. element
286N/A * declarations, attribute declarations, etc.
286N/A * @param objectType The type of the declaration, i.e.
286N/A * <code>ELEMENT_DECLARATION</code>. Note that
286N/A * <code>XSTypeDefinition.SIMPLE_TYPE</code> and
286N/A * <code>XSTypeDefinition.COMPLEX_TYPE</code> can also be used as the
286N/A * <code>objectType</code> to retrieve only complex types or simple
286N/A * types, instead of all types.
286N/A * @return A list of top-level definition of the specified type in
286N/A * <code>objectType</code> or an empty <code>XSNamedMap</code> if no
286N/A * such definitions exist.
286N/A */
286N/A public synchronized XSNamedMap getComponents(short objectType) {
286N/A if (objectType <= 0 || objectType > MAX_COMP_IDX ||
286N/A !GLOBAL_COMP[objectType]) {
286N/A return XSNamedMapImpl.EMPTY_MAP;
286N/A }
286N/A
286N/A if (fComponents == null)
286N/A fComponents = new XSNamedMap[MAX_COMP_IDX+1];
286N/A
286N/A // get the hashtable for this type of components
286N/A if (fComponents[objectType] == null) {
286N/A SymbolHash table = null;
286N/A switch (objectType) {
286N/A case XSConstants.TYPE_DEFINITION:
286N/A case XSTypeDefinition.COMPLEX_TYPE:
286N/A case XSTypeDefinition.SIMPLE_TYPE:
286N/A table = fGlobalTypeDecls;
286N/A break;
286N/A case XSConstants.ATTRIBUTE_DECLARATION:
286N/A table = fGlobalAttrDecls;
286N/A break;
286N/A case XSConstants.ELEMENT_DECLARATION:
286N/A table = fGlobalElemDecls;
286N/A break;
286N/A case XSConstants.ATTRIBUTE_GROUP:
286N/A table = fGlobalAttrGrpDecls;
286N/A break;
286N/A case XSConstants.MODEL_GROUP_DEFINITION:
286N/A table = fGlobalGroupDecls;
286N/A break;
286N/A case XSConstants.NOTATION_DECLARATION:
286N/A table = fGlobalNotationDecls;
286N/A break;
286N/A }
286N/A
286N/A // for complex/simple types, create a special implementation,
286N/A // which take specific types out of the hash table
286N/A if (objectType == XSTypeDefinition.COMPLEX_TYPE ||
286N/A objectType == XSTypeDefinition.SIMPLE_TYPE) {
286N/A fComponents[objectType] = new XSNamedMap4Types(fTargetNamespace, table, objectType);
286N/A }
286N/A else {
286N/A fComponents[objectType] = new XSNamedMapImpl(fTargetNamespace, table);
286N/A }
286N/A }
286N/A
286N/A return fComponents[objectType];
286N/A }
286N/A
286N/A public synchronized ObjectList getComponentsExt(short objectType) {
286N/A if (objectType <= 0 || objectType > MAX_COMP_IDX ||
286N/A !GLOBAL_COMP[objectType]) {
286N/A return ObjectListImpl.EMPTY_LIST;
286N/A }
286N/A
286N/A if (fComponentsExt == null)
286N/A fComponentsExt = new ObjectList[MAX_COMP_IDX+1];
286N/A
286N/A // get the hashtable for this type of components
286N/A if (fComponentsExt[objectType] == null) {
286N/A SymbolHash table = null;
286N/A switch (objectType) {
286N/A case XSConstants.TYPE_DEFINITION:
286N/A case XSTypeDefinition.COMPLEX_TYPE:
286N/A case XSTypeDefinition.SIMPLE_TYPE:
286N/A table = fGlobalTypeDeclsExt;
286N/A break;
286N/A case XSConstants.ATTRIBUTE_DECLARATION:
286N/A table = fGlobalAttrDeclsExt;
286N/A break;
286N/A case XSConstants.ELEMENT_DECLARATION:
286N/A table = fGlobalElemDeclsExt;
286N/A break;
286N/A case XSConstants.ATTRIBUTE_GROUP:
286N/A table = fGlobalAttrGrpDeclsExt;
286N/A break;
286N/A case XSConstants.MODEL_GROUP_DEFINITION:
286N/A table = fGlobalGroupDeclsExt;
286N/A break;
286N/A case XSConstants.NOTATION_DECLARATION:
286N/A table = fGlobalNotationDeclsExt;
286N/A break;
286N/A }
286N/A
286N/A Object[] entries = table.getEntries();
286N/A fComponentsExt[objectType] = new ObjectListImpl(entries, entries.length);
286N/A }
286N/A
286N/A return fComponentsExt[objectType];
286N/A }
286N/A
286N/A public synchronized void resetComponents() {
286N/A fComponents = null;
286N/A fComponentsExt = null;
286N/A }
286N/A
286N/A /**
286N/A * Convenience method. Returns a top-level simple or complex type
286N/A * definition.
286N/A * @param name The name of the definition.
286N/A * @return An <code>XSTypeDefinition</code> or null if such definition
286N/A * does not exist.
286N/A */
286N/A public XSTypeDefinition getTypeDefinition(String name) {
286N/A return getGlobalTypeDecl(name);
286N/A }
286N/A
286N/A /**
286N/A * Convenience method. Returns a top-level attribute declaration.
286N/A * @param name The name of the declaration.
286N/A * @return A top-level attribute declaration or null if such declaration
286N/A * does not exist.
286N/A */
286N/A public XSAttributeDeclaration getAttributeDeclaration(String name) {
286N/A return getGlobalAttributeDecl(name);
286N/A }
286N/A
286N/A /**
286N/A * Convenience method. Returns a top-level element declaration.
286N/A * @param name The name of the declaration.
286N/A * @return A top-level element declaration or null if such declaration
286N/A * does not exist.
286N/A */
286N/A public XSElementDeclaration getElementDeclaration(String name) {
286N/A return getGlobalElementDecl(name);
286N/A }
286N/A
286N/A /**
286N/A * Convenience method. Returns a top-level attribute group definition.
286N/A * @param name The name of the definition.
286N/A * @return A top-level attribute group definition or null if such
286N/A * definition does not exist.
286N/A */
286N/A public XSAttributeGroupDefinition getAttributeGroup(String name) {
286N/A return getGlobalAttributeGroupDecl(name);
286N/A }
286N/A
286N/A /**
286N/A * Convenience method. Returns a top-level model group definition.
286N/A *
286N/A * @param name The name of the definition.
286N/A * @return A top-level model group definition definition or null if such
286N/A * definition does not exist.
286N/A */
286N/A public XSModelGroupDefinition getModelGroupDefinition(String name) {
286N/A return getGlobalGroupDecl(name);
286N/A }
286N/A
286N/A /**
286N/A * Convenience method. Returns a top-level notation declaration.
286N/A *
286N/A * @param name The name of the declaration.
286N/A * @return A top-level notation declaration or null if such declaration
286N/A * does not exist.
286N/A */
286N/A public XSNotationDeclaration getNotationDeclaration(String name) {
286N/A return getGlobalNotationDecl(name);
286N/A }
286N/A
286N/A
286N/A /**
286N/A * [document location]
286N/A * @see <a href="http://www.w3.org/TR/xmlschema-1/#sd-document_location">[document location]</a>
286N/A * @return a list of document information item
286N/A */
286N/A public StringList getDocumentLocations() {
286N/A return new StringListImpl(fLocations);
286N/A }
286N/A
286N/A /**
286N/A * Return an <code>XSModel</code> that represents components in this schema
286N/A * grammar.
286N/A *
286N/A * @return an <code>XSModel</code> representing this schema grammar
286N/A */
286N/A public XSModel toXSModel() {
286N/A return new XSModelImpl(new SchemaGrammar[]{this});
286N/A }
286N/A
286N/A public XSModel toXSModel(XSGrammar[] grammars) {
286N/A if (grammars == null || grammars.length == 0)
286N/A return toXSModel();
286N/A
286N/A int len = grammars.length;
286N/A boolean hasSelf = false;
286N/A for (int i = 0; i < len; i++) {
286N/A if (grammars[i] == this) {
286N/A hasSelf = true;
286N/A break;
286N/A }
286N/A }
286N/A
286N/A SchemaGrammar[] gs = new SchemaGrammar[hasSelf ? len : len+1];
286N/A for (int i = 0; i < len; i++)
286N/A gs[i] = (SchemaGrammar)grammars[i];
286N/A if (!hasSelf)
286N/A gs[len] = this;
286N/A return new XSModelImpl(gs);
286N/A }
286N/A
286N/A /**
286N/A * @see org.apache.xerces.xs.XSNamespaceItem#getAnnotations()
286N/A */
286N/A public XSObjectList getAnnotations() {
286N/A if (fNumAnnotations == 0) {
286N/A return XSObjectListImpl.EMPTY_LIST;
286N/A }
286N/A return new XSObjectListImpl(fAnnotations, fNumAnnotations);
286N/A }
286N/A
286N/A public void addAnnotation(XSAnnotationImpl annotation) {
286N/A if (annotation == null) {
286N/A return;
286N/A }
286N/A if (fAnnotations == null) {
286N/A fAnnotations = new XSAnnotationImpl[2];
286N/A }
286N/A else if (fNumAnnotations == fAnnotations.length) {
286N/A XSAnnotationImpl[] newArray = new XSAnnotationImpl[fNumAnnotations << 1];
286N/A System.arraycopy(fAnnotations, 0, newArray, 0, fNumAnnotations);
286N/A fAnnotations = newArray;
286N/A }
286N/A fAnnotations[fNumAnnotations++] = annotation;
286N/A }
286N/A
286N/A public void setImmutable(boolean isImmutable) {
286N/A fIsImmutable = isImmutable;
286N/A }
286N/A
286N/A public boolean isImmutable() {
286N/A return fIsImmutable;
286N/A }
286N/A
286N/A} // class SchemaGrammar