net.sf.saxon.expr
Class XPathContext

java.lang.Object
  extended by net.sf.saxon.expr.XPathContext

public class XPathContext
extends Object

This class represents a context in which an XPath expression is evaluated.


Constructor Summary
XPathContext(Controller c)
          Constructor should only be called by the Controller, which acts as a XPathContext factory.
XPathContext(Item item)
          Constructor for use in free-standing Java applications.
XPathContext(XPathContext c)
          Constructor to create one XPathContext as a copy of another
 
Method Summary
 Value evaluateLocalVariable(int slotnumber)
          Get the value of a local variable, identified by its slot number
 Comparator getCollation(String name)
          Get a named collation
 Item getContextItem()
          Get the context item (XPath 2.0)
 int getContextPosition()
          Get the context position (the position of the context node in the context node list)
 Controller getController()
          Get the Controller.
 SequenceIterator getCurrentIterator()
          Get the current iterator
 Item getCurrentStylesheetItem()
          Get the current stylesheet item: supports the XSLT current() function
 Comparator getDefaultCollation()
          Get the default collation
 int getLast()
          Get the context size (the position of the last item in the current node list)
 Object[] getLocalVariableFrame()
          Get a reference to the local stack frame for variables.
 boolean isAtLast()
          Determine whether the context position is the same as the context size that is, whether position()=last()
 XPathContext newContext()
          Construct a new context as a copy of another
 void setCurrentIterator(SequenceIterator iter)
          Set a new sequence iterator.
 void setLocalVariable(int slotnumber, Value value)
          Set the value of a local variable, identified by its slot number
 void setLocalVariableFrame(Object[] variables)
          Set the local stack frame.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XPathContext

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


XPathContext

public XPathContext(XPathContext c)
Constructor to create one XPathContext as a copy of another


XPathContext

public XPathContext(Item item)
Constructor for use in free-standing Java applications. Must be used with care, since functions dependent on a Controller will not be available.

Method Detail

newContext

public XPathContext newContext()
Construct a new context as a copy of another


getController

public Controller getController()
Get the Controller. Returns null when running outside XSLT


setCurrentIterator

public void setCurrentIterator(SequenceIterator iter)
Set a new sequence iterator.


getCurrentIterator

public SequenceIterator getCurrentIterator()
Get the current iterator


getContextPosition

public int getContextPosition()
                       throws XPathException
Get the context position (the position of the context node in the context node list)

Returns:
the context position (starting at one)
Throws:
XPathException

getContextItem

public Item getContextItem()
Get the context item (XPath 2.0)

Returns:
the context item, or null if the context item is not set

getLast

public int getLast()
            throws XPathException
Get the context size (the position of the last item in the current node list)

Returns:
the context size
Throws:
XPathException

isAtLast

public boolean isAtLast()
                 throws XPathException
Determine whether the context position is the same as the context size that is, whether position()=last()

Throws:
XPathException

getCurrentStylesheetItem

public Item getCurrentStylesheetItem()
                              throws XPathException
Get the current stylesheet item: supports the XSLT current() function

Throws:
XPathException

getCollation

public Comparator getCollation(String name)
                        throws XPathException
Get a named collation

Throws:
XPathException

getDefaultCollation

public Comparator getDefaultCollation()
Get the default collation


getLocalVariableFrame

public Object[] getLocalVariableFrame()
Get a reference to the local stack frame for variables. Note that it's the caller's job to make a local copy of this. This is used for creating a Closure containing a retained copy of the variables for delayed evaluation.

Returns:
array of variables.

setLocalVariableFrame

public void setLocalVariableFrame(Object[] 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 heap, which means it can survive function returns and the like.


evaluateLocalVariable

public Value evaluateLocalVariable(int slotnumber)
Get the value of a local variable, identified by its slot number


setLocalVariable

public void setLocalVariable(int slotnumber,
                             Value value)
Set the value of a local variable, identified by its slot number