Class StaticContextOverlay

java.lang.Object
net.sf.saxon.expr.StaticContextOverlay
All Implemented Interfaces:
StaticContext, NamespaceResolver

public class StaticContextOverlay extends Object implements StaticContext, NamespaceResolver
This class implements the StaticContext interface by delegating everything except namespace resolution to an immutable base static context. A StaticContextOverlay is constructed when an XPath 4.0 expression includes a "declare namespace" declaration at the start. This modifies the state of the overlay (which is never used for more than one expression), but not the state of the base static context.
  • Constructor Details

    • StaticContextOverlay

      public StaticContextOverlay(StaticContext delegee)
      Construct a StaticContext object that delegates to an underlying ummutable StaticContext
      Parameters:
      delegee - the StaticContext to which requests are delegated
  • Method Details

    • getDelegee

      public StaticContext getDelegee()
    • getConfiguration

      public Configuration getConfiguration()
      Description copied from interface: StaticContext
      Get the system configuration
      Specified by:
      getConfiguration in interface StaticContext
      Returns:
      the Saxon configuration
    • getPackageData

      public PackageData getPackageData()
      Description copied from interface: StaticContext
      Get information about the containing package (unit of compilation)
      Specified by:
      getPackageData in interface StaticContext
      Returns:
      the package data
    • getImportedSchema

      public Schema getImportedSchema()
      Description copied from interface: StaticContext
      Get the in-scope schema declarations for the static context
      Specified by:
      getImportedSchema in interface StaticContext
    • makeEarlyEvaluationContext

      public XPathContext makeEarlyEvaluationContext()
      Description copied from interface: StaticContext
      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()
      Description copied from interface: StaticContext
      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()
      Description copied from interface: StaticContext
      Get the containing location. This is location information relevant to an expression or query as a whole. In the case of an XPath expression held in a node of an XML document, it will provide the location of that node. In the case of a query held in a file, it contains the location of the file (in its systemId property). The method does NOT provide fine-grained location information for each contained subexpression. The location that is returned should be immutable for the duration of parsing of an XPath expression or query.
      Specified by:
      getContainingLocation in interface StaticContext
      Returns:
      the containing location
    • issueWarning

      public void issueWarning(String message, String errorCode, Location locator)
      Description copied from interface: StaticContext
      Issue a compile-time warning.
      Specified by:
      issueWarning in interface StaticContext
      Parameters:
      message - 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()
      Description copied from interface: StaticContext
      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
      Returns:
      the system ID
    • getStaticBaseURI

      public String getStaticBaseURI()
      Description copied from interface: StaticContext
      Get the static base URI, for resolving any relative URI's used in the expression. Used by the document(), doc(), resolve-uri(), and base-uri() functions. May return null if the base URI is not known.
      Specified by:
      getStaticBaseURI in interface StaticContext
      Returns:
      the static base URI, or null if not known
    • bindVariable

      public Expression bindVariable(StructuredQName qName) throws XPathException
      Description copied from interface: StaticContext
      Bind a variable used in this expression to the Binding object in which it is declared
      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.
      Throws:
      XPathException - if the variable cannot be bound (has not been declared)
    • getFunctionLibrary

      public FunctionLibrary getFunctionLibrary()
      Description copied from interface: StaticContext
      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()
      Description copied from interface: StaticContext
      Get the name of the default collation.
      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
    • declarePrologNamespace

      public void declarePrologNamespace(String prefix, NamespaceUri uri) throws XPathException
      Register a namespace that is explicitly declared in the prolog of the XPath expression or query module.
      Specified by:
      declarePrologNamespace in interface StaticContext
      Parameters:
      prefix - The namespace prefix. Must not be null. May be zero-length to declare the default namespace for elements and types.
      uri - The namespace URI. Must not be null. The value "" (zero-length string) is used to undeclare a namespace; it is not an error if there is no existing binding for the namespace prefix. Must not be "##any", which is handled separately.
      Throws:
      XPathException - if the declaration is invalid
    • getDefaultElementNamespace

      public NamespaceUri getDefaultElementNamespace()
      Description copied from interface: StaticContext
      Get the default XPath namespace for elements and types
      Specified by:
      getDefaultElementNamespace in interface StaticContext
      Returns:
      the default namespace, or NamespaceConstant.NULL for the non-namespace
    • setUnprefixedElementMatchingPolicy

      public void setUnprefixedElementMatchingPolicy(UnprefixedElementMatchingPolicy policy)
      Description copied from interface: StaticContext
      Set 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 StaticContext.getDefaultElementNamespace(), or UnprefixedElementMatchingPolicy.DEFAULT_NAMESPACE_OR_NONE, which matches both the namespace given in StaticContext.getDefaultElementNamespace() and the null namespace, or UnprefixedElementMatchingPolicy.ANY_NAMESPACE, which matches any namespace (that is, it matches by local name only).
      Specified by:
      setUnprefixedElementMatchingPolicy in interface StaticContext
    • getUnprefixedElementMatchingPolicy

      public UnprefixedElementMatchingPolicy getUnprefixedElementMatchingPolicy()
      Description copied from interface: StaticContext
      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 StaticContext.getDefaultElementNamespace(), or UnprefixedElementMatchingPolicy.DEFAULT_NAMESPACE_OR_NONE, which matches both the namespace given in StaticContext.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
    • getDefaultFunctionNamespace

      public NamespaceUri getDefaultFunctionNamespace()
      Description copied from interface: StaticContext
      Get the default function namespace
      Specified by:
      getDefaultFunctionNamespace in interface StaticContext
      Returns:
      the default namespace for function names
    • isInBackwardsCompatibleMode

      public boolean isInBackwardsCompatibleMode()
      Description copied from interface: StaticContext
      Determine whether backwards compatibility mode is used
      Specified by:
      isInBackwardsCompatibleMode in interface StaticContext
      Returns:
      true if 1.0 compatibility mode is in force.
    • getNamespaceResolver

      public NamespaceResolver getNamespaceResolver()
      Description copied from interface: StaticContext
      Get a namespace resolver to resolve the namespaces declared in this static context.
      Specified by:
      getNamespaceResolver in interface StaticContext
      Returns:
      a namespace resolver.
    • getRequiredContextItemType

      public ItemType getRequiredContextItemType()
      Description copied from interface: StaticContext
      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
    • getRequiredContextValueType

      public SequenceType getRequiredContextValueType()
      Specified by:
      getRequiredContextValueType in interface StaticContext
    • getDecimalFormatManager

      public DecimalFormatManager getDecimalFormatManager()
      Description copied from interface: StaticContext
      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 no named decimal formats are available in this environment.
    • getXPathVersion

      public int getXPathVersion()
      Description copied from interface: StaticContext
      Get the XPath language level supported, as an integer (being the actual version number times ten). In Saxon 9.9 the possible values are 20 (XPath 2.0), 30 (XPath 3.0), 31 (XPath 3.1), and 305 (XPath 3.0 plus the extensions defined in XSLT 3.0). Saxon 11 adds support for 40 (XPath 4.0).
      Specified by:
      getXPathVersion in interface StaticContext
      Returns:
      the XPath language level; the return value will be either 20, 30, 305, 31 or 40
    • getKeyManager

      public KeyManager getKeyManager()
      Description copied from interface: StaticContext
      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
    • resolveTypeAlias

      public ItemType resolveTypeAlias(StructuredQName typeName)
      Description copied from interface: StaticContext
      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.
    • getOptimizerOptions

      public OptimizerOptions getOptimizerOptions()
      Description copied from interface: StaticContext
      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
    • getURIForPrefix

      public NamespaceUri getURIForPrefix(String prefix, boolean useDefault)
      Description copied from interface: NamespaceResolver
      Get the namespace URI corresponding to a given prefix. Return null if the prefix is not in scope.
      Specified by:
      getURIForPrefix in interface NamespaceResolver
      Parameters:
      prefix - the namespace prefix. May be the zero-length string, indicating that there is no prefix. This indicates either the default namespace or the null namespace, depending on the value of useDefault.
      useDefault - true if the default namespace is to be used when the prefix is "". If false, the method returns "" when the prefix is "". The default namespace is a property of the NamespaceResolver; in general it corresponds to the "default namespace for elements and types", but that cannot be assumed.
      Returns:
      the uri for the namespace, or null if the prefix is not in scope. The "null namespace" is represented by the pseudo-URI "".
    • iteratePrefixes

      public Iterator<String> iteratePrefixes()
      Description copied from interface: NamespaceResolver
      Get an iterator over all the prefixes declared in this namespace context. This will include the default namespace (prefix="") and the XML namespace where appropriate
      Specified by:
      iteratePrefixes in interface NamespaceResolver
      Returns:
      an iterator over all the prefixes for which a namespace binding exists, including the zero-length string to represent the null/absent prefix if it is bound