Package org.apache.xerces.impl.xs
Class XMLSchemaLoader
java.lang.Object
org.apache.xerces.impl.xs.XMLSchemaLoader
- All Implemented Interfaces:
XSElementDeclHelper
,org.apache.xerces.xni.grammars.XMLGrammarLoader
,org.apache.xerces.xni.parser.XMLComponent
,org.apache.xerces.xs.XSLoader
,DOMConfiguration
public class XMLSchemaLoader
extends Object
implements org.apache.xerces.xni.grammars.XMLGrammarLoader, org.apache.xerces.xni.parser.XMLComponent, XSElementDeclHelper, org.apache.xerces.xs.XSLoader, 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.
INTERNAL:
- Usage of this class is not supported. It may be altered or removed at any time.
- Version:
- $Id: XMLSchemaLoader.java 982466 2010-08-05 04:41:01Z mrglavas $
- Author:
- Neil Graham, IBM
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final String
Feature identifier: allow java encodings to be recognized when parsing schema docs.protected static final String
protected static final String
Feature identifier: continue after fatal error.protected static final String
Feature: disallow doctypeprotected static final String
static final String
Property identifier: entity resolver.protected static final String
Property identifier: error handler.static final String
Property identifier: error reporter.protected static final String
Feature: generate synthetic annotationsprotected static final String
Feature identifier: honour all schemaLocationsprotected static final String
Property identifier: JAXP schema source.protected static final String
Property identifier: locale.protected static final String
Feature identifier: namespace growthprotected static final String
protected static final String
Property identifier: Schema DV Factoryprotected static final String
Feature identifier: schema full checkingprotected static final String
Property identifier: schema location.protected static final String
Property identifier: no namespace schema location.protected static final String
protected static final String
Feature identifier: standard uri conformant feature.static final String
Property identifier: symbol table.protected static final String
Feature identifier: tolerate duplicatesprotected static final String
Feature identifier: validate annotations.static final String
Property identifier: grammar pool. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
canSetParameter
(String name, Object value) The configuration of a document.org.apache.xerces.xni.parser.XMLEntityResolver
Returns the registered entity resolver.org.apache.xerces.xni.parser.XMLErrorHandler
Returns the registered error handler.boolean
getFeature
(String featureId) Returns the state of a feature.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.getGlobalElementDecl
(org.apache.xerces.xni.QName element) Return the Locale the XMLGrammarLoader is using.getParameter
(String name) getProperty
(String propertyId) Returns the state of a property.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[]
Returns a list of feature identifiers that are recognized by this XMLGrammarLoader.String[]
Returns a list of property identifiers that are recognized by this XMLGrammarLoader.org.apache.xerces.xs.XSModel
Parse an XML Schema document from a resource identified by aLSInput
.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.void
loadGrammar
(org.apache.xerces.xni.parser.XMLInputSource[] source) Returns a Grammar object by parsing the contents of the entities pointed to by sources.org.apache.xerces.xs.XSModel
loadInputList
(org.apache.xerces.xs.LSInputList is) Parses the content of XML Schema documents specified as a list ofLSInput
s.org.apache.xerces.xs.XSModel
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
(String sl, String nsl, 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, 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
(String featureId, boolean state) Sets the state of a feature.void
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, String base)
-
Field Details
-
SCHEMA_FULL_CHECKING
Feature identifier: schema full checking- See Also:
-
CONTINUE_AFTER_FATAL_ERROR
Feature identifier: continue after fatal error.- See Also:
-
ALLOW_JAVA_ENCODINGS
Feature identifier: allow java encodings to be recognized when parsing schema docs.- See Also:
-
STANDARD_URI_CONFORMANT_FEATURE
Feature identifier: standard uri conformant feature.- See Also:
-
VALIDATE_ANNOTATIONS
Feature identifier: validate annotations.- See Also:
-
DISALLOW_DOCTYPE
Feature: disallow doctype- See Also:
-
GENERATE_SYNTHETIC_ANNOTATIONS
Feature: generate synthetic annotations- See Also:
-
HONOUR_ALL_SCHEMALOCATIONS
Feature identifier: honour all schemaLocations- See Also:
-
AUGMENT_PSVI
- See Also:
-
PARSER_SETTINGS
- See Also:
-
NAMESPACE_GROWTH
Feature identifier: namespace growth- See Also:
-
TOLERATE_DUPLICATES
Feature identifier: tolerate duplicates- See Also:
-
SCHEMA_DV_FACTORY
Property identifier: Schema DV Factory- See Also:
-
SYMBOL_TABLE
Property identifier: symbol table.- See Also:
-
ERROR_REPORTER
Property identifier: error reporter.- See Also:
-
ERROR_HANDLER
Property identifier: error handler.- See Also:
-
ENTITY_RESOLVER
Property identifier: entity resolver.- See Also:
-
XMLGRAMMAR_POOL
Property identifier: grammar pool.- See Also:
-
SCHEMA_LOCATION
Property identifier: schema location.- See Also:
-
SCHEMA_NONS_LOCATION
Property identifier: no namespace schema location.- See Also:
-
JAXP_SCHEMA_SOURCE
Property identifier: JAXP schema source.- See Also:
-
SECURITY_MANAGER
- See Also:
-
LOCALE
Property identifier: locale.- See Also:
-
ENTITY_MANAGER
- See Also:
-
-
Constructor Details
-
XMLSchemaLoader
public XMLSchemaLoader() -
XMLSchemaLoader
-
-
Method Details
-
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 interfaceorg.apache.xerces.xni.parser.XMLComponent
- Specified by:
getRecognizedFeatures
in interfaceorg.apache.xerces.xni.grammars.XMLGrammarLoader
-
getFeature
public boolean getFeature(String featureId) throws org.apache.xerces.xni.parser.XMLConfigurationException Returns the state of a feature.- Specified by:
getFeature
in interfaceorg.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(String featureId, boolean state) throws org.apache.xerces.xni.parser.XMLConfigurationException Sets the state of a feature.- Specified by:
setFeature
in interfaceorg.apache.xerces.xni.parser.XMLComponent
- Specified by:
setFeature
in interfaceorg.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
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 interfaceorg.apache.xerces.xni.parser.XMLComponent
- Specified by:
getRecognizedProperties
in interfaceorg.apache.xerces.xni.grammars.XMLGrammarLoader
-
getProperty
public Object getProperty(String propertyId) throws org.apache.xerces.xni.parser.XMLConfigurationException Returns the state of a property.- Specified by:
getProperty
in interfaceorg.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(String propertyId, Object state) throws org.apache.xerces.xni.parser.XMLConfigurationException Sets the state of a property.- Specified by:
setProperty
in interfaceorg.apache.xerces.xni.parser.XMLComponent
- Specified by:
setProperty
in interfaceorg.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
Set the locale to use for messages.- Specified by:
setLocale
in interfaceorg.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
Return the Locale the XMLGrammarLoader is using.- Specified by:
getLocale
in interfaceorg.apache.xerces.xni.grammars.XMLGrammarLoader
-
setErrorHandler
public void setErrorHandler(org.apache.xerces.xni.parser.XMLErrorHandler errorHandler) Sets the error handler.- Specified by:
setErrorHandler
in interfaceorg.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 interfaceorg.apache.xerces.xni.grammars.XMLGrammarLoader
-
setEntityResolver
public void setEntityResolver(org.apache.xerces.xni.parser.XMLEntityResolver entityResolver) Sets the entity resolver.- Specified by:
setEntityResolver
in interfaceorg.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 interfaceorg.apache.xerces.xni.grammars.XMLGrammarLoader
-
loadGrammar
public void loadGrammar(org.apache.xerces.xni.parser.XMLInputSource[] source) throws IOException, org.apache.xerces.xni.XNIException 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 entityorg.apache.xerces.xni.XNIException
- when a condition arises (such as a FatalError) that requires parsing of the entity be terminated
-
loadGrammar
public org.apache.xerces.xni.grammars.Grammar loadGrammar(org.apache.xerces.xni.parser.XMLInputSource source) throws 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 interfaceorg.apache.xerces.xni.grammars.XMLGrammarLoader
- 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.org.apache.xerces.xni.XNIException
-
resolveDocument
public static org.apache.xerces.xni.parser.XMLInputSource resolveDocument(XSDDescription desc, Hashtable locationPairs, org.apache.xerces.xni.parser.XMLEntityResolver entityResolver) throws 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:
- the XMLInputSource
- Throws:
IOException
-
processExternalHints
public static void processExternalHints(String sl, String nsl, Hashtable locations, XMLErrorReporter er) -
tokenizeSchemaLocationStr
-
getFeatureDefault
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 interfaceorg.apache.xerces.xni.parser.XMLComponent
- Parameters:
featureId
- The feature identifier.
-
getPropertyDefault
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 interfaceorg.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 interfaceorg.apache.xerces.xni.parser.XMLComponent
- Parameters:
componentManager
- The component manager.- Throws:
org.apache.xerces.xni.parser.XMLConfigurationException
-
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 theDOMConfiguration
interface:error-handler
(DOMErrorHandler
) andresource-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 interfaceorg.apache.xerces.xs.XSLoader
-
-
load
Description copied from interface:org.apache.xerces.xs.XSLoader
Parse an XML Schema document from a resource identified by aLSInput
.- Specified by:
load
in interfaceorg.apache.xerces.xs.XSLoader
- Parameters:
is
- TheLSInput
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 ofLSInput
s.- Specified by:
loadInputList
in interfaceorg.apache.xerces.xs.XSLoader
- Parameters:
is
- The list ofLSInput
s from which the XML Schema documents are to be read.- Returns:
- An XSModel representing the schema documents.
-
loadURI
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 interfaceorg.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 interfaceorg.apache.xerces.xs.XSLoader
- Parameters:
uriList
- The list of URI locations.- Returns:
- An XSModel representing the schema documents.
-
canSetParameter
- Specified by:
canSetParameter
in interfaceDOMConfiguration
-
getParameter
- Specified by:
getParameter
in interfaceDOMConfiguration
- Throws:
DOMException
-
getParameterNames
- Specified by:
getParameterNames
in interfaceDOMConfiguration
-
setParameter
- Specified by:
setParameter
in interfaceDOMConfiguration
- Throws:
DOMException
-
getGlobalElementDecl
- Specified by:
getGlobalElementDecl
in interfaceXSElementDeclHelper
-