Class UseWhenStaticContext

java.lang.Object
net.sf.saxon.sxpath.AbstractStaticContext
net.sf.saxon.style.UseWhenStaticContext
All Implemented Interfaces:
StaticContext

public class UseWhenStaticContext extends AbstractStaticContext implements StaticContext
This class implements the static context used for evaluating use-when and other static expressions in XSLT 3.0 A new instance of this class is created for each use-when expression encountered; there are therefore no issues with reusability. The class provides a Container for the expression as well as the static context information; the Executable contains the single XPath expression only, and is created for the purpose.
  • Constructor Details

    • UseWhenStaticContext

      public UseWhenStaticContext(Compilation compilation, NamespaceResolver namespaceContext)
      Create a static context for evaluating use-when expressions
      Parameters:
      compilation - the package compilation episode
      namespaceContext - the namespace context in which the static expression appears
  • Method Details

    • 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
      Overrides:
      makeRetainedStaticContext in class AbstractStaticContext
      Returns:
      a RetainedStaticContext object: either a newly created one, or one that is reused from a previous invocation.
    • getCompilation

      public Compilation getCompilation()
    • issueWarning

      public void issueWarning(String s, String errorCode, Location locator)
      Issue a compile-time warning
      Specified by:
      issueWarning in interface StaticContext
      Overrides:
      issueWarning in class AbstractStaticContext
      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 container of the expression. This is the containing entity (file) and is therefore useful for diagnostics. Use getBaseURI() to get the base URI, which may be different.
      Specified by:
      getSystemId in interface StaticContext
      Overrides:
      getSystemId in class AbstractStaticContext
      Returns:
      "" always
    • bindVariable

      public Expression bindVariable(StructuredQName qName) throws XPathException
      Bind a variable used in this element to its declaration
      Specified by:
      bindVariable in interface StaticContext
      Parameters:
      qName - the name of the variable
      Returns:
      an expression representing the variable reference, This will often be a VariableReference, suitably initialized to refer to the corresponding variable declaration, but in general it can be any expression which returns the variable's value when evaluated. In this version of the method, the value of the variable is known statically, so the returned expression is a literal containing the variable's value.
      Throws:
      XPathException - if the variable cannot be bound (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
      Overrides:
      getFunctionLibrary in class AbstractStaticContext
      Returns:
      the function library
    • getDefaultCollationName

      public String getDefaultCollationName()
      Get the name of the default collation.
      Specified by:
      getDefaultCollationName in interface StaticContext
      Overrides:
      getDefaultCollationName in class AbstractStaticContext
      Returns:
      the name of the default collation; or the name of the codepoint collation if no default collation has been defined
    • getDefaultFunctionNamespace

      public NamespaceUri getDefaultFunctionNamespace()
      Get the default function namespace
      Specified by:
      getDefaultFunctionNamespace in interface StaticContext
      Overrides:
      getDefaultFunctionNamespace in class AbstractStaticContext
      Returns:
      the default namesapce for functions
    • isInBackwardsCompatibleMode

      public boolean isInBackwardsCompatibleMode()
      Determine whether Backwards Compatible Mode is used
      Specified by:
      isInBackwardsCompatibleMode in interface StaticContext
      Overrides:
      isInBackwardsCompatibleMode in class AbstractStaticContext
      Returns:
      true if XPath 1.0 compatibility mode is to be set to true; otherwise false
    • isImportedSchema

      public boolean isImportedSchema(NamespaceUri namespace)
      Determine whether a Schema for a given target namespace has been imported. Note that the in-scope element declarations, attribute declarations and schema types are the types registered with the (schema-aware) configuration, provided that their namespace URI is registered in the static context as being an imported schema namespace. (A consequence of this is that within a Configuration, there can only be one schema for any given namespace, including the null namespace).
      Specified by:
      isImportedSchema in interface StaticContext
      Parameters:
      namespace - the target namespace in question
      Returns:
      true if the given 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
    • getNamespaceResolver

      public NamespaceResolver getNamespaceResolver()
      Get a namespace resolver to resolve the namespaces declared in this static context.
      Specified by:
      getNamespaceResolver in interface StaticContext
      Returns:
      a namespace resolver.
    • 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
      Overrides:
      getDecimalFormatManager in class AbstractStaticContext
      Returns:
      the decimal format manager for this static context, or null if named decimal formats are not supported in this environment.
    • getColumnNumber

      public int getColumnNumber()
    • getPublicId

      public String getPublicId()
    • getLineNumber

      public int getLineNumber()
    • 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
      Overrides:
      resolveTypeAlias in class AbstractStaticContext
      Parameters:
      typeName - the name of the type alias
      Returns:
      the corresponding item type, if the name is recognised; otherwise null. This implementation always returns null (type aliases cannot be used in XSLT static expressions).