net.sf.saxon.style

Class ExpressionContext

public class ExpressionContext extends Object implements XSLTStaticContext

An ExpressionContext represents the context for an XPath expression written in the stylesheet.
Constructor Summary
ExpressionContext(StyleElement styleElement)
Create a static context for XPath expressions in an XSLT stylesheet
Method Summary
ExpressionbindVariable(StructuredQName qName)
Bind a variable to an object that can be used to refer to it
StringgetBaseURI()
Get the Base URI of the element containing the expression, for resolving any relative URI's used in the expression.
StringCollatorgetCollation(String name)
Get a named collation.
ConfigurationgetConfiguration()
Get the system configuration
DecimalFormatManagergetDecimalFormatManager()
Get a DecimalFormatManager to resolve the names of decimal formats used in calls to the format-number() function.
StringgetDefaultCollationName()
Get the default collation.
StringgetDefaultElementNamespace()
Get the default XPath namespace for elements and types Return NamespaceConstant.NULL for the non-namespace
StringgetDefaultFunctionNamespace()
Get the default function namespace
ExecutablegetExecutable()
Get the executable
intgetFingerprint(String qname, boolean useDefault)
Get a fingerprint for a name, using this as the context for namespace resolution
FunctionLibrarygetFunctionLibrary()
Get the function library containing all the in-scope functions available in this static context
SetgetImportedSchemaNamespaces()
Get the set of imported schemas
intgetLineNumber()
Get the line number of the expression within its containing entity Returns -1 if no line number is available
LocationMapgetLocationMap()
Get the location map
NamePoolgetNamePool()
Get the NamePool used for compiling expressions
NamespaceResolvergetNamespaceResolver()
Get a copy of the NamespaceResolver suitable for saving in the executable code
StructuredQNamegetStructuredQName(String qname, boolean useDefault)
Get a StructuredQName for a name, using this as the context for namespace resolution
StyleElementgetStyleElement()
Get the stylesheet element containing this XPath expression
StringgetSystemId()
Get the System ID of the entity containing the expression (used for diagnostics)
StringgetURIForPrefix(String prefix)
Get the URI for a prefix, using this Element as the context for namespace resolution.
XSLStylesheetgetXSLStylesheet()
Get the XSLStylesheet object
booleanisAllowedBuiltInType(BuiltInAtomicType type)
Determine whether a built-in type is available in this context.
booleanisElementAvailable(String qname)
Determine if an extension element is available
booleanisImportedSchema(String namespace)
Test whether a schema has been imported for a given namespace
booleanisInBackwardsCompatibleMode()
Determine whether Backwards Compatible Mode is used
voidissueWarning(String s, SourceLocator locator)
Issue a compile-time warning
XPathContextmakeEarlyEvaluationContext()
Construct a dynamic context for early evaluation of constant subexpressions

Constructor Detail

ExpressionContext

public ExpressionContext(StyleElement styleElement)
Create a static context for XPath expressions in an XSLT stylesheet

Parameters: styleElement the element on which the XPath expression appears

Method Detail

bindVariable

public Expression bindVariable(StructuredQName qName)
Bind a variable to an object that can be used to refer to it

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

getBaseURI

public String getBaseURI()
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.

getCollation

public StringCollator getCollation(String name)
Get a named collation.

Parameters: name The name of the required collation. Supply null to get the default collation.

Returns: the collation; or null if the required collation is not found.

getConfiguration

public Configuration getConfiguration()
Get the system configuration

getDecimalFormatManager

public 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 named decimal formats are not supported in this environment.

getDefaultCollationName

public String getDefaultCollationName()
Get the default collation. Return null if no default collation has been defined

getDefaultElementNamespace

public String getDefaultElementNamespace()
Get the default XPath namespace for elements and types Return NamespaceConstant.NULL for the non-namespace

getDefaultFunctionNamespace

public String getDefaultFunctionNamespace()
Get the default function namespace

getExecutable

public Executable getExecutable()
Get the executable

Returns: the executable

getFingerprint

public int getFingerprint(String qname, boolean useDefault)
Get a fingerprint for a name, using this as the context for namespace resolution

Parameters: qname The name as written, in the form "[prefix:]localname" useDefault Defines the action when there is no prefix. If true, use the default namespace URI (as for element names). If false, use no namespace URI (as for attribute names).

Returns: -1 if the name is not already present in the name pool

getFunctionLibrary

public FunctionLibrary getFunctionLibrary()
Get the function library containing all the in-scope functions available in this static context

getImportedSchemaNamespaces

public Set getImportedSchemaNamespaces()
Get the set of imported schemas

Returns: a Set, the set of URIs representing the names of imported schemas

getLineNumber

public int getLineNumber()
Get the line number of the expression within its containing entity Returns -1 if no line number is available

getLocationMap

public LocationMap getLocationMap()
Get the location map

getNamePool

public NamePool getNamePool()
Get the NamePool used for compiling expressions

getNamespaceResolver

public NamespaceResolver getNamespaceResolver()
Get a copy of the NamespaceResolver suitable for saving in the executable code

Returns: a NamespaceResolver

getStructuredQName

public StructuredQName getStructuredQName(String qname, boolean useDefault)
Get a StructuredQName for a name, using this as the context for namespace resolution

Parameters: qname The name as written, in the form "[prefix:]localname" useDefault Defines the action when there is no prefix. If true, use the default namespace URI (as for element names). If false, use no namespace URI (as for attribute names).

Returns: -1 if the name is not already present in the name pool

getStyleElement

public StyleElement getStyleElement()
Get the stylesheet element containing this XPath expression

Returns: the element in the tree representation of the source stylesheet

getSystemId

public String getSystemId()
Get the System ID of the entity containing the expression (used for diagnostics)

getURIForPrefix

public String getURIForPrefix(String prefix)
Get the URI for a prefix, using this Element as the context for namespace resolution. The default namespace will not be used when the prefix is empty.

Parameters: prefix The prefix

Throws: XPathException if the prefix is not declared

getXSLStylesheet

public XSLStylesheet getXSLStylesheet()
Get the XSLStylesheet object

Returns: the XSLStylesheet object representing the outermost element of the stylesheet module

isAllowedBuiltInType

public boolean isAllowedBuiltInType(BuiltInAtomicType type)
Determine whether a built-in type is available in this context. This method caters for differences between host languages as to which set of types are built in.

Parameters: type the supposedly built-in type. This will always be a type in the XS or XDT namespace.

Returns: true if this type can be used in this static context

isElementAvailable

public boolean isElementAvailable(String qname)
Determine if an extension element is available

Throws: XPathException if the name is invalid or the prefix is not declared

isImportedSchema

public boolean isImportedSchema(String namespace)
Test whether a schema has been imported for a given namespace

Parameters: namespace the target namespace of the required schema

Returns: true if a schema for this namespace has been imported

isInBackwardsCompatibleMode

public boolean isInBackwardsCompatibleMode()
Determine whether Backwards Compatible Mode is used

issueWarning

public void issueWarning(String s, SourceLocator locator)
Issue a compile-time warning

makeEarlyEvaluationContext

public XPathContext makeEarlyEvaluationContext()
Construct a dynamic context for early evaluation of constant subexpressions