Class Context
java.lang.Object
com.icl.saxon.Context
- All Implemented Interfaces:
LastPositionFinder, XSLTContext
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.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final int -
Constructor Summary
ConstructorsConstructorDescriptionContext()The default constructor is not used within Saxon itself, but is available to applications (and is used in some samples).Constructor should only be called by the Controller, which acts as a Context factory. -
Method Summary
Modifier and TypeMethodDescriptionGet the Bindery used by this ContextGet the context node, provided it is a DOM NodeGet the context nodeintGet the context position (the position of the context node in the context node list)intGet the context size (the position of the last item in the current node list).Get the controller for this ContextGet the current node,provided it is a DOM Node.Get the current node.Get the current template.Get the saved exception value.Get the saxon:group activation stackintgetLast()Get the context size (the position of the last item in the current node list)intGet the last position, to be used only when the context object is being used as the last position findergetMode()Get the current mode (for use by the built-in handlers)Get the current Outputter.Get owner Document (enabling extension functions to create new Nodes)intgetRememberedNumber(NodeInfo node) Get the number of a node if it is the last remembered one.Get the return value from functionGet the static context.Get tail recursion parametersbooleanisAtLast()Determine whether the context position is the same as the context size that is, whether position()=last()Construct a new context as a copy of anothervoidsetContextNode(NodeInfo node) Set the context node.voidSet the controller for this ContextvoidsetCurrentNode(NodeInfo node) Set the current node.voidsetCurrentTemplate(XSLTemplate template) Set the current template.voidSet an exception value.voidsetLast(int last) Set the context size; this also makes the Context object responisble for returning the last() position.voidSet the LastPositionFinder, another object that will do the work of returning the last() positionvoidSet the mode (for use by the built-in handlers)voidsetPosition(int pos) Set the context positionvoidsetRememberedNumber(NodeInfo node, int number) Set the last remembered node, for node numbering purposesvoidsetReturnValue(Value value) Set return value from functionvoidSet the static contextvoidSet tail recursion parametersstringValue(Node n) Return the String value of a nodesystemProperty(String namespaceURI, String localName) Get the value of a system property
-
Field Details
-
VARIABLES
public static final int VARIABLES- See Also:
-
CURRENT_NODE
public static final int CURRENT_NODE- See Also:
-
CONTEXT_NODE
public static final int CONTEXT_NODE- See Also:
-
POSITION
public static final int POSITION- See Also:
-
LAST
public static final int LAST- See Also:
-
CONTROLLER
public static final int CONTROLLER- See Also:
-
CONTEXT_DOCUMENT
public static final int CONTEXT_DOCUMENT- See Also:
-
NO_DEPENDENCIES
public static final int NO_DEPENDENCIES- See Also:
-
ALL_DEPENDENCIES
public static final int ALL_DEPENDENCIES- See Also:
-
XSLT_CONTEXT
public static final int XSLT_CONTEXT- See Also:
-
-
Constructor Details
-
Context
public Context()The default constructor is not used within Saxon itself, but is available to applications (and is used in some samples). Because some expressions (for example union expressions) cannot execute without a Controller, a system default Controller is created. This is a quick fix, but is not entirely satisfactory, because it's not thread-safe. Applications are encouraged to create a Controller explicitly and use it only within a single thread. -
Context
Constructor should only be called by the Controller, which acts as a Context factory.
-
-
Method Details
-
newContext
Construct a new context as a copy of another -
setController
Set the controller for this Context -
getController
Get the controller for this Context -
getBindery
Get the Bindery used by this Context -
getOutputter
Get the current Outputter. This gives access to the writeStartTag, writeAttribute, and writeEndTag methods- Returns:
- the current Outputter
-
setMode
Set the mode (for use by the built-in handlers) -
getMode
Get the current mode (for use by the built-in handlers) -
setContextNode
Set the context node.
Note that this has no effect on position() or last(), which must be set separately.- Parameters:
node- the node that is to be the context node.
-
getContextNodeInfo
-
getContextNode
Get the context node, provided it is a DOM Node- Specified by:
getContextNodein interfaceXSLTContext- Returns:
- the context node if it is a DOM Node, otherwise null
-
setPosition
public void setPosition(int pos) Set the context position -
getContextPosition
public int getContextPosition()Get the context position (the position of the context node in the context node list)- Specified by:
getContextPositionin interfaceXSLTContext- Returns:
- the context position (starting at one)
-
setLast
public void setLast(int last) Set the context size; this also makes the Context object responisble for returning the last() position. -
setLastPositionFinder
Set the LastPositionFinder, another object that will do the work of returning the last() position -
getLast
Get the context size (the position of the last item in the current node list)- Returns:
- the context size
- Throws:
XPathException
-
isAtLast
Determine whether the context position is the same as the context size that is, whether position()=last()- Throws:
XPathException
-
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().- Specified by:
getContextSizein interfaceXSLTContext- Returns:
- 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- Specified by:
getLastPositionin interfaceLastPositionFinder
-
setCurrentNode
Set the current node. This is the node in the source document currently being processed (e.g. by apply-templates). -
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. -
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.- Specified by:
getCurrentNodein interfaceXSLTContext- Returns:
- the current node if it is a DOM Node; otherwise null.
-
setCurrentTemplate
Set the current template. This is used to support xsl:apply-imports -
getCurrentTemplate
Get the current template. This is used to support xsl:apply-imports -
getOwnerDocument
Get owner Document (enabling extension functions to create new Nodes)- Specified by:
getOwnerDocumentin interfaceXSLTContext
-
systemProperty
Get the value of a system property- Specified by:
systemPropertyin interfaceXSLTContext
-
stringValue
Return the String value of a node- Specified by:
stringValuein interfaceXSLTContext- Throws:
IllegalArgumentException- if it is not a Saxon node
-
setStaticContext
Set the static context -
getStaticContext
Get the static context. This is currently available only while processing an extension function -
setException
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 -
getException
Get the saved exception value. -
getGroupActivationStack
Get the saxon:group activation stack -
setRememberedNumber
Set the last remembered node, for node numbering purposes -
getRememberedNumber
Get the number of a node if it is the last remembered one.- Returns:
- the number of this node if known, else -1.
-
setTailRecursion
Set tail recursion parameters -
getTailRecursion
Get tail recursion parameters -
setReturnValue
Set return value from function- Throws:
TransformerException
-
getReturnValue
Get the return value from function
-