Package net.sf.saxon.expr
Class StaticContextOverlay
java.lang.Object
net.sf.saxon.expr.StaticContextOverlay
- All Implemented Interfaces:
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 Summary
ConstructorsConstructorDescriptionStaticContextOverlay(StaticContext delegee) Construct a StaticContext object that delegates to an underlying ummutable StaticContext -
Method Summary
Modifier and TypeMethodDescriptionbindVariable(StructuredQName qName) Bind a variable used in this expression to the Binding object in which it is declaredvoiddeclarePrologNamespace(String prefix, NamespaceUri uri) Register a namespace that is explicitly declared in the prolog of the XPath expression or query module.Get the system configurationGet the containing location.Get a DecimalFormatManager to resolve the names of decimal formats used in calls to the format-number() function.Get the name of the default collation.Get the default XPath namespace for elements and typesGet the default function namespaceGet the function library containing all the in-scope functions available in this static contextGet the in-scope schema declarations for the static contextGet the KeyManager, containing definitions of keys available for use.Get a namespace resolver to resolve the namespaces declared in this static context.Get the optimization options in use.Get information about the containing package (unit of compilation)Get the required type of the context item.Get the static base URI, for resolving any relative URI's used in the expression.Get the System ID of the container of the expression.Get the matching policy for unprefixed element names in axis steps.getURIForPrefix(String prefix, boolean useDefault) Get the namespace URI corresponding to a given prefix.intGet the XPath language level supported, as an integer (being the actual version number times ten).booleanDetermine whether backwards compatibility mode is usedvoidissueWarning(String message, String errorCode, Location locator) Issue a compile-time warning.Get an iterator over all the prefixes declared in this namespace context.Construct a dynamic context for early evaluation of constant subexpressions.Construct a RetainedStaticContext, which extracts information from this StaticContext to provide the subset of static context information that is potentially needed during expression evaluationresolveTypeAlias(StructuredQName typeName) Get type alias.voidSet the matching policy for unprefixed element names in axis steps.
-
Constructor Details
-
StaticContextOverlay
Construct a StaticContext object that delegates to an underlying ummutable StaticContext- Parameters:
delegee- the StaticContext to which requests are delegated
-
-
Method Details
-
getDelegee
-
getConfiguration
Description copied from interface:StaticContextGet the system configuration- Specified by:
getConfigurationin interfaceStaticContext- Returns:
- the Saxon configuration
-
getPackageData
Description copied from interface:StaticContextGet information about the containing package (unit of compilation)- Specified by:
getPackageDatain interfaceStaticContext- Returns:
- the package data
-
getImportedSchema
Description copied from interface:StaticContextGet the in-scope schema declarations for the static context- Specified by:
getImportedSchemain interfaceStaticContext
-
makeEarlyEvaluationContext
Description copied from interface:StaticContextConstruct a dynamic context for early evaluation of constant subexpressions.- Specified by:
makeEarlyEvaluationContextin interfaceStaticContext- Returns:
- a newly constructed dynamic context
-
makeRetainedStaticContext
Description copied from interface:StaticContextConstruct 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:
makeRetainedStaticContextin interfaceStaticContext- Returns:
- a RetainedStaticContext object: either a newly created one, or one that is reused from a previous invocation.
-
getContainingLocation
Description copied from interface:StaticContextGet 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:
getContainingLocationin interfaceStaticContext- Returns:
- the containing location
-
issueWarning
Description copied from interface:StaticContextIssue a compile-time warning.- Specified by:
issueWarningin interfaceStaticContext- Parameters:
message- The warning message. This should not contain any prefix such as "Warning".errorCode- Error code identifying the warning conditionlocator- the location of the construct in question. May be null.
-
getSystemId
Description copied from interface:StaticContextGet 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:
getSystemIdin interfaceStaticContext- Returns:
- the system ID
-
getStaticBaseURI
Description copied from interface:StaticContextGet 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:
getStaticBaseURIin interfaceStaticContext- Returns:
- the static base URI, or null if not known
-
bindVariable
Description copied from interface:StaticContextBind a variable used in this expression to the Binding object in which it is declared- Specified by:
bindVariablein interfaceStaticContext- 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
Description copied from interface:StaticContextGet the function library containing all the in-scope functions available in this static context- Specified by:
getFunctionLibraryin interfaceStaticContext- Returns:
- the function library
-
getDefaultCollationName
Description copied from interface:StaticContextGet the name of the default collation.- Specified by:
getDefaultCollationNamein interfaceStaticContext- Returns:
- the name of the default collation; or the name of the codepoint collation if no default collation has been defined
-
declarePrologNamespace
Register a namespace that is explicitly declared in the prolog of the XPath expression or query module.- Specified by:
declarePrologNamespacein interfaceStaticContext- 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
Description copied from interface:StaticContextGet the default XPath namespace for elements and types- Specified by:
getDefaultElementNamespacein interfaceStaticContext- Returns:
- the default namespace, or
NamespaceConstant.NULLfor the non-namespace
-
setUnprefixedElementMatchingPolicy
Description copied from interface:StaticContextSet the matching policy for unprefixed element names in axis steps. This is a Saxon extension. The value can be any ofUnprefixedElementMatchingPolicy.DEFAULT_NAMESPACE(the default), which uses the value ofStaticContext.getDefaultElementNamespace(), orUnprefixedElementMatchingPolicy.DEFAULT_NAMESPACE_OR_NONE, which matches both the namespace given inStaticContext.getDefaultElementNamespace()and the null namespace, orUnprefixedElementMatchingPolicy.ANY_NAMESPACE, which matches any namespace (that is, it matches by local name only).- Specified by:
setUnprefixedElementMatchingPolicyin interfaceStaticContext
-
getUnprefixedElementMatchingPolicy
Description copied from interface:StaticContextGet the matching policy for unprefixed element names in axis steps. This is a Saxon extension. The value can be any ofUnprefixedElementMatchingPolicy.DEFAULT_NAMESPACE(the default), which uses the value ofStaticContext.getDefaultElementNamespace(), orUnprefixedElementMatchingPolicy.DEFAULT_NAMESPACE_OR_NONE, which matches both the namespace given inStaticContext.getDefaultElementNamespace()and the null namespace, orUnprefixedElementMatchingPolicy.ANY_NAMESPACE, which matches any namespace (that is, it matches by local name only).- Specified by:
getUnprefixedElementMatchingPolicyin interfaceStaticContext- Returns:
- the policy for matching unprefixed element names
-
getDefaultFunctionNamespace
Description copied from interface:StaticContextGet the default function namespace- Specified by:
getDefaultFunctionNamespacein interfaceStaticContext- Returns:
- the default namespace for function names
-
isInBackwardsCompatibleMode
public boolean isInBackwardsCompatibleMode()Description copied from interface:StaticContextDetermine whether backwards compatibility mode is used- Specified by:
isInBackwardsCompatibleModein interfaceStaticContext- Returns:
- true if 1.0 compatibility mode is in force.
-
getNamespaceResolver
Description copied from interface:StaticContextGet a namespace resolver to resolve the namespaces declared in this static context.- Specified by:
getNamespaceResolverin interfaceStaticContext- Returns:
- a namespace resolver.
-
getRequiredContextItemType
Description copied from interface:StaticContextGet 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:
getRequiredContextItemTypein interfaceStaticContext- Returns:
- the required type of the context item
-
getRequiredContextValueType
- Specified by:
getRequiredContextValueTypein interfaceStaticContext
-
getDecimalFormatManager
Description copied from interface:StaticContextGet a DecimalFormatManager to resolve the names of decimal formats used in calls to the format-number() function.- Specified by:
getDecimalFormatManagerin interfaceStaticContext- 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:StaticContextGet 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:
getXPathVersionin interfaceStaticContext- Returns:
- the XPath language level; the return value will be either 20, 30, 305, 31 or 40
-
getKeyManager
Description copied from interface:StaticContextGet the KeyManager, containing definitions of keys available for use.- Specified by:
getKeyManagerin interfaceStaticContext- 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
Description copied from interface:StaticContextGet 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:
resolveTypeAliasin interfaceStaticContext- Parameters:
typeName- the name of the type alias- Returns:
- the corresponding item type, if the name is recognised; otherwise null.
-
getOptimizerOptions
Description copied from interface:StaticContextGet the optimization options in use. By default these are taken from theConfiguration- Specified by:
getOptimizerOptionsin interfaceStaticContext- Returns:
- the optimization options in use
-
getURIForPrefix
Description copied from interface:NamespaceResolverGet the namespace URI corresponding to a given prefix. Return null if the prefix is not in scope.- Specified by:
getURIForPrefixin interfaceNamespaceResolver- 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
Description copied from interface:NamespaceResolverGet 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:
iteratePrefixesin interfaceNamespaceResolver- 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
-