Class Executable

  • Direct Known Subclasses:

    public class Executable
    extends java.lang.Object
    A compiled stylesheet or a query in executable form. Note that the original stylesheet tree is not retained. In the case of XSLT 3.0, the Executable represents the collection of all packages making up a stylesheet; it is synthesized when the constituent packages are linked, and is not available during compilation (because each package is compiled separately). For XSLT the Executable will always be a PreparedStylesheet, which is a subclass.
    • Field Detail

      • schemaAware

        protected boolean schemaAware
    • Constructor Detail

      • Executable

        public Executable​(Configuration config)
        Create a new Executable (a collection of stylesheet modules and/or query modules)
        config - the Saxon Configuration
    • Method Detail

      • setConfiguration

        public void setConfiguration​(Configuration config)
        Set the configuration
        config - the Configuration
      • getConfiguration

        public Configuration getConfiguration()
        Get the configuration
        the Configuration
      • getTopLevelPackage

        public PackageData getTopLevelPackage()
      • setTopLevelPackage

        public void setTopLevelPackage​(PackageData topLevelPackage)
      • addPackage

        public void addPackage​(PackageData data)
        Add information about a package
        data - information about a package
      • getPackages

        public java.lang.Iterable<PackageData> getPackages()
        Get information about the packages in this executable
        a list of packages
      • getFunctionLibrary

        public FunctionLibraryList getFunctionLibrary()
        Get the library containing all the in-scope functions in the static context
        the function libary
      • setFunctionLibrary

        public void setFunctionLibrary​(FunctionLibraryList functionLibrary)
        Set the library containing all the in-scope functions in the static context
        functionLibrary - the function libary
      • setCharacterMapIndex

        public void setCharacterMapIndex​(CharacterMapIndex cmi)
        Set the index of named character maps
        cmi - a hash table that maps the names of character maps to the HashMap objects representing the character maps
      • getCharacterMapIndex

        public CharacterMapIndex getCharacterMapIndex()
        Get the index of named character maps
        the hash table that maps the names of character maps to the IntHashMap objects representing the character maps
      • setDefaultOutputProperties

        public void setDefaultOutputProperties​(java.util.Properties properties)
        Set the default output properties (the properties for the unnamed output format)
        properties - the output properties to be used when the unnamed output format is selected
      • getPrimarySerializationProperties

        public SerializationProperties getPrimarySerializationProperties()
        Get the primary output properties, that is, the output properties for the primary result destination. In XSLT these are the properties defined on unnamed xsl:output declarations in the top-level stylesheet package; in XQuery they are the properties defined using "declare option output:x = 'value'".
        the properties for the unnamed output format
      • setOutputProperties

        public void setOutputProperties​(StructuredQName qName,
                                        java.util.Properties properties)
        Add a named output format
        qName - the structured QName of the output format
        properties - the properties of the output format
      • getOutputProperties

        public java.util.Properties getOutputProperties()
        Get the properties for xsl:output. The object returned will be a clone of the internal values, and thus it can be mutated without mutating the Executable object.

        The returned properties object is a new, empty, Properties object that is backed by the live properties to supply default values for missing properties. This means that the property values must be read using the getProperty() method. Calling the get() method on the underlying Hashtable will return null.

        This method gets the output properties for the unnamed output format in the stylesheet.

        A Properties object reflecting the output properties defined for the default (unnamed) output format in the stylesheet. It may be mutated and supplied to the setOutputProperties() method of the Transformer, without affecting other transformations that use the same stylesheet.
        See Also:
      • getOutputProperties

        public java.util.Properties getOutputProperties​(StructuredQName qName)
        Get a named output format
        qName - the name of the output format
        properties the properties of the output format. Return null if there are no output properties with the given name
      • addQueryLibraryModule

        public void addQueryLibraryModule​(QueryModule module)
        Add an XQuery library module to the configuration. The Executable maintains a table indicating for each module namespace, the set of modules that have been loaded from that namespace. If a module import is encountered that specifies no location hint, all the known modules for that namespace are imported.
        module - the library module to be added to this executable
      • getQueryLibraryModules

        public java.util.List<QueryModule> getQueryLibraryModules​(NamespaceUri namespace)
        Locate the known XQuery library modules for a given module namespace.
        namespace - the module namespace URI
        a list of items each of which is the StaticQueryContext representing a module, or null if the module namespace is unknown
      • getQueryModuleWithSystemId

        public QueryModule getQueryModuleWithSystemId​(java.lang.String systemId,
                                                      QueryModule topModule)
        Get the query library module with a given systemID
        systemId - the SystemId of the required module
        topModule - the top-level query module (usually a main module, except when importing library modules into XSLT)
        the module with that system id if found, otherwise null
      • getQueryLibraryModules

        public java.util.List<QueryModule> getQueryLibraryModules()
        Get an iterator over all the query library modules (does not include the main module)
        an iterator whose returned items are instances of QueryModule
      • addQueryLocationHintProcessed

        public void addQueryLocationHintProcessed​(java.lang.String uri)
        Add a name to the list of query module location hints that have been processed during the construction of this executable
        uri - the name to be added (the location URI as it appears in the "import module" declaration, expanded to an absolute URI by resolving against the base URI, but before passing to the Module Resolver)
      • isQueryLocationHintProcessed

        public boolean isQueryLocationHintProcessed​(java.lang.String uri)
        Ask whether a query module location hint has already been processed
        uri - the query location hint (the location URI as it appears in the "import module" declaration, expanded to an absolute URI by resolving against the base URI, but before passing to the Module Resolver)
        true if the location hint has already been processed
      • fixupQueryModules

        public void fixupQueryModules​(QueryModule main)
                               throws XPathException
        Fix up global variables and functions in all query modules. This is done right at the end, because recursive imports are permitted
        main - the main query module
        XPathException - if an error occurs
      • explainGlobalVariables

        public void explainGlobalVariables​(ExpressionPresenter presenter)
                                    throws XPathException
        Explain (that is, output an expression tree) the global variables
        presenter - the destination for the explanation of the global variables
        XPathException - if writing to the output fails
      • registerGlobalParameter

        public void registerGlobalParameter​(GlobalParam param)
        Register a global parameter
        param - the stylesheet parameter (XSLT) or external variable (XQuery) to be registered
      • getGlobalParameters

        public java.util.Map<StructuredQName,​GlobalParam> getGlobalParameters()
        Get all the registered global parameters
        a list of all the stylesheet parameters (XSLT) or external variables (XQuery)
      • getGlobalParameter

        public GlobalParam getGlobalParameter​(StructuredQName name)
        Get the global parameter with a given name, if there is one
        name - the parameter name
        the global parameter with this name, if it exists, or null otherwise
      • checkSuppliedParameters

        public void checkSuppliedParameters​(GlobalParameterSet params)
                                     throws XPathException
        Check the supplied parameters. Checks that all required parameters have been supplied, and that no parameters supplied at run-time are declared static in the stylesheet, or were supplied eagerly at compile-time.

        Used in XSLT only.

        params - the set of parameters that have been supplied (null represents an empty set)
        XPathException - if there is a required parameter for which no value has been supplied
      • setCreatesSecondaryResult

        public void setCreatesSecondaryResult​(boolean flag)
        Set whether this executable represents a stylesheet that uses xsl:result-document to create secondary output documents
        flag - true if the executable uses xsl:result-document
      • createsSecondaryResult

        public boolean createsSecondaryResult()
        Ask whether this executable represents a stylesheet that uses xsl:result-document to create secondary output documents
        true if the executable uses xsl:result-document
      • setGlobalContextRequirement

        public void setGlobalContextRequirement​(GlobalContextRequirement requirement)
        Set the accumulators declared on xsl:global-context-item
        requirement - the requirements on the global context item
      • getGlobalContextRequirement

        public GlobalContextRequirement getGlobalContextRequirement()
        Get the constraints on the initial global context item
        the declared initial global context item requirements
      • checkInitialContextItem

        public Item checkInitialContextItem​(Item contextItem,
                                            XPathContext context)
                                     throws XPathException
        Check that the supplied global context item meets all requirements, and perform any required conversions or defaulting
        contextItem - the supplied context item
        context - a context for evaluation (in which the context item will be absent)
        a new/converted context item, or null if the global context item is to be absent
        XPathException - if the supplied item does not meet requirements, for example if it is the wrong type.
      • setSchemaAware

        public void setSchemaAware​(boolean aware)
        Set whether this executable is schema-aware. The initial value is false; it is set to true at compile time if the query or transformation imports a schema. If the value is false, then all documents used at run-time must be untyped
        aware - true if the executable is schema-aware
        java.lang.IllegalArgumentException - if schema-aware processing is requested in a Configuration that is not schema-aware
      • isSchemaAware

        public boolean isSchemaAware()
        Ask whether this executable is schema-aware, that is, whether the query or transformation imports a schema.
        true if the executable is schema-aware, false if not.