# Xerces2 Implementation: Class XMLSchemaLoader

## org.apache.xerces.impl.xs
Class XMLSchemaLoader

    java.lang.Object
      |
      +--org.apache.xerces.impl.xs.XMLSchemaLoader

All Implemented Interfaces:
  org.apache.xerces.dom3.DOMConfiguration, org.apache.xerces.xni.parser.XMLComponent, org.apache.xerces.xni.grammars.XMLGrammarLoader, org.apache.xerces.xs.XSLoader

public class XMLSchemaLoader
extends java.lang.Object
implements org.apache.xerces.xni.grammars.XMLGrammarLoader, org.apache.xerces.xni.parser.XMLComponent, org.apache.xerces.xs.XSLoader, org.apache.xerces.dom3.DOMConfiguration

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.

Version:
  $Id: XMLSchemaLoader.java,v 1.26 2004/01/29 22:26:00 mrglavas Exp $
Author:
  Neil Graham, IBM

Field Summary
`protected static java.lang.String` `ALLOW_JAVA_ENCODINGS` Feature identifier: allow java encodings to be recognized when parsing schema docs.
`protected static java.lang.String` `AUGMENT_PSVI`
`protected static java.lang.String` `CONTINUE_AFTER_FATAL_ERROR` Feature identifier: continue after fatal error.
`protected static java.lang.String` `DISALLOW_DOCTYPE` Feature: disallow doctype
`protected static java.lang.String` `ENTITY_MANAGER`
`static java.lang.String` `ENTITY_RESOLVER` Property identifier: entity resolver.
`protected static java.lang.String` `ERROR_HANDLER` Property identifier: error handler.
`static java.lang.String` `ERROR_REPORTER` Property identifier: error reporter.
`protected static java.lang.String` `JAXP_SCHEMA_SOURCE` Property identifier: JAXP schema source.
`protected static java.lang.String` `PARSER_SETTINGS`
`protected static java.lang.String` `SCHEMA_FULL_CHECKING` Feature identifier: schema full checking
`protected static java.lang.String` `SCHEMA_LOCATION` Property identifier: schema location.
`protected static java.lang.String` `SCHEMA_NONS_LOCATION` Property identifier: no namespace schema location.
`protected static java.lang.String` `SECURITY_MANAGER`
`protected static java.lang.String` `STANDARD_URI_CONFORMANT_FEATURE` Feature identifier: standard uri conformant feature.
`static java.lang.String` `SYMBOL_TABLE` Property identifier: symbol table.
`static java.lang.String` `XMLGRAMMAR_POOL` Property identifier: grammar pool.

Constructor Summary
`XMLSchemaLoader()`
`XMLSchemaLoader(SymbolTable symbolTable)`

Method Summary
`boolean` `canSetParameter(java.lang.String name, java.lang.Object value)` Check if setting a parameter to a specific value is supported.
`org.apache.xerces.dom3.DOMConfiguration` `getConfig()` The configuration of a document.
`org.apache.xerces.xni.parser.XMLEntityResolver` `getEntityResolver()` Returns the registered entity resolver.
`org.apache.xerces.xni.parser.XMLErrorHandler` `getErrorHandler()` Returns the registered error handler.
`boolean` `getFeature(java.lang.String featureId)` Returns the state of a feature.
`java.lang.Boolean` `getFeatureDefault(java.lang.String featureId)` Returns the default state for a feature, or null if this component does not want to report a default value for this feature.
`java.util.Locale` `getLocale()` Return the Locale the XMLGrammarLoader is using.
`java.lang.Object` `getParameter(java.lang.String name)` Return the value of a parameter if known.
`org.apache.xerces.dom3.DOMStringList` `getParameterNames()` The list of the parameters supported by this `DOMConfiguration` object and for which at least one value can be set by the application.
`java.lang.Object` `getProperty(java.lang.String propertyId)` Returns the state of a property.
`java.lang.Object` `getPropertyDefault(java.lang.String propertyId)` Returns the default state for a property, or null if this component does not want to report a default value for this property.
`java.lang.String[]` `getRecognizedFeatures()` Returns a list of feature identifiers that are recognized by this XMLGrammarLoader.
`java.lang.String[]` `getRecognizedProperties()` Returns a list of property identifiers that are recognized by this XMLGrammarLoader.
`org.apache.xerces.xs.XSModel` `load(org.w3c.dom.ls.LSInput is)` Parse an XML Schema document from a resource identified by a `LSInput` .
`org.apache.xerces.xni.grammars.Grammar` `loadGrammar(org.apache.xerces.xni.parser.XMLInputSource source)` Returns a Grammar object by parsing the contents of the entity pointed to by source.
`org.apache.xerces.xs.XSModel` `loadInputList(org.apache.xerces.xs.LSInputList is)` Parses the content of XML Schema documents specified as a list of `LSInput`s.
`org.apache.xerces.xs.XSModel` `loadURI(java.lang.String uri)` Parse an XML Schema document from a location identified by a URI reference.
`org.apache.xerces.xs.XSModel` `loadURIList(org.apache.xerces.xs.StringList uriList)` Parses the content of XML Schema documents specified as the list of URI references.
`static void` `processExternalHints(java.lang.String sl, java.lang.String nsl, java.util.Hashtable locations, XMLErrorReporter er)`
`void` `reset(org.apache.xerces.xni.parser.XMLComponentManager componentManager)` Resets the component.
`static org.apache.xerces.xni.parser.XMLInputSource` `resolveDocument(XSDDescription desc, java.util.Hashtable locationPairs, org.apache.xerces.xni.parser.XMLEntityResolver entityResolver)` This method tries to resolve location of the given schema.
`void` `setEntityResolver(org.apache.xerces.xni.parser.XMLEntityResolver entityResolver)` Sets the entity resolver.
`void` `setErrorHandler(org.apache.xerces.xni.parser.XMLErrorHandler errorHandler)` Sets the error handler.
`void` `setFeature(java.lang.String featureId, boolean state)` Sets the state of a feature.
`void` `setLocale(java.util.Locale locale)` Set the locale to use for messages.
`void` `setParameter(java.lang.String name, java.lang.Object value)` Set the value of a parameter.
`void` `setProperty(java.lang.String propertyId, java.lang.Object state)` Sets the state of a property.
`static boolean` `tokenizeSchemaLocationStr(java.lang.String schemaStr, java.util.Hashtable locations)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### SCHEMA_FULL_CHECKING

    protected static final java.lang.String SCHEMA_FULL_CHECKING

  Feature identifier: schema full checking

### CONTINUE_AFTER_FATAL_ERROR

    protected static final java.lang.String CONTINUE_AFTER_FATAL_ERROR

  Feature identifier: continue after fatal error.

### ALLOW_JAVA_ENCODINGS

    protected static final java.lang.String ALLOW_JAVA_ENCODINGS

  Feature identifier: allow java encodings to be recognized when parsing schema docs.

### STANDARD_URI_CONFORMANT_FEATURE

    protected static final java.lang.String STANDARD_URI_CONFORMANT_FEATURE

  Feature identifier: standard uri conformant feature.

### DISALLOW_DOCTYPE

    protected static final java.lang.String DISALLOW_DOCTYPE

  Feature: disallow doctype

### AUGMENT_PSVI

    protected static final java.lang.String AUGMENT_PSVI

### PARSER_SETTINGS

    protected static final java.lang.String PARSER_SETTINGS

### SYMBOL_TABLE

    public static final java.lang.String SYMBOL_TABLE

  Property identifier: symbol table.

### ERROR_REPORTER

    public static final java.lang.String ERROR_REPORTER

  Property identifier: error reporter.

### ERROR_HANDLER

    protected static final java.lang.String ERROR_HANDLER

  Property identifier: error handler.

### ENTITY_RESOLVER

    public static final java.lang.String ENTITY_RESOLVER

  Property identifier: entity resolver.

### XMLGRAMMAR_POOL

    public static final java.lang.String XMLGRAMMAR_POOL

  Property identifier: grammar pool.

### SCHEMA_LOCATION

    protected static final java.lang.String SCHEMA_LOCATION

  Property identifier: schema location.

### SCHEMA_NONS_LOCATION

    protected static final java.lang.String SCHEMA_NONS_LOCATION

  Property identifier: no namespace schema location.

### JAXP_SCHEMA_SOURCE

    protected static final java.lang.String JAXP_SCHEMA_SOURCE

  Property identifier: JAXP schema source.

### SECURITY_MANAGER

    protected static final java.lang.String SECURITY_MANAGER

### ENTITY_MANAGER

    protected static final java.lang.String ENTITY_MANAGER

Constructor Detail

### XMLSchemaLoader

    public XMLSchemaLoader()

### XMLSchemaLoader

    public XMLSchemaLoader(SymbolTable symbolTable)

Method Detail

### getRecognizedFeatures

    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.
  Specified by:
    `getRecognizedFeatures` in interface `org.apache.xerces.xni.grammars.XMLGrammarLoader`

### getFeature

    public boolean getFeature(java.lang.String featureId)
                       throws org.apache.xerces.xni.parser.XMLConfigurationException

  Returns the state of a feature.
  Specified by:
    `getFeature` in interface `org.apache.xerces.xni.grammars.XMLGrammarLoader`
  Parameters:
    `featureId` - The feature identifier.
  Throws:
    `org.apache.xerces.xni.parser.XMLConfigurationException` - Thrown on configuration error.

### setFeature

    public void setFeature(java.lang.String featureId,
                           boolean state)
                    throws org.apache.xerces.xni.parser.XMLConfigurationException

  Sets the state of a feature.
  Specified by:
    `setFeature` in interface `org.apache.xerces.xni.grammars.XMLGrammarLoader`
  Parameters:
    `featureId` - The feature identifier.
    `state` - The state of the feature.
  Throws:
    `org.apache.xerces.xni.parser.XMLConfigurationException` - Thrown when a feature is not recognized or cannot be set.

### getRecognizedProperties

    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.
  Specified by:
    `getRecognizedProperties` in interface `org.apache.xerces.xni.grammars.XMLGrammarLoader`

### getProperty

    public java.lang.Object getProperty(java.lang.String propertyId)
                                 throws org.apache.xerces.xni.parser.XMLConfigurationException

  Returns the state of a property.
  Specified by:
    `getProperty` in interface `org.apache.xerces.xni.grammars.XMLGrammarLoader`
  Parameters:
    `propertyId` - The property identifier.
  Throws:
    `org.apache.xerces.xni.parser.XMLConfigurationException` - Thrown on configuration error.

### setProperty

    public void setProperty(java.lang.String propertyId,
                            java.lang.Object state)
                     throws org.apache.xerces.xni.parser.XMLConfigurationException

  Sets the state of a property.
  Specified by:
    `setProperty` in interface `org.apache.xerces.xni.grammars.XMLGrammarLoader`
  Parameters:
    `propertyId` - The property identifier.
    `state` - The state of the property.
  Throws:
    `org.apache.xerces.xni.parser.XMLConfigurationException` - Thrown when a property is not recognized or cannot be set.

### setLocale

    public void setLocale(java.util.Locale locale)

  Set the locale to use for messages.
  Specified by:
    `setLocale` in interface `org.apache.xerces.xni.grammars.XMLGrammarLoader`
  Parameters:
    `locale` - The locale object to use for localization of messages.
  Throws:
    `org.apache.xerces.xni.XNIException` - Thrown if the parser does not support the specified locale.

### getLocale

    public java.util.Locale getLocale()

  Return the Locale the XMLGrammarLoader is using.
  Specified by:
    `getLocale` in interface `org.apache.xerces.xni.grammars.XMLGrammarLoader`

### setErrorHandler

    public void setErrorHandler(org.apache.xerces.xni.parser.XMLErrorHandler errorHandler)

  Sets the error handler.
  Specified by:
    `setErrorHandler` in interface `org.apache.xerces.xni.grammars.XMLGrammarLoader`
  Parameters:
    `errorHandler` - The error handler.

### getErrorHandler

    public org.apache.xerces.xni.parser.XMLErrorHandler getErrorHandler()

  Returns the registered error handler.
  Specified by:
    `getErrorHandler` in interface `org.apache.xerces.xni.grammars.XMLGrammarLoader`

### setEntityResolver

    public void setEntityResolver(org.apache.xerces.xni.parser.XMLEntityResolver entityResolver)

  Sets the entity resolver.
  Specified by:
    `setEntityResolver` in interface `org.apache.xerces.xni.grammars.XMLGrammarLoader`
  Parameters:
    `entityResolver` - The new entity resolver.

### getEntityResolver

    public org.apache.xerces.xni.parser.XMLEntityResolver getEntityResolver()

  Returns the registered entity resolver.
  Specified by:
    `getEntityResolver` in interface `org.apache.xerces.xni.grammars.XMLGrammarLoader`

### loadGrammar

    public org.apache.xerces.xni.grammars.Grammar loadGrammar(org.apache.xerces.xni.parser.XMLInputSource source)
                                                       throws java.io.IOException,
                                                              org.apache.xerces.xni.XNIException

  Returns a Grammar object by parsing the contents of the entity pointed to by source.
  Specified by:
    `loadGrammar` in interface `org.apache.xerces.xni.grammars.XMLGrammarLoader`
  Parameters:
    `source` - the location of the entity which forms the starting point of the grammar to be constructed.
  Throws:
    `java.io.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.

### resolveDocument

    public static org.apache.xerces.xni.parser.XMLInputSource resolveDocument(XSDDescription desc,
                                                                              java.util.Hashtable locationPairs,
                                                                              org.apache.xerces.xni.parser.XMLEntityResolver entityResolver)
                                                                       throws java.io.IOException

  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.
  Parameters:
    `desc` -
    `locationPairs` -
    `entityResolver` -
  Returns:
  Throws:
    `java.io.IOException` -

### processExternalHints

    public static void processExternalHints(java.lang.String sl,
                                            java.lang.String nsl,
                                            java.util.Hashtable locations,
                                            XMLErrorReporter er)

### tokenizeSchemaLocationStr

    public static boolean tokenizeSchemaLocationStr(java.lang.String schemaStr,
                                                    java.util.Hashtable locations)

### getFeatureDefault

    public java.lang.Boolean getFeatureDefault(java.lang.String featureId)

  Description copied from interface: `org.apache.xerces.xni.parser.XMLComponent`
  Returns the default state for a feature, or null if this component does not want to report a default value for this feature.
  Specified by:
    `getFeatureDefault` in interface `org.apache.xerces.xni.parser.XMLComponent`
  Following copied from interface: `org.apache.xerces.xni.parser.XMLComponent`
  Parameters:
    `featureId` - The feature identifier.

### getPropertyDefault

    public java.lang.Object getPropertyDefault(java.lang.String propertyId)

  Description copied from interface: `org.apache.xerces.xni.parser.XMLComponent`
  Returns the default state for a property, or null if this component does not want to report a default value for this property.
  Specified by:
    `getPropertyDefault` in interface `org.apache.xerces.xni.parser.XMLComponent`
  Following copied from interface: `org.apache.xerces.xni.parser.XMLComponent`
  Parameters:
    `propertyId` - The property identifier.

### reset

    public void reset(org.apache.xerces.xni.parser.XMLComponentManager componentManager)
               throws org.apache.xerces.xni.parser.XMLConfigurationException

  Description copied from interface: `org.apache.xerces.xni.parser.XMLComponent`
  Resets the component. The component can query the component manager about any features and properties that affect the operation of the component.
  Specified by:
    `reset` in interface `org.apache.xerces.xni.parser.XMLComponent`
  Following copied from interface: `org.apache.xerces.xni.parser.XMLComponent`
  Parameters:
    `componentManager` - The component manager.
  Throws:
    `XNIException` - Thrown by component on initialization error.

### getConfig

    public org.apache.xerces.dom3.DOMConfiguration getConfig()

  Description copied from interface: `org.apache.xerces.xs.XSLoader`
  The configuration of a document. It maintains a table of recognized parameters. Using the configuration, it is possible to change the behavior of the load methods. The configuration may support the setting of and the retrieval of the following non-boolean parameters defined on the `DOMConfiguration` interface: `error-handler` (`DOMErrorHandler`) and `resource-resolver` (`LSResourceResolver`).
  The following list of boolean parameters is defined:
  `"validate"`
    `true`
      [required] (default) Validate an XML Schema during loading. If validation errors are found, the error handler is notified.
    `false`
      [optional] Do not report errors during the loading of an XML Schema document.
  Specified by:
    `getConfig` in interface `org.apache.xerces.xs.XSLoader`

### load

    public org.apache.xerces.xs.XSModel load(org.w3c.dom.ls.LSInput is)

  Description copied from interface: `org.apache.xerces.xs.XSLoader`
  Parse an XML Schema document from a resource identified by a `LSInput` .
  Specified by:
    `load` in interface `org.apache.xerces.xs.XSLoader`
  Following copied from interface: `org.apache.xerces.xs.XSLoader`
  Parameters:
    `is` - The `DOMInputSource` from which the source document is to be read.
  Returns:
    An XSModel representing this schema.

### loadInputList

    public org.apache.xerces.xs.XSModel loadInputList(org.apache.xerces.xs.LSInputList is)

  Description copied from interface: `org.apache.xerces.xs.XSLoader`
  Parses the content of XML Schema documents specified as a list of `LSInput`s.
  Specified by:
    `loadInputList` in interface `org.apache.xerces.xs.XSLoader`
  Following copied from interface: `org.apache.xerces.xs.XSLoader`
  Parameters:
    `is` - The list of `LSInput`s from which the XML Schema documents are to be read.
  Returns:
    An XSModel representing the schema documents.

### loadURI

    public org.apache.xerces.xs.XSModel loadURI(java.lang.String uri)

  Description copied from interface: `org.apache.xerces.xs.XSLoader`
  Parse an XML Schema document from a location identified by a URI reference. If the URI contains a fragment identifier, the behavior is not defined by this specification.
  Specified by:
    `loadURI` in interface `org.apache.xerces.xs.XSLoader`
  Following copied from interface: `org.apache.xerces.xs.XSLoader`
  Parameters:
    `uri` - The location of the XML Schema document to be read.
  Returns:
    An XSModel representing this schema.

### loadURIList

    public org.apache.xerces.xs.XSModel loadURIList(org.apache.xerces.xs.StringList uriList)

  Description copied from interface: `org.apache.xerces.xs.XSLoader`
  Parses the content of XML Schema documents specified as the list of URI references. If the URI contains a fragment identifier, the behavior is not defined by this specification.
  Specified by:
    `loadURIList` in interface `org.apache.xerces.xs.XSLoader`
  Following copied from interface: `org.apache.xerces.xs.XSLoader`
  Parameters:
    `uri` - The list of URI locations.
  Returns:
    An XSModel representing the schema documents.

### canSetParameter

    public boolean canSetParameter(java.lang.String name,
                                   java.lang.Object value)

  Description copied from interface: `org.apache.xerces.dom3.DOMConfiguration`
  Check if setting a parameter to a specific value is supported.
  Specified by:
    `canSetParameter` in interface `org.apache.xerces.dom3.DOMConfiguration`
  Following copied from interface: `org.apache.xerces.dom3.DOMConfiguration`
  Parameters:
    `name` - The name of the parameter to check.
    `value` - An object. if `null`, the returned value is `true`.
  Returns:
    `true` if the parameter could be successfully set to the specified value, or `false` if the parameter is not recognized or the requested value is not supported. This does not change the current value of the parameter itself.

### getParameter

    public java.lang.Object getParameter(java.lang.String name)
                                  throws org.w3c.dom.DOMException

  Description copied from interface: `org.apache.xerces.dom3.DOMConfiguration`
  Return the value of a parameter if known.
  Specified by:
    `getParameter` in interface `org.apache.xerces.dom3.DOMConfiguration`
  Following copied from interface: `org.apache.xerces.dom3.DOMConfiguration`
  Parameters:
    `name` - The name of the parameter.
  Returns:
    The current object associated with the specified parameter or `null` if no object has been associated or if the parameter is not supported.
  Throws:
    `org.w3c.dom.DOMException` - NOT_FOUND_ERR: Raised when the parameter name is not recognized.

### getParameterNames

    public org.apache.xerces.dom3.DOMStringList getParameterNames()

  Description copied from interface: `org.apache.xerces.dom3.DOMConfiguration`
  The list of the parameters supported by this `DOMConfiguration` object and for which at least one value can be set by the application. Note that this list can also contain parameter names defined outside this specification.
  Specified by:
    `getParameterNames` in interface `org.apache.xerces.dom3.DOMConfiguration`

### setParameter

    public void setParameter(java.lang.String name,
                             java.lang.Object value)
                      throws org.w3c.dom.DOMException

  Description copied from interface: `org.apache.xerces.dom3.DOMConfiguration`
  Set the value of a parameter.
  Specified by:
    `setParameter` in interface `org.apache.xerces.dom3.DOMConfiguration`
  Following copied from interface: `org.apache.xerces.dom3.DOMConfiguration`
  Parameters:
    `name` - The name of the parameter to set.
    `value` - The new value or `null` if the user wishes to unset the parameter. While the type of the value parameter is defined as `DOMUserData`, the object type must match the type defined by the definition of the parameter. For example, if the parameter is "error-handler", the value must be of type `DOMErrorHandler`.
  Throws:
    `org.w3c.dom.DOMException` - NOT_FOUND_ERR: Raised when the parameter name is not recognized.
    NOT_SUPPORTED_ERR: Raised when the parameter name is recognized but the requested value cannot be set.
    TYPE_MISMATCH_ERR: Raised if the value type for this parameter name is incompatible with the expected value type.

Copyright © 1999-2004 Apache XML Project. All Rights Reserved.