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(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 valueItem
getContextItem()
Get the context itemXPathContext
getXPathContextObject()
For system use: get the wrapped XPathContext objectvoid
setContextItem(Item item)
Set the context item for evaluation of the XPath Expressionvoid
setContextNode(javax.xml.transform.Source source)
Set the context item to a node derived from a supplied Source object.void
setVariable(XPathVariable variable, ValueRepresentation value)
Set the value of an external variable used within the XPath expression
-
-
-
Constructor Detail
-
XPathDynamicContext
protected XPathDynamicContext(XPathContextMajor contextObject, SlotManager stackFrameMap)
-
-
Method Detail
-
setContextNode
public void setContextNode(javax.xml.transform.Source source) throws XPathException
Set the context item to a node derived from a supplied Source object. This may be any implementation of the Source interface recognized by Saxon. Note that the SaxonNodeInfo
interface, representing a node in a tree, is one such implementation; others includeStreamSource
,SAXSource
, andDOMSource
- Parameters:
source
- The source object representing the node that will be used as the context item- Throws:
XPathException
- if a failure occurs reading or parsing a Source object to build an input tree, or if the source is a document that was built under the wrong configuration
-
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, ValueRepresentation value) throws XPathException
Set the value of an external variable used within the XPath expression- Parameters:
variable
- the object representing the variable, as returned by theXPathEvaluator.declareVariable(String, String)
method. 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)
-
getXPathContextObject
public XPathContext getXPathContextObject()
For system use: get the wrapped XPathContext object- Returns:
- the underlying XPathContext object
-
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
-
-