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,org.w3c.dom.DOMConfiguration
public class XMLSchemaLoader extends java.lang.Object implements org.apache.xerces.xni.grammars.XMLGrammarLoader, org.apache.xerces.xni.parser.XMLComponent, XSElementDeclHelper, org.apache.xerces.xs.XSLoader, org.w3c.dom.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
Fields Modifier and Type Field Description protected static java.lang.StringALLOW_JAVA_ENCODINGSFeature identifier: allow java encodings to be recognized when parsing schema docs.protected static java.lang.StringAUGMENT_PSVIprotected static java.lang.StringCONTINUE_AFTER_FATAL_ERRORFeature identifier: continue after fatal error.protected static java.lang.StringDISALLOW_DOCTYPEFeature: disallow doctypeprotected static java.lang.StringENTITY_MANAGERstatic java.lang.StringENTITY_RESOLVERProperty identifier: entity resolver.protected static java.lang.StringERROR_HANDLERProperty identifier: error handler.static java.lang.StringERROR_REPORTERProperty identifier: error reporter.protected static java.lang.StringGENERATE_SYNTHETIC_ANNOTATIONSFeature: generate synthetic annotationsprotected static java.lang.StringHONOUR_ALL_SCHEMALOCATIONSFeature identifier: honour all schemaLocationsprotected static java.lang.StringJAXP_SCHEMA_SOURCEProperty identifier: JAXP schema source.protected static java.lang.StringLOCALEProperty identifier: locale.protected static java.lang.StringNAMESPACE_GROWTHFeature identifier: namespace growthprotected static java.lang.StringPARSER_SETTINGSprotected static java.lang.StringSCHEMA_DV_FACTORYProperty identifier: Schema DV Factoryprotected static java.lang.StringSCHEMA_FULL_CHECKINGFeature identifier: schema full checkingprotected static java.lang.StringSCHEMA_LOCATIONProperty identifier: schema location.protected static java.lang.StringSCHEMA_NONS_LOCATIONProperty identifier: no namespace schema location.protected static java.lang.StringSECURITY_MANAGERprotected static java.lang.StringSTANDARD_URI_CONFORMANT_FEATUREFeature identifier: standard uri conformant feature.static java.lang.StringSYMBOL_TABLEProperty identifier: symbol table.protected static java.lang.StringTOLERATE_DUPLICATESFeature identifier: tolerate duplicatesprotected static java.lang.StringVALIDATE_ANNOTATIONSFeature identifier: validate annotations.static java.lang.StringXMLGRAMMAR_POOLProperty identifier: grammar pool.
-
Constructor Summary
Constructors Constructor Description XMLSchemaLoader()XMLSchemaLoader(SymbolTable symbolTable)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancanSetParameter(java.lang.String name, java.lang.Object value)org.w3c.dom.DOMConfigurationgetConfig()The configuration of a document.org.apache.xerces.xni.parser.XMLEntityResolvergetEntityResolver()Returns the registered entity resolver.org.apache.xerces.xni.parser.XMLErrorHandlergetErrorHandler()Returns the registered error handler.booleangetFeature(java.lang.String featureId)Returns the state of a feature.java.lang.BooleangetFeatureDefault(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.XSElementDeclgetGlobalElementDecl(org.apache.xerces.xni.QName element)java.util.LocalegetLocale()Return the Locale the XMLGrammarLoader is using.java.lang.ObjectgetParameter(java.lang.String name)org.w3c.dom.DOMStringListgetParameterNames()java.lang.ObjectgetProperty(java.lang.String propertyId)Returns the state of a property.java.lang.ObjectgetPropertyDefault(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.XSModelload(org.w3c.dom.ls.LSInput is)Parse an XML Schema document from a resource identified by aLSInput.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.voidloadGrammar(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.XSModelloadInputList(org.apache.xerces.xs.LSInputList is)Parses the content of XML Schema documents specified as a list ofLSInputs.org.apache.xerces.xs.XSModelloadURI(java.lang.String uri)Parse an XML Schema document from a location identified by a URI reference.org.apache.xerces.xs.XSModelloadURIList(org.apache.xerces.xs.StringList uriList)Parses the content of XML Schema documents specified as the list of URI references.static voidprocessExternalHints(java.lang.String sl, java.lang.String nsl, java.util.Hashtable locations, XMLErrorReporter er)voidreset(org.apache.xerces.xni.parser.XMLComponentManager componentManager)Resets the component.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.voidsetEntityResolver(org.apache.xerces.xni.parser.XMLEntityResolver entityResolver)Sets the entity resolver.voidsetErrorHandler(org.apache.xerces.xni.parser.XMLErrorHandler errorHandler)Sets the error handler.voidsetFeature(java.lang.String featureId, boolean state)Sets the state of a feature.voidsetLocale(java.util.Locale locale)Set the locale to use for messages.voidsetParameter(java.lang.String name, java.lang.Object value)voidsetProperty(java.lang.String propertyId, java.lang.Object state)Sets the state of a property.static booleantokenizeSchemaLocationStr(java.lang.String schemaStr, java.util.Hashtable locations, java.lang.String base)
-
-
-
Field Detail
-
SCHEMA_FULL_CHECKING
protected static final java.lang.String SCHEMA_FULL_CHECKING
Feature identifier: schema full checking- See Also:
- Constant Field Values
-
CONTINUE_AFTER_FATAL_ERROR
protected static final java.lang.String CONTINUE_AFTER_FATAL_ERROR
Feature identifier: continue after fatal error.- See Also:
- Constant Field Values
-
ALLOW_JAVA_ENCODINGS
protected static final java.lang.String ALLOW_JAVA_ENCODINGS
Feature identifier: allow java encodings to be recognized when parsing schema docs.- See Also:
- Constant Field Values
-
STANDARD_URI_CONFORMANT_FEATURE
protected static final java.lang.String STANDARD_URI_CONFORMANT_FEATURE
Feature identifier: standard uri conformant feature.- See Also:
- Constant Field Values
-
VALIDATE_ANNOTATIONS
protected static final java.lang.String VALIDATE_ANNOTATIONS
Feature identifier: validate annotations.- See Also:
- Constant Field Values
-
DISALLOW_DOCTYPE
protected static final java.lang.String DISALLOW_DOCTYPE
Feature: disallow doctype- See Also:
- Constant Field Values
-
GENERATE_SYNTHETIC_ANNOTATIONS
protected static final java.lang.String GENERATE_SYNTHETIC_ANNOTATIONS
Feature: generate synthetic annotations- See Also:
- Constant Field Values
-
HONOUR_ALL_SCHEMALOCATIONS
protected static final java.lang.String HONOUR_ALL_SCHEMALOCATIONS
Feature identifier: honour all schemaLocations- See Also:
- Constant Field Values
-
AUGMENT_PSVI
protected static final java.lang.String AUGMENT_PSVI
- See Also:
- Constant Field Values
-
PARSER_SETTINGS
protected static final java.lang.String PARSER_SETTINGS
- See Also:
- Constant Field Values
-
NAMESPACE_GROWTH
protected static final java.lang.String NAMESPACE_GROWTH
Feature identifier: namespace growth- See Also:
- Constant Field Values
-
TOLERATE_DUPLICATES
protected static final java.lang.String TOLERATE_DUPLICATES
Feature identifier: tolerate duplicates- See Also:
- Constant Field Values
-
SCHEMA_DV_FACTORY
protected static final java.lang.String SCHEMA_DV_FACTORY
Property identifier: Schema DV Factory- See Also:
- Constant Field Values
-
SYMBOL_TABLE
public static final java.lang.String SYMBOL_TABLE
Property identifier: symbol table.- See Also:
- Constant Field Values
-
ERROR_REPORTER
public static final java.lang.String ERROR_REPORTER
Property identifier: error reporter.- See Also:
- Constant Field Values
-
ERROR_HANDLER
protected static final java.lang.String ERROR_HANDLER
Property identifier: error handler.- See Also:
- Constant Field Values
-
ENTITY_RESOLVER
public static final java.lang.String ENTITY_RESOLVER
Property identifier: entity resolver.- See Also:
- Constant Field Values
-
XMLGRAMMAR_POOL
public static final java.lang.String XMLGRAMMAR_POOL
Property identifier: grammar pool.- See Also:
- Constant Field Values
-
SCHEMA_LOCATION
protected static final java.lang.String SCHEMA_LOCATION
Property identifier: schema location.- See Also:
- Constant Field Values
-
SCHEMA_NONS_LOCATION
protected static final java.lang.String SCHEMA_NONS_LOCATION
Property identifier: no namespace schema location.- See Also:
- Constant Field Values
-
JAXP_SCHEMA_SOURCE
protected static final java.lang.String JAXP_SCHEMA_SOURCE
Property identifier: JAXP schema source.- See Also:
- Constant Field Values
-
SECURITY_MANAGER
protected static final java.lang.String SECURITY_MANAGER
- See Also:
- Constant Field Values
-
LOCALE
protected static final java.lang.String LOCALE
Property identifier: locale.- See Also:
- Constant Field Values
-
ENTITY_MANAGER
protected static final java.lang.String ENTITY_MANAGER
- See Also:
- Constant Field Values
-
-
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:
getRecognizedFeaturesin interfaceorg.apache.xerces.xni.parser.XMLComponent- Specified by:
getRecognizedFeaturesin interfaceorg.apache.xerces.xni.grammars.XMLGrammarLoader
-
getFeature
public boolean getFeature(java.lang.String featureId) throws org.apache.xerces.xni.parser.XMLConfigurationExceptionReturns the state of a feature.- Specified by:
getFeaturein 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(java.lang.String featureId, boolean state) throws org.apache.xerces.xni.parser.XMLConfigurationExceptionSets the state of a feature.- Specified by:
setFeaturein interfaceorg.apache.xerces.xni.parser.XMLComponent- Specified by:
setFeaturein 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
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:
getRecognizedPropertiesin interfaceorg.apache.xerces.xni.parser.XMLComponent- Specified by:
getRecognizedPropertiesin interfaceorg.apache.xerces.xni.grammars.XMLGrammarLoader
-
getProperty
public java.lang.Object getProperty(java.lang.String propertyId) throws org.apache.xerces.xni.parser.XMLConfigurationExceptionReturns the state of a property.- Specified by:
getPropertyin 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(java.lang.String propertyId, java.lang.Object state) throws org.apache.xerces.xni.parser.XMLConfigurationExceptionSets the state of a property.- Specified by:
setPropertyin interfaceorg.apache.xerces.xni.parser.XMLComponent- Specified by:
setPropertyin 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
public void setLocale(java.util.Locale locale)
Set the locale to use for messages.- Specified by:
setLocalein 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
public java.util.Locale getLocale()
Return the Locale the XMLGrammarLoader is using.- Specified by:
getLocalein interfaceorg.apache.xerces.xni.grammars.XMLGrammarLoader
-
setErrorHandler
public void setErrorHandler(org.apache.xerces.xni.parser.XMLErrorHandler errorHandler)
Sets the error handler.- Specified by:
setErrorHandlerin 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:
getErrorHandlerin interfaceorg.apache.xerces.xni.grammars.XMLGrammarLoader
-
setEntityResolver
public void setEntityResolver(org.apache.xerces.xni.parser.XMLEntityResolver entityResolver)
Sets the entity resolver.- Specified by:
setEntityResolverin 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:
getEntityResolverin interfaceorg.apache.xerces.xni.grammars.XMLGrammarLoader
-
loadGrammar
public void loadGrammar(org.apache.xerces.xni.parser.XMLInputSource[] source) throws java.io.IOException, org.apache.xerces.xni.XNIExceptionReturns 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:
java.io.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 java.io.IOException, org.apache.xerces.xni.XNIExceptionReturns a Grammar object by parsing the contents of the entity pointed to by source.- Specified by:
loadGrammarin 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:
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.org.apache.xerces.xni.XNIException
-
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:
- the XMLInputSource
- 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, java.lang.String base)
-
getFeatureDefault
public java.lang.Boolean getFeatureDefault(java.lang.String featureId)
Description copied from interface:org.apache.xerces.xni.parser.XMLComponentReturns the default state for a feature, or null if this component does not want to report a default value for this feature.- Specified by:
getFeatureDefaultin interfaceorg.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.XMLComponentReturns the default state for a property, or null if this component does not want to report a default value for this property.- Specified by:
getPropertyDefaultin 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.XMLConfigurationExceptionDescription copied from interface:org.apache.xerces.xni.parser.XMLComponentResets the component. The component can query the component manager about any features and properties that affect the operation of the component.- Specified by:
resetin interfaceorg.apache.xerces.xni.parser.XMLComponent- Parameters:
componentManager- The component manager.- Throws:
org.apache.xerces.xni.parser.XMLConfigurationException
-
getConfig
public org.w3c.dom.DOMConfiguration getConfig()
Description copied from interface:org.apache.xerces.xs.XSLoaderThe 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 theDOMConfigurationinterface: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:
getConfigin interfaceorg.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.XSLoaderParse an XML Schema document from a resource identified by aLSInput.- Specified by:
loadin interfaceorg.apache.xerces.xs.XSLoader- Parameters:
is- TheLSInputfrom 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.XSLoaderParses the content of XML Schema documents specified as a list ofLSInputs.- Specified by:
loadInputListin interfaceorg.apache.xerces.xs.XSLoader- Parameters:
is- The list ofLSInputs 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.XSLoaderParse 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:
loadURIin 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.XSLoaderParses 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:
loadURIListin interfaceorg.apache.xerces.xs.XSLoader- Parameters:
uriList- The list of URI locations.- Returns:
- An XSModel representing the schema documents.
-
canSetParameter
public boolean canSetParameter(java.lang.String name, java.lang.Object value)- Specified by:
canSetParameterin interfaceorg.w3c.dom.DOMConfiguration
-
getParameter
public java.lang.Object getParameter(java.lang.String name) throws org.w3c.dom.DOMException- Specified by:
getParameterin interfaceorg.w3c.dom.DOMConfiguration- Throws:
org.w3c.dom.DOMException
-
getParameterNames
public org.w3c.dom.DOMStringList getParameterNames()
- Specified by:
getParameterNamesin interfaceorg.w3c.dom.DOMConfiguration
-
setParameter
public void setParameter(java.lang.String name, java.lang.Object value) throws org.w3c.dom.DOMException- Specified by:
setParameterin interfaceorg.w3c.dom.DOMConfiguration- Throws:
org.w3c.dom.DOMException
-
getGlobalElementDecl
public XSElementDecl getGlobalElementDecl(org.apache.xerces.xni.QName element)
- Specified by:
getGlobalElementDeclin interfaceXSElementDeclHelper
-
-