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 ExpressionbindVariable(StructuredQName qName)Bind a variable to an object that can be used to refer to itConfigurationgetConfiguration()Get the system configurationLocationgetContainingLocation()Get the containing location of an XPath expression within the stylesheetDecimalFormatManagergetDecimalFormatManager()Get a DecimalFormatManager to resolve the names of decimal formats used in calls to the format-number() function.java.lang.StringgetDefaultCollationName()Get the default collation.java.lang.StringgetDefaultElementNamespace()Get the default XPath namespace for elements and types Return NamespaceConstant.NULL for the non-namespacejava.lang.StringgetDefaultFunctionNamespace()Get the default function namespaceFunctionLibrarygetFunctionLibrary()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 schemasKeyManagergetKeyManager()Get the KeyManager, containing definitions of keys available for use.NamespaceResolvergetNamespaceResolver()Get a copy of the NamespaceResolver suitable for saving in the executable codeOptimizerOptionsgetOptimizerOptions()Get the optimization options in use.StylesheetPackagegetPackageData()Get the containing XSLT packageItemTypegetRequiredContextItemType()Get the required type of the context item.java.lang.StringgetStaticBaseURI()Get the Base URI of the element containing the expression, for resolving any relative URI's used in the expression.StyleElementgetStyleElement()Get the stylesheet element containing this XPath expressionjava.lang.StringgetSystemId()Get the System ID of the entity containing the expression (used for diagnostics)UnprefixedElementMatchingPolicygetUnprefixedElementMatchingPolicy()Get the matching policy for unprefixed element names in axis steps.intgetXPathVersion()Get the XPath language level supported, as an integer (being the actual version number times ten).booleanisImportedSchema(java.lang.String namespace)Test whether a schema has been imported for a given namespacebooleanisInBackwardsCompatibleMode()Determine whether Backwards Compatible Mode is usedbooleanisSchemaAware()Ask whether expressions compiled under this static context are schema-aware.voidissueWarning(java.lang.String s, Location locator)Issue a compile-time warningXPathContextmakeEarlyEvaluationContext()Construct a dynamic context for early evaluation of constant subexpressionsRetainedStaticContextmakeRetainedStaticContext()Construct a RetainedStaticContext, which extracts information from this StaticContext to provide the subset of static context information that is potentially needed during expression evaluationItemTyperesolveTypeAlias(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:
getConfigurationin interfaceStaticContext- Returns:
- the Saxon configuration
-
getPackageData
public StylesheetPackage getPackageData()
Get the containing XSLT package- Specified by:
getPackageDatain 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:
makeEarlyEvaluationContextin 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:
makeRetainedStaticContextin 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:
getContainingLocationin 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:
issueWarningin 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:
getSystemIdin 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:
getStaticBaseURIin 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:
getNamespaceResolverin 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:
getRequiredContextItemTypein 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:
getDecimalFormatManagerin 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:
getOptimizerOptionsin 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:
bindVariablein 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:
getFunctionLibraryin 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:
getDefaultCollationNamein 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:
getDefaultElementNamespacein interfaceStaticContext- Returns:
- the default namespace, or
NamespaceConstant.NULLfor the non-namespace
-
getDefaultFunctionNamespace
public java.lang.String getDefaultFunctionNamespace()
Get the default function namespace- Specified by:
getDefaultFunctionNamespacein interfaceStaticContext- Returns:
- the default namespace for function names
-
isInBackwardsCompatibleMode
public boolean isInBackwardsCompatibleMode()
Determine whether Backwards Compatible Mode is used- Specified by:
isInBackwardsCompatibleModein 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:
getXPathVersionin 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:
isImportedSchemain 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:
getImportedSchemaNamespacesin 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:
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
-
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:
resolveTypeAliasin 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:
getUnprefixedElementMatchingPolicyin interfaceStaticContext
-
-