Class XMLSchemaLoader
- java.lang.Object
-
- org.smooks.engine.delivery.sax.ng.org.apache.xerces.impl.xs.XMLSchemaLoader
-
- All Implemented Interfaces:
XSElementDeclHelper,XMLGrammarLoader,XMLComponent,XSLoader,DOMConfiguration
public class XMLSchemaLoader extends Object implements XMLGrammarLoader, XMLComponent, XSElementDeclHelper, 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.
- Version:
- $Id$
- Author:
- Neil Graham, IBM
-
-
Field Summary
Fields Modifier and Type Field Description protected static StringALLOW_JAVA_ENCODINGSFeature identifier: allow java encodings to be recognized when parsing schema docs.protected static StringAUGMENT_PSVIprotected static StringCONTINUE_AFTER_FATAL_ERRORFeature identifier: continue after fatal error.protected static StringDISALLOW_DOCTYPEFeature: disallow doctypeprotected static StringENTITY_MANAGERstatic StringENTITY_RESOLVERProperty identifier: entity resolver.protected static StringERROR_HANDLERProperty identifier: error handler.static StringERROR_REPORTERProperty identifier: error reporter.protected static StringGENERATE_SYNTHETIC_ANNOTATIONSFeature: generate synthetic annotationsprotected static StringHONOUR_ALL_SCHEMALOCATIONSFeature identifier: honour all schemaLocationsprotected static StringJAXP_SCHEMA_SOURCEProperty identifier: JAXP schema source.protected static StringLOCALEProperty identifier: locale.protected static StringNAMESPACE_GROWTHFeature identifier: namespace growthprotected static StringPARSER_SETTINGSprotected static StringSCHEMA_DV_FACTORYProperty identifier: Schema DV Factoryprotected static StringSCHEMA_FULL_CHECKINGFeature identifier: schema full checkingprotected static StringSCHEMA_LOCATIONProperty identifier: schema location.protected static StringSCHEMA_NONS_LOCATIONProperty identifier: no namespace schema location.protected static StringSECURITY_MANAGERprotected static StringSTANDARD_URI_CONFORMANT_FEATUREFeature identifier: standard uri conformant feature.static StringSYMBOL_TABLEProperty identifier: symbol table.protected static StringTOLERATE_DUPLICATESFeature identifier: tolerate duplicatesprotected static StringVALIDATE_ANNOTATIONSFeature identifier: validate annotations.static 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(String name, Object value)DOMConfigurationgetConfig()The configuration of a document.XMLEntityResolvergetEntityResolver()Returns the registered entity resolver.XMLErrorHandlergetErrorHandler()Returns the registered error handler.booleangetFeature(String featureId)Returns the state of a feature.BooleangetFeatureDefault(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(QName element)LocalegetLocale()Return the Locale the XMLGrammarLoader is using.ObjectgetParameter(String name)DOMStringListgetParameterNames()ObjectgetProperty(String propertyId)Returns the state of a property.ObjectgetPropertyDefault(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.XSModelload(LSInput is)Parse an XML Schema document from a resource identified by aLSInput.GrammarloadGrammar(XMLInputSource source)Returns a Grammar object by parsing the contents of the entity pointed to by source.voidloadGrammar(XMLInputSource[] source)Returns a Grammar object by parsing the contents of the entities pointed to by sources.XSModelloadInputList(LSInputList is)Parses the content of XML Schema documents specified as a list ofLSInputs.XSModelloadURI(String uri)Parse an XML Schema document from a location identified by a URI reference.XSModelloadURIList(StringList uriList)Parses the content of XML Schema documents specified as the list of URI references.static voidprocessExternalHints(String sl, String nsl, Hashtable locations, XMLErrorReporter er)voidreset(XMLComponentManager componentManager)Resets the component.static XMLInputSourceresolveDocument(XSDDescription desc, Hashtable locationPairs, XMLEntityResolver entityResolver)This method tries to resolve location of the given schema.voidsetEntityResolver(XMLEntityResolver entityResolver)Sets the entity resolver.voidsetErrorHandler(XMLErrorHandler errorHandler)Sets the error handler.voidsetFeature(String featureId, boolean state)Sets the state of a feature.voidsetLocale(Locale locale)Set the locale to use for messages.voidsetParameter(String name, Object value)voidsetProperty(String propertyId, Object state)Sets the state of a property.static booleantokenizeSchemaLocationStr(String schemaStr, Hashtable locations, String base)
-
-
-
Field Detail
-
SCHEMA_FULL_CHECKING
protected static final String SCHEMA_FULL_CHECKING
Feature identifier: schema full checking- See Also:
- Constant Field Values
-
CONTINUE_AFTER_FATAL_ERROR
protected static final String CONTINUE_AFTER_FATAL_ERROR
Feature identifier: continue after fatal error.- See Also:
- Constant Field Values
-
ALLOW_JAVA_ENCODINGS
protected static final 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 String STANDARD_URI_CONFORMANT_FEATURE
Feature identifier: standard uri conformant feature.- See Also:
- Constant Field Values
-
VALIDATE_ANNOTATIONS
protected static final String VALIDATE_ANNOTATIONS
Feature identifier: validate annotations.- See Also:
- Constant Field Values
-
DISALLOW_DOCTYPE
protected static final String DISALLOW_DOCTYPE
Feature: disallow doctype- See Also:
- Constant Field Values
-
GENERATE_SYNTHETIC_ANNOTATIONS
protected static final String GENERATE_SYNTHETIC_ANNOTATIONS
Feature: generate synthetic annotations- See Also:
- Constant Field Values
-
HONOUR_ALL_SCHEMALOCATIONS
protected static final String HONOUR_ALL_SCHEMALOCATIONS
Feature identifier: honour all schemaLocations- See Also:
- Constant Field Values
-
AUGMENT_PSVI
protected static final String AUGMENT_PSVI
- See Also:
- Constant Field Values
-
PARSER_SETTINGS
protected static final String PARSER_SETTINGS
- See Also:
- Constant Field Values
-
NAMESPACE_GROWTH
protected static final String NAMESPACE_GROWTH
Feature identifier: namespace growth- See Also:
- Constant Field Values
-
TOLERATE_DUPLICATES
protected static final String TOLERATE_DUPLICATES
Feature identifier: tolerate duplicates- See Also:
- Constant Field Values
-
SCHEMA_DV_FACTORY
protected static final String SCHEMA_DV_FACTORY
Property identifier: Schema DV Factory- See Also:
- Constant Field Values
-
SYMBOL_TABLE
public static final String SYMBOL_TABLE
Property identifier: symbol table.- See Also:
- Constant Field Values
-
ERROR_REPORTER
public static final String ERROR_REPORTER
Property identifier: error reporter.- See Also:
- Constant Field Values
-
ERROR_HANDLER
protected static final String ERROR_HANDLER
Property identifier: error handler.- See Also:
- Constant Field Values
-
ENTITY_RESOLVER
public static final String ENTITY_RESOLVER
Property identifier: entity resolver.- See Also:
- Constant Field Values
-
XMLGRAMMAR_POOL
public static final String XMLGRAMMAR_POOL
Property identifier: grammar pool.- See Also:
- Constant Field Values
-
SCHEMA_LOCATION
protected static final String SCHEMA_LOCATION
Property identifier: schema location.- See Also:
- Constant Field Values
-
SCHEMA_NONS_LOCATION
protected static final String SCHEMA_NONS_LOCATION
Property identifier: no namespace schema location.- See Also:
- Constant Field Values
-
JAXP_SCHEMA_SOURCE
protected static final String JAXP_SCHEMA_SOURCE
Property identifier: JAXP schema source.- See Also:
- Constant Field Values
-
SECURITY_MANAGER
protected static final String SECURITY_MANAGER
- See Also:
- Constant Field Values
-
LOCALE
protected static final String LOCALE
Property identifier: locale.- See Also:
- Constant Field Values
-
ENTITY_MANAGER
protected static final String ENTITY_MANAGER
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
XMLSchemaLoader
public XMLSchemaLoader()
-
XMLSchemaLoader
public XMLSchemaLoader(SymbolTable symbolTable)
-
-
Method Detail
-
getRecognizedFeatures
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.- Specified by:
getRecognizedFeaturesin interfaceXMLComponent- Specified by:
getRecognizedFeaturesin interfaceXMLGrammarLoader
-
getFeature
public boolean getFeature(String featureId) throws XMLConfigurationException
Returns the state of a feature.- Specified by:
getFeaturein interfaceXMLGrammarLoader- Parameters:
featureId- The feature identifier.- Throws:
XMLConfigurationException- Thrown on configuration error.
-
setFeature
public void setFeature(String featureId, boolean state) throws XMLConfigurationException
Sets the state of a feature.- Specified by:
setFeaturein interfaceXMLComponent- Specified by:
setFeaturein interfaceXMLGrammarLoader- Parameters:
featureId- The feature identifier.state- The state of the feature.- Throws:
XMLConfigurationException- Thrown when a feature is not recognized or cannot be set.
-
getRecognizedProperties
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.- Specified by:
getRecognizedPropertiesin interfaceXMLComponent- Specified by:
getRecognizedPropertiesin interfaceXMLGrammarLoader
-
getProperty
public Object getProperty(String propertyId) throws XMLConfigurationException
Returns the state of a property.- Specified by:
getPropertyin interfaceXMLGrammarLoader- Parameters:
propertyId- The property identifier.- Throws:
XMLConfigurationException- Thrown on configuration error.
-
setProperty
public void setProperty(String propertyId, Object state) throws XMLConfigurationException
Sets the state of a property.- Specified by:
setPropertyin interfaceXMLComponent- Specified by:
setPropertyin interfaceXMLGrammarLoader- Parameters:
propertyId- The property identifier.state- The state of the property.- Throws:
XMLConfigurationException- Thrown when a property is not recognized or cannot be set.
-
setLocale
public void setLocale(Locale locale)
Set the locale to use for messages.- Specified by:
setLocalein interfaceXMLGrammarLoader- Parameters:
locale- The locale object to use for localization of messages.- Throws:
XNIException- Thrown if the parser does not support the specified locale.
-
getLocale
public Locale getLocale()
Return the Locale the XMLGrammarLoader is using.- Specified by:
getLocalein interfaceXMLGrammarLoader
-
setErrorHandler
public void setErrorHandler(XMLErrorHandler errorHandler)
Sets the error handler.- Specified by:
setErrorHandlerin interfaceXMLGrammarLoader- Parameters:
errorHandler- The error handler.
-
getErrorHandler
public XMLErrorHandler getErrorHandler()
Returns the registered error handler.- Specified by:
getErrorHandlerin interfaceXMLGrammarLoader
-
setEntityResolver
public void setEntityResolver(XMLEntityResolver entityResolver)
Sets the entity resolver.- Specified by:
setEntityResolverin interfaceXMLGrammarLoader- Parameters:
entityResolver- The new entity resolver.
-
getEntityResolver
public XMLEntityResolver getEntityResolver()
Returns the registered entity resolver.- Specified by:
getEntityResolverin interfaceXMLGrammarLoader
-
loadGrammar
public void loadGrammar(XMLInputSource[] source) throws IOException, 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 entityXNIException- when a condition arises (such as a FatalError) that requires parsing of the entity be terminated
-
loadGrammar
public Grammar loadGrammar(XMLInputSource source) throws IOException, XNIException
Returns a Grammar object by parsing the contents of the entity pointed to by source.- Specified by:
loadGrammarin interfaceXMLGrammarLoader- 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
-
resolveDocument
public static XMLInputSource resolveDocument(XSDDescription desc, Hashtable locationPairs, 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
public static boolean tokenizeSchemaLocationStr(String schemaStr, Hashtable locations, String base)
-
getFeatureDefault
public Boolean getFeatureDefault(String featureId)
Description copied from interface: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 interfaceXMLComponent- Parameters:
featureId- The feature identifier.
-
getPropertyDefault
public Object getPropertyDefault(String propertyId)
Description copied from interface: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 interfaceXMLComponent- Parameters:
propertyId- The property identifier.
-
reset
public void reset(XMLComponentManager componentManager) throws XMLConfigurationException
Description copied from interface: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 interfaceXMLComponent- Parameters:
componentManager- The component manager.- Throws:
XMLConfigurationException
-
getConfig
public DOMConfiguration getConfig()
Description copied from interface: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.
-
-
load
public XSModel load(LSInput is)
Description copied from interface:XSLoaderParse an XML Schema document from a resource identified by aLSInput.
-
loadInputList
public XSModel loadInputList(LSInputList is)
Description copied from interface:XSLoaderParses the content of XML Schema documents specified as a list ofLSInputs.- Specified by:
loadInputListin interfaceXSLoader- Parameters:
is- The list ofLSInputs from which the XML Schema documents are to be read.- Returns:
- An XSModel representing the schema documents.
-
loadURI
public XSModel loadURI(String uri)
Description copied from interface: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.
-
loadURIList
public XSModel loadURIList(StringList uriList)
Description copied from interface: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 interfaceXSLoader- Parameters:
uriList- The list of URI locations.- Returns:
- An XSModel representing the schema documents.
-
canSetParameter
public boolean canSetParameter(String name, Object value)
- Specified by:
canSetParameterin interfaceDOMConfiguration
-
getParameter
public Object getParameter(String name) throws DOMException
- Specified by:
getParameterin interfaceDOMConfiguration- Throws:
DOMException
-
getParameterNames
public DOMStringList getParameterNames()
- Specified by:
getParameterNamesin interfaceDOMConfiguration
-
setParameter
public void setParameter(String name, Object value) throws DOMException
- Specified by:
setParameterin interfaceDOMConfiguration- Throws:
DOMException
-
getGlobalElementDecl
public XSElementDecl getGlobalElementDecl(QName element)
- Specified by:
getGlobalElementDeclin interfaceXSElementDeclHelper
-
-