FileDocCategorySizeDatePackage
XMLSchemaLoader.javaAPI DocApache Xerces 3.0.155790Fri Sep 14 20:33:52 BST 2007org.apache.xerces.impl.xs

XMLSchemaLoader

public class XMLSchemaLoader extends Object implements org.apache.xerces.xni.grammars.XMLGrammarLoader, org.apache.xerces.xs.XSLoader, DOMConfiguration, org.apache.xerces.xni.parser.XMLComponent
This class implements xni.grammars.XMLGrammarLoader. It also serves as implementation of xs.XSLoader interface and DOMConfiguration interface. This class is designed to interact either with a proxy for a user application which wants to preparse schemas, or with our own Schema validator. It is hoped that none of these "external" classes will therefore need to communicate directly with XSDHandler in future.

This class only knows how to make XSDHandler do its thing. The caller must ensure that all its properties (schemaLocation, JAXPSchemaSource etc.) have been properly set.

xerces.internal
author
Neil Graham, IBM
version
$Id: XMLSchemaLoader.java 521495 2007-03-22 22:12:05Z mrglavas $

Fields Summary
protected static final String
SCHEMA_FULL_CHECKING
Feature identifier: schema full checking
protected static final String
CONTINUE_AFTER_FATAL_ERROR
Feature identifier: continue after fatal error.
protected static final String
ALLOW_JAVA_ENCODINGS
Feature identifier: allow java encodings to be recognized when parsing schema docs.
protected static final String
STANDARD_URI_CONFORMANT_FEATURE
Feature identifier: standard uri conformant feature.
protected static final String
VALIDATE_ANNOTATIONS
Feature identifier: validate annotations.
protected static final String
DISALLOW_DOCTYPE
Feature: disallow doctype
protected static final String
GENERATE_SYNTHETIC_ANNOTATIONS
Feature: generate synthetic annotations
protected static final String
HONOUR_ALL_SCHEMALOCATIONS
Feature identifier: honour all schemaLocations
protected static final String
AUGMENT_PSVI
protected static final String
PARSER_SETTINGS
private static final String[]
RECOGNIZED_FEATURES
public static final String
SYMBOL_TABLE
Property identifier: symbol table.
public static final String
ERROR_REPORTER
Property identifier: error reporter.
protected static final String
ERROR_HANDLER
Property identifier: error handler.
public static final String
ENTITY_RESOLVER
Property identifier: entity resolver.
public static final String
XMLGRAMMAR_POOL
Property identifier: grammar pool.
protected static final String
SCHEMA_LOCATION
Property identifier: schema location.
protected static final String
SCHEMA_NONS_LOCATION
Property identifier: no namespace schema location.
protected static final String
JAXP_SCHEMA_SOURCE
Property identifier: JAXP schema source.
protected static final String
SECURITY_MANAGER
protected static final String
ENTITY_MANAGER
private static final String[]
RECOGNIZED_PROPERTIES
private org.apache.xerces.util.ParserConfigurationSettings
fLoaderConfig
private org.apache.xerces.impl.XMLErrorReporter
fErrorReporter
private org.apache.xerces.impl.XMLEntityManager
fEntityManager
private org.apache.xerces.xni.parser.XMLEntityResolver
fUserEntityResolver
private org.apache.xerces.xni.grammars.XMLGrammarPool
fGrammarPool
private String
fExternalSchemas
private String
fExternalNoNSSchema
private Object
fJAXPSource
private boolean
fIsCheckedFully
private boolean
fJAXPProcessed
private boolean
fSettingsChanged
private org.apache.xerces.impl.xs.traversers.XSDHandler
fSchemaHandler
private XSGrammarBucket
fGrammarBucket
private XSDeclarationPool
fDeclPool
private SubstitutionGroupHandler
fSubGroupHandler
private org.apache.xerces.impl.xs.models.CMBuilder
fCMBuilder
private XSDDescription
fXSDDescription
private WeakHashMap
fJAXPCache
private Locale
fLocale
private DOMStringList
fRecognizedParameters
private org.apache.xerces.util.DOMErrorHandlerWrapper
fErrorHandler
DOM L3 error handler
private org.apache.xerces.util.DOMEntityResolverWrapper
fResourceResolver
DOM L3 resource resolver
Constructors Summary
public XMLSchemaLoader()

    
    // default constructor.  Create objects we absolutely need:
      
        this( new SymbolTable(), null, new XMLEntityManager(), null, null, null);
    
public XMLSchemaLoader(org.apache.xerces.util.SymbolTable symbolTable)

        this( symbolTable, null, new XMLEntityManager(), null, null, null);
    
XMLSchemaLoader(org.apache.xerces.impl.XMLErrorReporter errorReporter, XSGrammarBucket grammarBucket, SubstitutionGroupHandler sHandler, org.apache.xerces.impl.xs.models.CMBuilder builder)
This constractor is used by the XMLSchemaValidator. Additional properties, i.e. XMLEntityManager, will be passed during reset(XMLComponentManager).

param
errorReporter
param
grammarBucket
param
sHandler
param
builder

        this(null, errorReporter, null, grammarBucket, sHandler, builder);
    
XMLSchemaLoader(org.apache.xerces.util.SymbolTable symbolTable, org.apache.xerces.impl.XMLErrorReporter errorReporter, org.apache.xerces.impl.XMLEntityManager entityResolver, XSGrammarBucket grammarBucket, SubstitutionGroupHandler sHandler, org.apache.xerces.impl.xs.models.CMBuilder builder)

        
        // store properties and features in configuration
        fLoaderConfig.addRecognizedFeatures(RECOGNIZED_FEATURES);
        fLoaderConfig.addRecognizedProperties(RECOGNIZED_PROPERTIES); 
        if (symbolTable != null){ 
            fLoaderConfig.setProperty(SYMBOL_TABLE, symbolTable);       
        }
        
        if(errorReporter == null) {
            errorReporter = new XMLErrorReporter ();
            errorReporter.setLocale(fLocale);
            errorReporter.setProperty(ERROR_HANDLER, new DefaultErrorHandler());
            
        }
        fErrorReporter = errorReporter;
        // make sure error reporter knows about schemas...
        if(fErrorReporter.getMessageFormatter(XSMessageFormatter.SCHEMA_DOMAIN) == null) {
            fErrorReporter.putMessageFormatter(XSMessageFormatter.SCHEMA_DOMAIN, new XSMessageFormatter());
        }
        fLoaderConfig.setProperty(ERROR_REPORTER, fErrorReporter);
        fEntityManager = entityResolver;   
        // entity manager is null if XMLSchemaValidator creates the loader  
        if (fEntityManager != null){   
            fLoaderConfig.setProperty(ENTITY_MANAGER, fEntityManager);
        }
        
        // by default augment PSVI (i.e. don't use declaration pool)
        fLoaderConfig.setFeature(AUGMENT_PSVI, true);
        
        if(grammarBucket == null ) {
            grammarBucket = new XSGrammarBucket();
        }
        fGrammarBucket = grammarBucket;
        if(sHandler == null) {
            sHandler = new SubstitutionGroupHandler(fGrammarBucket);
        }
        fSubGroupHandler = sHandler;
        
        //get an instance of the CMNodeFactory */
        CMNodeFactory nodeFactory = new CMNodeFactory() ;
        
        if(builder == null) {
            builder = new CMBuilder(nodeFactory);
        }
        fCMBuilder = builder;
        fSchemaHandler = new XSDHandler(fGrammarBucket);
        fDeclPool = new XSDeclarationPool();
        fJAXPCache = new WeakHashMap();
        
        fSettingsChanged = true;
    
Methods Summary
public booleancanSetParameter(java.lang.String name, java.lang.Object value)

        if(value instanceof Boolean){
            if (name.equals(Constants.DOM_VALIDATE) ||
                name.equals(SCHEMA_FULL_CHECKING) ||
                name.equals(VALIDATE_ANNOTATIONS) ||
                name.equals(CONTINUE_AFTER_FATAL_ERROR) ||
                name.equals(ALLOW_JAVA_ENCODINGS) ||
                name.equals(STANDARD_URI_CONFORMANT_FEATURE) ||
                name.equals(GENERATE_SYNTHETIC_ANNOTATIONS) ||
                name.equals(HONOUR_ALL_SCHEMALOCATIONS)) {
                return true;
                
            }
            return false;			
        }
        if (name.equals(Constants.DOM_ERROR_HANDLER) ||
            name.equals(Constants.DOM_RESOURCE_RESOLVER) ||
            name.equals(SYMBOL_TABLE) ||
            name.equals(ERROR_REPORTER) ||
            name.equals(ERROR_HANDLER) ||
            name.equals(ENTITY_RESOLVER) ||
            name.equals(XMLGRAMMAR_POOL) ||
            name.equals(SCHEMA_LOCATION) ||
            name.equals(SCHEMA_NONS_LOCATION) ||
            name.equals(JAXP_SCHEMA_SOURCE)) {
            return true;
        }
        return false;
    
org.apache.xerces.xni.parser.XMLInputSourcedom2xmlInputSource(org.w3c.dom.ls.LSInput is)

        // need to wrap the LSInput with an XMLInputSource
        XMLInputSource xis = null;
        
        /**
         * An LSParser looks at inputs specified in LSInput in
         * the following order: characterStream, byteStream,
         * stringData, systemId, publicId. For consistency
         * have the same behaviour for XSLoader.
         */
        
        // check whether there is a Reader
        // according to DOM, we need to treat such reader as "UTF-16".
        if (is.getCharacterStream() != null) {
            xis = new XMLInputSource(is.getPublicId(), is.getSystemId(),
                    is.getBaseURI(), is.getCharacterStream(),
            "UTF-16");
        }
        // check whether there is an InputStream
        else if (is.getByteStream() != null) {
            xis = new XMLInputSource(is.getPublicId(), is.getSystemId(),
                    is.getBaseURI(), is.getByteStream(),
                    is.getEncoding());
        }
        // if there is a string data, use a StringReader
        // according to DOM, we need to treat such data as "UTF-16".
        else if (is.getStringData() != null && is.getStringData().length() != 0) {
            xis = new XMLInputSource(is.getPublicId(), is.getSystemId(),
                    is.getBaseURI(), new StringReader(is.getStringData()),
            "UTF-16");
        }
        // otherwise, just use the public/system/base Ids
        else {
            xis = new XMLInputSource(is.getPublicId(), is.getSystemId(),
                    is.getBaseURI());
        }
        
        return xis;
    
public org.w3c.dom.DOMConfigurationgetConfig()

        return this;
    
public org.apache.xerces.xni.parser.XMLEntityResolvergetEntityResolver()
Returns the registered entity resolver.

        return fUserEntityResolver;
    
public org.apache.xerces.xni.parser.XMLErrorHandlergetErrorHandler()
Returns the registered error handler.

        return fErrorReporter.getErrorHandler();
    
public booleangetFeature(java.lang.String featureId)
Returns the state of a feature.

param
featureId The feature identifier.
throws
XMLConfigurationException Thrown on configuration error.

                
        return fLoaderConfig.getFeature(featureId);        
    
public java.lang.BooleangetFeatureDefault(java.lang.String featureId)

        if (featureId.equals(AUGMENT_PSVI)){
            return Boolean.TRUE;
        }
        return null;
    
public java.util.LocalegetLocale()
Return the Locale the XMLGrammarLoader is using.

        return fLocale;
    
public java.lang.ObjectgetParameter(java.lang.String name)

        
        if (name.equals(Constants.DOM_ERROR_HANDLER)){
            return (fErrorHandler != null) ? fErrorHandler.getErrorHandler() : null;
        }
        else if (name.equals(Constants.DOM_RESOURCE_RESOLVER)) {
            return (fResourceResolver != null) ? fResourceResolver.getEntityResolver() : null;
        }
        
        try {
            boolean feature = getFeature(name);
            return (feature) ? Boolean.TRUE : Boolean.FALSE;
        } catch (Exception e) {
            Object property;
            try {
                property = getProperty(name);
                return property;
            } catch (Exception ex) {
                String msg =
                    DOMMessageFormatter.formatMessage(
                            DOMMessageFormatter.DOM_DOMAIN,
                            "FEATURE_NOT_SUPPORTED",
                            new Object[] { name });
                throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
            }
        }
    
public org.w3c.dom.DOMStringListgetParameterNames()

        if (fRecognizedParameters == null){
            Vector v = new Vector();
            v.add(Constants.DOM_VALIDATE);
            v.add(Constants.DOM_ERROR_HANDLER);
            v.add(Constants.DOM_RESOURCE_RESOLVER);
            v.add(SYMBOL_TABLE);
            v.add(ERROR_REPORTER);
            v.add(ERROR_HANDLER);
            v.add(ENTITY_RESOLVER);
            v.add(XMLGRAMMAR_POOL);
            v.add(SCHEMA_LOCATION);
            v.add(SCHEMA_NONS_LOCATION);
            v.add(JAXP_SCHEMA_SOURCE);
            v.add(SCHEMA_FULL_CHECKING);
            v.add(CONTINUE_AFTER_FATAL_ERROR);
            v.add(ALLOW_JAVA_ENCODINGS);
            v.add(STANDARD_URI_CONFORMANT_FEATURE);
            v.add(VALIDATE_ANNOTATIONS);
            v.add(GENERATE_SYNTHETIC_ANNOTATIONS);
            v.add(HONOUR_ALL_SCHEMALOCATIONS);
            fRecognizedParameters = new DOMStringListImpl(v);      	
        }
        return fRecognizedParameters;
    
public java.lang.ObjectgetProperty(java.lang.String propertyId)
Returns the state of a property.

param
propertyId The property identifier.
throws
XMLConfigurationException Thrown on configuration error.

        return fLoaderConfig.getProperty(propertyId);
    
public java.lang.ObjectgetPropertyDefault(java.lang.String propertyId)

        // TODO Auto-generated method stub
        return null;
    
public java.lang.String[]getRecognizedFeatures()
Returns a list of feature identifiers that are recognized by this XMLGrammarLoader. This method may return null if no features are recognized.

        return (String[])(RECOGNIZED_FEATURES.clone());
    
public java.lang.String[]getRecognizedProperties()
Returns a list of property identifiers that are recognized by this XMLGrammarLoader. This method may return null if no properties are recognized.

        return (String[])(RECOGNIZED_PROPERTIES.clone());
    
private voidinitGrammarBucket()

        if(fGrammarPool != null) {
            Grammar [] initialGrammars = fGrammarPool.retrieveInitialGrammarSet(XMLGrammarDescription.XML_SCHEMA);
            for (int i = 0; i < initialGrammars.length; i++) {
                // put this grammar into the bucket, along with grammars
                // imported by it (directly or indirectly)
                if (!fGrammarBucket.putGrammar((SchemaGrammar)(initialGrammars[i]), true)) {
                    // REVISIT: a conflict between new grammar(s) and grammars
                    // in the bucket. What to do? A warning? An exception?
                    fErrorReporter.reportError(XSMessageFormatter.SCHEMA_DOMAIN,
                            "GrammarConflict", null,
                            XMLErrorReporter.SEVERITY_WARNING);
                }
            }
        }
    
public org.apache.xerces.xs.XSModelload(org.w3c.dom.ls.LSInput is)

        try {
            Grammar g = loadGrammar(dom2xmlInputSource(is));
            return ((XSGrammar) g).toXSModel();
        } catch (Exception e) {
            reportDOMFatalError(e);
            return null;
        }
    
public voidloadGrammar(org.apache.xerces.xni.parser.XMLInputSource[] source)
Returns a Grammar object by parsing the contents of the entities pointed to by sources.

param
source the locations of the entity which forms the staring point of the grammars to be constructed
throws
IOException when a problem is encounted reading the entity
throws
XNIException when a condition arises (such as a FatalError) that requires parsing of the entity be terminated

        int numSource = source.length;
        for (int i = 0; i < numSource; ++i) {
            loadGrammar(source[i]);
        }   
    
public org.apache.xerces.xni.grammars.GrammarloadGrammar(org.apache.xerces.xni.parser.XMLInputSource source)
Returns a Grammar object by parsing the contents of the entity pointed to by source.

param
source the location of the entity which forms the starting point of the grammar to be constructed.
throws
IOException When a problem is encountered reading the entity XNIException When a condition arises (such as a FatalError) that requires parsing of the entity be terminated.

        
        // REVISIT: this method should have a namespace parameter specified by 
        // user. In this case we can easily detect if a schema asked to be loaded
        // is already in the local cache.
        
        reset(fLoaderConfig);
        fSettingsChanged = false;
        XSDDescription desc = new XSDDescription();
        desc.fContextType = XSDDescription.CONTEXT_PREPARSE;
        desc.setBaseSystemId(source.getBaseSystemId());
        desc.setLiteralSystemId( source.getSystemId());
        // none of the other fields make sense for preparsing
        Hashtable locationPairs = new Hashtable();
        // Process external schema location properties.
        // We don't call tokenizeSchemaLocationStr here, because we also want
        // to check whether the values are valid URI.
        processExternalHints(fExternalSchemas, fExternalNoNSSchema,
                locationPairs, fErrorReporter);
        SchemaGrammar grammar = loadSchema(desc, source, locationPairs);
        
        if(grammar != null && fGrammarPool != null) {
            fGrammarPool.cacheGrammars(XMLGrammarDescription.XML_SCHEMA, fGrammarBucket.getGrammars());
            // NOTE: we only need to verify full checking in case the schema was not provided via JAXP
            // since full checking already verified for all JAXP schemas
            if(fIsCheckedFully && fJAXPCache.get(grammar) != grammar) {
                XSConstraints.fullSchemaChecking(fGrammarBucket, fSubGroupHandler, fCMBuilder, fErrorReporter);
            }
        }
        return grammar;
    
public org.apache.xerces.xs.XSModelloadInputList(org.apache.xerces.xs.LSInputList is)

        int length = is.getLength();
        if (length == 0) {
            return null;
        }
        SchemaGrammar[] gs = new SchemaGrammar[length];
        for (int i = 0; i < length; i++) {
            try {
                gs[i] = (SchemaGrammar) loadGrammar(dom2xmlInputSource(is.item(i)));
            } catch (Exception e) {
                reportDOMFatalError(e);
                return null;
            }
        }
        return new XSModelImpl(gs);
    
SchemaGrammarloadSchema(XSDDescription desc, org.apache.xerces.xni.parser.XMLInputSource source, java.util.Hashtable locationPairs)
This method is called either from XMLGrammarLoader.loadGrammar or from XMLSchemaValidator. Note: in either case, the EntityManager (or EntityResolvers) are not going to be invoked to resolve the location of the schema in XSDDescription

param
desc
param
source
param
locationPairs
return
An XML Schema grammar
throws
IOException
throws
XNIException

        
        // this should only be done once per invocation of this object;
        // unless application alters JAXPSource in the mean time.
        if(!fJAXPProcessed) {
            processJAXPSchemaSource(locationPairs);
        }
        SchemaGrammar grammar = fSchemaHandler.parseSchema(source, desc, locationPairs);
        
        return grammar;
    
public org.apache.xerces.xs.XSModelloadURI(java.lang.String uri)

        try {
            Grammar g = loadGrammar(new XMLInputSource(null, uri, null));
            return ((XSGrammar)g).toXSModel();
        }
        catch (Exception e){
            reportDOMFatalError(e);
            return null;
        }
    
public org.apache.xerces.xs.XSModelloadURIList(org.apache.xerces.xs.StringList uriList)

        int length = uriList.getLength();
        if (length == 0) {
            return null;
        }
        SchemaGrammar[] gs = new SchemaGrammar[length];
        for (int i = 0; i < length; i++) {
            try {
                gs[i] =
                    (SchemaGrammar) loadGrammar(new XMLInputSource(null, uriList.item(i), null));
            } catch (Exception e) {
                reportDOMFatalError(e);
                return null;
            }
        }
        return new XSModelImpl(gs);
    
private booleanparserSettingsUpdated(org.apache.xerces.xni.parser.XMLComponentManager componentManager)

        try {
            return componentManager.getFeature(PARSER_SETTINGS);     
        }
        catch (XMLConfigurationException e) {}
        return true;
    
public static voidprocessExternalHints(java.lang.String sl, java.lang.String nsl, java.util.Hashtable locations, org.apache.xerces.impl.XMLErrorReporter er)

        if (sl != null) {
            try {
                // get the attribute decl for xsi:schemaLocation
                // because external schema location property has the same syntax
                // as xsi:schemaLocation
                XSAttributeDecl attrDecl = SchemaGrammar.SG_XSI.getGlobalAttributeDecl(SchemaSymbols.XSI_SCHEMALOCATION);
                // validation the string value to get the list of URI's
                attrDecl.fType.validate(sl, null, null);
                if (!tokenizeSchemaLocationStr(sl, locations)) {
                    // report warning (odd number of items)
                    er.reportError(XSMessageFormatter.SCHEMA_DOMAIN,
                            "SchemaLocation",
                            new Object[]{sl},
                            XMLErrorReporter.SEVERITY_WARNING);
                }
            }
            catch (InvalidDatatypeValueException ex) {
                // report warning (not list of URI's)
                er.reportError(XSMessageFormatter.SCHEMA_DOMAIN,
                        ex.getKey(), ex.getArgs(),
                        XMLErrorReporter.SEVERITY_WARNING);
            }
        }
        
        if (nsl != null) {
            try {
                // similarly for no ns schema location property
                XSAttributeDecl attrDecl = SchemaGrammar.SG_XSI.getGlobalAttributeDecl(SchemaSymbols.XSI_NONAMESPACESCHEMALOCATION);
                attrDecl.fType.validate(nsl, null, null);
                LocationArray la = ((LocationArray)locations.get(XMLSymbols.EMPTY_STRING));
                if(la == null) {
                    la = new LocationArray();
                    locations.put(XMLSymbols.EMPTY_STRING, la);
                }
                la.addLocation(nsl);
            }
            catch (InvalidDatatypeValueException ex) {
                // report warning (not a URI)
                er.reportError(XSMessageFormatter.SCHEMA_DOMAIN,
                        ex.getKey(), ex.getArgs(),
                        XMLErrorReporter.SEVERITY_WARNING);
            }
        }
    
private voidprocessJAXPSchemaSource(java.util.Hashtable locationPairs)
Translate the various JAXP SchemaSource property types to XNI XMLInputSource. Valid types are: String, org.xml.sax.InputSource, InputStream, File, or Object[] of any of previous types. REVISIT: the JAXP 1.2 spec is less than clear as to whether this property should be available to imported schemas. I have assumed that it should. - NG Note: all JAXP schema files will be checked for full-schema validity if the feature was set up

        fJAXPProcessed = true;
        if (fJAXPSource == null) {
            return;
        }
        
        Class componentType = fJAXPSource.getClass().getComponentType();
        XMLInputSource xis = null;
        String sid = null;
        if (componentType == null) {
            // Not an array
            if (fJAXPSource instanceof InputStream ||
                    fJAXPSource instanceof InputSource) {
                SchemaGrammar g = (SchemaGrammar)fJAXPCache.get(fJAXPSource);
                if (g != null) {
                    fGrammarBucket.putGrammar(g);
                    return;
                }
            }
            fXSDDescription.reset();
            xis = xsdToXMLInputSource(fJAXPSource);
            sid = xis.getSystemId();
            fXSDDescription.fContextType = XSDDescription.CONTEXT_PREPARSE;
            if (sid != null) {
                fXSDDescription.setBaseSystemId(xis.getBaseSystemId());
                fXSDDescription.setLiteralSystemId(sid);
                fXSDDescription.setExpandedSystemId(sid);
                fXSDDescription.fLocationHints = new String[]{sid};
            }
            SchemaGrammar g = loadSchema(fXSDDescription, xis, locationPairs);
            // it is possible that we won't be able to resolve JAXP schema-source location
            if (g != null) {
                if (fJAXPSource instanceof InputStream ||
                        fJAXPSource instanceof InputSource) {
                    fJAXPCache.put(fJAXPSource, g);
                    if (fIsCheckedFully) {
                        XSConstraints.fullSchemaChecking(fGrammarBucket, fSubGroupHandler, fCMBuilder, fErrorReporter);
                    }
                }
                fGrammarBucket.putGrammar(g);
            }
            return;
        } 
        else if ( (componentType != Object.class) &&
                (componentType != String.class) &&
                (componentType != File.class) &&
                (componentType != InputStream.class) &&
                (componentType != InputSource.class) &&
                !File.class.isAssignableFrom(componentType) &&
                !InputStream.class.isAssignableFrom(componentType) &&
                !InputSource.class.isAssignableFrom(componentType) &&
                !componentType.isInterface()
        ) {
            // Not an Object[], String[], File[], InputStream[], InputSource[]
            MessageFormatter mf = fErrorReporter.getMessageFormatter(XSMessageFormatter.SCHEMA_DOMAIN);
            throw new XMLConfigurationException(
                    XMLConfigurationException.NOT_SUPPORTED, 
                    mf.formatMessage(fErrorReporter.getLocale(), "jaxp12-schema-source-type.2",
                    new Object [] {componentType.getName()}));
        }
        
        // JAXP spec. allow []s of type String, File, InputStream,
        // InputSource also, apart from [] of type Object.
        Object[] objArr = (Object[]) fJAXPSource;
        // make local vector for storing target namespaces of schemasources specified in object arrays.
        ArrayList jaxpSchemaSourceNamespaces = new ArrayList();
        for (int i = 0; i < objArr.length; i++) {
            if (objArr[i] instanceof InputStream ||
                    objArr[i] instanceof InputSource) {
                SchemaGrammar g = (SchemaGrammar)fJAXPCache.get(objArr[i]);
                if (g != null) {
                    fGrammarBucket.putGrammar(g);
                    continue;
                }
            }
            fXSDDescription.reset();
            xis = xsdToXMLInputSource(objArr[i]);
            sid = xis.getSystemId();
            fXSDDescription.fContextType = XSDDescription.CONTEXT_PREPARSE;
            if (sid != null) {
                fXSDDescription.setBaseSystemId(xis.getBaseSystemId());
                fXSDDescription.setLiteralSystemId(sid);
                fXSDDescription.setExpandedSystemId(sid);
                fXSDDescription.fLocationHints = new String[]{sid};
            }
            String targetNamespace = null ;
            // load schema
            SchemaGrammar grammar = fSchemaHandler.parseSchema(xis,fXSDDescription, locationPairs);
            
            if (fIsCheckedFully) {
                XSConstraints.fullSchemaChecking(fGrammarBucket, fSubGroupHandler, fCMBuilder, fErrorReporter);
            }                                   
            if (grammar != null) {
                targetNamespace = grammar.getTargetNamespace();
                if (jaxpSchemaSourceNamespaces.contains(targetNamespace)) {
                    // when an array of objects is passed it is illegal to have two schemas that share same namespace.
                    MessageFormatter mf = fErrorReporter.getMessageFormatter(XSMessageFormatter.SCHEMA_DOMAIN);
                    throw new java.lang.IllegalArgumentException(mf.formatMessage(fErrorReporter.getLocale(), 
                            "jaxp12-schema-source-ns", null));
                }
                else {
                    jaxpSchemaSourceNamespaces.add(targetNamespace) ;
                }
                if (objArr[i] instanceof InputStream ||
                        objArr[i] instanceof InputSource) {
                    fJAXPCache.put(objArr[i], grammar);
                }
                fGrammarBucket.putGrammar(grammar);
            }
            else {
                //REVISIT: What should be the acutal behavior if grammar can't be loaded as specified in schema source?
            }
        }
    
voidreportDOMFatalError(java.lang.Exception e)

                if (fErrorHandler != null) {
                    DOMErrorImpl error = new DOMErrorImpl();
                    error.fException = e;
                    error.fMessage = e.getMessage();
                    error.fSeverity = DOMError.SEVERITY_FATAL_ERROR;
                    fErrorHandler.getErrorHandler().handleError(error);
                }
            
public voidreset(org.apache.xerces.xni.parser.XMLComponentManager componentManager)

        
        fGrammarBucket.reset();
        
        fSubGroupHandler.reset();		
        
        if (!fSettingsChanged || !parserSettingsUpdated(componentManager)) {
            // need to reprocess JAXP schema sources
            fJAXPProcessed = false;
            // reinitialize grammar bucket
            initGrammarBucket();
            return;           
        } 
        
        // get registered entity manager to be able to resolve JAXP schema-source property:
        // Note: in case XMLSchemaValidator has created the loader, 
        // the entity manager property is null
        fEntityManager = (XMLEntityManager)componentManager.getProperty(ENTITY_MANAGER);      
        
        // get the error reporter
        fErrorReporter = (XMLErrorReporter)componentManager.getProperty(ERROR_REPORTER);
        
        boolean psvi = true;
        try {
            psvi = componentManager.getFeature(AUGMENT_PSVI);
        } catch (XMLConfigurationException e) {
            psvi = false;
        }
        
        if (!psvi) {
            fDeclPool.reset();
            fCMBuilder.setDeclPool(fDeclPool);
            fSchemaHandler.setDeclPool(fDeclPool);
        } else {
            fCMBuilder.setDeclPool(null);
            fSchemaHandler.setDeclPool(null);
        }
        
        // get schema location properties
        try {
            fExternalSchemas = (String) componentManager.getProperty(SCHEMA_LOCATION);
            fExternalNoNSSchema =
                (String) componentManager.getProperty(SCHEMA_NONS_LOCATION);
        } catch (XMLConfigurationException e) {
            fExternalSchemas = null;
            fExternalNoNSSchema = null;
        }
        // get JAXP sources if available
        try {
            fJAXPSource = componentManager.getProperty(JAXP_SCHEMA_SOURCE);
            fJAXPProcessed = false;
            
        } catch (XMLConfigurationException e) {
            fJAXPSource = null;
            fJAXPProcessed = false;
        }
        
        // clear grammars, and put the one for schema namespace there
        try {
            fGrammarPool = (XMLGrammarPool) componentManager.getProperty(XMLGRAMMAR_POOL);
        } catch (XMLConfigurationException e) {
            fGrammarPool = null;
        }
        initGrammarBucket();
        // get continue-after-fatal-error feature
        try {
            boolean fatalError = componentManager.getFeature(CONTINUE_AFTER_FATAL_ERROR);
            fErrorReporter.setFeature(CONTINUE_AFTER_FATAL_ERROR, fatalError);
        } catch (XMLConfigurationException e) {
        }
        // set full validation to false        
        try {
            fIsCheckedFully = componentManager.getFeature(SCHEMA_FULL_CHECKING);
        }
        catch (XMLConfigurationException e){
            fIsCheckedFully = false;
        }
        // get generate-synthetic-annotations feature
        try {
            fSchemaHandler.setGenerateSyntheticAnnotations(componentManager.getFeature(GENERATE_SYNTHETIC_ANNOTATIONS));
        }
        catch (XMLConfigurationException e) {
            fSchemaHandler.setGenerateSyntheticAnnotations(false);
        }
        fSchemaHandler.reset(componentManager);		 
    
public static org.apache.xerces.xni.parser.XMLInputSourceresolveDocument(XSDDescription desc, java.util.Hashtable locationPairs, org.apache.xerces.xni.parser.XMLEntityResolver entityResolver)
This method tries to resolve location of the given schema. The loader stores the namespace/location pairs in a hashtable (use "" as the namespace of absent namespace). When resolving an entity, loader first tries to find in the hashtable whether there is a value for that namespace, if so, pass that location value to the user-defined entity resolver.

param
desc
param
locationPairs
param
entityResolver
return
the XMLInputSource
throws
IOException

        String loc = null;
        // we consider the schema location properties for import
        if (desc.getContextType() == XSDDescription.CONTEXT_IMPORT ||
                desc.fromInstance()) {
            // use empty string as the key for absent namespace
            String namespace = desc.getTargetNamespace();
            String ns = namespace == null ? XMLSymbols.EMPTY_STRING : namespace;
            // get the location hint for that namespace
            LocationArray tempLA = (LocationArray)locationPairs.get(ns);
            if(tempLA != null)
                loc = tempLA.getFirstLocation();
        }
        
        // if it's not import, or if the target namespace is not set
        // in the schema location properties, use location hint
        if (loc == null) {
            String[] hints = desc.getLocationHints();
            if (hints != null && hints.length > 0)
                loc = hints[0];
        }
        
        String expandedLoc = XMLEntityManager.expandSystemId(loc, desc.getBaseSystemId(), false);
        desc.setLiteralSystemId(loc);
        desc.setExpandedSystemId(expandedLoc);
        return entityResolver.resolveEntity(desc);
    
private static org.apache.xerces.xni.parser.XMLInputSourcesaxToXMLInputSource(org.xml.sax.InputSource sis)

        String publicId = sis.getPublicId();
        String systemId = sis.getSystemId();
        
        Reader charStream = sis.getCharacterStream();
        if (charStream != null) {
            return new XMLInputSource(publicId, systemId, null, charStream,
                    null);
        }
        
        InputStream byteStream = sis.getByteStream();
        if (byteStream != null) {
            return new XMLInputSource(publicId, systemId, null, byteStream,
                    sis.getEncoding());
        }
        
        return new XMLInputSource(publicId, systemId, null);
    
public voidsetEntityResolver(org.apache.xerces.xni.parser.XMLEntityResolver entityResolver)
Sets the entity resolver.

param
entityResolver The new entity resolver.

        fUserEntityResolver = entityResolver;
        fLoaderConfig.setProperty(ENTITY_RESOLVER, entityResolver);
        fEntityManager.setProperty(ENTITY_RESOLVER, entityResolver);
    
public voidsetErrorHandler(org.apache.xerces.xni.parser.XMLErrorHandler errorHandler)
Sets the error handler.

param
errorHandler The error handler.

        fErrorReporter.setProperty(ERROR_HANDLER, errorHandler);
    
public voidsetFeature(java.lang.String featureId, boolean state)
Sets the state of a feature.

param
featureId The feature identifier.
param
state The state of the feature.
throws
XMLConfigurationException Thrown when a feature is not recognized or cannot be set.

        fSettingsChanged = true; 
        if(featureId.equals(CONTINUE_AFTER_FATAL_ERROR)) {
            fErrorReporter.setFeature(CONTINUE_AFTER_FATAL_ERROR, state);
        } 
        else if(featureId.equals(GENERATE_SYNTHETIC_ANNOTATIONS)) {
            fSchemaHandler.setGenerateSyntheticAnnotations(state);
        }
        fLoaderConfig.setFeature(featureId, state);
    
public voidsetLocale(java.util.Locale locale)
Set the locale to use for messages.

param
locale The locale object to use for localization of messages.
exception
XNIException Thrown if the parser does not support the specified locale.

        fLocale = locale;
        fErrorReporter.setLocale(locale);
    
public voidsetParameter(java.lang.String name, java.lang.Object value)

        if (value instanceof Boolean) {
            boolean state = ((Boolean) value).booleanValue();
            if (name.equals("validate") && state) {
                return;
            }
            try {
                setFeature(name, state);
            } catch (Exception e) {
                String msg =
                    DOMMessageFormatter.formatMessage(
                            DOMMessageFormatter.DOM_DOMAIN,
                            "FEATURE_NOT_SUPPORTED",
                            new Object[] { name });
                throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
            }
            return;
        }
        if (name.equals(Constants.DOM_ERROR_HANDLER)) {
            if (value instanceof DOMErrorHandler) {
                try {
                    fErrorHandler = new DOMErrorHandlerWrapper((DOMErrorHandler) value);
                    setErrorHandler(fErrorHandler);
                } catch (XMLConfigurationException e) {
                }
            } else {
                // REVISIT: type mismatch
                String msg =
                    DOMMessageFormatter.formatMessage(
                            DOMMessageFormatter.DOM_DOMAIN,
                            "FEATURE_NOT_SUPPORTED",
                            new Object[] { name });
                throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
            }
            return;
            
        }
        if (name.equals(Constants.DOM_RESOURCE_RESOLVER)) {
            if (value instanceof LSResourceResolver) {
                try {
                    fResourceResolver = new DOMEntityResolverWrapper((LSResourceResolver) value);
                    setEntityResolver(fResourceResolver);
                } 
                catch (XMLConfigurationException e) {}
            } else {
                // REVISIT: type mismatch
                String msg =
                    DOMMessageFormatter.formatMessage(
                            DOMMessageFormatter.DOM_DOMAIN,
                            "FEATURE_NOT_SUPPORTED",
                            new Object[] { name });
                throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
            }
            return;
        }
        
        try {
            setProperty(name, value);
        } catch (Exception ex) {
            
            String msg =
                DOMMessageFormatter.formatMessage(
                        DOMMessageFormatter.DOM_DOMAIN,
                        "FEATURE_NOT_SUPPORTED",
                        new Object[] { name });
            throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
            
        }
        
    
public voidsetProperty(java.lang.String propertyId, java.lang.Object state)
Sets the state of a property.

param
propertyId The property identifier.
param
state The state of the property.
throws
XMLConfigurationException Thrown when a property is not recognized or cannot be set.

                   
        fSettingsChanged = true;
        fLoaderConfig.setProperty(propertyId, state);    
        if(propertyId.equals( JAXP_SCHEMA_SOURCE)) {
            fJAXPSource = state;
            fJAXPProcessed = false;
        }  
        else if(propertyId.equals( XMLGRAMMAR_POOL)) {
            fGrammarPool = (XMLGrammarPool)state;
        } 
        else if (propertyId.equals(SCHEMA_LOCATION)){
            fExternalSchemas = (String)state;
        }
        else if (propertyId.equals(SCHEMA_NONS_LOCATION)){
            fExternalNoNSSchema = (String) state;
        }
        else if (propertyId.equals(ENTITY_RESOLVER)){
            fEntityManager.setProperty(ENTITY_RESOLVER, state);
        }
        else if (propertyId.equals(ERROR_REPORTER)){
            fErrorReporter = (XMLErrorReporter)state;
            if (fErrorReporter.getMessageFormatter(XSMessageFormatter.SCHEMA_DOMAIN) == null) {
                fErrorReporter.putMessageFormatter(XSMessageFormatter.SCHEMA_DOMAIN, new XSMessageFormatter());
            }
        }
    
public static booleantokenizeSchemaLocationStr(java.lang.String schemaStr, java.util.Hashtable locations)

        if (schemaStr!= null) {
            StringTokenizer t = new StringTokenizer(schemaStr, " \n\t\r");
            String namespace, location;
            while (t.hasMoreTokens()) {
                namespace = t.nextToken ();
                if (!t.hasMoreTokens()) {
                    return false; // error!
                }
                location = t.nextToken();
                LocationArray la = ((LocationArray)locations.get(namespace));
                if(la == null) {
                    la = new LocationArray();
                    locations.put(namespace, la);
                }
                la.addLocation(location);
            }
        }
        return true;
    
private org.apache.xerces.xni.parser.XMLInputSourcexsdToXMLInputSource(java.lang.Object val)

        if (val instanceof String) {
            // String value is treated as a URI that is passed through the
            // EntityResolver
            String loc = (String) val;          
            fXSDDescription.reset();
            fXSDDescription.setValues(null, loc, null, null);
            XMLInputSource xis = null;
            try {
                xis = fEntityManager.resolveEntity(fXSDDescription);
            } 
            catch (IOException ex) {
                fErrorReporter.reportError(XSMessageFormatter.SCHEMA_DOMAIN,
                        "schema_reference.4",
                        new Object[] { loc }, XMLErrorReporter.SEVERITY_ERROR);
            }
            if (xis == null) {
                // REVISIT: can this happen?
                // Treat value as a URI and pass in as systemId
                return new XMLInputSource(null, loc, null);
            }
            return xis;
        } 
        else if (val instanceof InputSource) {
            return saxToXMLInputSource((InputSource) val);
        } 
        else if (val instanceof InputStream) {
            return new XMLInputSource(null, null, null,
                    (InputStream) val, null);
        } 
        else if (val instanceof File) {
            File file = (File) val;
            InputStream is = null;
            try {
                is = new BufferedInputStream(new FileInputStream(file));
            } catch (FileNotFoundException ex) {
                fErrorReporter.reportError(XSMessageFormatter.SCHEMA_DOMAIN,
                        "schema_reference.4", new Object[] { file.toString() },
                        XMLErrorReporter.SEVERITY_ERROR);
            }
            return new XMLInputSource(null, null, null, is, null);
        }
        MessageFormatter mf = fErrorReporter.getMessageFormatter(XSMessageFormatter.SCHEMA_DOMAIN);
        throw new XMLConfigurationException(
                XMLConfigurationException.NOT_SUPPORTED, 
                mf.formatMessage(fErrorReporter.getLocale(), "jaxp12-schema-source-type.1",
                new Object [] {val != null ? val.getClass().getName() : "null"}));