Package net.sf.saxon.expr
Interface StaticContext
- All Known Implementing Classes:
AbstractStaticContext,ExpressionContext,IndependentContext,JAXPXPathStaticContext,QueryLibrary,QueryLibraryImpl,QueryModule,SchemaElement.XPathStaticContext,StaticContextOverlay,TextValueTemplateContext,UseWhenStaticContext
public interface StaticContext
A StaticContext contains the information needed while an expression or pattern
is being parsed. The information is also sometimes needed at run-time. The StaticContext
object can be used to parse multiple expressions, so in general it must be immutable.
The XPath 4.0 "declare namespace" mechanism, which modifies the static context for
a single XPath expression is handled by an implementation
StaticContextOverlay
which handles the mutable parts of the static context and delegates everything else
to an immutable implementation.-
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.default OptimizerOptionsGet 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.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.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.
-
Method Details
-
getConfiguration
Configuration getConfiguration()Get the system configuration- Returns:
- the Saxon configuration
-
getPackageData
PackageData getPackageData()Get information about the containing package (unit of compilation)- Returns:
- the package data
-
getImportedSchema
Schema getImportedSchema()Get the in-scope schema declarations for the static context -
makeEarlyEvaluationContext
XPathContext makeEarlyEvaluationContext()Construct a dynamic context for early evaluation of constant subexpressions.- Returns:
- a newly constructed dynamic context
-
makeRetainedStaticContext
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- Returns:
- a RetainedStaticContext object: either a newly created one, or one that is reused from a previous invocation.
-
getContainingLocation
Location getContainingLocation()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.- Returns:
- the containing location
-
issueWarning
Issue a compile-time warning.- 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
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.- Returns:
- the system ID
-
getStaticBaseURI
String getStaticBaseURI()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.- Returns:
- the static base URI, or null if not known
-
bindVariable
Bind a variable used in this expression to the Binding object in which it is declared- 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
FunctionLibrary getFunctionLibrary()Get the function library containing all the in-scope functions available in this static context- Returns:
- the function library
-
getDefaultCollationName
String getDefaultCollationName()Get the name of the default collation.- 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.- 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
NamespaceUri getDefaultElementNamespace()Get the default XPath namespace for elements and types- Returns:
- the default namespace, or
NamespaceConstant.NULLfor the non-namespace
-
setUnprefixedElementMatchingPolicy
Set 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 ofgetDefaultElementNamespace(), orUnprefixedElementMatchingPolicy.DEFAULT_NAMESPACE_OR_NONE, which matches both the namespace given ingetDefaultElementNamespace()and the null namespace, orUnprefixedElementMatchingPolicy.ANY_NAMESPACE, which matches any namespace (that is, it matches by local name only). -
getUnprefixedElementMatchingPolicy
UnprefixedElementMatchingPolicy getUnprefixedElementMatchingPolicy()Get 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 ofgetDefaultElementNamespace(), orUnprefixedElementMatchingPolicy.DEFAULT_NAMESPACE_OR_NONE, which matches both the namespace given ingetDefaultElementNamespace()and the null namespace, orUnprefixedElementMatchingPolicy.ANY_NAMESPACE, which matches any namespace (that is, it matches by local name only).- Returns:
- the policy for matching unprefixed element names
-
getDefaultFunctionNamespace
NamespaceUri getDefaultFunctionNamespace()Get the default function namespace- Returns:
- the default namespace for function names
-
isInBackwardsCompatibleMode
boolean isInBackwardsCompatibleMode()Determine whether backwards compatibility mode is used- Returns:
- true if 1.0 compatibility mode is in force.
-
getNamespaceResolver
NamespaceResolver getNamespaceResolver()Get a namespace resolver to resolve the namespaces declared in this static context.- Returns:
- a namespace resolver.
-
getRequiredContextItemType
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.- Returns:
- the required type of the context item
- Since:
- 9.3
-
getRequiredContextValueType
SequenceType getRequiredContextValueType() -
getDecimalFormatManager
DecimalFormatManager getDecimalFormatManager()Get a DecimalFormatManager to resolve the names of decimal formats used in calls to the format-number() function.- Returns:
- the decimal format manager for this static context, or null if no named decimal formats are available in this environment.
- Since:
- 9.2
-
getXPathVersion
int getXPathVersion()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).- Returns:
- the XPath language level; the return value will be either 20, 30, 305, 31 or 40
- Since:
- 9.7
-
getKeyManager
KeyManager getKeyManager()Get the KeyManager, containing definitions of keys available for use.- 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
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.- Parameters:
typeName- the name of the type alias- Returns:
- the corresponding item type, if the name is recognised; otherwise null.
-
getOptimizerOptions
Get the optimization options in use. By default these are taken from theConfiguration- Returns:
- the optimization options in use
-