net.sf.saxon.sxpath

Class AbstractStaticContext

public abstract class AbstractStaticContext extends Object implements StaticContext

An abstract and configurable implementation of the StaticContext interface, which defines the static context of an XPath expression.

This class implements those parts of the functionality of a static context that tend to be common to most implementations: simple-valued properties such as base URI and default element namespace; availability of the standard function library; and support for collations.

Method Summary
protected voidaddFunctionLibrary(FunctionLibrary library)
Add a function library to the list of function libraries
voiddeclareCollation(String name, StringCollator comparator, boolean isDefault)
Declare a named collation
StringgetBaseURI()
Get the Base URI, for resolving any relative URI's used in the expression.
StringCollatorgetCollation(String name)
Get a named collation.
intgetColumnNumber()
Return the character position where the current document event ends.
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 name of the default collation.
StringgetDefaultElementNamespace()
Get the default namespace URI for elements and types Return NamespaceConstant.NULL (that is, the zero-length string) for the non-namespace
StringgetDefaultFunctionNamespace()
Get the default function namespace.
ExecutablegetExecutable()
Get the Executable (representing a complete stylesheet or query)
FunctionLibrarygetFunctionLibrary()
Get the function library containing all the in-scope functions available in this static context.
intgetHostLanguage()
Get the host language (XSLT, XQuery, XPath) used to implement the code in this container
intgetLineNumber()
Get the line number of the expression within that container.
LocationMapgetLocationMap()
LocationProvidergetLocationProvider()
Get the LocationProvider allowing location identifiers to be resolved.
NamePoolgetNamePool()
Get the NamePool used for compiling expressions
StringgetPublicId()
Return the public identifier.
StringgetSystemId()
Get the system ID of the container of the expression.
booleanisAllowedBuiltInType(BuiltInAtomicType type)
Determine whether a built-in type is available in this context.
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
voidsetBackwardsCompatibilityMode(boolean compatible)
Set XPath 1.0 compatibility mode on or off (by default, it is false)
voidsetBaseURI(String baseURI)
Set the base URI in the static context
protected voidsetConfiguration(Configuration config)
Set the Configuration.
voidsetDefaultElementNamespace(String uri)
Set the default namespace for elements and types
protected voidsetDefaultFunctionLibrary()
Initialize the default function library for XPath.
voidsetDefaultFunctionNamespace(String uri)
Set the default function namespace
voidsetFunctionLibrary(FunctionLibrary lib)
Set the function library to be used
voidsetLocationMap(LocationMap locationMap)
Set the location map, which is used for translating location identifiers into URIs and line numbers

Method Detail

addFunctionLibrary

protected final void addFunctionLibrary(FunctionLibrary library)
Add a function library to the list of function libraries

Parameters: library the function library to be added

declareCollation

public void declareCollation(String name, StringCollator comparator, boolean isDefault)
Declare a named collation

Parameters: name The name of the collation (technically, a URI) comparator The StringCollator used to implement the collating sequence isDefault True if this is to be used as the default collation

getBaseURI

public String getBaseURI()
Get the Base URI, for resolving any relative URI's used in the expression. Used by the document() function, resolve-uri(), etc.

Returns: "" if no base URI has been set

getCollation

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

Returns: the collation identified by the given name, as set previously using declareCollation. Return null if no collation with this name is found.

getColumnNumber

public int getColumnNumber()
Return the character position where the current document event ends.

Returns: -1 (no column number is available).

See Also: AbstractStaticContext

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.

Since: 9.2

getDefaultCollationName

public 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

getDefaultElementNamespace

public String getDefaultElementNamespace()
Get the default namespace URI for elements and types Return NamespaceConstant.NULL (that is, the zero-length string) for the non-namespace

Returns: the default namespace for elements and type

getDefaultFunctionNamespace

public String getDefaultFunctionNamespace()
Get the default function namespace. The value "" (or NamespaceConstant.NULL) represents the non-namespace

Returns: the default namesapce for functions

getExecutable

public Executable getExecutable()
Get the Executable (representing a complete stylesheet or query)

Returns: the executable

getFunctionLibrary

public FunctionLibrary getFunctionLibrary()
Get the function library containing all the in-scope functions available in this static context. This method is called by the XPath parser when binding a function call in the XPath expression to an implementation of the function.

getHostLanguage

public int getHostLanguage()
Get the host language (XSLT, XQuery, XPath) used to implement the code in this container

Returns: the value XPATH

getLineNumber

public int getLineNumber()
Get the line number of the expression within that container. Used to construct error messages.

Returns: -1 always

getLocationMap

public LocationMap getLocationMap()

getLocationProvider

public LocationProvider getLocationProvider()
Get the LocationProvider allowing location identifiers to be resolved.

Returns: the LocationProvider that translates location identifiers into URIs and line numbers

getNamePool

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

getPublicId

public String getPublicId()
Return the public identifier.

The return value is the public identifier of the document entity or of the external parsed entity in which the markup that triggered the event appears.

Returns: null (always).

See Also: AbstractStaticContext

getSystemId

public String getSystemId()
Get the system ID of the container of the expression. Used to construct error messages.

Returns: "" always

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 namespace.

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

isInBackwardsCompatibleMode

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

Returns: true if XPath 1.0 backwards compatibility has been selected (by default, it is false)

issueWarning

public void issueWarning(String s, SourceLocator locator)
Issue a compile-time warning. This method is used during XPath expression compilation to output warning conditions. The default implementation writes the message to System.err. To change the destination of messages, create a subclass of StandaloneContext that overrides this method.

makeEarlyEvaluationContext

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

setBackwardsCompatibilityMode

public void setBackwardsCompatibilityMode(boolean compatible)
Set XPath 1.0 compatibility mode on or off (by default, it is false)

Parameters: compatible true if XPath 1.0 compatibility mode is to be set to true, false if it is to be set to false.

setBaseURI

public void setBaseURI(String baseURI)
Set the base URI in the static context

Parameters: baseURI the base URI of the expression

setConfiguration

protected void setConfiguration(Configuration config)
Set the Configuration. This is protected so it can be used only by subclasses; the configuration will normally be set at construction time

Parameters: config the configuration

setDefaultElementNamespace

public void setDefaultElementNamespace(String uri)
Set the default namespace for elements and types

Parameters: uri the namespace to be used for unprefixed element and type names. The value "" (or NamespaceConstant.NULL) represents the non-namespace

setDefaultFunctionLibrary

protected final void setDefaultFunctionLibrary()
Initialize the default function library for XPath. This can be overridden using setFunctionLibrary().

setDefaultFunctionNamespace

public void setDefaultFunctionNamespace(String uri)
Set the default function namespace

Parameters: uri the namespace to be used for unprefixed function names. The value "" (or NamespaceConstant.NULL) represents the non-namespace

setFunctionLibrary

public void setFunctionLibrary(FunctionLibrary lib)
Set the function library to be used

Parameters: lib the function library

setLocationMap

public void setLocationMap(LocationMap locationMap)
Set the location map, which is used for translating location identifiers into URIs and line numbers

Parameters: locationMap the location map to be used