net.sf.saxon.expr

Class XPathContextMajor

public class XPathContextMajor extends XPathContextMinor

This class represents a "major context" in which an XPath expression is evaluated: a "major context" object allows all aspects of the dynamic context to change, whereas a "minor context" only allows changes to the focus and the destination for push output.
Constructor Summary
XPathContextMajor(Controller controller)
Constructor should only be called by the Controller, which acts as a XPathContext factory.
XPathContextMajor(Item item, Executable exec)
Constructor for use in free-standing Java applications.
XPathContextMajor(Item item, Configuration config)
Constructor for use in free-standing Java applications.
Method Summary
GroupIteratorgetCurrentGroupIterator()
Get the current group iterator.
ModegetCurrentMode()
Get the current mode.
RegexIteratorgetCurrentRegexIterator()
Get the current regex iterator.
RulegetCurrentTemplateRule()
Get the current template.
ParameterSetgetLocalParameters()
Get the local parameters for the current template call.
UserFunctiongetTailCallFunction()
Determine whether the body of a function is to be repeated, due to tail-recursive function calls
ParameterSetgetTunnelParameters()
Get the tunnel parameters for the current template call.
XPathContextMajornewContext()
Construct a new context as a copy of another.
static XPathContextMajornewContext(XPathContextMinor prev)
Create a new "major" context (one that is capable of holding a stack frame with local variables
voidopenStackFrame(SlotManager map)
Create a new stack frame for local variables, using the supplied SlotManager to define the allocation of slots to individual variables
voidopenStackFrame(int numberOfVariables)
Create a new stack frame large enough to hold a given number of local variables, for which no stack frame map is available.
voidrequestTailCall(UserFunction fn, ValueRepresentation[] variables)
Reset the local stack frame.
voidresetStackFrameMap(SlotManager map, int numberOfParams)
Reset the stack frame variable map, while reusing the StackFrame object itself.
voidsetCurrentGroupIterator(GroupIterator iterator)
Set the current grouping iterator.
voidsetCurrentMode(Mode mode)
Set the current mode.
voidsetCurrentRegexIterator(RegexIterator currentRegexIterator)
Set the current regex iterator.
voidsetCurrentTemplateRule(Rule rule)
Set the current template.
voidsetLocalParameters(ParameterSet localParameters)
Set the local parameters for the current template call.
voidsetOrigin(InstructionInfo expr)
Set the creating expression (for use in diagnostics).
voidsetStackFrame(SlotManager map, ValueRepresentation[] variables)
Set the local stack frame.
voidsetTunnelParameters(ParameterSet tunnelParameters)
Set the tunnel parameters for the current template call.
intuseLocalParameter(StructuredQName qName, LocalParam binding, boolean isTunnel)
Use local parameter.

Constructor Detail

XPathContextMajor

public XPathContextMajor(Controller controller)
Constructor should only be called by the Controller, which acts as a XPathContext factory.

Parameters: controller the Controller

XPathContextMajor

public XPathContextMajor(Item item, Executable exec)
Constructor for use in free-standing Java applications.

Parameters: item the item to use as the initial context item. If this is null, the comtext item is initially undefined (which will cause a dynamic error if it is referenced). exec the Executable

XPathContextMajor

public XPathContextMajor(Item item, Configuration config)

Deprecated: since 9.0 - use XPathContextMajor

Constructor for use in free-standing Java applications.

Parameters: item the item to use as the initial context item. If this is null, the comtext item is initially undefined (which will cause a dynamic error if it is referenced). config the Saxon Configuration

Method Detail

getCurrentGroupIterator

public GroupIterator getCurrentGroupIterator()
Get the current group iterator. This supports the current-group() and current-grouping-key() functions in XSLT 2.0

Returns: the current grouped collection

getCurrentMode

public Mode getCurrentMode()
Get the current mode.

Returns: the current mode. May return null if the current mode is the default mode.

getCurrentRegexIterator

public RegexIterator getCurrentRegexIterator()
Get the current regex iterator. This supports the functionality of the regex-group() function in XSLT 2.0.

Returns: the current regular expressions iterator

getCurrentTemplateRule

public Rule getCurrentTemplateRule()
Get the current template. This is used to support xsl:apply-imports

Returns: the current template

getLocalParameters

public ParameterSet getLocalParameters()
Get the local parameters for the current template call.

Returns: the supplied parameters

getTailCallFunction

public UserFunction getTailCallFunction()
Determine whether the body of a function is to be repeated, due to tail-recursive function calls

Returns: null if no tail call has been requested, or the name of the function to be called otherwise

getTunnelParameters

public ParameterSet getTunnelParameters()
Get the tunnel parameters for the current template call.

Returns: the supplied tunnel parameters

newContext

public XPathContextMajor newContext()
Construct a new context as a copy of another. The new context is effectively added to the top of a stack, and contains a pointer to the previous context

newContext

public static XPathContextMajor newContext(XPathContextMinor prev)
Create a new "major" context (one that is capable of holding a stack frame with local variables

Parameters: prev the previous context (the one causing the new context to be created)

Returns: the new major context

openStackFrame

public void openStackFrame(SlotManager map)
Create a new stack frame for local variables, using the supplied SlotManager to define the allocation of slots to individual variables

Parameters: map the SlotManager for the new stack frame

openStackFrame

public void openStackFrame(int numberOfVariables)
Create a new stack frame large enough to hold a given number of local variables, for which no stack frame map is available. This is used in particular when evaluating match patterns of template rules.

Parameters: numberOfVariables The number of local variables to be accommodated.

requestTailCall

public void requestTailCall(UserFunction fn, ValueRepresentation[] variables)
Reset the local stack frame. This method is used when processing a tail-recursive function. Instead of the function being called recursively, the parameters are set to new values and the function body is evaluated repeatedly

Parameters: fn the user function being called using tail recursion variables the parameter to be supplied to the user function

resetStackFrameMap

public void resetStackFrameMap(SlotManager map, int numberOfParams)
Reset the stack frame variable map, while reusing the StackFrame object itself. This is done on a tail call to a different function

Parameters: map the SlotManager representing the stack frame contents numberOfParams the number of parameters required on the new stack frame

setCurrentGroupIterator

public void setCurrentGroupIterator(GroupIterator iterator)
Set the current grouping iterator. This supports the current-group() and current-grouping-key() functions in XSLT 2.0

Parameters: iterator the new current GroupIterator

setCurrentMode

public void setCurrentMode(Mode mode)
Set the current mode.

Parameters: mode the new current mode

setCurrentRegexIterator

public void setCurrentRegexIterator(RegexIterator currentRegexIterator)
Set the current regex iterator. This supports the functionality of the regex-group() function in XSLT 2.0.

Parameters: currentRegexIterator the current regex iterator

setCurrentTemplateRule

public void setCurrentTemplateRule(Rule rule)
Set the current template. This is used to support xsl:apply-imports. The caller is responsible for remembering the previous current template and resetting it after use.

Parameters: rule the current template rule

setLocalParameters

public void setLocalParameters(ParameterSet localParameters)
Set the local parameters for the current template call.

Parameters: localParameters the supplied parameters

setOrigin

public void setOrigin(InstructionInfo expr)
Set the creating expression (for use in diagnostics). The origin is generally set to "this" by the object that creates the new context. It's up to the debugger to determine whether this information is useful. The object will either be an Expression, allowing information about the calling instruction to be obtained, or null.

setStackFrame

public void setStackFrame(SlotManager map, ValueRepresentation[] variables)
Set the local stack frame. This method is used when creating a Closure to support delayed evaluation of expressions. The "stack frame" is actually on the Java heap, which means it can survive function returns and the like.

Parameters: map the SlotManager, which holds static details of the allocation of variables to slots variables the array of "slots" to hold the actual variable values. This array will be copied if it is too small to hold all the variables defined in the SlotManager

setTunnelParameters

public void setTunnelParameters(ParameterSet tunnelParameters)
Set the tunnel parameters for the current template call.

Parameters: tunnelParameters the supplied tunnel parameters

useLocalParameter

public int useLocalParameter(StructuredQName qName, LocalParam binding, boolean isTunnel)
Use local parameter. This is called when a local xsl:param element is processed. If a parameter of the relevant name was supplied, it is bound to the xsl:param element. Otherwise the method returns false, so the xsl:param default will be evaluated

Parameters: qName The fingerprint of the parameter name binding The XSLParam element to bind its value to isTunnel True if a tunnel parameter is required, else false

Returns: ParameterSet.NOT_SUPPLIED, ParameterSet.SUPPLIED, or ParameterSet.SUPPLIED_AND_CHECKED