Package net.sf.saxon.style

## Class ExpressionContext

- java.lang.Object
- - net.sf.saxon.style.ExpressionContext

- All Implemented Interfaces:
    `StaticContext`
  Direct Known Subclasses:
    `TextValueTemplateContext`

      public class ExpressionContext
      extends java.lang.Object
      implements StaticContext

  An ExpressionContext represents the context for an XPath expression written in the stylesheet.

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `ExpressionContext​(StyleElement styleElement, StructuredQName attributeName)` | Create a static context for XPath expressions in an XSLT stylesheet

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `Expression` | `bindVariable​(StructuredQName qName)` | Bind a variable to an object that can be used to refer to it
    `Configuration` | `getConfiguration()` | Get the system configuration
    `Location` | `getContainingLocation()` | Get the containing location of an XPath expression within the stylesheet
    `DecimalFormatManager` | `getDecimalFormatManager()` | Get a DecimalFormatManager to resolve the names of decimal formats used in calls to the format-number() function.
    `java.lang.String` | `getDefaultCollationName()` | Get the default collation.
    `java.lang.String` | `getDefaultElementNamespace()` | Get the default XPath namespace for elements and types Return NamespaceConstant.NULL for the non-namespace
    `java.lang.String` | `getDefaultFunctionNamespace()` | Get the default function namespace
    `FunctionLibrary` | `getFunctionLibrary()` | Get the function library containing all the in-scope functions available in this static context
    `java.util.Set<java.lang.String>` | `getImportedSchemaNamespaces()` | Get the set of imported schemas
    `KeyManager` | `getKeyManager()` | Get the KeyManager, containing definitions of keys available for use.
    `NamespaceResolver` | `getNamespaceResolver()` | Get a copy of the NamespaceResolver suitable for saving in the executable code
    `OptimizerOptions` | `getOptimizerOptions()` | Get the optimization options in use.
    `StylesheetPackage` | `getPackageData()` | Get the containing XSLT package
    `ItemType` | `getRequiredContextItemType()` | Get the required type of the context item.
    `java.lang.String` | `getStaticBaseURI()` | Get the Base URI of the element containing the expression, for resolving any relative URI's used in the expression.
    `StyleElement` | `getStyleElement()` | Get the stylesheet element containing this XPath expression
    `java.lang.String` | `getSystemId()` | Get the System ID of the entity containing the expression (used for diagnostics)
    `UnprefixedElementMatchingPolicy` | `getUnprefixedElementMatchingPolicy()` | Get the matching policy for unprefixed element names in axis steps.
    `int` | `getXPathVersion()` | Get the XPath language level supported, as an integer (being the actual version number times ten).
    `boolean` | `isImportedSchema​(java.lang.String namespace)` | Test whether a schema has been imported for a given namespace
    `boolean` | `isInBackwardsCompatibleMode()` | Determine whether Backwards Compatible Mode is used
    `boolean` | `isSchemaAware()` | Ask whether expressions compiled under this static context are schema-aware.
    `void` | `issueWarning​(java.lang.String s, Location locator)` | Issue a compile-time warning
    `XPathContext` | `makeEarlyEvaluationContext()` | Construct a dynamic context for early evaluation of constant subexpressions
    `RetainedStaticContext` | `makeRetainedStaticContext()` | Construct a RetainedStaticContext, which extracts information from this StaticContext to provide the subset of static context information that is potentially needed during expression evaluation
    `ItemType` | `resolveTypeAlias​(StructuredQName typeName)` | Get type alias.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ExpressionContext

          public ExpressionContext​(StyleElement styleElement,
                                   StructuredQName attributeName)

      Create a static context for XPath expressions in an XSLT stylesheet
      Parameters:
        `styleElement` - the element on which the XPath expression appears
        `attributeName` - the name of the attribute in which the XPath expression appears; or null if the expression appears in a text node

  - ### Method Detail

    - #### getConfiguration

          public Configuration getConfiguration()

      Get the system configuration
      Specified by:
        `getConfiguration` in interface `StaticContext`
      Returns:
        the Saxon configuration

    - #### getPackageData

          public StylesheetPackage getPackageData()

      Get the containing XSLT package
      Specified by:
        `getPackageData` in interface `StaticContext`
      Returns:
        the containing XSLT package

    - #### isSchemaAware

          public boolean isSchemaAware()

      Ask whether expressions compiled under this static context are schema-aware. They must be schema-aware if the expression is to handle typed (validated) nodes
      Returns:
        true if expressions are schema-aware

    - #### makeEarlyEvaluationContext

          public XPathContext makeEarlyEvaluationContext()

      Construct a dynamic context for early evaluation of constant subexpressions
      Specified by:
        `makeEarlyEvaluationContext` in interface `StaticContext`
      Returns:
        a newly constructed dynamic context

    - #### makeRetainedStaticContext

          public RetainedStaticContext makeRetainedStaticContext()

      Construct a RetainedStaticContext, which extracts information from this StaticContext to provide the subset of static context information that is potentially needed during expression evaluation
      Specified by:
        `makeRetainedStaticContext` in interface `StaticContext`
      Returns:
        a RetainedStaticContext object: either a newly created one, or one that is reused from a previous invocation.

    - #### getContainingLocation

          public Location getContainingLocation()

      Get the containing location of an XPath expression within the stylesheet
      Specified by:
        `getContainingLocation` in interface `StaticContext`
      Returns:
        a Location that identifies the containing element, together with the name of the attribute holding the XPath expression in question.

    - #### issueWarning

          public void issueWarning​(java.lang.String s,
                                   Location locator)

      Issue a compile-time warning
      Specified by:
        `issueWarning` in interface `StaticContext`
      Parameters:
        `s` - The warning message. This should not contain any prefix such as "Warning".
        `locator` - the location of the construct in question. May be null.

    - #### getSystemId

          public java.lang.String getSystemId()

      Get the System ID of the entity containing the expression (used for diagnostics)
      Specified by:
        `getSystemId` in interface `StaticContext`
      Returns:
        the system ID

    - #### getStaticBaseURI

          public java.lang.String getStaticBaseURI()

      Get the Base URI of the element containing the expression, for resolving any relative URI's used in the expression. Used by the document() function.
      Specified by:
        `getStaticBaseURI` in interface `StaticContext`
      Returns:
        the static base URI, or null if not known

    - #### getNamespaceResolver

          public NamespaceResolver getNamespaceResolver()

      Get a copy of the NamespaceResolver suitable for saving in the executable code
      Specified by:
        `getNamespaceResolver` in interface `StaticContext`
      Returns:
        a NamespaceResolver

    - #### getRequiredContextItemType

          public ItemType getRequiredContextItemType()

      Get the required type of the context item. If no type has been explicitly declared for the context item, an instance of AnyItemType (representing the type item()) is returned.
      Specified by:
        `getRequiredContextItemType` in interface `StaticContext`
      Returns:
        the required type of the context item
      Since:
        9.3

    - #### getDecimalFormatManager

          public DecimalFormatManager getDecimalFormatManager()

      Get a DecimalFormatManager to resolve the names of decimal formats used in calls to the format-number() function.
      Specified by:
        `getDecimalFormatManager` in interface `StaticContext`
      Returns:
        the decimal format manager for this static context, or null if named decimal formats are not supported in this environment.

    - #### getOptimizerOptions

          public OptimizerOptions getOptimizerOptions()

      Get the optimization options in use. By default these are taken from the `Configuration`
      Specified by:
        `getOptimizerOptions` in interface `StaticContext`
      Returns:
        the optimization options in use
      Since:
        9.9

    - #### bindVariable

          public Expression bindVariable​(StructuredQName qName)
                                  throws XPathException

      Bind a variable to an object that can be used to refer to it
      Specified by:
        `bindVariable` in interface `StaticContext`
      Parameters:
        `qName` - the name of the variable
      Returns:
        a VariableDeclaration object that can be used to identify it in the Bindery,
      Throws:
        `XPathException` - if the variable has not been declared

    - #### getFunctionLibrary

          public FunctionLibrary getFunctionLibrary()

      Get the function library containing all the in-scope functions available in this static context
      Specified by:
        `getFunctionLibrary` in interface `StaticContext`
      Returns:
        the function library

    - #### getDefaultCollationName

          public java.lang.String getDefaultCollationName()

      Get the default collation. Return null if no default collation has been defined
      Specified by:
        `getDefaultCollationName` in interface `StaticContext`
      Returns:
        the name of the default collation; or the name of the codepoint collation if no default collation has been defined

    - #### getDefaultElementNamespace

          public java.lang.String getDefaultElementNamespace()

      Get the default XPath namespace for elements and types Return NamespaceConstant.NULL for the non-namespace
      Specified by:
        `getDefaultElementNamespace` in interface `StaticContext`
      Returns:
        the default namespace, or `NamespaceConstant.NULL` for the non-namespace

    - #### getDefaultFunctionNamespace

          public java.lang.String getDefaultFunctionNamespace()

      Get the default function namespace
      Specified by:
        `getDefaultFunctionNamespace` in interface `StaticContext`
      Returns:
        the default namespace for function names

    - #### isInBackwardsCompatibleMode

          public boolean isInBackwardsCompatibleMode()

      Determine whether Backwards Compatible Mode is used
      Specified by:
        `isInBackwardsCompatibleMode` in interface `StaticContext`
      Returns:
        true if 1.0 compaibility mode is in force.

    - #### getXPathVersion

          public int getXPathVersion()

      Get the XPath language level supported, as an integer (being the actual version number times ten). In Saxon 9.9, for XSLT, the possible values are 30 (XPath 3.0), 31 (XPath 3.1), and 305 (XPath 3.0 plus the extensions defined in XSLT 3.0).
      Specified by:
        `getXPathVersion` in interface `StaticContext`
      Returns:
        the XPath language level; the return value will be either 30, 305, or 31
      Since:
        9.7

    - #### isImportedSchema

          public boolean isImportedSchema​(java.lang.String namespace)

      Test whether a schema has been imported for a given namespace
      Specified by:
        `isImportedSchema` in interface `StaticContext`
      Parameters:
        `namespace` - the target namespace of the required schema
      Returns:
        true if a schema for this namespace has been imported

    - #### getImportedSchemaNamespaces

          public java.util.Set<java.lang.String> getImportedSchemaNamespaces()

      Get the set of imported schemas
      Specified by:
        `getImportedSchemaNamespaces` in interface `StaticContext`
      Returns:
        a Set, the set of URIs representing the names of imported schemas

    - #### getKeyManager

          public KeyManager getKeyManager()

      Get the KeyManager, containing definitions of keys available for use.
      Specified by:
        `getKeyManager` in interface `StaticContext`
      Returns:
        the KeyManager. This is used to resolve key names, both explicit calls on key() used in XSLT, and system-generated calls on key() which may also appear in XQuery and XPath

    - #### getStyleElement

          public StyleElement getStyleElement()

      Get the stylesheet element containing this XPath expression
      Returns:
        the element in the tree representation of the source stylesheet

    - #### resolveTypeAlias

          public ItemType resolveTypeAlias​(StructuredQName typeName)

      Get type alias. This is a Saxon extension. A type alias is a QName which can be used as a shorthand for an itemtype, using the syntax ~typename anywhere that an item type is permitted.
      Specified by:
        `resolveTypeAlias` in interface `StaticContext`
      Parameters:
        `typeName` - the name of the type alias
      Returns:
        the corresponding item type, if the name is recognised; otherwise null.

    - #### getUnprefixedElementMatchingPolicy

          public UnprefixedElementMatchingPolicy getUnprefixedElementMatchingPolicy()

      Get the matching policy for unprefixed element names in axis steps. This is a Saxon extension. The value can be any of `UnprefixedElementMatchingPolicy.DEFAULT_NAMESPACE` (the default), which uses the value of `getDefaultElementNamespace()`, or `UnprefixedElementMatchingPolicy.DEFAULT_NAMESPACE_OR_NONE`, which matches both the namespace given in `getDefaultElementNamespace()` and the null namespace, or `UnprefixedElementMatchingPolicy.ANY_NAMESPACE`, which matches any namespace (that is, it matches by local name only).
      Specified by:
        `getUnprefixedElementMatchingPolicy` in interface `StaticContext`