Class 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
    • Constructor Detail

      • XMLSchemaLoader

        public XMLSchemaLoader()
      • XMLSchemaLoader

        public XMLSchemaLoader​(SymbolTable symbolTable)
    • Method Detail

      • setLocale

        public void setLocale​(Locale locale)
        Set the locale to use for messages.
        Specified by:
        setLocale in interface XMLGrammarLoader
        Parameters:
        locale - The locale object to use for localization of messages.
        Throws:
        XNIException - Thrown if the parser does not support the specified locale.
      • 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 entity
        XNIException - 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:
        loadGrammar in interface 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.
        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
      • tokenizeSchemaLocationStr

        public static boolean tokenizeSchemaLocationStr​(String schemaStr,
                                                        Hashtable locations,
                                                        String base)
      • getFeatureDefault

        public Boolean getFeatureDefault​(String featureId)
        Description copied from interface: 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 interface XMLComponent
        Parameters:
        featureId - The feature identifier.
      • getPropertyDefault

        public Object getPropertyDefault​(String propertyId)
        Description copied from interface: 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 interface XMLComponent
        Parameters:
        propertyId - The property identifier.
      • getConfig

        public DOMConfiguration getConfig()
        Description copied from interface: 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 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.
        Specified by:
        getConfig in interface XSLoader
      • load

        public XSModel load​(LSInput is)
        Description copied from interface: XSLoader
        Parse an XML Schema document from a resource identified by a LSInput .
        Specified by:
        load in interface XSLoader
        Parameters:
        is - The LSInput from which the source document is to be read.
        Returns:
        An XSModel representing this schema.
      • loadInputList

        public XSModel loadInputList​(LSInputList is)
        Description copied from interface: XSLoader
        Parses the content of XML Schema documents specified as a list of LSInputs.
        Specified by:
        loadInputList in interface XSLoader
        Parameters:
        is - The list of LSInputs 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: 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 interface XSLoader
        Parameters:
        uri - The location of the XML Schema document to be read.
        Returns:
        An XSModel representing this schema.
      • loadURIList

        public XSModel loadURIList​(StringList uriList)
        Description copied from interface: 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 interface XSLoader
        Parameters:
        uriList - The list of URI locations.
        Returns:
        An XSModel representing the schema documents.