Package net.sf.saxon.style
Class ExpressionContext
- java.lang.Object
-
- net.sf.saxon.style.ExpressionContext
-
- All Implemented Interfaces:
StaticContext
- Direct Known Subclasses:
TextValueTemplateContext
public class ExpressionContext extends java.lang.Object implements StaticContext
An ExpressionContext represents the context for an XPath expression written in the stylesheet.
-
-
Constructor Summary
Constructors Constructor Description ExpressionContext(StyleElement styleElement, StructuredQName attributeName)
Create a static context for XPath expressions in an XSLT stylesheet
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Expression
bindVariable(StructuredQName qName)
Bind a variable to an object that can be used to refer to itConfiguration
getConfiguration()
Get the system configurationLocation
getContainingLocation()
Get the containing location of an XPath expression within the stylesheetDecimalFormatManager
getDecimalFormatManager()
Get a DecimalFormatManager to resolve the names of decimal formats used in calls to the format-number() function.java.lang.String
getDefaultCollationName()
Get the default collation.java.lang.String
getDefaultElementNamespace()
Get the default XPath namespace for elements and types Return NamespaceConstant.NULL for the non-namespacejava.lang.String
getDefaultFunctionNamespace()
Get the default function namespaceFunctionLibrary
getFunctionLibrary()
Get the function library containing all the in-scope functions available in this static contextjava.util.Set<java.lang.String>
getImportedSchemaNamespaces()
Get the set of imported schemasKeyManager
getKeyManager()
Get the KeyManager, containing definitions of keys available for use.NamespaceResolver
getNamespaceResolver()
Get a copy of the NamespaceResolver suitable for saving in the executable codeOptimizerOptions
getOptimizerOptions()
Get the optimization options in use.StylesheetPackage
getPackageData()
Get the containing XSLT packageItemType
getRequiredContextItemType()
Get the required type of the context item.java.lang.String
getStaticBaseURI()
Get the Base URI of the element containing the expression, for resolving any relative URI's used in the expression.StyleElement
getStyleElement()
Get the stylesheet element containing this XPath expressionjava.lang.String
getSystemId()
Get the System ID of the entity containing the expression (used for diagnostics)UnprefixedElementMatchingPolicy
getUnprefixedElementMatchingPolicy()
Get the matching policy for unprefixed element names in axis steps.int
getXPathVersion()
Get the XPath language level supported, as an integer (being the actual version number times ten).boolean
isImportedSchema(java.lang.String namespace)
Test whether a schema has been imported for a given namespaceboolean
isInBackwardsCompatibleMode()
Determine whether Backwards Compatible Mode is usedboolean
isSchemaAware()
Ask whether expressions compiled under this static context are schema-aware.void
issueWarning(java.lang.String s, Location locator)
Issue a compile-time warningXPathContext
makeEarlyEvaluationContext()
Construct a dynamic context for early evaluation of constant subexpressionsRetainedStaticContext
makeRetainedStaticContext()
Construct a RetainedStaticContext, which extracts information from this StaticContext to provide the subset of static context information that is potentially needed during expression evaluationItemType
resolveTypeAlias(StructuredQName typeName)
Get type alias.
-
-
-
Constructor Detail
-
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 appearsattributeName
- the name of the attribute in which the XPath expression appears; or null if the expression appears in a text node
-
-
Method Detail
-
getConfiguration
public Configuration getConfiguration()
Get the system configuration- Specified by:
getConfiguration
in interfaceStaticContext
- Returns:
- the Saxon configuration
-
getPackageData
public StylesheetPackage getPackageData()
Get the containing XSLT package- Specified by:
getPackageData
in interfaceStaticContext
- 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
-
makeEarlyEvaluationContext
public XPathContext makeEarlyEvaluationContext()
Construct a dynamic context for early evaluation of constant subexpressions- Specified by:
makeEarlyEvaluationContext
in interfaceStaticContext
- 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 interfaceStaticContext
- 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 interfaceStaticContext
- 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(java.lang.String s, Location locator)
Issue a compile-time warning- Specified by:
issueWarning
in interfaceStaticContext
- Parameters:
s
- The warning message. This should not contain any prefix such as "Warning".locator
- the location of the construct in question. May be null.
-
getSystemId
public java.lang.String getSystemId()
Get the System ID of the entity containing the expression (used for diagnostics)- Specified by:
getSystemId
in interfaceStaticContext
- Returns:
- the system ID
-
getStaticBaseURI
public java.lang.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 interfaceStaticContext
- 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 interfaceStaticContext
- 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 interfaceStaticContext
- 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 interfaceStaticContext
- 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 theConfiguration
- Specified by:
getOptimizerOptions
in interfaceStaticContext
- 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 interfaceStaticContext
- 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 interfaceStaticContext
- Returns:
- the function library
-
getDefaultCollationName
public java.lang.String getDefaultCollationName()
Get the default collation. Return null if no default collation has been defined- Specified by:
getDefaultCollationName
in interfaceStaticContext
- Returns:
- the name of the default collation; or the name of the codepoint collation if no default collation has been defined
-
getDefaultElementNamespace
public java.lang.String getDefaultElementNamespace()
Get the default XPath namespace for elements and types Return NamespaceConstant.NULL for the non-namespace- Specified by:
getDefaultElementNamespace
in interfaceStaticContext
- Returns:
- the default namespace, or
NamespaceConstant.NULL
for the non-namespace
-
getDefaultFunctionNamespace
public java.lang.String getDefaultFunctionNamespace()
Get the default function namespace- Specified by:
getDefaultFunctionNamespace
in interfaceStaticContext
- Returns:
- the default namespace for function names
-
isInBackwardsCompatibleMode
public boolean isInBackwardsCompatibleMode()
Determine whether Backwards Compatible Mode is used- Specified by:
isInBackwardsCompatibleMode
in interfaceStaticContext
- 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 interfaceStaticContext
- Returns:
- the XPath language level; the return value will be either 30, 305, or 31
- Since:
- 9.7
-
isImportedSchema
public boolean isImportedSchema(java.lang.String namespace)
Test whether a schema has been imported for a given namespace- Specified by:
isImportedSchema
in interfaceStaticContext
- Parameters:
namespace
- the target namespace of the required schema- Returns:
- true if a schema for this namespace has been imported
-
getImportedSchemaNamespaces
public java.util.Set<java.lang.String> getImportedSchemaNamespaces()
Get the set of imported schemas- Specified by:
getImportedSchemaNamespaces
in interfaceStaticContext
- 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 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
-
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 interfaceStaticContext
- 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 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).- Specified by:
getUnprefixedElementMatchingPolicy
in interfaceStaticContext
-
-