Package net.sf.saxon

Class Configuration

  • All Implemented Interfaces:
    SourceResolver, NotationSet
    Direct Known Subclasses:
    ProfessionalConfiguration

    public class Configuration
    extends java.lang.Object
    implements SourceResolver, NotationSet
    This class holds details of user-selected configuration options for a set of transformations and/or queries. When running XSLT, the preferred way of setting configuration options is via the JAXP TransformerFactory interface, but the Configuration object provides a finer level of control. As yet there is no standard API for XQuery, so the only way of setting Configuration information is to use the methods on this class directly.

    As well as holding configuration settings, this class acts as a factory for classes providing service in particular areas: error handling, URI resolution, and the like. Some of these services are chosen on the basis of the current platform (Java or .NET), some vary depending whether the environment is schema-aware or not.

    The Configuration provides access to a NamePool which is used to manage all the names used in stylesheets, queries, schemas, and source and documents: the NamePool allocates integer codes to these names allowing efficient storage and comparison. Normally there will be a one-to-one relationship between a NamePool and a Configuration. It is possible, however, for several Configuration objects to share the same NamePool. Until Saxon 8.9, by default all Configuration objects shared a single NamePool unless configured otherwise; this changed in 8.9 so that the default is to allocate a new NamePool for each Configuration.

    The Configuration establishes the scope within which node identity is managed. Every document belongs to a Configuration, and every node has a distinct identity within that Configuration. In consequence, it is not possible for any query or transformation to manipulate multiple documents unless they all belong to the same Configuration.

    Saxon-EE has a subclass of the Configuration class which provides the additional services needed for schema-aware processing. The EnterpriseConfiguration also holds a cache of loaded schema components used for compiling schema-aware transformations and queries, and for validating instance documents.

    Since Saxon 8.4, the JavaDoc documentation for Saxon attempts to identify interfaces that are considered stable, and will only be changed in a backwards-incompatible way if there is an overriding reason to do so. These interfaces and methods are labelled with the JavaDoc "since" tag. The value 8.n indicates a method in this category that was introduced in Saxon version 8.n: or in the case of 8.4, that was present in Saxon 8.4 and possibly in earlier releases. (In some cases, these methods have been unchanged for a long time.) Methods without a "since" tag, although public, are provided for internal use or for use by advanced users, and are subject to change from one release to the next. The presence of a "since" tag on a class or interface indicates that there are one or more methods in the class that are considered stable; it does not mean that all methods are stable.

    Since:
    8.4
    • Constructor Detail

      • Configuration

        public Configuration()
        Create a non-schema-aware configuration object with default settings for all options.
        Since:
        8.4
    • Method Detail

      • newConfiguration

        public static Configuration newConfiguration()
        Factory method to create a Configuration, of the class defined using conditional compilation tags when compiling this version of Saxon: that is, the type of Configuration appropriate to the edition of the software being used. This method does not check that the Configuration is licensed.
        Returns:
        a Configuration object of the class appropriate to the Saxon edition in use.
        Since:
        9.2
      • newLicensedConfiguration

        public static Configuration newLicensedConfiguration()
        Factory method to create a Configuration, of the class defined using conditional compilation tags when compiling this version of Saxon: that is, the type of Configuration appropriate to the edition of the software being used, taking into account the license available. For example if the software is EE, but only a PE license is available, the method returns a ProfessionalConfiguration.
        Returns:
        a Configuration object of the class appropriate to the Saxon edition in use.
        Since:
        9.2
      • readConfiguration

        public static Configuration readConfiguration​(javax.xml.transform.Source source)
                                               throws XPathException
        Factory method to construct a Configuration object by reading a configuration file.
        Parameters:
        source - Source object containing the configuration file
        Returns:
        the resulting Configuration
        Throws:
        XPathException - if the configuration file cannot be read or is invalid
      • readConfiguration

        public static Configuration readConfiguration​(javax.xml.transform.Source source,
                                                      Configuration baseConfiguration)
                                               throws XPathException
        Factory method to construct a Configuration object by reading a configuration file. This version of the method creates a configuration that is "compatible" with the supplied configuration, in that it shares the same NamePool and DocumentNumberAllocator. (This is used by fn:transform)
        Parameters:
        source - Source object containing the configuration file
        baseConfiguration - an existing configuration whose NamePool and DocumentNumberAllocator will be used in the new Configuration; the license details from the base configuration will also be shared
        Returns:
        the resulting Configuration
        Throws:
        XPathException - if the configuration file cannot be read or is invalid
      • instantiateConfiguration

        public static Configuration instantiateConfiguration​(java.lang.String className,
                                                             java.lang.ClassLoader classLoader)
                                                      throws java.lang.ClassNotFoundException,
                                                             java.lang.InstantiationException,
                                                             java.lang.IllegalAccessException
        Instantiate a Configuration object with a given class name
        Parameters:
        className - the class name
        classLoader - the class loader to be used
        Returns:
        a Configuration of the required class
        Throws:
        java.lang.ClassNotFoundException - if the class is not found
        java.lang.InstantiationException - if the class cannot be instantiated
        java.lang.IllegalAccessException - if the class is not accessible
      • isAssertionsEnabled

        public static boolean isAssertionsEnabled()
        Ask if Java is being run with assertions enabled (-ea option)
        Returns:
        true if the -ea option is set
      • readConfigurationFile

        protected Configuration readConfigurationFile​(javax.xml.transform.Source source)
                                               throws XPathException
        Read the configuration file an construct a new Configuration (the real one)
        Parameters:
        source - the source of the configuration file
        Returns:
        the Configuration that will be used for real work
        Throws:
        XPathException - if the configuration file cannot be read or is invalid
      • init

        protected void init()
      • makeLicensedConfiguration

        public static Configuration makeLicensedConfiguration​(java.lang.ClassLoader classLoader,
                                                              java.lang.String className)
                                                       throws java.lang.RuntimeException
        Static method to instantiate a professional or enterprise configuration.

        This method fails if the specified configuration class cannot be loaded, but it does not check whether there is a license available.

        Parameters:
        classLoader - - the class loader to be used. If null, the context class loader for the current thread is used.
        className - - the name of the configuration class. Defaults to "com.saxonica.config.ProfessionalConfiguration" if null is supplied. This allows an assembly qualified name to be supplied under .NET. The class, once instantiated, must be an instance of Configuration.
        Returns:
        the new ProfessionalConfiguration or EnterpriseConfiguration
        Throws:
        java.lang.RuntimeException - if the required Saxon edition cannot be loaded
        Since:
        9.2 (renamed from makeSchemaAwareConfiguration)
      • importLicenseDetails

        public void importLicenseDetails​(Configuration config)
      • getEditionCode

        public java.lang.String getEditionCode()
        Get the edition code identifying this configuration: "HE", "PE" or "EE"
        Returns:
        the code identifying the Saxon edition associated with this configuration
      • setProcessor

        public void setProcessor​(Configuration.ApiProvider processor)
        Save the ApiProvider object that owns this Configuration in the relevant API.

        Note: it is possible to use multiple APIs over the same Configuration. This mechanism is only capable of holding one of these, and is therefore only really useful in cases where the API in use is homogeneous.

        Parameters:
        processor - This can be any ApiProvider, but it is typically one of the following:
        • When using the Java s9api interface, the net.sf.saxon.s9api.Processor
        • When using the .NET interface, the Saxon.Api.Processor
        • When using the JAXP transformation interface, the JAXP TransformerFactory
        • When using the JAXP XPath interface, the JAXP XPathFactory
        • When using the JAXP Schema interface, the JAXP SchemaFactory
        • When using XQJ, the XQDataSource
        Since:
        9.2. Changed in 9.9 to require an Configuration.ApiProvider rather than any Object.
      • getProcessor

        public Configuration.ApiProvider getProcessor()
        Get the Processor object that created this Configuration in the relevant API.

        The main purpose of this interface is to allow extension functions called from a stylesheet or query to get access to the originating processor. This is particularly useful when methods are static as there is then limited scope for passing data from the calling application to the code of the extension function.

        Returns:
        the processor that was supplied to the setProcessor(ApiProvider) method, or null if this method has not been called. In practice this property is used to hold one of the following:
        • When using the Java s9api interface, the net.sf.saxon.s9api.Processor
        • When using the .NET interface, the Saxon.Api.Processor
        • When using the JAXP transformation interface, the JAXP TransformerFactory
        • When using the JAXP XPath interface, the JAXP XPathFactory
        • When using the JAXP Schema interface, the JAXP SchemaFactory
        • When using XQJ, the XQDataSource
        Since:
        9.2. Changed in 9.9 to return an Configuration.ApiProvider rather than any Object.
      • getProductTitle

        public java.lang.String getProductTitle()
        Get a message used to identify this product when a transformation is run using the -t option
        Returns:
        A string containing both the product name and the product version
        Since:
        8.4
      • checkLicensedFeature

        public void checkLicensedFeature​(int feature,
                                         java.lang.String name,
                                         int localLicenseId)
                                  throws LicenseException
        Check whether a particular feature is licensed, with a fatal error if it is not
        Parameters:
        feature - the feature in question, identified by a constant in class Configuration.LicenseFeature
        name - the name of the feature for use in diagnostics
        localLicenseId - identifies an embedded license, or -1 if not applicable
        Throws:
        LicenseException - if the feature is not licensed. This is a RunTimeException, so it will normally be fatal.
      • disableLicensing

        public void disableLicensing()
        Instruct Saxon to run as if no license is available. This method is provided for testing purposes, so that tests with and without a license can be run without making changes to the classpath.
      • isFeatureAllowedBySecondaryLicense

        public boolean isFeatureAllowedBySecondaryLicense​(int localLicenseId,
                                                          int feature)
        Ask whether a particular feature is enabled by an embedded license (embedded in a SEF file)
        Parameters:
        localLicenseId - the identifier of the embedded license
        feature - the feature in question, identified by a constant in class Configuration.LicenseFeature
        Returns:
        true if the embedded license exists and enables the requested feature
      • isLicensedFeature

        public boolean isLicensedFeature​(int feature)
        Determine if a particular feature is licensed.
        Parameters:
        feature - the feature in question, identified by a constant in class Configuration.LicenseFeature
        Returns:
        true if the feature is licensed, false if it is not.
      • requireProfessionalLicense

        public void requireProfessionalLicense​(java.lang.String featureName)
                                        throws LicenseException
        Assert that a PE license is required, and fail if none is available
        Parameters:
        featureName - name of the required feature, to include in the error message. This can be any name (for example "XQuery Update"), it does not have to correspond with a particular property held in the license file.
        Throws:
        LicenseException - if no license key is available
      • getLicenseFeature

        public java.lang.String getLicenseFeature​(java.lang.String name)
        Get the value of a named license feature
        Parameters:
        name - the name of the feature. This is one of the properties explicitly recorded in the license file, for example "Licensor", "Licensee", "Email", "Issued", "Serial".
        Returns:
        the value of the feature if present, or null otherwise
      • getLicenseFeatures

        public java.util.Properties getLicenseFeatures()
        Get all license features, as a Properties object mapping feature names to feature values.
        Returns:
        a map containing all license features as name-value pairs. The names and values are those explicitly recorded in the license file, for example "Issued":"2022-11-25". If there is no license, the method returns null.
        Since:
        12.3
      • displayLicenseMessage

        public void displayLicenseMessage()
        Display a message about the license status
      • registerLocalLicense

        public int registerLocalLicense​(java.lang.String dmk)
        Register a local license file (for use within a single transformation (etc))
        Parameters:
        dmk - the license in encoded form
        Returns:
        an integer identifying this license uniquely within the configuration, or -1 if not accepted
      • setDynamicLoader

        public void setDynamicLoader​(IDynamicLoader dynamicLoader)
        Set the DynamicLoader to be used. By default an instance of DynamicLoader is used for all dynamic loading of Java classes. This method allows the actions of the standard DynamicLoader to be overridden
        Parameters:
        dynamicLoader - the DynamicLoader to be used by this Configuration
      • getDynamicLoader

        public IDynamicLoader getDynamicLoader()
        Get the DynamicLoader used by this Configuration. By default the standard system-supplied dynamic loader is returned.
        Returns:
        the DynamicLoader in use - either a user-supplied DynamicLoader, or the standard one supplied by the system.
      • getClass

        public java.lang.Class<?> getClass​(java.lang.String className,
                                           boolean tracing)
                                    throws XPathException
        Load a class using the class name provided. Note that the method does not check that the object is of the right class.

        This method is intended for internal use only. The call is delegated to the DynamicLoader, which may be overridden by a user-defined DynamicLoader.

        Parameters:
        className - A string containing the name of the class, for example "com.microstar.sax.LarkDriver"
        tracing - true if diagnostic tracing is required
        Returns:
        an instance of the class named, or null if it is not loadable.
        Throws:
        XPathException - if the class cannot be loaded.
      • getInstance

        public java.lang.Object getInstance​(java.lang.String className)
                                     throws XPathException
        Instantiate a class using the class name provided. Note that the method does not check that the object is of the right class.

        This method is intended for internal use only. The call is delegated to the DynamicLoader, which may be overridden by a user-defined DynamicLoader.

        Diagnostic output is produced if the option "isTiming" is set (corresponding to the -t option on the command line).

        Parameters:
        className - A string containing the name of the class, for example "com.microstar.sax.LarkDriver"
        Returns:
        an instance of the class named, or null if it is not loadable.
        Throws:
        XPathException - if the class cannot be loaded.
      • getResourceResolver

        public ResourceResolver getResourceResolver()
        Returns the current resource resolver. If the configuration does not have a resolver when this method is called, a default CatalogResourceResolver will be constructed and returned.
        Returns:
        The resolver.
      • setResourceResolver

        public void setResourceResolver​(ResourceResolver resolver)
        Set the ResourceResolver to be used in this configuration. This is used as a fallback whenever the local ResourceResolver for a particular task (for example the XsltCompiler or the XQueryEvaluator) either (a) has not been set, or (b) has been called and returns null.

        If a user-written ResourceResolver is supplied then it must be able to handle a wide range of requests, not just for XML source documents and stylesheets, but also for schemas, unparsed text resources, and external entities. One way to achieve this by inheriting from the CatalogResourceResolver, only overriding those methods that need to change. Another method is to construct a ChainedResourceResolver that first handles specific cases, and then passes control to the standard ResourceResolver.

        In cases where the request is for a non-XML resource, the object delivered by the ResourceResolver must be a StreamSource.

        The ResourceResolver may return null to indicate that the URI is to be resolved by the fallback DirectResourceResolver.

        Parameters:
        resolver - The ResourceResolver to be used.
        Since:
        11.1. Replaces setURIResolver()
      • setParameterizedURIResolver

        @Deprecated
        public void setParameterizedURIResolver()
        Deprecated.
        since 11.1 - use setBooleanProperty(Feature.RECOGNIZE_URI_QUERY_PARAMETERS, true);
        Set the URIResolver to a URI resolver that allows query parameters after the URI
      • getProtocolRestrictor

        public ProtocolRestrictor getProtocolRestrictor()
        Get the ProtocolRestrictor in use. This restricts the URI schemes that may be used when dereferencing a resource. The ProtocolRestrictor can be set by setting the property Feature.ALLOWED_PROTOCOLS to a comma-separated list of permitted protocols.
        Returns:
        the ProtocolRestrictor in use
      • makeResourceResolver

        public ResourceResolver makeResourceResolver​(java.lang.String className)
                                              throws XPathException
        Create an instance of a URIResolver with a specified class name. Note that this method does not register the URIResolver with this Configuration.
        Parameters:
        className - The fully-qualified name of the URIResolver class
        Returns:
        The newly created URIResolver
        Throws:
        XPathException - if the requested class does not implement the ResourceResolver interface
      • setErrorReporterFactory

        public void setErrorReporterFactory​(java.util.function.Function<Configuration,​? extends ErrorReporter> factory)
      • getLogger

        public Logger getLogger()
      • reportFatalError

        public void reportFatalError​(XPathException err)
        Report a fatal error
        Parameters:
        err - the exception to be reported
      • setStandardErrorOutput

        public void setStandardErrorOutput​(java.io.PrintStream out)
        Set the standard error output to be used in all cases where no more specific destination is defined. This defaults to System.err.

        The method has no effect unless the getLogger() object is an instance of StandardLogger. In that case it calls StandardLogger.setPrintStream(PrintStream)

        Parameters:
        out - the stream to be used for error output where no more specific destination has been supplied. The caller is responsible for closing this stream after use (if necessary).
        Since:
        9.3
      • setLogger

        public void setLogger​(Logger logger)
        Register a new logger to be used in the Saxon event logging mechanism
        Parameters:
        logger - the Logger to be used as default. The caller is responsible for ensuring that this is closed after use (if necessary), which can be achieved by calling either Logger.close() or close();
        Since:
        9.6
      • setXMLVersion

        public void setXMLVersion​(int version)
        Set the XML version to be used by default for validating characters and names. Note that source documents specifying xml version="1.0" or "1.1" are accepted regardless of this setting. The effect of this switch is to change the validation rules for types such as Name and NCName, to change the meaning of \i and \c in regular expressions, and to determine whether the serializer allows XML 1.1 documents to be constructed.
        Parameters:
        version - one of the constants XML10 or XML11
        Since:
        8.6
      • getXMLVersion

        public int getXMLVersion()
        Get the XML version to be used by default for validating characters and names
        Returns:
        one of the constants XML10 or XML11
        Since:
        8.6
      • getParseOptions

        public ParseOptions getParseOptions()
        Get the parsing and document building options defined in this configuration
        Returns:
        the parsing and document building options. Note that any changes to this ParseOptions object will be reflected back in the Configuration; if changes are to be made locally, the caller should create a copy.
        Since:
        9.2. From 12.x the ParseOptions object is immutable, which means any changes must be written back using setParseOptions(net.sf.saxon.lib.ParseOptions)
      • setParseOptions

        public void setParseOptions​(ParseOptions options)
        Set the parsing and document building options to be used in this configuration.
      • setMediaQueryEvaluator

        public void setMediaQueryEvaluator​(java.util.Comparator<java.lang.String> comparator)
        Set a comparator which can be used to assess whether the media pseudo-attribute in an xml-stylesheet processing instruction matches the media requested in the API for the transformation
        Parameters:
        comparator - a comparator which returns 0 (equals) when the first argument of the compare method is the value of the media attribute in the xml-stylesheet processing instruction, and the second argument is the value of the required media given in the calling API. The default implementation always returns 0, indicating that the media pseudo-attribute is ignored. An alternative implementation, consistent with previous Saxon releases, would be compare the strings for equality. A fully conformant implementation could implement the syntax and semantics of media queries as defined in CSS 3.
      • getMediaQueryEvaluator

        public java.util.Comparator<java.lang.String> getMediaQueryEvaluator()
        Get a comparator which can be used to assess whether the media pseudo-attribute in an xml-stylesheet processing instruction matches the media requested in the API for the transformation
        Returns:
        a comparator which returns 0 (equals) when the first argument of the compare method is the value of the media attribute in the xml-stylesheet processing instruction, and the second argument is the value of the required media given in the calling API. The default implementation always returns 0, indicating that the media pseudo-attribute is ignored. An alternative implementation, consistent with previous Saxon releases, would be to compare the strings for equality. A fully conformant implementation could implement the syntax and semantics of media queries as defined in CSS 3.
      • setConversionRules

        public void setConversionRules​(ConversionRules rules)
        Set the conversion rules to be used to convert between atomic types. By default, The rules depend on the versions of XML and XSD in use by the configuration.
        Parameters:
        rules - the conversion rules to be used
        Since:
        9.3
      • getConversionRules

        public ConversionRules getConversionRules()
        Get the conversion rules used to convert between atomic types. By default, the rules depend on the versions of XML and XSD in use by the configuration
        Returns:
        the appropriate conversion rules
        Since:
        9.3
      • getXsdVersion

        public int getXsdVersion()
        Get the version of XML Schema to be used
        Returns:
        XSD10 or XSD11
        Since:
        9.2
      • getConversionContext

        public XPathContext getConversionContext()
        Get an XPathContext object with sufficient capability to perform comparisons and conversions
        Returns:
        a dynamic context for performing conversions
      • getValidCharacterChecker

        public IntPredicateProxy getValidCharacterChecker()
        Get an IntPredicate that tests whether a given character is valid in the selected version of XML
        Returns:
        an IntPredicate whose matches() method tests a character for validity against the version of XML (1.0 or 1.1) selected by this configuration
      • setTreeModel

        public void setTreeModel​(int treeModel)
        Set the Tree Model used by this Configuration. This is typically Builder.LINKED_TREE or Builder.TINY_TREE, or Builder.TINY_TREE_CONDENSED. The default is Builder.TINY_TREE.
        Parameters:
        treeModel - the integer constant representing the selected Tree Model
        Since:
        8.4 (Condensed tinytree added in 9.2)
      • isLineNumbering

        public boolean isLineNumbering()
        Determine whether source documents will maintain line numbers, for the benefit of the saxon:line-number() extension function as well as run-time tracing.
        Returns:
        true if line numbers are maintained in source documents
        Since:
        8.4
      • setLineNumbering

        public void setLineNumbering​(boolean lineNumbering)
        Determine whether source documents will maintain line numbers, for the benefit of the saxon:line-number() extension function as well as run-time tracing.
        Parameters:
        lineNumbering - true if line numbers are maintained in source documents
        Since:
        8.4
      • setXIncludeAware

        public void setXIncludeAware​(boolean state)
        Set whether or not source documents (including stylesheets and schemas) are have XInclude processing applied to them, or not. Default is false.
        Parameters:
        state - true if XInclude elements are to be expanded, false if not
        Since:
        8.9
      • isXIncludeAware

        public boolean isXIncludeAware()
        Test whether or not source documents (including stylesheets and schemas) are to have XInclude processing applied to them, or not
        Returns:
        true if XInclude elements are to be expanded, false if not
        Since:
        8.9
      • setTraceListener

        public void setTraceListener​(TraceListener traceListener)
        Set the TraceListener to be used for run-time tracing of instruction execution.

        Note: this method should not be used if the Configuration is multithreading. In that situation, use setCompileWithTracing(boolean) to force stylesheets and queries to be compiled with trace code enabled, and use Controller.addTraceListener(net.sf.saxon.lib.TraceListener) to supply a TraceListener at run time.

        Parameters:
        traceListener - The TraceListener to be used. If null is supplied, any existing TraceListener is removed
        Since:
        8.4
      • setTraceListenerClass

        public void setTraceListenerClass​(java.lang.String className)
        Set the name of the trace listener class to be used for run-time tracing of instruction execution. A new instance of this class will be created for each query or transformation that requires tracing. The class must be an instance of TraceListener.
        Parameters:
        className - the name of the trace listener class. If null, any existing trace listener is removed from the configuration.
        Throws:
        java.lang.IllegalArgumentException - if the class cannot be instantiated or does not implement TraceListener
        Since:
        9.1. Changed in 9.4 to allow null to be supplied.
      • getTraceListenerClass

        public java.lang.String getTraceListenerClass()
        Get the name of the trace listener class to be used for run-time tracing of instruction execution. A new instance of this class will be created for each query or transformation that requires tracing. The class must be an instance of TraceListener.
        Returns:
        the name of the trace listener class, or null if no trace listener class has been nominated.
        Since:
        9.1
      • setTraceListenerOutputFile

        public void setTraceListenerOutputFile​(java.lang.String filename)
        Set the name of the file to be used for TraceListener output. (By default, it is sent to System.err)
        Parameters:
        filename - the filename for TraceListener output
        Since:
        9.8
      • getTraceListenerOutputFile

        public java.lang.String getTraceListenerOutputFile()
        Get the name of the file to be used for TraceListener output. Returns null if no value has been set
        Returns:
        the filename to be used for TraceListener output, or null if none has been set
        Since:
        9.8
      • isCompileWithTracing

        public boolean isCompileWithTracing()
        Determine whether compile-time generation of trace code was requested
        Returns:
        true if compile-time generation of code was requested at the Configuration level. Note that tracing can also be requested at the XQueryCompiler or XsltCompiler level.
        Since:
        8.8
      • setCompileWithTracing

        public void setCompileWithTracing​(boolean trace)
        Request compile-time generation of trace code (or not)
        Parameters:
        trace - true if compile-time generation of trace code is required
        Since:
        8.8
      • makeTraceListener

        public TraceListener makeTraceListener​(java.lang.String className)
                                        throws XPathException
        Create an instance of a TraceListener with a specified class name
        Parameters:
        className - The fully qualified class name of the TraceListener to be constructed
        Returns:
        the newly constructed TraceListener
        Throws:
        XPathException - if the requested class does not implement the net.sf.saxon.trace.TraceListener interface
      • getXSLTFunctionSet

        public BuiltInFunctionSet getXSLTFunctionSet​(int version)
        Get the set of functions in the "fn" namespace
        Parameters:
        version - The XPath or XSLT version. 20 requests the XPath 2.0 function set (used in XSD assertion processing), 30 or 31 gives the XSLT 3.0 function set, and 40 the XSLT 4.0 function set
        Returns:
        the relevant function library
      • getXPathFunctionSet

        public BuiltInFunctionSet getXPathFunctionSet​(int version)
        Get the set of functions in the "fn" namespace defined in the F&O specification
        Parameters:
        version - The XPath version (eg 20, 30, 31, 40)
        Returns:
        the function library
      • makeSystemFunction

        public SystemFunction makeSystemFunction​(java.lang.String localName,
                                                 int arity,
                                                 int xpathVersion)
        Make a function in the "fn" namespace
        Parameters:
        localName - the local name of the function
        arity - the arity of the function
        Returns:
        the function
      • makeSystemFunction40

        public SystemFunction makeSystemFunction40​(java.lang.String localName,
                                                   int arity)
      • registerExtensionFunction

        public void registerExtensionFunction​(ExtensionFunctionDefinition function)
        Register an extension function that is to be made available within any stylesheet, query, or XPath expression compiled under the control of this processor. This method registers an extension function implemented as an instance of ExtensionFunctionDefinition, using an arbitrary name and namespace. This supplements the ability to call arbitrary Java methods using a namespace and local name that are related to the Java class and method name.
        Parameters:
        function - the object that implements the extension function.
        Since:
        9.2
      • getIntegratedFunctionLibrary

        public IntegratedFunctionLibrary getIntegratedFunctionLibrary()
        Get the IntegratedFunction library containing integrated extension functions
        Returns:
        the IntegratedFunctionLibrary
        Since:
        9.2
      • getBuiltInExtensionLibraryList

        public FunctionLibraryList getBuiltInExtensionLibraryList​(int version)
        Get the function library list for built-in functions other than the functions in the core FN namespace. This includes for example functions for the math, array, and map namespaces, extensions in the Saxon namespace, and EXPath extensions for the file and binary modules. The actual set of libraries varies by Saxon edition. The function library list is created if it does not already exist. The client can add additional libraries to the returned library list. However, this should be regarded as a "system programming" interface, exposing capabilities that might have unpredictable effects.
        Parameters:
        version - The configuration can hold different library lists for different XPath versions. The version number currently affects the map and array libraries, which exist in 3.1 and 4.0 versions. Specifying 40 gives the XPath 4.0 version of these libraries, anything else gives the XPath 3.1 version.
        Returns:
        the function library list for built-in function libraries other than the core FN namespace.
      • getUseWhenFunctionLibrary

        public UseWhen30FunctionSet getUseWhenFunctionLibrary​(int version)
      • makeBuiltInExtensionLibraryList

        protected FunctionLibraryList makeBuiltInExtensionLibraryList​(int version)
      • getVendorFunctionSet

        public BuiltInFunctionSet getVendorFunctionSet()
        Get the function library for Saxon-defined extension functions available in this edition
        Returns:
        the function library
      • bindSaxonExtensionFunction

        public SystemFunction bindSaxonExtensionFunction​(java.lang.String localName,
                                                         int arity)
                                                  throws XPathException
        Instantiate a Saxon extension function. This generally requires Saxon-PE or higher, so it will fail with this Configuration
        Parameters:
        localName - the local name of the function in the Saxon namespace
        arity - the function arity
        Returns:
        the system function with this name and arity
        Throws:
        XPathException - if no suitable function is available
      • addExtensionBinders

        public void addExtensionBinders​(FunctionLibraryList list)
        Add the registered extension binders to a function library. This method is intended primarily for internal use
        Parameters:
        list - the function library list
      • getSystemFunction

        public FunctionItem getSystemFunction​(StructuredQName name,
                                              int arity)
        Get a system function. This can be any function defined in XPath functions and operators, including functions in the math, map, and array namespaces. Experimental 4.0 functions are available if the configuration property Feature.XQUERY_VERSION is set to 4.0.

        Constructor functions for known atomic types are also available, as are integrated extension functions registered with the configuration.

        Saxon extension functions and reflexive Java extensions are available provided that a licensed Processor is used.

        Parameters:
        name - the name of the required function
        arity - the arity of the required function
        Returns:
        the requested function, or null if there is no such function. Note that some functions (those with particular context dependencies) may be unsuitable for dynamic calling.
      • newUserFunction

        public UserFunction newUserFunction​(boolean memoFunction,
                                            FunctionStreamability streamability)
        Make a UserFunction object. This method is for internal use.
        Parameters:
        memoFunction - true if the function is to be a memo function.
        streamability - the declared streamability of the function
        Returns:
        the newly created user-defined function
      • registerCollation

        public void registerCollation​(java.lang.String collationURI,
                                      StringCollator collator)
        Register a collation. Collation URIs registered using this interface will be picked up before calling the CollationURIResolver.
        Parameters:
        collationURI - the URI of the collation. This should be an absolute URI, though it is not checked
        collator - the implementation of the collation
        Since:
        9.6
      • setCollationURIResolver

        public void setCollationURIResolver​(CollationURIResolver resolver)
        Set a CollationURIResolver to be used to resolve collation URIs (that is, to take a URI identifying a collation, and return the corresponding collation). Note that Saxon attempts first to resolve a collation URI using the resolver registered with the Controller; if that returns null, it tries again using the resolver registered with the Configuration.

        Note that it is undefined whether collation URIs are resolved at compile time or at run-time. It is therefore inadvisable to change the CollationURIResolver after compiling a query or stylesheet and before running it.

        Parameters:
        resolver - the collation URI resolver to be used. This replaces any collation URI resolver previously registered.
        Since:
        8.5
      • getCollationURIResolver

        public CollationURIResolver getCollationURIResolver()
        Get the collation URI resolver associated with this configuration. This will return the CollationURIResolver previously set using the setCollationURIResolver(net.sf.saxon.lib.CollationURIResolver) method; if this has not been called, it returns the system-defined collation URI resolver
        Returns:
        the registered CollationURIResolver
        Since:
        8.5
      • getCollation

        public StringCollator getCollation​(java.lang.String collationName)
                                    throws XPathException
        Get the collation with a given collation name. If the collation name has not been registered in this CollationMap, the CollationURIResolver registered with the Configuration is called. If this cannot resolve the collation name, it should return null.
        Parameters:
        collationName - the collation name as an absolute URI
        Returns:
        the StringCollator with this name if known, or null if not known
        Throws:
        XPathException - if the collation URI is recognized but is invalid; for example, if it is a URI that takes parameters, and the parameters are invalid. If a user-supplied collation URI resolver is in use, then any exception thrown by that resolver is passed on to the caller.
      • getCollation

        public StringCollator getCollation​(java.lang.String collationURI,
                                           java.lang.String baseURI)
                                    throws XPathException
        Get the collation with a given collation name, supplying a relative URI and base URI separately. If the collation name has not been registered in this CollationMap, the CollationURIResolver registered with the Configuration is called. If this cannot resolve the collation name, it should return null.
        Parameters:
        collationURI - the collation name as a relative or absolute URI
        baseURI - the base URI to be used to resolve the collationURI if it is relative
        Returns:
        the StringCollator with this name if known, or null if not known
        Throws:
        XPathException - if a failure occurs during URI resolution
      • getCollation

        public StringCollator getCollation​(java.lang.String collationURI,
                                           java.lang.String baseURI,
                                           java.lang.String errorCode)
                                    throws XPathException
        Get the collation with a given collation name, supplying a relative URI and base URI separately, and throwing an error if it cannot be found. If the collation name has not been registered in this CollationMap, the CollationURIResolver registered with the Configuration is called. If this cannot resolve the collation name, it should return null.
        Parameters:
        collationURI - the collation name as a relative or absolute URI
        baseURI - the base URI to be used to resolve the collationURI if it is relative; may be null if the supplied collationURI is known to be absolute
        errorCode - the error to raise if the collation is not known
        Returns:
        the StringCollator with this name if known, or null if not known
        Throws:
        XPathException - if a failure occurs during URI resolution
      • getDefaultCollationName

        public java.lang.String getDefaultCollationName()
        Get the name of the global default collation
        Returns:
        the name of the default collation. If none has been set, returns the URI of the Unicode codepoint collation
      • setDefaultCollection

        public void setDefaultCollection​(java.lang.String uri)
        Set the default collection.

        If no default collection URI is specified, then a request for the default collection is handled by calling the registered collection URI resolver with an argument of null.

        Parameters:
        uri - the URI of the default collection. Calling the collection() function with no arguments is equivalent to calling collection() with this URI as an argument. The URI will be dereferenced by passing it to the registered CollectionFinder. If null is supplied, any existing default collection is removed.
        Since:
        9.2
      • getDefaultCollection

        public java.lang.String getDefaultCollection()
        Get the URI of the default collection. Returns null if no default collection URI has been registered.
        Returns:
        the default collection URI. This is dereferenced in the same way as a normal collection URI (via the CollectionFinder) to return a sequence of nodes
        Since:
        9.2
      • setCollectionFinder

        public void setCollectionFinder​(CollectionFinder cf)
        Set the collection finder associated with this configuration. This is used to dereference collection URIs used in the fn:collection and fn:uri-collection functions
        Parameters:
        cf - the CollectionFinder to be used
        Since:
        9.7
      • getCollectionFinder

        public CollectionFinder getCollectionFinder()
        Get the collection finder associated with this configuration. This is used to dereference collection URIs used in the fn:collection and fn:uri-collection functions
        Returns:
        the CollectionFinder to be used
        Since:
        9.7
      • registerCollection

        public void registerCollection​(java.lang.String collectionURI,
                                       ResourceCollection collection)
        Register a specific URI and bind it to a specific ResourceCollection. A collection that is registered in this way will be returned prior to calling any registered CollectionFinder. This method should only be used while the configuration is being initialized for use; the effect of adding or replacing collections dynamically while a configuration is in use is undefined.
        Parameters:
        collectionURI - the collection URI to be registered. Must not be null.
        collection - the ResourceCollection to be associated with this URI. Must not be null.
        Since:
        9.7.0.2. Modified in 11.0 to work independently of (and prior to invoking) the registered CollectionFinder.
      • getRegisteredCollection

        public ResourceCollection getRegisteredCollection​(java.lang.String uri)
        Get a registered collection with a given URI if there is one
        Parameters:
        uri - the collection URI
        Returns:
        the registered collection with this URI if there is one, or null otherwise
      • registerFileExtension

        public void registerFileExtension​(java.lang.String extension,
                                          java.lang.String mediaType)
        Set the media type to be associated with a file extension by the standard collection handler
        Parameters:
        extension - the file extension, for example "xml". The value "" sets the default media type to be used for unregistered file extensions.
        mediaType - the corresponding media type, for example "application/xml". The choice of media type determines how a resource with this extension gets parsed, when the file appears as part of a collection.
        Since:
        9.7.0.1
      • registerMediaType

        public void registerMediaType​(java.lang.String contentType,
                                      ResourceFactory factory)
        Associate a media type with a resource factory. This method may be called to customize the behaviour of a collection to recognize different file extensions
        Parameters:
        contentType - a media type or MIME type, for example application/xsd+xml
        factory - a ResourceFactory used to parse (or otherwise process) resources of that type
        Since:
        9.7.0.6
      • getMediaTypeForFileExtension

        public java.lang.String getMediaTypeForFileExtension​(java.lang.String extension)
        Get the media type to be associated with a file extension by the standard collection handler
        Parameters:
        extension - the file extension, for example "xml". The value "" gets the default media type to be used for unregistered file extensions. the default media type is also returned if the supplied file extension is not registered.
        Returns:
        the corresponding media type, for example "application/xml". The choice of media type determines how a resource with this extension gets parsed, when the file appears as part of a collection.
        Since:
        9.7.0.1
      • getResourceFactoryForMediaType

        public ResourceFactory getResourceFactoryForMediaType​(java.lang.String mediaType)
        Get the resource factory associated with a media type
        Parameters:
        mediaType - the media type or MIME type, for example "application/xml"
        Returns:
        the associated resource factory if one has been registered for this media type, or null otherwise
      • setLocalizerFactory

        public void setLocalizerFactory​(LocalizerFactory factory)
        Set the localizer factory to be used
        Parameters:
        factory - the LocalizerFactory
        Since:
        9.2
      • getLocalizerFactory

        public LocalizerFactory getLocalizerFactory()
        Get the localizer factory in use
        Returns:
        the LocalizerFactory, if any. If none has been set, returns null.
        Since:
        9.2
      • setDefaultLanguage

        public void setDefaultLanguage​(java.lang.String language)
        Set the default language to be used for number and date formatting when no language is specified. If none is set explicitly, the default Locale for the Java Virtual Machine is used.
        Parameters:
        language - the default language to be used, as an ISO code for example "en" or "fr-CA"
        Throws:
        java.lang.IllegalArgumentException - if not valid as an xs:language instance.
        Since:
        9.2. Validated from 9.7 against xs:language type.
      • getDefaultLanguage

        public java.lang.String getDefaultLanguage()
        Get the default language. Unless an explicit default is set, this will be the language of the default Locale for the Java Virtual Machine
        Returns:
        the default language
        Since:
        9.2
      • setDefaultCountry

        public void setDefaultCountry​(java.lang.String country)
        Set the default country to be used for number and date formatting when no country is specified. If none is set explicitly, the default Locale for the Java Virtual Machine is used.
        Parameters:
        country - the default country to be used, as an ISO code for example "US" or "GB"
        Since:
        9.2
      • getDefaultCountry

        public java.lang.String getDefaultCountry()
        Get the default country to be used for number and date formatting when no country is specified. If none is set explicitly, the default Locale for the Java Virtual Machine is used.
        Returns:
        the default country to be used, as an ISO code for example "US" or "GB"
        Since:
        9.2
      • setDefaultRegexEngine

        public void setDefaultRegexEngine​(java.lang.String engine)
        Set the default regular expression engine to be used
        Parameters:
        engine - the default regular expression engine to be used. The value must be one of:
        • S - the Saxon regular expression engine (derived form Apache Jakarta)
        • J - the Java JDK regular expression engine
        • N - (on .NET only) - the .NET regular expression engine
      • getDefaultRegexEngine

        public java.lang.String getDefaultRegexEngine()
        Get the default regular expression to be used
        Returns:
        the default regular expression to be used. Returns "S" if no value has been explicitly set.
      • compileRegularExpression

        public RegularExpression compileRegularExpression​(UnicodeString regex,
                                                          java.lang.String flags,
                                                          java.lang.String hostLanguage,
                                                          java.util.List<java.lang.String> warnings)
                                                   throws XPathException
        Compile a regular expression (or, in some configurations, get a compiled regular expression from a cache
        Parameters:
        regex - the regular expression as a string
        flags - the value of the flags attribute
        hostLanguage - one of "XSD10", "XSD11", XP20" or "XP30". Also allow combinations, e.g. "XP20/XSD11".
        warnings - if non-null, any warnings from the regular expression compiler will be added to this list. If null, the warnings are ignored.
        Returns:
        the compiled regular expression
        Throws:
        XPathException - if the regular expression or the flags are invalid
      • makeNumberer

        public Numberer makeNumberer​(java.lang.String language,
                                     java.lang.String country)
        Load a Numberer class for a given language and check it is OK. This method is provided primarily for internal use.
        Parameters:
        language - the language for which a Numberer is required. May be null, indicating default language. The language may include variants such as "en-GB" for British English or "fr-CA" for Canadian French.
        country - the country for which a Numberer is required. May be null, indicating default country. This is the country of a date/time to be formatted, and does not contribute to selection of a locale.
        Returns:
        a suitable numberer. If no specific numberer is available for the language, the default numberer (normally English) is used.
      • setModuleURIResolver

        public void setModuleURIResolver​(ModuleURIResolver resolver)
        Set a user-defined ModuleURIResolver for resolving URIs used in "import module" declarations in an XQuery prolog. This acts as the default value for the ModuleURIResolver in the StaticQueryContext, and may be overridden by a more specific ModuleURIResolver nominated as part of the StaticQueryContext.
        Parameters:
        resolver - the URI resolver for XQuery modules. May be null, in which case any existing Module URI Resolver is removed from the configuration
      • setModuleURIResolver

        public void setModuleURIResolver​(java.lang.String className)
                                  throws javax.xml.transform.TransformerException
        Create and register an instance of a ModuleURIResolver with a specified class name. This will be used for resolving URIs in XQuery "import module" declarations, unless a more specific ModuleURIResolver has been nominated as part of the StaticQueryContext.
        Parameters:
        className - The fully-qualified name of the LocationHintResolver class
        Throws:
        javax.xml.transform.TransformerException - if the requested class does not implement the net.sf.saxon.LocationHintResolver interface
      • getModuleURIResolver

        public ModuleURIResolver getModuleURIResolver()
        Get the user-defined ModuleURIResolver for resolving URIs used in "import module" declarations in the XQuery prolog; returns null if none has been explicitly set.
        Returns:
        the resolver for Module URIs
      • getStandardModuleURIResolver

        public ModuleURIResolver getStandardModuleURIResolver()
        Get the standard system-defined ModuleURIResolver for resolving URIs used in "import module" declarations in the XQuery prolog.
        Returns:
        the standard system-defined ModuleURIResolver for resolving URIs
      • getUnparsedTextURIResolver

        public UnparsedTextURIResolver getUnparsedTextURIResolver()
        Get the URI resolver used for resolving URIs passed to the unparsed-text(), unparsed-text-available(), and unparsed-text-lines() functions, as well as json-doc().
        Returns:
        the URI resolver set for these functions, if one has been set, or the standard system-supplied resolver otherwise
      • setUnparsedTextURIResolver

        public void setUnparsedTextURIResolver​(UnparsedTextURIResolver resolver)
        Set the URI resolver to be used for resolving URIs passed to the unparsed-text(), unparsed-text-available(), and unparsed-text-lines() functions, as well as json-doc().
        Parameters:
        resolver - the URI resolver to be used for these functions.
      • getDefaultXsltCompilerInfo

        public CompilerInfo getDefaultXsltCompilerInfo()
        Get the default options for XSLT compilation
        Returns:
        the default options for XSLT compilation. The CompilerInfo object will reflect any options set using other methods available for this Configuration object
      • getDefaultStaticQueryContext

        public StaticQueryContext getDefaultStaticQueryContext()
        Get the default options for XQuery compilation
        Returns:
        the default XQuery static context for this configuration
      • makeStaticQueryContext

        protected StaticQueryContext makeStaticQueryContext​(boolean copyFromDefault)
        Make a new static query context object using the factory registered with this configuration
        Parameters:
        copyFromDefault - true if the new static query context is to copy the properties of the default static query context held in the configuration
        Returns:
        the new static query context object
      • registerFunctionAnnotationHandler

        public void registerFunctionAnnotationHandler​(FunctionAnnotationHandler handler)
        Register a FunctionAnnotationHandler to handle XQuery function annotations in a particular namespace
        Parameters:
        handler - a function annotation handler to be invoked in respect of function annotations in the relevant namespace
      • getFunctionAnnotationHandler

        public FunctionAnnotationHandler getFunctionAnnotationHandler​(NamespaceUri namespace)
        Get the FunctionAnnotationHandler used to handle XQuery function annotations in a particular namespace
        Parameters:
        namespace - the namespace
        Returns:
        a function annotation handler to be invoked in respect of function annotations in the relevant namespace, or null if none has been registered
      • isStreamabilityEnabled

        public boolean isStreamabilityEnabled()
        Ask whether streamability checking is enabled for this configuration
        Returns:
        always false for Saxon-HE
      • getSourceParserClass

        public java.lang.String getSourceParserClass()
        Get the name of the class that will be instantiated to create an XML parser for parsing source documents (for example, documents loaded using the document() or doc() functions).

        This method is retained in Saxon for backwards compatibility, but the preferred way of choosing an XML parser is to use JAXP interfaces, for example by supplying a JAXP SAXSource object initialized with an appropriate implementation of org.xml.sax.XMLReader.

        Returns:
        the fully qualified name of the XML parser class
      • setSourceParserClass

        public void setSourceParserClass​(java.lang.String sourceParserClass)
        Set the name of the class that will be instantiated to create an XML parser for parsing source documents (for example, documents loaded using the document() or doc() functions).

        This method is retained in Saxon for backwards compatibility, but the preferred way of choosing an XML parser is to use JAXP interfaces, for example by supplying a JAXP SAXSource object initialized with an appropriate implementation of org.xml.sax.XMLReader.

        Parameters:
        sourceParserClass - the fully qualified name of the XML parser class. This must implement the SAX2 XMLReader interface. The value "#DEFAULT" requests the internal JDK default parser.
      • getStyleParserClass

        public java.lang.String getStyleParserClass()
        Get the name of the class that will be instantiated to create an XML parser for parsing stylesheet modules.

        This method is retained in Saxon for backwards compatibility, but the preferred way of choosing an XML parser is to use JAXP interfaces, for example by supplying a JAXP Source object initialized with an appropriate implementation of org.xml.sax.XMLReader.

        Returns:
        the fully qualified name of the XML parser class
      • setStyleParserClass

        public void setStyleParserClass​(java.lang.String parser)
        Set the name of the class that will be instantiated to create an XML parser for parsing stylesheet modules.

        This method is retained in Saxon for backwards compatibility, but the preferred way of choosing an XML parser is to use JAXP interfaces, for example by supplying a JAXP Source object initialized with an appropriate implementation of org.xml.sax.XMLReader.

        Parameters:
        parser - the fully qualified name of the XML parser class. The value "#DEFAULT" requests the internal * JDK default parser.
      • getOutputURIResolver

        public OutputURIResolver getOutputURIResolver()
        Get the OutputURIResolver that will be used to resolve URIs used in the href attribute of the xsl:result-document instruction.
        Returns:
        the OutputURIResolver. If none has been supplied explicitly, the default OutputURIResolver is returned.
        Since:
        8.4
      • setSerializerFactory

        public void setSerializerFactory​(SerializerFactory factory)
        Set a custom SerializerFactory. This will be used to create a serializer for a given set of output properties and result destination.
        Parameters:
        factory - a custom SerializerFactory
        Since:
        8.8
      • getSerializerFactory

        public SerializerFactory getSerializerFactory()
        Get the SerializerFactory. This returns the standard built-in SerializerFactory, unless a custom SerializerFactory has been registered.
        Returns:
        the SerializerFactory in use
        Since:
        8.8
      • getCharacterSetFactory

        public CharacterSetFactory getCharacterSetFactory()
        Get the CharacterSetFactory. Note: at present this cannot be changed.
        Returns:
        the CharacterSetFactory in use.
        Since:
        9.2
      • setDefaultSerializationProperties

        public void setDefaultSerializationProperties​(java.util.Properties props)
        Set the default serialization properties.

        The method name is a misnomer, retained for backwards compatibility. A SerializationProperties object contains a set of Properties holding simple properties, together with an optional CharacterMap holding a character map. This method returns the simple properties only. In fact the default properties held in the Configuration only contain simple properties, and never a character map.

        Parameters:
        props - the default properties
      • getDefaultSerializationProperties

        public java.util.Properties getDefaultSerializationProperties()
        Get the default output properties. The returned value can be modified in-situ using methods such as Properties.setProperty(String, String) to change the defaults in force for the Configuration.

        The method name is a misnomer, retained for backwards compatibility. A SerializationProperties object contains a set of Properties holding simple properties, together with an optional CharacterMap holding a character map. This method returns the simple properties only. In fact the default properties held in the Configuration only contain simple properties, and never a character map.

        Returns:
        the default output properties.
      • obtainDefaultSerializationProperties

        public SerializationProperties obtainDefaultSerializationProperties()
        Obtain a default SerializationProperties object.
        Returns:
        the default serialization properties. This is obtained by wrapping the default output properties maintained in the Configuration within a SerializationProperties wrapper. The returned value can be modified in-situ using methods such as SerializationProperties.setProperty(String, String) to change the defaults in force for the Configuration.
      • processResultDocument

        public void processResultDocument​(ResultDocument instruction,
                                          PushEvaluator content,
                                          XPathContext context)
                                   throws XPathException
        Process an xsl:result-document instruction. The Saxon-HE version of this method simply executes the instruction. The Saxon-EE version starts a new thread, and executes the instruction in that thread.
        Parameters:
        instruction - the instruction to be executed
        content - the expression that defines the content of the new result document
        context - the evaluation context
        Throws:
        XPathException - if any dynamic error occurs
      • getMultithreadedItemMappingIterator

        public SequenceIterator getMultithreadedItemMappingIterator​(SequenceIterator base,
                                                                    ItemMappingFunction action)
                                                             throws XPathException
        Get an item mapping iterator suitable for multi-threaded execution, if this is permitted
        Parameters:
        base - iterator over the input sequence
        action - mapping function to be applied to each item in the input sequence.
        Returns:
        an iterator over the result sequence
        Throws:
        XPathException - if (for example) a dynamic error occurs while priming the queue
      • isTiming

        public boolean isTiming()
        Determine whether brief progress messages and timing information will be output.

        This method is provided largely for internal use. Progress messages are normally controlled directly from the command line interfaces, and are not normally used when driving Saxon from the Java API.

        Returns:
        true if these messages are to be output.
      • setTiming

        public void setTiming​(boolean timing)
        Determine whether brief progress messages and timing information will be output.

        This method is provided largely for internal use. Progress messages are normally controlled directly from the command line interfaces, and are not normally used when running from a Java application.

        The name of the method is poorly chosen, since many of the progress messages that are output have little to do with timing or instrumentation.

        If enabled, the relevant messages will be sent either to the destination set using setLogger(Logger) or to the destination set using setStandardErrorOutput(PrintStream), depending on the message.

        Parameters:
        timing - true if these messages are to be output.
      • isVersionWarning

        @Deprecated
        public boolean isVersionWarning()
        Deprecated.
        since 10.0; the method has had no effect since Saxon 9.8
        Determine whether a warning is to be output when running against a stylesheet labelled as version="1.0". The XSLT specification requires such a warning unless the user disables it.
        Returns:
        always false.
        Since:
        8.4
      • setVersionWarning

        @Deprecated
        public void setVersionWarning​(boolean warn)
        Deprecated.
        since 10.0; the method has had no effect since Saxon 9.8
        Determine whether a warning is to be output when the version attribute of the stylesheet does not match the XSLT processor version. (In the case where the stylesheet version is "1.0", the XSLT specification requires such a warning unless the user disables it.)
        Parameters:
        warn - ignored.
        Since:
        8.4
      • isValidation

        public boolean isValidation()
        Determine whether the XML parser for source documents will be asked to perform validation of source documents
        Returns:
        true if DTD validation is requested.
        Since:
        8.4
      • setValidation

        public void setValidation​(boolean validation)
        Determine whether the XML parser for source documents will be asked to perform DTD validation of source documents
        Parameters:
        validation - true if DTD validation is to be requested.
        Since:
        8.4
      • makeDocumentProjector

        public FilterFactory makeDocumentProjector​(PathMap.PathMapRoot map)
        Create a document projector for a given path map root. Document projection is available only in Saxon-EE, so the Saxon-HE version of this method throws an exception
        Parameters:
        map - a path map root in a path map. This might represent the call to the initial context item for a query, or it might represent a call on the doc() function. The path map contains information about the paths that the query uses within this document.
        Returns:
        a push filter that implements document projection
        Throws:
        java.lang.UnsupportedOperationException - if this is not a schema-aware configuration, or if no Saxon-EE license is available
      • makeDocumentProjector

        public FilterFactory makeDocumentProjector​(XQueryExpression exp)
        Create a document projector for the document supplied as the initial context item in a query. Document projection is available only in Saxon-EE, so the Saxon-HE version of this method throws an exception
        Parameters:
        exp - an XQuery expression. The document projector that is returned will be for the document supplied as the context item to this query.
        Returns:
        a push filter that implements document projection
        Throws:
        java.lang.UnsupportedOperationException - if this is not a schema-aware configuration, or if no Saxon-EE license is available
      • getSchemaValidationMode

        public int getSchemaValidationMode()
        Ask whether source documents (supplied as a StreamSource or SAXSource) should be subjected to schema validation, and if so, in what validation mode
        Returns:
        the schema validation mode previously set using setSchemaValidationMode(), or the default mode Validation.STRIP otherwise.
      • setSchemaValidationMode

        public void setSchemaValidationMode​(int validationMode)
        Say whether source documents (supplied as a StreamSource or SAXSource) should be subjected to schema validation, and if so, in what validation mode. This value may be overridden at the level of a Controller for an individual transformation or query.
        Parameters:
        validationMode - the validation (or construction) mode to be used for source documents. One of Validation.STRIP, Validation.PRESERVE, Validation.STRICT, Validation.LAX
        Since:
        8.4
      • setValidationWarnings

        public void setValidationWarnings​(boolean warn)
        Indicate whether schema validation failures on result documents are to be treated as fatal errors or as warnings. Note that all validation errors are reported to the error() method of the ErrorListener, and processing always continues except when that method chooses to throw an exception. At the end of the document, a fatal error is thrown if (a) there have been any validation errors, and (b) this option is not set.
        Parameters:
        warn - true if schema validation failures are to be treated as warnings; false if they are to be treated as fatal errors.
        Since:
        8.4
      • isValidationWarnings

        public boolean isValidationWarnings()
        Determine whether schema validation failures on result documents are to be treated as fatal errors or as warnings. Note that all validation errors are reported to the error() method of the ErrorListener, and processing always continues except when that method chooses to throw an exception. At the end of the document, a fatal error is thrown if (a) there have been any validation errors, and (b) this option is not set.
        Returns:
        true if validation errors are to be treated as warnings (that is, the validation failure is reported but processing continues as normal); false if validation errors are fatal.
        Since:
        8.4
      • setExpandAttributeDefaults

        public void setExpandAttributeDefaults​(boolean expand)
        Indicate whether attributes that have a fixed or default value are to be expanded when generating a final result tree. By default (and for conformance with the W3C specifications) it is required that fixed and default values should be expanded. However, there are use cases for example when generating XHTML when this serves no useful purpose and merely bloats the output.

        This option can be overridden at the level of a PipelineConfiguration

        Parameters:
        expand - true if fixed and default values are to be expanded as required by the W3C specifications; false if this action is to be disabled. Note that this only affects the validation of final result trees; it is not possible to suppress expansion of fixed or default values on input documents, as this would make the type annotations on input nodes unsound.
        Since:
        9.0
      • isExpandAttributeDefaults

        public boolean isExpandAttributeDefaults()
        Determine whether elements and attributes that have a fixed or default value are to be expanded. This option applies both to DTD-defined attribute defaults and to schema-defined defaults for elements and attributes. If an XML parser is used that does not report whether defaults have been used, this option is ignored.

        This option can be overridden at the level of a PipelineConfiguration

        Returns:
        true if elements and attributes that have a fixed or default value are to be expanded, false if defaults are not to be expanded. The default value is true. Note that the setting "false" is potentially non-conformant with the W3C specifications.
        Since:
        9.0
      • getNamePool

        public NamePool getNamePool()
        Get the target namepool to be used for stylesheets/queries and for source documents.
        Returns:
        the target name pool. If no NamePool has been specified explicitly, the default NamePool is returned.
        Since:
        8.4
      • setNamePool

        public void setNamePool​(NamePool targetNamePool)
        Set the NamePool to be used for stylesheets/queries and for source documents.

        Using this method allows several Configurations to share the same NamePool. This was the normal default arrangement until Saxon 8.9, which changed the default so that each Configuration uses its own NamePool.

        Sharing a NamePool creates a potential bottleneck, since changes to the namepool are synchronized.

        Parameters:
        targetNamePool - The NamePool to be used.
        Since:
        8.4
      • getTypeHierarchy

        public TypeHierarchy getTypeHierarchy()
        Get the TypeHierarchy: a cache holding type information
        Returns:
        the type hierarchy cache
      • getTypeChecker

        public TypeChecker getTypeChecker​(boolean backwardsCompatible)
        Get an appropriate type-checker. The type-checker that is returned depends on whether backwards compatible (XPath 1.0) mode is enabled (which requires Saxon-PE or higher)
        Parameters:
        backwardsCompatible - set to true if XPath 1.0 compatibility mode is required
        Returns:
        a suitable TypeChecker
      • makeTypeAliasManager

        public TypeAliasManager makeTypeAliasManager()
        Make a TypeAliasManager appropriate to the type of Configuration
        Returns:
        a new TypeAliasManager
      • getDocumentNumberAllocator

        public DocumentNumberAllocator getDocumentNumberAllocator()
        Get the document number allocator.

        The document number allocator is used to allocate a unique number to each document built under this configuration. The document number forms the basis of all tests for node identity; it is therefore essential that when two documents are accessed in the same XPath expression, they have distinct document numbers. Normally this is ensured by building them under the same Configuration. Using this method together with setDocumentNumberAllocator(net.sf.saxon.tree.util.DocumentNumberAllocator), however, it is possible to have two different Configurations that share a single DocumentNumberAllocator

        Returns:
        the current DocumentNumberAllocator
        Since:
        9.0
      • setDocumentNumberAllocator

        public void setDocumentNumberAllocator​(DocumentNumberAllocator allocator)
        Set the document number allocator.

        The document number allocator is used to allocate a unique number to each document built under this configuration. The document number forms the basis of all tests for node identity; it is therefore essential that when two documents are accessed in the same XPath expression, they have distinct document numbers. Normally this is ensured by building them under the same Configuration. Using this method together with getDocumentNumberAllocator(), however, it is possible to have two different Configurations that share a single DocumentNumberAllocator

        This method is for advanced applications only. Misuse of the method can cause problems with node identity. The method should not be used except while initializing a Configuration, and it should be used only to arrange for two different configurations to share the same DocumentNumberAllocators. In this case they should also share the same NamePool.

        Parameters:
        allocator - the DocumentNumberAllocator to be used
        Since:
        9.0
      • isCompatible

        public boolean isCompatible​(Configuration other)
        Determine whether two Configurations are compatible. When queries, transformations, and path expressions are run, all the Configurations used to build the documents and to compile the queries and stylesheets must be compatible. Two Configurations are compatible if they share the same NamePool and the same DocumentNumberAllocator.
        Parameters:
        other - the other Configuration to be compared with this one
        Returns:
        true if the two configurations are compatible
      • getGlobalDocumentPool

        public DocumentPool getGlobalDocumentPool()
        Get the global document pool. This is used for documents preloaded during query or stylesheet compilation. The user application can preload documents into the global pool, where they will be found if any query or stylesheet requests the specified document using the doc() or document() function.
        Returns:
        the global document pool
        Since:
        9.1
      • isStripsAllWhiteSpace

        public boolean isStripsAllWhiteSpace()
        Determine whether whitespace-only text nodes are to be stripped unconditionally from source documents.
        Returns:
        true if the space stripping rules for the default parseOptions cause whitespace text nodes to be stripped from all elements.
        Since:
        8.4
      • getSourceParser

        public org.xml.sax.XMLReader getSourceParser()
                                              throws javax.xml.transform.TransformerFactoryConfigurationError
        Get a parser for source documents. The parser is allocated from a pool if any are available from the pool: the client should ideally return the parser to the pool after use, so that it can be reused.

        This method is intended primarily for internal use.

        Returns:
        a parser, in which the namespace properties must be set as follows: namespaces=true; namespace-prefixes=false. The DTD validation feature of the parser will be set on or off depending on the setValidation(boolean) setting.
        Throws:
        javax.xml.transform.TransformerFactoryConfigurationError - if a failure occurs configuring the parser for use.
      • reuseSourceParser

        public void reuseSourceParser​(org.xml.sax.XMLReader parser)
        Return a source parser to the pool, for reuse
        Parameters:
        parser - The parser: the caller must not supply a parser that was obtained by any mechanism other than calling the getSourceParser() method. Must not be null.
      • getStyleParser

        public org.xml.sax.XMLReader getStyleParser()
                                             throws javax.xml.transform.TransformerFactoryConfigurationError
        Get the parser for stylesheet documents. This parser is also used for schema documents.

        This method is intended for internal use only.

        Returns:
        an XML parser (a SAX2 parser) that can be used for stylesheets and schema documents
        Throws:
        javax.xml.transform.TransformerFactoryConfigurationError - if an error occurs configuring the parser
      • reuseStyleParser

        public void reuseStyleParser​(org.xml.sax.XMLReader parser)
        Return a stylesheet (or schema) parser to the pool, for reuse
        Parameters:
        parser - The parser: the caller must not supply a parser that was obtained by any mechanism other than calling the getStyleParser() method.
      • loadSchema

        public void loadSchema​(java.lang.String absoluteURI)
                        throws SchemaException
        Simple interface to load a schema document
        Parameters:
        absoluteURI - the absolute URI of the location of the schema document
        Throws:
        SchemaException - if the schema document at the given location cannot be read or is invalid
      • readSchema

        public NamespaceUri readSchema​(PipelineConfiguration pipe,
                                       java.lang.String baseURI,
                                       java.lang.String schemaLocation,
                                       NamespaceUri expected)
                                throws SchemaException
        Read a schema from a given schema location

        This method is intended for internal use.

        Parameters:
        pipe - the PipelineConfiguration
        baseURI - the base URI of the instruction requesting the reading of the schema
        schemaLocation - the location of the schema to be read
        expected - The expected targetNamespace of the schema being read, or null if there is no expectation
        Returns:
        the target namespace of the schema; null if no schema has been read
        Throws:
        java.lang.UnsupportedOperationException - when called in the non-schema-aware version of the product
        SchemaException - if the schema cannot be read
      • readMultipleSchemas

        public void readMultipleSchemas​(PipelineConfiguration pipe,
                                        java.lang.String baseURI,
                                        java.util.List<java.lang.String> schemaLocations,
                                        NamespaceUri expected)
                                 throws SchemaException
        Read schemas from a list of schema locations.

        This method is intended for internal use.

        Parameters:
        pipe - the pipeline configuration
        baseURI - the base URI against which the schema locations are to be resolved
        schemaLocations - the relative URIs specified as schema locations
        expected - the namespace URI which is expected as the target namespace of the loaded schema
        Throws:
        SchemaException - if an error occurs
      • readInlineSchema

        public NamespaceUri readInlineSchema​(NodeInfo root,
                                             NamespaceUri expected,
                                             ErrorReporter errorReporter)
                                      throws SchemaException
        Read an inline schema from a stylesheet.

        This method is intended for internal use.

        Parameters:
        root - the xs:schema element in the stylesheet
        expected - the target namespace expected; null if there is no expectation.
        errorReporter - The destination for error messages. May be null, in which case the errorListener registered with this Configuration is used.
        Returns:
        the actual target namespace of the schema
        Throws:
        SchemaException - if the schema cannot be processed
      • needEnterpriseEdition

        protected void needEnterpriseEdition()
        Throw an error indicating that a request cannot be satisfied because it requires the schema-aware edition of Saxon
      • addSchemaSource

        public void addSchemaSource​(javax.xml.transform.Source schemaSource)
                             throws SchemaException
        Load a schema, which will be available for use by all subsequent operations using this Configuration. Any errors will be notified to the ErrorListener associated with this Configuration.
        Parameters:
        schemaSource - the JAXP Source object identifying the schema document to be loaded
        Throws:
        SchemaException - if the schema cannot be read or parsed or if it is invalid
        java.lang.UnsupportedOperationException - if the configuration is not schema-aware
        Since:
        8.4
      • addSchemaSource

        public void addSchemaSource​(javax.xml.transform.Source schemaSource,
                                    ErrorReporter errorReporter)
                             throws SchemaException
        Load a schema, which will be available for use by all subsequent operations using this EnterpriseConfiguration.
        Parameters:
        schemaSource - the JAXP Source object identifying the schema document to be loaded
        errorReporter - the ErrorListener to be notified of any errors in the schema.
        Throws:
        SchemaException - if the schema cannot be read or parsed or if it is invalid
      • addSchemaForBuiltInNamespace

        public void addSchemaForBuiltInNamespace​(NamespaceUri namespace)
        Add a built-in schema for a given namespace. This is a no-op if the configuration is not schema-aware
        Parameters:
        namespace - the namespace. Currently built-in schemas are available for the XML and FN namespaces
      • isSchemaAvailable

        public boolean isSchemaAvailable​(NamespaceUri targetNamespace)
        Determine whether the Configuration contains a cached schema for a given target namespace
        Parameters:
        targetNamespace - the target namespace of the schema being sought (supply "" for the unnamed namespace)
        Returns:
        true if the schema for this namespace is available, false if not.
      • clearSchemaCache

        public void clearSchemaCache()
        Remove all schema components that have been loaded into this Configuration. This method must not be used if any processes (such as stylesheet or query compilations or executions) are currently active. In a multi-threaded environment, it is the user's responsibility to ensure that this method is not called unless it is safe to do so.
      • getImportedNamespaces

        public java.util.Set<NamespaceUri> getImportedNamespaces()
        Get the set of namespaces of imported schemas
        Returns:
        a Set whose members are the namespaces of all schemas in the schema cache, as String objects
      • sealNamespace

        public void sealNamespace​(NamespaceUri namespace)
        Mark a schema namespace as being sealed. This is done when components from this namespace are first used for validating a source document or compiling a source document or query. Once a namespace has been sealed, it is not permitted to change the schema components in that namespace by redefining them, deriving new types by extension, or adding to their substitution groups.
        Parameters:
        namespace - the namespace URI of the components to be sealed
      • getDeclaredSchemaParameters

        public java.util.Collection<GlobalParam> getDeclaredSchemaParameters()
        Get the set of saxon:param schema parameters declared in the schema held by this Configuration.
        Returns:
        the set of parameters. May return null if none have been declared.
      • getExtensionsOfType

        public java.lang.Iterable<? extends SchemaType> getExtensionsOfType​(SchemaType type)
        Get the set of complex types that have been defined as extensions of a given type. Note that we do not seal the schema namespace, so this list is not necessarily final; we must assume that new extensions of built-in simple types can be added at any time
        Parameters:
        type - the type whose extensions are required
        Returns:
        an iterator over the types that are derived from the given type by extension
      • importComponents

        public void importComponents​(javax.xml.transform.Source source)
                              throws XPathException
        Import a precompiled Schema Component Model from a given Source. The schema components derived from this schema document are added to the cache of schema components maintained by this SchemaManager
        Parameters:
        source - the XML file containing the schema component model, as generated by a previous call on exportComponents(net.sf.saxon.event.Receiver)
        Throws:
        XPathException - if an error occurs
      • exportComponents

        public void exportComponents​(Receiver out)
                              throws XPathException
        Export a precompiled Schema Component Model containing all the components (except built-in components) that have been loaded into this Processor.
        Parameters:
        out - the destination to recieve the precompiled Schema Component Model in the form of an XML document
        Throws:
        XPathException - if a failure occurs
      • getElementDeclaration

        public SchemaDeclaration getElementDeclaration​(int fingerprint)
        Get a global element declaration by fingerprint
        Parameters:
        fingerprint - the NamePool fingerprint of the element name
        Returns:
        the element declaration whose name matches the given fingerprint, or null if no element declaration with this name has been registered.
      • getElementDeclaration

        public SchemaDeclaration getElementDeclaration​(StructuredQName qName)
        Get a global element declaration by name.
        Parameters:
        qName - the name of the required element declaration
        Returns:
        the element declaration whose name matches the given name, or null if no element declaration with this name has been registered.
      • getAttributeDeclaration

        public SchemaDeclaration getAttributeDeclaration​(int fingerprint)
        Get a global attribute declaration by fingerprint
        Parameters:
        fingerprint - the NamePool fingerprint of the element name
        Returns:
        the attribute declaration whose name matches the given fingerprint, or null if no element declaration with this name has been registered.
      • getAttributeDeclaration

        public SchemaDeclaration getAttributeDeclaration​(StructuredQName attributeName)
        Get a global attribute declaration by name
        Parameters:
        attributeName - the name of the required attribute declaration
        Returns:
        the attribute declaration whose name matches the given fingerprint, or null if no element declaration with this name has been registered.
      • getSchemaType

        public SchemaType getSchemaType​(StructuredQName name)
        Get the top-level schema type definition with a given QName.
        Parameters:
        name - the name of the required schema type
        Returns:
        the schema type , or null if there is none with this name.
        Since:
        9.7
      • makeUserUnionType

        public ItemType makeUserUnionType​(java.util.List<AtomicType> memberTypes)
        Make a union type with a given list of member types
        Parameters:
        memberTypes - the member types
        Returns:
        null for a Saxon-HE or -PE Configuration
      • isDeclaredNotation

        public boolean isDeclaredNotation​(NamespaceUri uri,
                                          java.lang.String local)
        Ask whether a given notation has been declared in the schema
        Specified by:
        isDeclaredNotation in interface NotationSet
        Parameters:
        uri - the targetNamespace of the notation
        local - the local part of the notation name
        Returns:
        true if the notation has been declared, false if not
        Since:
        9.3
      • checkTypeDerivationIsOK

        public void checkTypeDerivationIsOK​(SchemaType derived,
                                            SchemaType base,
                                            int block)
                                     throws SchemaException
        Check that a type is validly derived from another type, following the rules for the Schema Component Constraint "Is Type Derivation OK (Simple)" (3.14.6) or "Is Type Derivation OK (Complex)" (3.4.6) as appropriate.
        Parameters:
        derived - the derived type
        base - the base type; the algorithm tests whether derivation from this type is permitted
        block - the derivations that are blocked by the relevant element declaration
        Throws:
        SchemaException - if the derivation is not allowed
      • prepareValidationReporting

        public void prepareValidationReporting​(XPathContext context,
                                               ParseOptions options)
        Set validation reporting options. Called by instructions that invoke validation to set up an appropriate invalidity handler
        Parameters:
        context - the XPath evaluation context
        options - the parser options, to be updated
      • getDocumentValidator

        public Receiver getDocumentValidator​(Receiver receiver,
                                             java.lang.String systemId,
                                             ParseOptions validationOptions,
                                             Location initiatingLocation)
        Get a document-level validator to add to a Receiver pipeline.

        This method is intended for internal use.

        Parameters:
        receiver - The receiver to which events should be sent after validation
        systemId - the base URI of the document being validated
        validationOptions - Supplies options relevant to XSD validation
        initiatingLocation - The location of the expression that requested validation
        Returns:
        A Receiver to which events can be sent for validation
      • getElementValidator

        public Receiver getElementValidator​(Receiver receiver,
                                            ParseOptions validationOptions,
                                            Location locationId)
                                     throws XPathException
        Get a Receiver that can be used to validate an element, and that passes the validated element on to a target receiver. If validation is not supported, the returned receiver will be the target receiver.

        This method is intended for internal use.

        Parameters:
        receiver - the target receiver tp receive the validated element
        validationOptions - options affecting the way XSD validation is done
        locationId - current location in the stylesheet or query
        Returns:
        The target receiver, indicating that with this configuration, no validation is performed.
        Throws:
        XPathException - if a validator for the element cannot be created
      • getAnnotationStripper

        public Receiver getAnnotationStripper​(Receiver destination)
        Add to a pipeline a receiver that strips all type annotations. This has a null implementation in the Saxon-HE product, because type annotations can never arise.

        This method is intended for internal use.

        Parameters:
        destination - the Receiver that events will be written to after whitespace stripping
        Returns:
        the Receiver to which events should be sent for stripping
      • makeParser

        public org.xml.sax.XMLReader makeParser​(java.lang.String className)
                                         throws javax.xml.transform.TransformerFactoryConfigurationError
        Create a new SAX XMLReader object using the class name provided.

        The named class must exist and must implement the org.xml.sax.XMLReader or Parser interface.

        This method returns an instance of the parser named.

        This method is intended for internal use.

        Parameters:
        className - A string containing the name of the SAX parser class, for example "com.microstar.sax.LarkDriver"; alternatively, the value "#DEFAULT" to get the internal default JDK parser
        Returns:
        an instance of the Parser class named, or null if it is not loadable or is not a Parser.
        Throws:
        javax.xml.transform.TransformerFactoryConfigurationError - if a failure occurs configuring the parser of this class
      • newExpressionParser

        public XPathParser newExpressionParser​(java.lang.String language,
                                               boolean updating,
                                               StaticContext env)
                                        throws XPathException
        Make an expression Parser for a specified version of XPath or XQuery
        Parameters:
        language - set to "XP" (XPath) or "XQ" (XQuery) or "PATTERN" (XSLT Patterns)
        updating - indicates whether or not XQuery update syntax may be used. Note that XQuery Update is supported only in Saxon-EE
        env -
        Returns:
        the XPath or Query parser
        Throws:
        XPathException - if this version of Saxon does not support the requested options
      • newExpressionExporter

        public ExpressionPresenter newExpressionExporter​(java.lang.String target,
                                                         java.io.OutputStream destination,
                                                         StylesheetPackage rootPackage)
                                                  throws XPathException
        Get a new ExpressionPresenter capable of exporting a compiled stylesheet
        Parameters:
        target - the target environment, e.g. EE, JS
        destination - the destination for the output file
        rootPackage - the root package of the export
        Returns:
        a suitable Expression Presenter
        Throws:
        XPathException - if none is available (e.g. because this is not Saxon-EE)
      • setDebugger

        public void setDebugger​(Debugger debugger)
        Set the debugger to be used.

        This method is provided for advanced users only, and is subject to change.

        Parameters:
        debugger - the debugger to be used, or null if no debugger is to be used
      • getDebugger

        public Debugger getDebugger()
        Get the debugger in use. This will be null if no debugger has been registered.

        This method is provided for advanced users only, and is subject to change.

        Returns:
        the debugger in use, or null if none is in use
      • makeSlotManager

        public SlotManager makeSlotManager()
        Factory method to create a SlotManager.

        This method is provided for advanced users only, and is subject to change.

        Returns:
        a SlotManager (which is a skeletal stack frame representing the mapping of variable names to slots on the stack frame)
      • makeStreamingTransformer

        public Receiver makeStreamingTransformer​(Mode mode,
                                                 ParameterSet ordinaryParams,
                                                 ParameterSet tunnelParams,
                                                 Outputter output,
                                                 XPathContext context)
                                          throws XPathException
        Create a streaming transformer
        Parameters:
        mode - the initial mode, which must be a streaming mode
        ordinaryParams - the parameters that are not tunnel parameters
        tunnelParams - the tunnel parameters
        output - the destination for the result
        context - the initial XPath context
        Returns:
        a Receiver to which the streamed input document will be pushed
        Throws:
        XPathException - if a streaming transformer cannot be created (which is always the case in Saxon-HE and Saxon-PE)
      • getFocusTrackerFactory

        public java.util.function.Function<SequenceIterator,​FocusTrackingIterator> getFocusTrackerFactory​(Executable exec,
                                                                                                                boolean multithreaded)
        Get a factory function that can be used to wrap a SequenceIterator in a FocusTrackingIterator. This is called by the Controller to get a default factory function; the value can be overridden by the application using Controller.setFocusTrackerFactory(java.util.function.Function). The FocusTrackingIterator that is created by the factory must be thread-safe if it is to be used for iterating over a sequence where the items might be processed asynchronously using xsl:result-document; for this reason this method is overridden for a Saxon-EE configuration.
        Parameters:
        exec - the executable; supplied so that the factory can be sensitive to whether calls on xsl:result-document are possible
        multithreaded - set to true to get a factory suitable for creating focus tracking iterators for a multi-threaded xsl:for-each instruction
        Returns:
        a suitable factory function
      • checkStrictStreamability

        public void checkStrictStreamability​(XSLTemplate template,
                                             Expression body)
                                      throws XPathException
        Check the streamability of a template rule
        Parameters:
        template - the xsl:template element in the stylesheet tree
        body - of the compiled body of the template rule
        Throws:
        XPathException - if streamability problems are found
      • isStreamedNode

        public boolean isStreamedNode​(NodeInfo node)
        Ask whether a given node is a streamed node
        Parameters:
        node - the node in question
        Returns:
        true if the node is a node in a streamed document
      • getOptimizerOptions

        public OptimizerOptions getOptimizerOptions()
        Get the optimization options in use
        Returns:
        the configured optimization options
      • getPermittedOptimizerOptions

        public OptimizerOptions getPermittedOptimizerOptions()
        Get the optimization options permitted in this configuration
        Returns:
        the permitted optimization options
      • obtainOptimizer

        public Optimizer obtainOptimizer()
        Factory method to get an Optimizer.

        This method is intended for internal use only.

        Returns:
        the optimizer used in this configuration, which is created if necessary
      • obtainOptimizer

        public Optimizer obtainOptimizer​(OptimizerOptions options)
        Factory method to get an Optimizer with specified optimizer options.

        This method is intended for internal use only.

        Parameters:
        options - the optimizer options
        Returns:
        a new optimizer with the specified options set (provided the optimizations are available in this Saxon configuration)
      • makeContextItemStaticInfo

        public ContextItemStaticInfo makeContextItemStaticInfo​(ItemType itemType,
                                                               boolean maybeUndefined)
        Factory method to make a ContextItemStaticInfo
        Parameters:
        itemType - the item type of the context item. If the context item is absent, set this to ErrorType.getInstance().
        maybeUndefined - set to true if it is possible (or certain) that the context item will be absent.
        Returns:
        the ContextItemStaticInfo
      • getDefaultContextItemStaticInfo

        public ContextItemStaticInfo getDefaultContextItemStaticInfo()
        Get a default ContextItemStaticInfo, indication no information is available about the context item type
        Returns:
        the default ContextItemStaticInfo
      • makeXQueryExpression

        public XQueryExpression makeXQueryExpression​(Expression exp,
                                                     QueryModule mainModule,
                                                     boolean streaming)
                                              throws XPathException
        Factory method to make an XQueryExpression
        Parameters:
        exp - the expression forming the body of the query
        mainModule - the query module containing the expression
        streaming - true if streamed execution is requested
        Returns:
        the XQueryExpression
        Throws:
        XPathException - if an error occurs
      • makeSequenceExtent

        public GroundedValue makeSequenceExtent​(Expression expression,
                                                int ref,
                                                XPathContext context)
                                         throws XPathException
        Make a SequenceExtent, given the expected reference count
        Parameters:
        expression - the expression to be evaluated
        ref - the (nominal) number of times the value of the expression is required
        context - the XPath dynamic evaluation context
        Returns:
        the constructed SequenceExtent
        Throws:
        XPathException - if evaluation of the expression fails
      • makeStyleNodeFactory

        public StyleNodeFactory makeStyleNodeFactory​(Compilation compilation)
        Factory method to make the StyleNodeFactory, used for constructing elements in a stylesheet document
        Parameters:
        compilation - the compilation episode (compiling one package)
        Returns:
        the StyleNodeFactory used in this Configuration
      • makeEvaluateInstruction

        public Expression makeEvaluateInstruction​(XSLEvaluate source,
                                                  ComponentDeclaration decl)
                                           throws XPathException
        Make an instruction to implement xsl:evaluate
        Parameters:
        source - the xsl:evaluate element in the raw stylesheet tree
        decl - the corresponding component declaration
        Returns:
        the compiled instruction
        Throws:
        XPathException - if static errors are found
      • makeStylesheetPackage

        public StylesheetPackage makeStylesheetPackage()
        Factory method to make a StylesheetPackage
        Returns:
        a StylesheetPackage suitable for use in this Configuration
      • makeAccumulatorRegistry

        public AccumulatorRegistry makeAccumulatorRegistry()
        Factory method to make the AccumulatorRegistry, used for static information about the accumulators defined in a package
        Returns:
        a new AccumulatorRegistry appropriate to this Configuration
      • registerExternalObjectModel

        public void registerExternalObjectModel​(ExternalObjectModel model)
        Register an external object model with this Configuration.
        Parameters:
        model - The external object model. This can either be one of the system-supplied external object models such as Axiom, DOM4J, JDOM, or XOM, or a user-supplied external object model.
        See Also:
        AxiomObjectModel, DOM4JObjectModel, JDOM2ObjectModel, XOMObjectModel
      • deregisterExternalObjectModel

        public void deregisterExternalObjectModel​(ExternalObjectModel model)
        Remove an entry from the list of registered external object models
        Parameters:
        model - the model to be removed
      • clearExternalObjectModels

        public void clearExternalObjectModels()
        Clear all the registered external object models
      • getExternalObjectModel

        public ExternalObjectModel getExternalObjectModel​(java.lang.String uri)
        Get the external object model with a given URI, if registered
        Parameters:
        uri - the identifying URI of the required external object model
        Returns:
        the requested external object model if available, or null otherwise
      • getExternalObjectModel

        public ExternalObjectModel getExternalObjectModel​(java.lang.Class<?> nodeClass)
        Get the external object model that recognizes a particular class of node, if available
        Parameters:
        nodeClass - the class of the Node object in the external object model
        Returns:
        the requested external object model if available, or null otherwise
      • getExternalObjectModels

        public java.util.List<ExternalObjectModel> getExternalObjectModels()
        Get all the registered external object models.

        This method is intended for internal use only.

        Returns:
        a list of external object models supported. The members of the list are of type ExternalObjectModel
      • makeMethodMap

        public java.util.Map<java.lang.String,​FunctionItem> makeMethodMap​(java.lang.Class<?> javaClass,
                                                                                java.lang.String required)
        Make a map representing the methods defined in a class. This map is specific to the class, not to a particular instance. The functions present in this map take an extra first argument representing the target instance; the functions returned in the final instance-level map will be partial applications of the functions in the class-level map.
        Parameters:
        javaClass - the Java class whose methods are required
        required - if non-null, indicates the key of the entry that is required in the map. If this parameter is supplied, then the map will be limited to a single entry with this key, since it is known that the other entries would never be used
        Returns:
        a map whose entries represent public instance-level methods in the supplied Java class, to the extent that these methods have unique names.
        Throws:
        java.lang.UnsupportedOperationException - except in subclasses
      • externalObjectAsMap

        public MapItem externalObjectAsMap​(ObjectValue<?> value,
                                           java.lang.String required)
        Convert a Java object to a map
        Parameters:
        value - the (wrapped) Java object to be converted
        required - if non-null, indicates the key of the entry that is required in the map. If this parameter is supplied, then the map will be limited to a single entry with this key, since it is known that the other entries would never be used.
        Returns:
        an XDM map containing entries representing the public instance-level methods available in the object, to the extent that they have unique names.
        Throws:
        java.lang.UnsupportedOperationException - except in subclasses
      • makeObjectLookupExpression

        public Expression makeObjectLookupExpression​(Expression lhs,
                                                     Expression rhs)
        Make an object lookup expression: supports the construct X?Y where X is an external Java object. Requires Saxon-PE or higher
        Parameters:
        lhs - the left-hand operand
        rhs - the right-hand operand
        Returns:
        the constructed expression
      • unravel

        public NodeInfo unravel​(javax.xml.transform.Source source)
        Get a NodeInfo corresponding to a DOM or other external Node, either by wrapping or unwrapping the external Node.

        This method is intended for internal use.

        Parameters:
        source - A Source representing the wrapped or unwrapped external Node. This will typically be a DOMSource, but it may be a similar Source recognized by some other registered external object model.
        Returns:
        If the Source is a DOMSource and the underlying node is a wrapper around a Saxon NodeInfo, returns the wrapped Saxon NodeInfo. If the Source is a DOMSource and the undelying node is not such a wrapper, returns a new Saxon NodeInfo that wraps the DOM Node. If the Source is any other kind of source, it is offered to each registered external object model for similar treatment. The result is the NodeInfo object obtained by wrapping or unwrapping the supplied external node.
        Throws:
        java.lang.IllegalArgumentException - if the source object is not of a recognized class. This method does not call the registered to resolve the Source.
      • isExtensionElementAvailable

        public boolean isExtensionElementAvailable​(StructuredQName qName)
        Ask whether an extension element with a particular name is available
        Parameters:
        qName - the extension element name
        Returns:
        false (always, in the case of Saxon-HE)
        Since:
        9.7
      • setStaticQueryContextFactory

        public void setStaticQueryContextFactory​(StaticQueryContextFactory factory)
        Set the StaticQueryContextFactory used for creating instances of StaticQueryContext
        Parameters:
        factory - the factory class to be used when a new StaticQueryContext is required. Note that this is not used for the default StaticQueryContext held in the Configuration itself.
        Since:
        9.5.1.2.
      • newStaticQueryContext

        public StaticQueryContext newStaticQueryContext()
        Get a new StaticQueryContext (which is also the factory class for creating a query parser). Note that this method is used to underpin the s9api and XQJ APIs for XQuery compilation, and that modifying the behaviour of the StaticQueryContext can affect the behaviour of those APIs
        Returns:
        a new StaticQueryContext
      • newPendingUpdateList

        public PendingUpdateList newPendingUpdateList()
        Get a new Pending Update List
        Returns:
        the new Pending Update List
        Throws:
        java.lang.UnsupportedOperationException - if called when using Saxon-HE
      • makePipelineConfiguration

        public PipelineConfiguration makePipelineConfiguration()
        Make a PipelineConfiguration from the properties of this Configuration
        Returns:
        a new PipelineConfiguration
        Since:
        8.4
      • makeSchemaURIResolver

        public SchemaURIResolver makeSchemaURIResolver​(ResourceResolver resolver)
        Make a SchemaURIResolver that wraps a supplied ResourceResolver
        Parameters:
        resolver - the underlying ResourceResolver
        Returns:
        a new SchemaURIResolver (or null if this is not an EnterpriseConfiguration)
        Since:
        10.0
      • getConfiguration

        public static Configuration getConfiguration​(XPathContext context)
        Get the configuration, given the context. This is provided as a static method to make it accessible as an extension function.
        Parameters:
        context - the XPath dynamic context
        Returns:
        the Saxon Configuration for a given XPath dynamic context
      • setSourceResolver

        public void setSourceResolver​(SourceResolver resolver)
        Supply a SourceResolver. This is used for handling unknown implementations of the Source interface: a user-supplied SourceResolver can handle such Source objects and translate them to a kind of Source that Saxon understands.
        Parameters:
        resolver - the source resolver.
      • getSourceResolver

        public SourceResolver getSourceResolver()
        Get the current SourceResolver. If none has been supplied, a system-defined SourceResolver is returned.
        Returns:
        the current SourceResolver
      • resolveSource

        public ActiveSource resolveSource​(javax.xml.transform.Source source,
                                          Configuration config)
                                   throws XPathException
        Resolve a Source.
        Specified by:
        resolveSource in interface SourceResolver
        Parameters:
        source - A source object, typically the source supplied as the first argument to Transformer.transform(javax.xml.transform.Source, javax.xml.transform.Result) or similar methods.
        config - The Configuration. This provides the SourceResolver with access to configuration information; it also allows the SourceResolver to invoke the resolveSource() method on the Configuration object as a fallback implementation.
        Returns:
        a source object that Saxon knows how to process. This must be an instance of one of the classes StreamSource, SAXSource, DOMSource, AugmentedSource, NodeInfo, or PullSource. Return null if the Source object is not recognized
        Throws:
        XPathException - if the Source object is recognized but cannot be processed
      • buildDocumentTree

        public TreeInfo buildDocumentTree​(javax.xml.transform.Source source)
                                   throws XPathException
        Build a document tree, using options set on this Configuration and on the supplied source object. Options set on the source object override options set in the Configuration. The Source object must be one of the kinds of source recognized by Saxon, or a source that can be resolved using the registered SourceResolver. This method always constructs a new tree, it never wraps or returns an existing tree.
        Parameters:
        source - the Source to be used. This may be an AugmentedSource, allowing options to be specified for the way in which this document will be built. If an AugmentedSource is supplied then options set in the AugmentedSource take precedence over options set in the Configuration.

        If any error occurs reading or parsing the supplied Source, the error is notified to the ErrorListener registered with this Configuration.

        Returns:
        the constructed document as a TreeInfo
        Throws:
        XPathException - if any errors occur during document parsing or validation. Detailed errors occurring during schema validation will be written to the ErrorListener associated with the AugmentedSource, if supplied, or with the Configuration otherwise.
        Since:
        9.7; based on the original buildDocument(Source) method, but adapted to return the TreeInfo containing information about the constructed tree, including a reference to its root node.
      • buildDocumentTree

        public TreeInfo buildDocumentTree​(javax.xml.transform.Source source,
                                          ParseOptions parseOptions)
                                   throws XPathException
        Build a document, using specified options for parsing and building. This method always constructs a new tree, it never wraps an existing document (regardless of anything in the parseOptions)
        Parameters:
        source - the source of the document to be constructed. If this is an AugmentedSource, then any parser options contained in the AugmentedSource take precedence over options specified in the parseOptions argument.
        parseOptions - options for parsing and constructing the document. Any options that are not explicitly set in parseOptions default first to the values supplied in the source argument if it is an AugmentedSource, and then to the values set in this Configuration. The supplied parseOptions object is not modified.
        Returns:
        the constructed document as a TreeInfo
        Throws:
        XPathException - if parsing fails, or if the Source represents a node other than a document node
        Since:
        9.7; based on the original buildDocument(Source, ParseOptions) method, but adapted to return the TreeInfo containing information about the constructed tree, including a reference to its root node.
      • getTreeStatistics

        public TreeStatistics getTreeStatistics()
        Get the collection of tree-builder statistics for this configuration, used for learning suitable amounts of space to allocate for different kinds of tree
        Returns:
        the object in which tree statistics are accumulated
      • makeEmitter

        public Receiver makeEmitter​(java.lang.String eqName,
                                    java.util.Properties props)
                             throws XPathException
        Load a named output emitter or SAX2 ContentHandler and check it is OK.
        Parameters:
        eqName - the EQName of the user-supplied ContentHandler (requested as a prefixed value of the method attribute in xsl:output, or anywhere that serialization parameters are allowed), encoded in EQName format as Q{uri}local
        props - the properties to be used in the case of a dynamically-loaded ContentHandler.
        Returns:
        a Receiver (despite the name, it is not required to be an Emitter)
        Throws:
        XPathException - if a failure occurs creating the Emitter
      • setConfigurationProperty

        public void setConfigurationProperty​(java.lang.String name,
                                             java.lang.Object value)
        Set a property of the configuration. This method underpins the setAttribute() method of the TransformerFactory implementation, and is provided to enable setting of Configuration properties using URIs without instantiating a TransformerFactory: specifically, this may be useful when running XQuery, and it is also used by the Validator API.

        From Saxon 9.9, an alternative interface is available: setConfigurationProperty(Feature, Object). The new interface is more efficient because it avoids expensive string comparisons. The old interface is retained mainly for compatibility, and also because there are a few cases where it cannot easily be replaced, for example when using composite feature URIs to delegate configuration options to the XML parser.

        Parameters:
        name - the URI identifying the property to be set. See the class FeatureKeys for constants representing the property names that can be set.
        value - the value of the property. Note that boolean values may be supplied either as a Boolean, or as one of the strings "0", "1", "true", "false", "yes", "no", "on", or "off".
        Throws:
        java.lang.IllegalArgumentException - if the property name is not recognized or if the value is not a valid value for the named property
      • setConfigurationProperty

        public <T> void setConfigurationProperty​(Feature<T> feature,
                                                 T value)
        Set a property of the configuration.

        This is the preferred way of setting configuration options from application code where it is known statically which feature is being set. Other methods are provided for use by wrapper APIs (such as the JAXP API) where the feature name is supplied dynamically as a string.

        Type Parameters:
        T - the type of value required for this particular feature
        Parameters:
        feature - the property to be set. See the class Feature for constants representing the property names that can be set.
        value - the value of the property. This must be of the correct type corresponding to the chosen Feature.
        Throws:
        java.lang.IllegalArgumentException - if the property name is not recognized or if the value is not a valid value for the named property
      • setFeature

        protected void setFeature​(FeatureData feature,
                                  java.lang.Object value)
        Internal supporting method for setting configuration properties
        Parameters:
        feature - details of the property to be set
        value - value of the property to be set
      • requireBoolean

        public static boolean requireBoolean​(java.lang.String propertyName,
                                             java.lang.Object value)
        Validate a property value where the required type is boolean
        Parameters:
        propertyName - the name of the property
        value - the supplied value of the property. This may be either a java.lang.Boolean, or a string taking one of the values on|off, true|false, yes|no, or 1|0 (suited to the conventions of different configuration APIs that end up calling this method)
        Returns:
        the value as a boolean
        Throws:
        java.lang.IllegalArgumentException - if the supplied value cannot be validated as a recognized boolean value
      • requireInteger

        protected int requireInteger​(java.lang.String propertyName,
                                     java.lang.Object value)
        Validate a property value where the required type is integer
        Parameters:
        propertyName - the name of the property
        value - the supplied value of the property. This may be either a java.lang.Integer, or a string that can be parsed as an integer (suited to the conventions of different configuration APIs that end up calling this method)
        Returns:
        the value as an integer
        Throws:
        java.lang.IllegalArgumentException - if the supplied value cannot be validated as a recognized boolean value
      • internalSetBooleanProperty

        protected void internalSetBooleanProperty​(int code,
                                                  java.lang.String name,
                                                  java.lang.Object value)
        Set a boolean property value, without checking that it is a recognized property name
        Parameters:
        code - the numeric code of the property to be set
        name - the name of the property (used only for diagnostics)
        value - a representation of the boolean value. This may be either a java.lang.Boolean, or a string taking one of the values on|off, true|false, yes|no, or 1|0 (suited to the conventions of different configuration APIs that end up calling this method)
      • getBooleanProperty

        public boolean getBooleanProperty​(Feature<java.lang.Boolean> feature)
        Get a boolean property of the configuration
        Parameters:
        feature - the integer code of the required property. See the class FeatureCode for constants representing the property names that can be requested. This class only recognizes properties whose type is boolean.
        Returns:
        the value of the property. In the case of an unrecognized property name, the value returned is false: no error is thrown.
      • setBooleanProperty

        public void setBooleanProperty​(java.lang.String propertyName,
                                       boolean value)
        Set a boolean property of the configuration
        Parameters:
        propertyName - the name of the required property. See the class FeatureKeys for constants representing the property names that can be requested. This class only recognizes properties whose type is boolean.
        value - the value of the property.
        Throws:
        java.lang.IllegalArgumentException - if the property name is not recognized (as a property whose expected value is boolean)
      • setBooleanProperty

        public void setBooleanProperty​(Feature<java.lang.Boolean> feature,
                                       boolean value)
        Set a boolean property of the configuration
        Parameters:
        feature - the required property. See the class Feature for constants representing the property names that can be requested. This class only recognizes properties whose type is boolean.
        value - the value of the property.
        Throws:
        java.lang.IllegalArgumentException - if the feature is not recognized (as a feature whose expected value is boolean)
      • requireString

        protected java.lang.String requireString​(java.lang.String propertyName,
                                                 java.lang.Object value)
      • instantiateClassName

        protected java.lang.Object instantiateClassName​(java.lang.String propertyName,
                                                        java.lang.Object value,
                                                        java.lang.Class<?> requiredClass)
      • getConfigurationProperty

        public java.lang.Object getConfigurationProperty​(java.lang.String name)
        Get a property of the configuration
        Parameters:
        name - the name of the required property. See the class FeatureKeys for constants representing the property names that can be requested.
        Returns:
        the value of the property. Note that boolean values are returned as a Boolean, even if the value was supplied as a string (for example "true" or "on").
        Throws:
        java.lang.IllegalArgumentException - thrown if the property is not one that Saxon recognizes.
      • getConfigurationProperty

        public <T> T getConfigurationProperty​(Feature<T> feature)
        Get a property of the configuration.

        This is the preferred way of getting configuration options from application code where it is known statically which feature is being set. Other methods are provided for use by wrapper APIs (such as the JAXP API) where the feature name is supplied dynamically as a string.

        Type Parameters:
        T - the type of value returned for this particular feature
        Parameters:
        feature - the required property. See the class Feature for constants representing the properties that can be requested.
        Returns:
        the value of the property; the type of the result depends on the chosen Feature.
        Since:
        9.9
      • getFeature

        protected java.lang.Object getFeature​(FeatureData feature)
      • isJITEnabled

        public boolean isJITEnabled()
        Ask whether just-in-time compilation of XSLT template rules is in force
        Returns:
        true if just-in-time compilation is enabled (this is the default in Saxon-EE and not available in other configurations)
      • close

        public void close()
        Close any resources held by the Configuration. This implementation closes the Logger and/or trace output file if one has been allocated. It also makes the Cleaner unreachable, allowing the relevant thread to terminate.
      • makePackageLoader

        public IPackageLoader makePackageLoader()
        Create a package loader, for reloading SEF files, appropriate to the Saxon edition being used
        Returns:
        a package loader
      • createValidityReporter

        public InvalidityReportGenerator createValidityReporter()
        Register a report generator for reporting invalidities detected in the course of schema validation
        Returns:
        a report generator.
        Throws:
        java.lang.UnsupportedOperationException - (always) in Saxon-HE
      • makeMode

        public SimpleMode makeMode​(StructuredQName modeName,
                                   CompilerInfo compilerInfo)
        Make a new Mode - this can be overridden in subclasses to produce optimized variants
        Parameters:
        modeName - the name of the mode
        compilerInfo - information on the compiler, that can alter rule optimization
        Returns:
        an instantiated Mode
      • makeTemplateRule

        public TemplateRule makeTemplateRule()
        Factory method to create a Template Rule
        Returns:
        a new TemplateRule appropriate to this Configuration
      • makeThreadManager

        public XPathContextMajor.ThreadManager makeThreadManager()
        Make a ThreadManager for asynchronous xsl:result-document instructions
        Returns:
        a new ThreadManager (or null in the case of Saxon-HE)
      • makeCompilerInfo

        public CompilerInfo makeCompilerInfo()
        Make an XSLT CompilerInfo object - can be overridden in a subclass to produce variants capable of optimization
        Returns:
        a new CompilerInfo object
      • makeCompilerService

        public ICompilerService makeCompilerService​(HostLanguage hostLanguage)
        Make a CompilerService object, to handle byte code generation, or null if byte code generation is not available
        Parameters:
        hostLanguage - eg Configuration.XSLT
        Returns:
        a CompilerService, or null
      • setLabel

        public void setLabel​(java.lang.String label)
        Set a label for this configuration
        Parameters:
        label - the label to associate
      • getLabel

        public java.lang.String getLabel()
        Get the associated label for this configuration (typically, the value of the @label attribute in the configuration file)
        Returns:
        the associated label
      • registerCleanupAction

        public CleanerProxy.CleanableProxy registerCleanupAction​(java.lang.Object obj,
                                                                 java.lang.Runnable action)