org.apache.xerces.impl.xs

Class XMLSchemaLoader

Implemented Interfaces:
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, 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.42 2005/07/25 04:54:15 mrglavas Exp $
Author:
Neil Graham, IBM

Field Summary

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

Constructor Summary

XMLSchemaLoader()
XMLSchemaLoader(SymbolTable symbolTable)

Method Summary

boolean
canSetParameter(String name, Object value)
DOMConfiguration
getConfig()
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(String featureId)
Returns the state of a feature.
Boolean
getFeatureDefault(String featureId)
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)
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.
org.apache.xerces.xs.XSModel
load(LSInput is)
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(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)
org.apache.xerces.xs.XSModel
loadURI(String uri)
org.apache.xerces.xs.XSModel
loadURIList(org.apache.xerces.xs.StringList uriList)
static void
processExternalHints(String sl, String nsl, Hashtable locations, XMLErrorReporter er)
void
reset(org.apache.xerces.xni.parser.XMLComponentManager componentManager)
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
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)

Field Details

ALLOW_JAVA_ENCODINGS

protected static final String ALLOW_JAVA_ENCODINGS
Feature identifier: allow java encodings to be recognized when parsing schema docs.

AUGMENT_PSVI

protected static final String AUGMENT_PSVI

CONTINUE_AFTER_FATAL_ERROR

protected static final String CONTINUE_AFTER_FATAL_ERROR
Feature identifier: continue after fatal error.

DISALLOW_DOCTYPE

protected static final String DISALLOW_DOCTYPE
Feature: disallow doctype

ENTITY_MANAGER

protected static final String ENTITY_MANAGER

ENTITY_RESOLVER

public static final String ENTITY_RESOLVER
Property identifier: entity resolver.

ERROR_HANDLER

protected static final String ERROR_HANDLER
Property identifier: error handler.

ERROR_REPORTER

public static final String ERROR_REPORTER
Property identifier: error reporter.

GENERATE_SYNTHETIC_ANNOTATIONS

protected static final String GENERATE_SYNTHETIC_ANNOTATIONS
Feature: generate synthetic annotations

HONOUR_ALL_SCHEMALOCATIONS

protected static final String HONOUR_ALL_SCHEMALOCATIONS
Feature identifier: honour all schemaLocations

JAXP_SCHEMA_SOURCE

protected static final String JAXP_SCHEMA_SOURCE
Property identifier: JAXP schema source.

PARSER_SETTINGS

protected static final String PARSER_SETTINGS

SCHEMA_FULL_CHECKING

protected static final String SCHEMA_FULL_CHECKING
Feature identifier: schema full checking

SCHEMA_LOCATION

protected static final String SCHEMA_LOCATION
Property identifier: schema location.

SCHEMA_NONS_LOCATION

protected static final String SCHEMA_NONS_LOCATION
Property identifier: no namespace schema location.

SECURITY_MANAGER

protected static final String SECURITY_MANAGER

STANDARD_URI_CONFORMANT_FEATURE

protected static final String STANDARD_URI_CONFORMANT_FEATURE
Feature identifier: standard uri conformant feature.

SYMBOL_TABLE

public static final String SYMBOL_TABLE
Property identifier: symbol table.

VALIDATE_ANNOTATIONS

protected static final String VALIDATE_ANNOTATIONS
Feature identifier: validate annotations.

XMLGRAMMAR_POOL

public static final String XMLGRAMMAR_POOL
Property identifier: grammar pool.

Constructor Details

XMLSchemaLoader

public XMLSchemaLoader()

XMLSchemaLoader

public XMLSchemaLoader(SymbolTable symbolTable)

Method Details

canSetParameter

public boolean canSetParameter(String name,
                               Object value)

getConfig

public DOMConfiguration getConfig()

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

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

getFeature

public boolean getFeature(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.

getFeatureDefault

public Boolean getFeatureDefault(String featureId)
Specified by:
getFeatureDefault in interface org.apache.xerces.xni.parser.XMLComponent

getLocale

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

getParameter

public Object getParameter(String name)
            throws DOMException

getParameterNames

public DOMStringList getParameterNames()

getProperty

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

getPropertyDefault

public Object getPropertyDefault(String propertyId)
Specified by:
getPropertyDefault in interface org.apache.xerces.xni.parser.XMLComponent

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:
getRecognizedFeatures in interface org.apache.xerces.xni.grammars.XMLGrammarLoader
getRecognizedFeatures in interface org.apache.xerces.xni.parser.XMLComponent

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:
getRecognizedProperties in interface org.apache.xerces.xni.grammars.XMLGrammarLoader
getRecognizedProperties in interface org.apache.xerces.xni.parser.XMLComponent

load

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

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

loadGrammar

public void loadGrammar(source[] )
            throws IOException,
                   org.apache.xerces.xni.XNIException
Returns a Grammar object by parsing the contents of the entities pointed to by sources.
Parameters:
Throws:
org.apache.xerces.xni.XNIException - when a condition arises (such as a FatalError) that requires parsing of the entity be terminated

loadInputList

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

loadURI

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

loadURIList

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

processExternalHints

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

reset

public void reset(org.apache.xerces.xni.parser.XMLComponentManager componentManager)
            throws org.apache.xerces.xni.parser.XMLConfigurationException
Specified by:
reset in interface org.apache.xerces.xni.parser.XMLComponent

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:

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.

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.

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 interface org.apache.xerces.xni.grammars.XMLGrammarLoader
setFeature in interface org.apache.xerces.xni.parser.XMLComponent
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.

setLocale

public void setLocale(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.

setParameter

public void setParameter(String name,
                         Object value)
            throws DOMException

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 interface org.apache.xerces.xni.grammars.XMLGrammarLoader
setProperty in interface org.apache.xerces.xni.parser.XMLComponent
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.

tokenizeSchemaLocationStr

public static boolean tokenizeSchemaLocationStr(String schemaStr,
                                                Hashtable locations)

Copyright B) 1999-2005 Apache XML Project. All Rights Reserved.