Package net.sf.saxon.sxpath
Class AbstractStaticContext
- java.lang.Object
-
- net.sf.saxon.sxpath.AbstractStaticContext
-
- All Implemented Interfaces:
StaticContext
- Direct Known Subclasses:
IndependentContext,JAXPXPathStaticContext,UseWhenStaticContext
public abstract class AbstractStaticContext extends java.lang.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.
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanusingDefaultFunctionLibrary
-
Constructor Summary
Constructors Constructor Description AbstractStaticContext()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddFunctionLibrary(FunctionLibrary library)Add a function library to the list of function librariesvoiddeclareCollation(java.lang.String name, StringCollator comparator, boolean isDefault)Declare a named collationjava.lang.StringgetBaseURI()Get the Base URI, for resolving any relative URI's used in the expression.StringCollatorgetCollation(java.lang.String name)Get a named collation.CollationMapgetCollationMap()Get the collation map in useintgetColumnNumber()Return the character position where the current document event ends.ConfigurationgetConfiguration()Get the system configurationDecimalFormatManagergetDecimalFormatManager()Get a DecimalFormatManager to resolve the names of decimal formats used in calls to the format-number() function.java.lang.StringgetDefaultCollationName()Get the name of the default collation.java.lang.StringgetDefaultElementNamespace()Get the default namespace URI for elements and types Return NamespaceConstant.NULL (that is, the zero-length string) for the non-namespacejava.lang.StringgetDefaultFunctionNamespace()Get the default function namespace.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 containerintgetLineNumber()Get the line number of the expression within that container.LocationMapgetLocationMap()Get the location map.LocationProvidergetLocationProvider()Get the LocationProvider allowing location identifiers to be resolved.NamePoolgetNamePool()Get the NamePool used for compiling expressionsjava.lang.StringgetPublicId()Return the public identifier.ItemTypegetRequiredContextItemType()Get the required type of the context item.java.lang.StringgetSystemId()Get the system ID of the container of the expression.DecimalValuegetXPathLanguageLevel()Get the XPath language level supported, as a string.booleanisAllowedBuiltInType(BuiltInAtomicType type)Determine whether a built-in type is available in this context.booleanisInBackwardsCompatibleMode()Determine whether Backwards Compatible Mode is usedbooleanisSchemaAware()Ask whether this static context is schema-awarevoidissueWarning(java.lang.String s, javax.xml.transform.SourceLocator locator)Issue a compile-time warning.XPathContextmakeEarlyEvaluationContext()Construct a dynamic context for early evaluation of constant subexpressionsvoidsetBackwardsCompatibilityMode(boolean option)Set XPath 1.0 backwards compatibility mode on or offvoidsetBaseURI(java.lang.String baseURI)Set the base URI in the static contextvoidsetCollationMap(CollationMap collationMap)Set a collation map to override use of the default collation map from the configurationprotected voidsetConfiguration(Configuration config)Set the Configuration.voidsetDecimalFormatManager(DecimalFormatManager manager)Set the DecimalFormatManager used to resolve the names of decimal formats used in calls to the format-number() function.voidsetDefaultElementNamespace(java.lang.String uri)Set the default namespace for elements and typesprotected voidsetDefaultFunctionLibrary()Initialize the default function library for XPath.voidsetDefaultFunctionNamespace(java.lang.String uri)Set the default function namespacevoidsetFunctionLibrary(FunctionLibraryList lib)Set the function library to be usedvoidsetLocationMap(LocationMap locationMap)Set the location map, which is used for translating location identifiers into URIs and line numbersvoidsetSchemaAware(boolean aware)Say whether this static context is schema-awarevoidsetXPathLanguageLevel(DecimalValue level)Set the XPath language level supported, as a string.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.sf.saxon.expr.StaticContext
bindVariable, getImportedSchemaNamespaces, getNamespaceResolver, getURIForPrefix, isImportedSchema
-
-
-
-
Method Detail
-
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
-
getConfiguration
public Configuration getConfiguration()
Get the system configuration- Specified by:
getConfigurationin interfaceStaticContext- Returns:
- the Saxon configuration
-
setCollationMap
public void setCollationMap(CollationMap collationMap)
Set a collation map to override use of the default collation map from the configuration- Parameters:
collationMap- the collation map to be used
-
getCollationMap
public CollationMap getCollationMap()
Get the collation map in use- Returns:
- the collation map
-
setSchemaAware
public void setSchemaAware(boolean aware)
Say whether this static context is schema-aware- Parameters:
aware- true if this static context is schema-aware
-
isSchemaAware
public boolean isSchemaAware()
Ask whether this static context is schema-aware- Specified by:
isSchemaAwarein interfaceStaticContext- Returns:
- true if this context is schema-aware
-
setDefaultFunctionLibrary
protected final void setDefaultFunctionLibrary()
Initialize the default function library for XPath. This can be overridden using setFunctionLibrary().
-
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
-
getHostLanguage
public int getHostLanguage()
Get the host language (XSLT, XQuery, XPath) used to implement the code in this container- Returns:
- the value
Configuration.XPATH
-
makeEarlyEvaluationContext
public XPathContext makeEarlyEvaluationContext()
Construct a dynamic context for early evaluation of constant subexpressions- Specified by:
makeEarlyEvaluationContextin interfaceStaticContext- Returns:
- a newly constructed dynamic context
-
getLocationMap
public LocationMap getLocationMap()
Description copied from interface:StaticContextGet the location map. This is a mapping from short location ids held with each expression or subexpression, to a fully-resolved location in a source stylesheet or query.- Specified by:
getLocationMapin interfaceStaticContext- Returns:
- the location map
-
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
-
setBaseURI
public void setBaseURI(java.lang.String baseURI)
Set the base URI in the static context- Parameters:
baseURI- the base URI of the expression
-
getBaseURI
public java.lang.String getBaseURI()
Get the Base URI, for resolving any relative URI's used in the expression. Used by the document() function, resolve-uri(), etc.- Specified by:
getBaseURIin interfaceStaticContext- Returns:
- "" if no base URI has been set
-
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.- Specified by:
getFunctionLibraryin interfaceStaticContext- Returns:
- the function library
-
setFunctionLibrary
public void setFunctionLibrary(FunctionLibraryList lib)
Set the function library to be used- Parameters:
lib- the function library
-
declareCollation
public void declareCollation(java.lang.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 sequenceisDefault- True if this is to be used as the default collation
-
getCollation
public StringCollator getCollation(java.lang.String name)
Get a named collation.- Specified by:
getCollationin interfaceStaticContext- Parameters:
name- The name of the required collation. Supply null to get the default collation.- Returns:
- the collation identified by the given name, as set previously using declareCollation. Return null if no collation with this name is found.
-
getDefaultCollationName
public java.lang.String getDefaultCollationName()
Get the name of the default collation.- 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
-
getNamePool
public NamePool getNamePool()
Get the NamePool used for compiling expressions- Specified by:
getNamePoolin interfaceStaticContext- Returns:
- the name pool
-
issueWarning
public void issueWarning(java.lang.String s, javax.xml.transform.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 the error listener registered with the Configuration.- 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 container of the expression. Used to construct error messages.- Specified by:
getSystemIdin interfaceStaticContext- Returns:
- "" always
-
getLineNumber
public int getLineNumber()
Get the line number of the expression within that container. Used to construct error messages.- Specified by:
getLineNumberin interfaceStaticContext- Returns:
- -1 always
-
getDefaultElementNamespace
public java.lang.String getDefaultElementNamespace()
Get the default namespace URI for elements and types Return NamespaceConstant.NULL (that is, the zero-length string) for the non-namespace- Specified by:
getDefaultElementNamespacein interfaceStaticContext- Returns:
- the default namespace for elements and type
-
setDefaultElementNamespace
public void setDefaultElementNamespace(java.lang.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
-
setDefaultFunctionNamespace
public void setDefaultFunctionNamespace(java.lang.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
-
getDefaultFunctionNamespace
public java.lang.String getDefaultFunctionNamespace()
Get the default function namespace. The value "" (or NamespaceConstant.NULL) represents the non-namespace- Specified by:
getDefaultFunctionNamespacein interfaceStaticContext- Returns:
- the default namesapce for functions
-
setXPathLanguageLevel
public void setXPathLanguageLevel(DecimalValue level)
Set the XPath language level supported, as a string. The current levels supported are 2.0, and 3.0. The default is 2.0. If running XQuery 1.0, the value is "2.0"; if running XQuery 3.0, it is 3.0.- Parameters:
level- the XPath language level- Since:
- 9.3
-
getXPathLanguageLevel
public DecimalValue getXPathLanguageLevel()
Get the XPath language level supported, as a string. The current levels supported are "2.0", and "3.0". The default is "2.0". If running XQuery 1.0, the value is "2.0"; if running XQuery 3.0, it is "3.0".- Specified by:
getXPathLanguageLevelin interfaceStaticContext- Returns:
- the XPath language level
- Since:
- 9.3
-
setBackwardsCompatibilityMode
public void setBackwardsCompatibilityMode(boolean option)
Set XPath 1.0 backwards compatibility mode on or off- Parameters:
option- true if XPath 1.0 compatibility mode is to be set to true; otherwise false
-
isInBackwardsCompatibleMode
public boolean isInBackwardsCompatibleMode()
Determine whether Backwards Compatible Mode is used- Specified by:
isInBackwardsCompatibleModein interfaceStaticContext- Returns:
- true if XPath 1.0 compatibility mode is to be set to true; otherwise false
-
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.- Specified by:
isAllowedBuiltInTypein interfaceStaticContext- 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
-
setDecimalFormatManager
public void setDecimalFormatManager(DecimalFormatManager manager)
Set the DecimalFormatManager used to resolve the names of decimal formats used in calls to the format-number() function.- Parameters:
manager- the decimal format manager for this static context, or null if no named decimal formats are available in this environment.
-
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; a newly created empty DecimalFormatManager if none has been supplied
- Since:
- 9.2
-
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
-
getPublicId
public java.lang.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:
getSystemId()
-
getColumnNumber
public int getColumnNumber()
Return the character position where the current document event ends.- Returns:
- -1 (no column number is available).
- See Also:
getLineNumber()
-
-