Class XMLGrammarCachingConfiguration

  • All Implemented Interfaces:
    XML11Configurable, XMLComponentManager, XMLParserConfiguration, XMLPullParserConfiguration

    public class XMLGrammarCachingConfiguration
    extends XIncludeAwareParserConfiguration

    This configuration provides a generic way of using Xerces's grammar caching facilities. It extends the XIncludeAwareParserConfiguration and thus may validate documents according to XML schemas or DTD's. It also allows the user to preparse a grammar, and to lock the grammar pool implementation such that no more grammars will be added.

    Using the org.smooks.engine.delivery.sax.ng.org.apache.xerces.xni.parser property, an application may instantiate a Xerces SAX or DOM parser with this configuration. When invoked in this manner, the default behaviour will be elicited; to use this configuration's specific facilities, the user will need to reference it directly.

    In addition to the features and properties recognized by the base parser configuration, this class recognizes these additional features and properties:

    Version:
    $Id$
    Author:
    Neil Graham, IBM
    • Constructor Detail

      • XMLGrammarCachingConfiguration

        public XMLGrammarCachingConfiguration()
        Default constructor.
      • XMLGrammarCachingConfiguration

        public XMLGrammarCachingConfiguration​(SymbolTable symbolTable)
        Constructs a parser configuration using the specified symbol table.
        Parameters:
        symbolTable - The symbol table to use.
      • XMLGrammarCachingConfiguration

        public XMLGrammarCachingConfiguration​(SymbolTable symbolTable,
                                              XMLGrammarPool grammarPool)
        Constructs a parser configuration using the specified symbol table and grammar pool.

        REVISIT: Grammar pool will be updated when the new validation engine is implemented.

        Parameters:
        symbolTable - The symbol table to use.
        grammarPool - The grammar pool to use.
      • XMLGrammarCachingConfiguration

        public XMLGrammarCachingConfiguration​(SymbolTable symbolTable,
                                              XMLGrammarPool grammarPool,
                                              XMLComponentManager parentSettings)
        Constructs a parser configuration using the specified symbol table, grammar pool, and parent settings.

        REVISIT: Grammar pool will be updated when the new validation engine is implemented.

        Parameters:
        symbolTable - The symbol table to use.
        grammarPool - The grammar pool to use.
        parentSettings - The parent settings.
    • Method Detail

      • lockGrammarPool

        public void lockGrammarPool()
      • clearGrammarPool

        public void clearGrammarPool()
      • unlockGrammarPool

        public void unlockGrammarPool()
      • parseGrammar

        public Grammar parseGrammar​(String type,
                                    String uri)
                             throws XNIException,
                                    IOException
        Parse a grammar from a location identified by an URI. This method also adds this grammar to the XMLGrammarPool
        Parameters:
        type - The type of the grammar to be constructed
        uri - The location of the grammar to be constructed. The parser will not expand this URI or make it available to the EntityResolver
        Returns:
        The newly created Grammar.
        Throws:
        XNIException - thrown on an error in grammar construction
        IOException - thrown if an error is encountered in reading the file
      • parseGrammar

        public Grammar parseGrammar​(String type,
                                    XMLInputSource is)
                             throws XNIException,
                                    IOException
        Parse a grammar from a location identified by an XMLInputSource. This method also adds this grammar to the XMLGrammarPool
        Parameters:
        type - The type of the grammar to be constructed
        is - The XMLInputSource containing this grammar's information If a URI is included in the systemId field, the parser will not expand this URI or make it available to the EntityResolver
        Returns:
        The newly created Grammar.
        Throws:
        XNIException - thrown on an error in grammar construction
        IOException - thrown if an error is encountered in reading the file
      • checkFeature

        protected void checkFeature​(String featureId)
                             throws XMLConfigurationException
        Check a feature. If feature is known and supported, this method simply returns. Otherwise, the appropriate exception is thrown.
        Overrides:
        checkFeature in class XML11Configuration
        Parameters:
        featureId - The unique identifier (URI) of the feature.
        Throws:
        XMLConfigurationException - Thrown for configuration error. In general, components should only throw this exception if it is really a critical error.
      • checkProperty

        protected void checkProperty​(String propertyId)
                              throws XMLConfigurationException
        Check a property. If the property is known and supported, this method simply returns. Otherwise, the appropriate exception is thrown.
        Overrides:
        checkProperty in class XML11Configuration
        Parameters:
        propertyId - The unique identifier (URI) of the property being set.
        Throws:
        XMLConfigurationException - Thrown for configuration error. In general, components should only throw this exception if it is really a critical error.