Class Executable

java.lang.Object
net.sf.saxon.expr.instruct.Executable
Direct Known Subclasses:
PreparedStylesheet

public class Executable extends 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 Details

    • schemaAware

      protected boolean schemaAware
  • Constructor Details

    • Executable

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

    • setConfiguration

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

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

      public PackageData getTopLevelPackage()
    • setTopLevelPackage

      public void setTopLevelPackage(PackageData topLevelPackage)
    • addPackage

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

      public Iterable<PackageData> getPackages()
      Get information about the packages in this executable
      Returns:
      a list of packages
    • setHostLanguage

      public void setHostLanguage(HostLanguage language)
      Set the host language
      Parameters:
      language - the host language, as a constant such as HostLanguage.XSLT or HostLanguage.XQUERY
    • getHostLanguage

      public HostLanguage getHostLanguage()
      Get the host language
      Returns:
      a value identifying the host language: HostLanguage.XQUERY or HostLanguage.XSLT
    • getFunctionLibrary

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

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

      public void setCharacterMapIndex(CharacterMapIndex cmi)
      Set the index of named character maps
      Parameters:
      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
      Returns:
      the hash table that maps the names of character maps to the IntHashMap objects representing the character maps
    • setDefaultOutputProperties

      public void setDefaultOutputProperties(Properties properties)
      Set the default output properties (the properties for the unnamed output format)
      Parameters:
      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'".
      Returns:
      the properties for the unnamed output format
    • setOutputProperties

      public void setOutputProperties(StructuredQName qName, Properties properties)
      Add a named output format
      Parameters:
      qName - the structured QName of the output format
      properties - the properties of the output format
    • getOutputProperties

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

      Returns:
      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 Properties getOutputProperties(StructuredQName qName)
      Get a named output format
      Parameters:
      qName - the name of the output format
      Returns:
      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.
      Parameters:
      module - the library module to be added to this executable
    • getQueryLibraryModules

      public List<QueryModule> getQueryLibraryModules(NamespaceUri namespace)
      Locate the known XQuery library modules for a given module namespace.
      Parameters:
      namespace - the module namespace URI
      Returns:
      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(String systemId, QueryModule topModule)
      Get the query library module with a given systemID
      Parameters:
      systemId - the SystemId of the required module
      topModule - the top-level query module (usually a main module, except when importing library modules into XSLT)
      Returns:
      the module with that system id if found, otherwise null
    • getQueryLibraryModules

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

      public void addQueryLocationHintProcessed(String uri)
      Add a name to the list of query module location hints that have been processed during the construction of this executable
      Parameters:
      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(String uri)
      Ask whether a query module location hint has already been processed
      Parameters:
      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)
      Returns:
      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
      Parameters:
      main - the main query module
      Throws:
      XPathException - if an error occurs
    • explainGlobalVariables

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

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

      public Map<StructuredQName,GlobalParam> getGlobalParameters()
      Get all the registered global parameters
      Returns:
      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
      Parameters:
      name - the parameter name
      Returns:
      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.

      Parameters:
      params - the set of parameters that have been supplied (null represents an empty set)
      Throws:
      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
      Parameters:
      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
      Returns:
      true if the executable uses xsl:result-document
    • setGlobalContextRequirement

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

      public GlobalContextRequirement getGlobalContextRequirement()
      Get the constraints on the initial global context item
      Returns:
      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
      Parameters:
      contextItem - the supplied context item
      context - a context for evaluation (in which the context item will be absent)
      Returns:
      a new/converted context item, or null if the global context item is to be absent
      Throws:
      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
      Parameters:
      aware - true if the executable is schema-aware
      Throws:
      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.
      Returns:
      true if the executable is schema-aware, false if not.