Package net.sf.saxon.sxpath
Class XPathDynamicContext
- java.lang.Object
-
- net.sf.saxon.sxpath.XPathDynamicContext
-
public class XPathDynamicContext extends java.lang.Object
This object represents the dynamic XPath execution context for use in the free-standing Saxon XPath API. The dynamic context holds the context item and the values of external variables used by the XPath expression.This object is always created via the method
XPathExpression.createDynamicContext(net.sf.saxon.om.Item)
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
XPathDynamicContext(ItemType contextItemType, XPathContextMajor contextObject, SlotManager stackFrameMap)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
checkExternalVariables(SlotManager stackFrameMap, int numberOfExternals)
Check that all external variables have been given a valueCollectionFinder
getCollectionFinder()
Get the collection finder associated with this configuration.Item
getContextItem()
Get the context itemErrorReporter
getErrorReporter()
Get the error listener.ResourceResolver
getResourceResolver()
Get the resource resolver.UnparsedTextURIResolver
getUnparsedTextURIResolver()
Get the URI resolver for unparsed text.XPathContext
getXPathContextObject()
For system use: get the wrapped XPathContext objectvoid
setCollectionFinder(CollectionFinder cf)
Set the collection finder associated with this configuration.void
setContextItem(Item item)
Set the context item for evaluation of the XPath Expressionvoid
setErrorReporter(ErrorReporter listener)
Set the error listener.void
setResourceResolver(ResourceResolver resolver)
Set an object that will be used to resolve URIs used in document(), etc.void
setUnparsedTextURIResolver(UnparsedTextURIResolver resolver)
Set an object that will be used to resolve URIs used in fn:unparsed-text() and related functions.void
setVariable(XPathVariable variable, Sequence value)
Set the value of an external variable used within the XPath expression
-
-
-
Constructor Detail
-
XPathDynamicContext
protected XPathDynamicContext(ItemType contextItemType, XPathContextMajor contextObject, SlotManager stackFrameMap)
-
-
Method Detail
-
setContextItem
public void setContextItem(Item item) throws XPathException
Set the context item for evaluation of the XPath Expression- Parameters:
item
- the context item- Throws:
XPathException
- if the node is in a document that was built under the wrong configuration
-
getContextItem
public Item getContextItem()
Get the context item- Returns:
- the context item if there is one, or null otherwise
-
setVariable
public void setVariable(XPathVariable variable, Sequence value) throws XPathException
Set the value of an external variable used within the XPath expression- Parameters:
variable
- the object representing the variable. Note that setting the value of a variable does not modify theXPathVariable
object itself, which means that this method is thread-safe.value
- The value of the variable.- Throws:
XPathException
- if the supplied value does not conform to the required type of the variable; or if the supplied value contains a node that does not belong to this Configuration (or another Configuration that shares the same namePool)
-
setResourceResolver
public void setResourceResolver(ResourceResolver resolver)
Set an object that will be used to resolve URIs used in document(), etc. The URIResolver is set locally to this XPathContext object.- Parameters:
resolver
- An object that implements the URIResolver interface, or null.- Since:
- 9.2. Changed in 9.6 to set the URIResolver locally. Changed in 11.1 to use a ResourceResolver rather than a URIResolver.
-
getResourceResolver
public ResourceResolver getResourceResolver()
Get the resource resolver.- Returns:
- the user-supplied URI resolver if there is one, or null otherwise. If no Resolver has been set locally, the Resolver in the Controller is returned; this in turn defaults to the resolver set in the Configuration.
- Since:
- 9.2. Changed in 9.6 to use a local URIResolver. Changed in 11.1 to use a ResourceResolver rather than a URIResolver.
-
getCollectionFinder
public CollectionFinder getCollectionFinder()
Get the collection finder associated with this configuration. This is used to dereference collection URIs used in the fn:collection and fn:uri-collection functions- Returns:
- the CollectionFinder to be used
- Since:
- 9.7
-
setCollectionFinder
public void setCollectionFinder(CollectionFinder cf)
Set the collection finder associated with this configuration. This is used to dereference collection URIs used in the fn:collection and fn:uri-collection functions- Parameters:
cf
- the CollectionFinder to be used- Since:
- 9.7
-
setErrorReporter
public void setErrorReporter(ErrorReporter listener)
Set the error listener. The ErrorListener is set locally to this XPathContext object.- Parameters:
listener
- the ErrorListener to be used- Since:
- 9.2. Changed in 9.6 to set the ErrorListener locally. Changed in 10.0 to use an ErrorReporter rather than an ErrorListener
-
getErrorReporter
public ErrorReporter getErrorReporter()
Get the error listener. If no ErrorListener has been set locally, the ErrorListener in the Controller is returned; this in turn defaults to the ErrorListener set in the Configuration.- Returns:
- the ErrorListener in use. This will always be an UnfailingErrorListener, which is a Saxon subclass of ErrorListener that throws no exceptions.
- Since:
- 9.2. Changed in 9.6 to use a local ErrorListener. Changed in 10.0 to use an ErrorReporter rather than an ErrorListener
-
getXPathContextObject
public XPathContext getXPathContextObject()
For system use: get the wrapped XPathContext object- Returns:
- the underlying XPathContext object
-
setUnparsedTextURIResolver
public void setUnparsedTextURIResolver(UnparsedTextURIResolver resolver)
Set an object that will be used to resolve URIs used in fn:unparsed-text() and related functions.- Parameters:
resolver
- An object that implements the UnparsedTextURIResolver interface, or null.- Since:
- 9.5
-
getUnparsedTextURIResolver
public UnparsedTextURIResolver getUnparsedTextURIResolver()
Get the URI resolver for unparsed text.- Returns:
- the user-supplied unparsed text URI resolver if there is one, or the system-defined one otherwise
- Since:
- 9.5
-
checkExternalVariables
protected void checkExternalVariables(SlotManager stackFrameMap, int numberOfExternals) throws XPathException
Check that all external variables have been given a value- Parameters:
stackFrameMap
- describes the stack framenumberOfExternals
- the number of variables that need to be supplied- Throws:
XPathException
- if required variables have not been given a value
-
-