public class

XMLSchemaLoader

extends Object
implements XMLGrammarLoader XMLComponent XSLoader DOMConfiguration
java.lang.Object
   ↳ org.apache.xerces.impl.xs.XMLSchemaLoader

Class Overview

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.

Summary

Constants
String ALLOW_JAVA_ENCODINGS Feature identifier: allow java encodings to be recognized when parsing schema docs.
String AUGMENT_PSVI
String CONTINUE_AFTER_FATAL_ERROR Feature identifier: continue after fatal error.
String DISALLOW_DOCTYPE Feature: disallow doctype
String ENTITY_MANAGER
String ENTITY_RESOLVER Property identifier: entity resolver.
String ERROR_HANDLER Property identifier: error handler.
String ERROR_REPORTER Property identifier: error reporter.
String GENERATE_SYNTHETIC_ANNOTATIONS Feature: generate synthetic annotations
String HONOUR_ALL_SCHEMALOCATIONS Feature identifier: honour all schemaLocations
String JAXP_SCHEMA_SOURCE Property identifier: JAXP schema source.
String PARSER_SETTINGS
String SCHEMA_FULL_CHECKING Feature identifier: schema full checking
String SCHEMA_LOCATION Property identifier: schema location.
String SCHEMA_NONS_LOCATION Property identifier: no namespace schema location.
String SECURITY_MANAGER
String STANDARD_URI_CONFORMANT_FEATURE Feature identifier: standard uri conformant feature.
String SYMBOL_TABLE Property identifier: symbol table.
String VALIDATE_ANNOTATIONS Feature identifier: validate annotations.
String XMLGRAMMAR_POOL Property identifier: grammar pool.
Public Constructors
XMLSchemaLoader()
XMLSchemaLoader(SymbolTable symbolTable)
Public Methods
boolean canSetParameter(String name, Object value)
DOMConfiguration getConfig()
The configuration of a document.
XMLEntityResolver getEntityResolver()
Returns the registered entity resolver.
XMLErrorHandler getErrorHandler()
Returns the registered error handler.
boolean getFeature(String featureId)
Returns the state of a feature.
Boolean getFeatureDefault(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.
Locale getLocale()
Return the Locale the XMLGrammarLoader is using.
Object getParameter(String name)
DOMStringList getParameterNames()
Object getProperty(String propertyId)
Returns the state of a property.
Object getPropertyDefault(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.
String[] getRecognizedFeatures()
Returns a list of feature identifiers that are recognized by this XMLGrammarLoader.
String[] getRecognizedProperties()
Returns a list of property identifiers that are recognized by this XMLGrammarLoader.
XSModel load(LSInput is)
Parse an XML Schema document from a resource identified by a LSInput .
void loadGrammar(XMLInputSource[] source)
Returns a Grammar object by parsing the contents of the entities pointed to by sources.
Grammar loadGrammar(XMLInputSource source)
Returns a Grammar object by parsing the contents of the entity pointed to by source.
XSModel loadInputList(LSInputList is)
Parses the content of XML Schema documents specified as a list of LSInputs.
XSModel loadURI(String uri)
Parse an XML Schema document from a location identified by a URI reference.
XSModel loadURIList(StringList uriList)
Parses the content of XML Schema documents specified as the list of URI references.
static void processExternalHints(String sl, String nsl, Hashtable locations, XMLErrorReporter er)
void reset(XMLComponentManager componentManager)
Resets the component.
static XMLInputSource resolveDocument(XSDDescription desc, Hashtable locationPairs, XMLEntityResolver entityResolver)
This method tries to resolve location of the given schema.
void setEntityResolver(XMLEntityResolver entityResolver)
Sets the entity resolver.
void setErrorHandler(XMLErrorHandler errorHandler)
Sets the error handler.
void setFeature(String featureId, boolean state)
Sets the state of a feature.
void setLocale(Locale locale)
Set the locale to use for messages.
void setParameter(String name, Object value)
void setProperty(String propertyId, Object state)
Sets the state of a property.
static boolean tokenizeSchemaLocationStr(String schemaStr, Hashtable locations)
[Expand]
Inherited Methods
From class java.lang.Object
From interface org.apache.xerces.xni.grammars.XMLGrammarLoader
From interface org.apache.xerces.xni.parser.XMLComponent
From interface org.apache.xerces.xs.XSLoader
From interface org.w3c.dom.DOMConfiguration

Constants

protected static final String ALLOW_JAVA_ENCODINGS

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

Constant Value: "http://apache.org/xml/features/allow-java-encodings"

protected static final String AUGMENT_PSVI

Constant Value: "http://apache.org/xml/features/validation/schema/augment-psvi"

protected static final String CONTINUE_AFTER_FATAL_ERROR

Feature identifier: continue after fatal error.

Constant Value: "http://apache.org/xml/features/continue-after-fatal-error"

protected static final String DISALLOW_DOCTYPE

Feature: disallow doctype

Constant Value: "http://apache.org/xml/features/disallow-doctype-decl"

protected static final String ENTITY_MANAGER

Constant Value: "http://apache.org/xml/properties/internal/entity-manager"

public static final String ENTITY_RESOLVER

Property identifier: entity resolver.

Constant Value: "http://apache.org/xml/properties/internal/entity-resolver"

protected static final String ERROR_HANDLER

Property identifier: error handler.

Constant Value: "http://apache.org/xml/properties/internal/error-handler"

public static final String ERROR_REPORTER

Property identifier: error reporter.

Constant Value: "http://apache.org/xml/properties/internal/error-reporter"

protected static final String GENERATE_SYNTHETIC_ANNOTATIONS

Feature: generate synthetic annotations

Constant Value: "http://apache.org/xml/features/generate-synthetic-annotations"

protected static final String HONOUR_ALL_SCHEMALOCATIONS

Feature identifier: honour all schemaLocations

Constant Value: "http://apache.org/xml/features/honour-all-schemaLocations"

protected static final String JAXP_SCHEMA_SOURCE

Property identifier: JAXP schema source.

Constant Value: "http://java.sun.com/xml/jaxp/properties/schemaSource"

protected static final String PARSER_SETTINGS

Constant Value: "http://apache.org/xml/features/internal/parser-settings"

protected static final String SCHEMA_FULL_CHECKING

Feature identifier: schema full checking

Constant Value: "http://apache.org/xml/features/validation/schema-full-checking"

protected static final String SCHEMA_LOCATION

Property identifier: schema location.

Constant Value: "http://apache.org/xml/properties/schema/external-schemaLocation"

protected static final String SCHEMA_NONS_LOCATION

Property identifier: no namespace schema location.

Constant Value: "http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation"

protected static final String SECURITY_MANAGER

Constant Value: "http://apache.org/xml/properties/security-manager"

protected static final String STANDARD_URI_CONFORMANT_FEATURE

Feature identifier: standard uri conformant feature.

Constant Value: "http://apache.org/xml/features/standard-uri-conformant"

public static final String SYMBOL_TABLE

Property identifier: symbol table.

Constant Value: "http://apache.org/xml/properties/internal/symbol-table"

protected static final String VALIDATE_ANNOTATIONS

Feature identifier: validate annotations.

Constant Value: "http://apache.org/xml/features/validate-annotations"

public static final String XMLGRAMMAR_POOL

Property identifier: grammar pool.

Constant Value: "http://apache.org/xml/properties/internal/grammar-pool"

Public Constructors

public XMLSchemaLoader ()

public XMLSchemaLoader (SymbolTable symbolTable)

Public Methods

public boolean canSetParameter (String name, Object value)

public DOMConfiguration getConfig ()

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.

public XMLEntityResolver getEntityResolver ()

Returns the registered entity resolver.

public XMLErrorHandler getErrorHandler ()

Returns the registered error handler.

public boolean getFeature (String featureId)

Returns the state of a feature.

Parameters
featureId The feature identifier.
Throws
XMLConfigurationException Thrown on configuration error.

public Boolean getFeatureDefault (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.

Parameters
featureId The feature identifier.

public Locale getLocale ()

Return the Locale the XMLGrammarLoader is using.

public Object getParameter (String name)

Throws
DOMException

public DOMStringList getParameterNames ()

public Object getProperty (String propertyId)

Returns the state of a property.

Parameters
propertyId The property identifier.
Throws
XMLConfigurationException Thrown on configuration error.

public Object getPropertyDefault (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.

Parameters
propertyId The property identifier.

public String[] getRecognizedFeatures ()

Returns a list of feature identifiers that are recognized by this XMLGrammarLoader. This method may return null if no features are recognized.

public String[] getRecognizedProperties ()

Returns a list of property identifiers that are recognized by this XMLGrammarLoader. This method may return null if no properties are recognized.

public XSModel load (LSInput is)

Parse an XML Schema document from a resource identified by a LSInput .

Parameters
is The LSInput from which the source document is to be read.
Returns
  • An XSModel representing this schema.

public void loadGrammar (XMLInputSource[] source)

Returns a Grammar object by parsing the contents of the entities pointed to by sources.

Parameters
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
XNIException when a condition arises (such as a FatalError) that requires parsing of the entity be terminated

public Grammar loadGrammar (XMLInputSource source)

Returns a Grammar object by parsing the contents of the entity pointed to by source.

Parameters
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.
XNIException

public XSModel loadInputList (LSInputList is)

Parses the content of XML Schema documents specified as a list of LSInputs.

Parameters
is The list of LSInputs from which the XML Schema documents are to be read.
Returns
  • An XSModel representing the schema documents.

public XSModel loadURI (String uri)

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.

Parameters
uri The location of the XML Schema document to be read.
Returns
  • An XSModel representing this schema.

public XSModel loadURIList (StringList uriList)

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.

Parameters
uriList The list of URI locations.
Returns
  • An XSModel representing the schema documents.

public static void processExternalHints (String sl, String nsl, Hashtable locations, XMLErrorReporter er)

public void reset (XMLComponentManager componentManager)

Resets the component. The component can query the component manager about any features and properties that affect the operation of the component.

Parameters
componentManager The component manager.

public static XMLInputSource resolveDocument (XSDDescription desc, Hashtable locationPairs, 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.

Returns
  • the XMLInputSource
Throws
IOException

public void setEntityResolver (XMLEntityResolver entityResolver)

Sets the entity resolver.

Parameters
entityResolver The new entity resolver.

public void setErrorHandler (XMLErrorHandler errorHandler)

Sets the error handler.

Parameters
errorHandler The error handler.

public void setFeature (String featureId, boolean state)

Sets the state of a feature.

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

public void setLocale (Locale locale)

Set the locale to use for messages.

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

public void setParameter (String name, Object value)

Throws
DOMException

public void setProperty (String propertyId, Object state)

Sets the state of a property.

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

public static boolean tokenizeSchemaLocationStr (String schemaStr, Hashtable locations)