This class represents a context in which an expression is evaluated or a template is executed
(as defined in the XSLT specification). It also provides a range of services to node handlers,
for example access to the outputter and bindery, and the applyTemplates() function.
ALL_DEPENDENCIES
public static final int ALL_DEPENDENCIES
- 255
CONTEXT_DOCUMENT
public static final int CONTEXT_DOCUMENT
- 128
CONTEXT_NODE
public static final int CONTEXT_NODE
- 8
CONTROLLER
public static final int CONTROLLER
- 64
CURRENT_NODE
public static final int CURRENT_NODE
- 4
LAST
public static final int LAST
- 32
NO_DEPENDENCIES
public static final int NO_DEPENDENCIES
- 0
POSITION
public static final int POSITION
- 16
VARIABLES
public static final int VARIABLES
- 1
XSLT_CONTEXT
public static final int XSLT_CONTEXT
- 69
getBindery
public Bindery getBindery()
Get the Bindery used by this Context
getContextNode
public Node getContextNode()
Get the context node, provided it is a DOM Node
- getContextNode in interface XSLTContext
- the context node if it is a DOM Node, otherwise null
getContextNodeInfo
public NodeInfo getContextNodeInfo()
Get the context node
- the context node
getContextPosition
public int getContextPosition()
Get the context position (the position of the context node in the context node list)
- getContextPosition in interface XSLTContext
- the context position (starting at one)
getContextSize
public int getContextSize()
Get the context size (the position of the last item in the current node list).
This is the XSLTContext method: it differs from getLast() in that it cannot throw
an exception.
This method should be called only from within extension functions. If any error occurs,
it will be accessible via Context#getException().
- getContextSize in interface XSLTContext
- the context size
getController
public Controller getController()
Get the controller for this Context
getCurrentNode
public Node getCurrentNode()
Get the current node,provided it is a DOM Node.
This is the node in the source document currently being processed
(e.g. by apply-templates). It is not necessarily the same as the context node: the context
node can change in a sub-expression, the current node cannot.
- getCurrentNode in interface XSLTContext
- the current node if it is a DOM Node; otherwise null.
getCurrentNodeInfo
public NodeInfo getCurrentNodeInfo()
Get the current node. This is the node in the source document currently being processed
(e.g. by apply-templates). It is not necessarily the same as the context node: the context
node can change in a sub-expression, the current node cannot.
getCurrentTemplate
public XSLTemplate getCurrentTemplate()
Get the current template. This is used to support xsl:apply-imports
getException
public XPathException getException()
Get the saved exception value.
getGroupActivationStack
public Stack getGroupActivationStack()
Get the saxon:group activation stack
getLast
public int getLast()
throws XPathException
Get the context size (the position of the last item in the current node list)
- the context size
getLastPosition
public int getLastPosition()
Get the last position, to be used only
when the context object is being used as the last position finder
- getLastPosition in interface LastPositionFinder
getMode
public Mode getMode()
Get the current mode (for use by the built-in handlers)
getOutputter
public Outputter getOutputter()
Get the current Outputter. This gives access to the writeStartTag, writeAttribute,
and writeEndTag methods
- the current Outputter
getOwnerDocument
public Document getOwnerDocument()
Get owner Document (enabling extension functions to create new Nodes)
- getOwnerDocument in interface XSLTContext
getRememberedNumber
public int getRememberedNumber(NodeInfo node)
Get the number of a node if it is the last remembered one.
- the number of this node if known, else -1.
getReturnValue
public Value getReturnValue()
Get the return value from function
getStaticContext
public StaticContext getStaticContext()
Get the static context. This is currently available only while processing an
extension function
getTailRecursion
public ParameterSet getTailRecursion()
Get tail recursion parameters
isAtLast
public boolean isAtLast()
throws XPathException
Determine whether the context position is the same as the context size
that is, whether position()=last()
newContext
public Context newContext()
Construct a new context as a copy of another
setContextNode
public void setContextNode(NodeInfo node)
Set the context node.
Note that this has no effect on position() or last(), which must be set separately.
node
- the node that is to be the context node.
setController
public void setController(Controller c)
Set the controller for this Context
setCurrentNode
public void setCurrentNode(NodeInfo node)
Set the current node. This is the node in the source document currently being processed
(e.g. by apply-templates).
setCurrentTemplate
public void setCurrentTemplate(XSLTemplate template)
Set the current template. This is used to support xsl:apply-imports
setException
public void setException(XPathException err)
Set an exception value. This is useful when an extension function makes a call
such as getContextSize() that causes an error. The error is saved as part of the
context, and reported on return from the extension function
setLast
public void setLast(int last)
Set the context size; this also makes the Context object responisble for returning the last()
position.
setLastPositionFinder
public void setLastPositionFinder(LastPositionFinder finder)
Set the LastPositionFinder, another object that will do the work of returning the last()
position
setMode
public void setMode(Mode mode)
Set the mode (for use by the built-in handlers)
setPosition
public void setPosition(int pos)
Set the context position
setRememberedNumber
public void setRememberedNumber(NodeInfo node,
int number)
Set the last remembered node, for node numbering purposes
setReturnValue
public void setReturnValue(Value value)
throws TransformerException
Set return value from function
setStaticContext
public void setStaticContext(StaticContext sc)
Set the static context
setTailRecursion
public void setTailRecursion(ParameterSet p)
Set tail recursion parameters
stringValue
public String stringValue(Node n)
Return the String value of a node
- stringValue in interface XSLTContext
systemProperty
public Object systemProperty(String namespaceURI,
String localName)
Get the value of a system property
- systemProperty in interface XSLTContext