Class ExpressionContext

java.lang.Object
net.sf.saxon.style.ExpressionContext
All Implemented Interfaces:
StaticContext
Direct Known Subclasses:
TextValueTemplateContext

public class ExpressionContext extends Object implements StaticContext
An ExpressionContext represents the context for an XPath expression written in the stylesheet.
  • Constructor Details

    • 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 Details

    • 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
    • getAttributeName

      public StructuredQName getAttributeName()
      Get the name of the attribute containing the expression being parsed
      Returns:
      the attribute name
    • 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(String s, String errorCode, 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".
      errorCode - Error code identifying the warning condition
      locator - the location of the construct in question. May be null.
    • getSystemId

      public 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 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 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 NamespaceUri 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 NamespaceUri 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 31 or 40
      Since:
      9.7
    • isImportedSchema

      public boolean isImportedSchema(NamespaceUri 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 Set<NamespaceUri> 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
      Returns:
      the policy for matching unprefixed element names