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
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 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected final voidaddFunctionLibrary(FunctionLibrary library) Add a function library to the list of function librariesvoiddeclareCollation(String name, StringCollator comparator, boolean isDefault) Deprecated.since 9.6.Get the system configurationGet the containing location.Get a DecimalFormatManager to resolve the names of decimal formats used in calls to the format-number() function.Get the name of the default collation.Get the default namespace URI for elements and types Return NamespaceConstant.NULL (that is, the zero-length string) for the non-namespaceGet the default function namespace.Get the function library containing all the in-scope functions available in this static context.intGet the host language (XSLT, XQuery, XPath) used to implement the code in this containerGet the KeyManager, containing definitions of keys available for use.Get data about the unit of compilation (XQuery module, XSLT package) to which this container belongsGet the required type of the context item.Get the Base URI, for resolving any relative URI's used in the expression.Get the system ID of the container of the expression.intGet the XPath language level supported, as an integer (being the actual version number times ten).booleanDetermine whether Backwards Compatible Mode is usedvoidissueWarning(String s, Location locator) Issue a compile-time warning.Construct a dynamic context for early evaluation of constant subexpressionsConstruct a RetainedStaticContext, which extracts information from this StaticContext to provide the subset of static context information that is potentially needed during expression evaluationresolveTypeAlias(StructuredQName typeName) Get type alias.voidsetBackwardsCompatibilityMode(boolean option) Set XPath 1.0 backwards compatibility mode on or offvoidsetBaseURI(String baseURI) Set the base URI in the static contextprotected voidsetConfiguration(Configuration config) Set the Configuration.voidsetContainingLocation(Location location) Set the containing location, which represents the location of the outermost expression using this static context (typically, subexpressions will have a nested location that refers to this outer containing location)voidSet the DecimalFormatManager used to resolve the names of decimal formats used in calls to the format-number() function.voidsetDefaultCollationName(String collationName) Set the name of the default collation for this static context.voidSet the default namespace for elements and typesprotected final voidInitialize the default function library for XPath.final voidsetDefaultFunctionLibrary(int version) voidSet the default function namespacevoidSet the function library to be usedvoidsetPackageData(PackageData packageData) Set data about the unit of compilation (XQuery module, XSLT package)voidsetSchemaAware(boolean aware) Say whether this static context is schema-awarevoidsetTypeAlias(StructuredQName name, ItemType type) Register an alias for an ItemType.voidsetXPathLanguageLevel(int level) Set the XPath language level supported.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.sf.saxon.expr.StaticContext
bindVariable, getImportedSchemaNamespaces, getNamespaceResolver, getOptimizerOptions, isImportedSchema
-
Field Details
-
usingDefaultFunctionLibrary
protected boolean usingDefaultFunctionLibrary
-
-
Constructor Details
-
AbstractStaticContext
public AbstractStaticContext()
-
-
Method Details
-
setConfiguration
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
Get the system configuration- Specified by:
getConfigurationin interfaceStaticContext- Returns:
- the Saxon configuration
-
setPackageData
Set data about the unit of compilation (XQuery module, XSLT package)- Parameters:
packageData- the package data
-
getPackageData
Get data about the unit of compilation (XQuery module, XSLT package) to which this container belongs- Specified by:
getPackageDatain interfaceStaticContext- Returns:
- the package data
-
setSchemaAware
public void setSchemaAware(boolean aware) Say whether this static context is schema-aware- Parameters:
aware- true if this static context is schema-aware
-
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.
-
setDefaultFunctionLibrary
protected final void setDefaultFunctionLibrary()Initialize the default function library for XPath. This can be overridden using setFunctionLibrary(). -
setDefaultFunctionLibrary
public final void setDefaultFunctionLibrary(int version) -
addFunctionLibrary
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
Construct a dynamic context for early evaluation of constant subexpressions- Specified by:
makeEarlyEvaluationContextin interfaceStaticContext- Returns:
- a newly constructed dynamic context
-
getContainingLocation
Description copied from interface:StaticContextGet the containing location. This is location information relevant to an expression or query as a whole. In the case of an XPath expression held in a node of an XML document, it will provide the location of that node. In the case of a query held in a file, it contains the location of the file (in its systemId property). The method does NOT provide fine-grained location information for each contained subexpression. The location that is returned should be immutable for the duration of parsing of an XPath expression or query.- Specified by:
getContainingLocationin interfaceStaticContext- Returns:
- the containing location
-
setContainingLocation
Set the containing location, which represents the location of the outermost expression using this static context (typically, subexpressions will have a nested location that refers to this outer containing location)- Parameters:
location- the location map to be used
-
setBaseURI
Set the base URI in the static context- Parameters:
baseURI- the base URI of the expression; the value null is allowed to indicate that the base URI is not available.
-
getStaticBaseURI
Get the Base URI, for resolving any relative URI's used in the expression. Used by the document() function, resolve-uri(), etc.- Specified by:
getStaticBaseURIin interfaceStaticContext- Returns:
- "" if no base URI has been set
-
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
Set the function library to be used- Parameters:
lib- the function library
-
declareCollation
Deprecated.since 9.6. All collations are now registered at the level of the Configuration. If this method is called, the effect is (a) the supplied collation is registered with the configuration, and (b) if isDefault=true, the collation becomes the default collation for this static contextDeclare 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
-
setDefaultCollationName
Set the name of the default collation for this static context.- Parameters:
collationName- the name of the default collation
-
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
-
issueWarning
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
Get the system ID of the container of the expression. Used to construct error messages.- Specified by:
getSystemIdin interfaceStaticContext- Returns:
- "" always
-
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
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
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
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(int level) Set the XPath language level supported. The current levels supported are 20 (=2.0) and 31 (=3.1). The default is 3.1.- Parameters:
level- the XPath language level- Since:
- 9.3. From 9.8 this only affects the XPath syntax that is accepted;
it does not affect the function library that is available, which must be
set separately using
setFunctionLibrary(FunctionLibraryList)
-
getXPathVersion
public int getXPathVersion()Get the XPath language level supported, as an integer (being the actual version number times ten). In Saxon 9.9 the possible values are 20 (XPath 2.0), 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 20, 30, 305, or 31
- Since:
- 9.7
-
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
-
setDecimalFormatManager
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
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
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
-
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
-
setTypeAlias
Register an alias for an ItemType. This is a Saxon extension. Iftypenamehas been registered as an alias for, say, map{xs:string, xs:integer*}, then the syntax~typenameis accepted anywhere this ItemType would be accepted. -
resolveTypeAlias
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.
-