com.icl.saxon.functions
Class Extensions

java.lang.Object
  |
  +--com.icl.saxon.functions.Extensions

public class Extensions
extends java.lang.Object

This class implements functions that are supplied as standard with SAXON, but which are not defined in the XSLT or XPath specifications.

To invoke these functions, use a function call of the form prefix:name() where name is the method name, and prefix maps to a URI such as http://icl.com/saxon/com.icl.saxon.functions.Extensions (only the part of the URI after the last slash is important).


Constructor Summary
Extensions()
           
 
Method Summary
static NodeSetValue difference(NodeSetValue p1, NodeSetValue p2)
          Return the difference of two node-sets
static NodeSetValue distinct(Context context, NodeSetValue in, Expression exp)
          Given a node-set, return a subset that includes only nodes with distinct string-values for the supplied expression
static NodeSetValue distinct(NodeSetValue in)
          Given a node-set, return a subset that includes only nodes with distinct string-values
static Value eval(Context c, Expression expr)
          Evaluate the stored expression supplied in the first argument
static Value evaluate(Context c, java.lang.String expr)
          Evaluate the expression supplied in the first argument as a string
static boolean exists(Context context, NodeSetValue nsv, Expression expression)
          Test whether node-set contains a node that satisfies a given condition
static Value expression(Context c, java.lang.String expr)
          Return an object representing a stored expression, from the string supplied in the first argument.
static boolean forAll(Context context, NodeSetValue nsv, Expression expression)
          Test whether all nodes in a node-set satisfy a given condition
static Context getContext(Context c)
          Return the Context object
static Value getUserData(Context c, java.lang.String name)
          Retrieve a value associated with the context node
static boolean hasSameNodes(NodeSetValue p1, NodeSetValue p2)
          Determine whether two node-sets contain the same nodes
static NodeSetValue highest(Context context, NodeSetValue nsv, Expression expression)
          Get the maximum numeric value of a stored expression over a set of nodes
static NodeSetValue highest(NodeSetValue nsv)
          Get the node with maximum numeric value of the string-value of each of a set of nodes
static Value IF(Value test, Value thenValue, Value elseValue)
          Return the value of the second argument if the first is true, or the third argument otherwise.
static NodeSetValue intersection(NodeSetValue p1, NodeSetValue p2)
          Return the intersection of two node-sets
static boolean isNull(java.lang.Object x)
          Test whether an encapsulated Java object is null
static NodeSetValue leading(Context context, NodeSetValue in, Expression exp)
          Get the nodes that staisfy the given expression, up to and excluding the first one (in document order) that doesn't
static double linenumber(Context c)
          Return the line number of the context node.
static NodeSetValue lowest(Context context, NodeSetValue nsv, Expression expression)
          Get the node with minimum numeric value of a stored expression over a set of nodes
static NodeSetValue lowest(NodeSetValue nsv)
          Get the node with minimum numeric value of the string-value of each of a set of nodes
static double max(Context context, NodeSetValue nsv, Expression expression)
          Get the maximum numeric value of a stored expression over a set of nodes
static double max(NodeSetValue nsv)
          Get the maximum numeric value of the string-value of each of a set of nodes
static double min(Context context, NodeSetValue nsv, Expression expression)
          Get the minimum numeric value of a stored expression over a set of nodes
static double min(NodeSetValue nsv)
          Get the minimum numeric value of the string-value of each of a set of nodes
static NodeSetValue nodeset(Value frag)
          Convert a result tree fragment to a node-set.
static java.lang.String path(Context c)
          Return an XPath expression that identifies the current node
static NodeSetValue range(Context context, double start, double finish)
          Return a node-set whose nodes have string-values "1", "2", ...
static void setUserData(Context c, java.lang.String name, Value value)
          Save a value associated with the context node
static java.lang.String showNodeset(Context c, NodeSetValue in)
          A diagnostic function to print the contents of a node-set
static double sum(Context context, NodeSetValue nsv, Expression expression)
          Total a stored expression over a set of nodes
static java.lang.String systemid(Context c)
          Return the system identifier of the context node
static NodeSetValue tokenize(Context context, java.lang.String s)
          Return a node-set by tokenizing a supplied string.
static NodeSetValue tokenize(Context context, java.lang.String s, java.lang.String delim)
          Return a node-set by tokenizing a supplied string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Extensions

public Extensions()
Method Detail

nodeset

public static NodeSetValue nodeset(Value frag)
                            throws org.xml.sax.SAXException
Convert a result tree fragment to a node-set. (Redundant at XSLT version 1.1)

systemid

public static java.lang.String systemid(Context c)
                                 throws org.xml.sax.SAXException
Return the system identifier of the context node

linenumber

public static double linenumber(Context c)
                         throws org.xml.sax.SAXException
Return the line number of the context node. This must be returned as a double to meet the calling requirements for extension functions.

intersection

public static NodeSetValue intersection(NodeSetValue p1,
                                        NodeSetValue p2)
                                 throws org.xml.sax.SAXException
Return the intersection of two node-sets
Parameters:
p1 - The first node-set
p2 - The second node-set
Returns:
A node-set containing all nodes that are in both p1 and p2

difference

public static NodeSetValue difference(NodeSetValue p1,
                                      NodeSetValue p2)
                               throws org.xml.sax.SAXException
Return the difference of two node-sets
Parameters:
p1 - The first node-set
p2 - The second node-set
Returns:
A node-set containing all nodes that are in p1 and not in p2

hasSameNodes

public static boolean hasSameNodes(NodeSetValue p1,
                                   NodeSetValue p2)
                            throws org.xml.sax.SAXException
Determine whether two node-sets contain the same nodes
Parameters:
p1 - The first node-set
p2 - The second node-set
Returns:
true if p1 and p2 contain the same set of nodes

IF

public static Value IF(Value test,
                       Value thenValue,
                       Value elseValue)
                throws org.xml.sax.SAXException
Return the value of the second argument if the first is true, or the third argument otherwise. Note that all three arguments are evaluated.
Parameters:
test - A value treated as a boolean
thenValue - Any value
elseValue - Any value
Returns:
(test ? thenValue : elseValue)

evaluate

public static Value evaluate(Context c,
                             java.lang.String expr)
                      throws org.xml.sax.SAXException
Evaluate the expression supplied in the first argument as a string

eval

public static Value eval(Context c,
                         Expression expr)
                  throws org.xml.sax.SAXException
Evaluate the stored expression supplied in the first argument

expression

public static Value expression(Context c,
                               java.lang.String expr)
                        throws org.xml.sax.SAXException
Return an object representing a stored expression, from the string supplied in the first argument.

sum

public static double sum(Context context,
                         NodeSetValue nsv,
                         Expression expression)
                  throws org.xml.sax.SAXException
Total a stored expression over a set of nodes

max

public static double max(NodeSetValue nsv)
                  throws org.xml.sax.SAXException
Get the maximum numeric value of the string-value of each of a set of nodes

max

public static double max(Context context,
                         NodeSetValue nsv,
                         Expression expression)
                  throws org.xml.sax.SAXException
Get the maximum numeric value of a stored expression over a set of nodes

min

public static double min(NodeSetValue nsv)
                  throws org.xml.sax.SAXException
Get the minimum numeric value of the string-value of each of a set of nodes

min

public static double min(Context context,
                         NodeSetValue nsv,
                         Expression expression)
                  throws org.xml.sax.SAXException
Get the minimum numeric value of a stored expression over a set of nodes

highest

public static NodeSetValue highest(NodeSetValue nsv)
                            throws org.xml.sax.SAXException
Get the node with maximum numeric value of the string-value of each of a set of nodes

highest

public static NodeSetValue highest(Context context,
                                   NodeSetValue nsv,
                                   Expression expression)
                            throws org.xml.sax.SAXException
Get the maximum numeric value of a stored expression over a set of nodes

lowest

public static NodeSetValue lowest(NodeSetValue nsv)
                           throws org.xml.sax.SAXException
Get the node with minimum numeric value of the string-value of each of a set of nodes

lowest

public static NodeSetValue lowest(Context context,
                                  NodeSetValue nsv,
                                  Expression expression)
                           throws org.xml.sax.SAXException
Get the node with minimum numeric value of a stored expression over a set of nodes

distinct

public static NodeSetValue distinct(NodeSetValue in)
                             throws org.xml.sax.SAXException
Given a node-set, return a subset that includes only nodes with distinct string-values

distinct

public static NodeSetValue distinct(Context context,
                                    NodeSetValue in,
                                    Expression exp)
                             throws org.xml.sax.SAXException
Given a node-set, return a subset that includes only nodes with distinct string-values for the supplied expression

leading

public static NodeSetValue leading(Context context,
                                   NodeSetValue in,
                                   Expression exp)
                            throws org.xml.sax.SAXException
Get the nodes that staisfy the given expression, up to and excluding the first one (in document order) that doesn't

exists

public static boolean exists(Context context,
                             NodeSetValue nsv,
                             Expression expression)
                      throws org.xml.sax.SAXException
Test whether node-set contains a node that satisfies a given condition

forAll

public static boolean forAll(Context context,
                             NodeSetValue nsv,
                             Expression expression)
                      throws org.xml.sax.SAXException
Test whether all nodes in a node-set satisfy a given condition

range

public static NodeSetValue range(Context context,
                                 double start,
                                 double finish)
                          throws org.xml.sax.SAXException
Return a node-set whose nodes have string-values "1", "2", ... "n"

tokenize

public static NodeSetValue tokenize(Context context,
                                    java.lang.String s)
                             throws org.xml.sax.SAXException
Return a node-set by tokenizing a supplied string. Tokens are delimited by any sequence of whitespace characters.

tokenize

public static NodeSetValue tokenize(Context context,
                                    java.lang.String s,
                                    java.lang.String delim)
                             throws org.xml.sax.SAXException
Return a node-set by tokenizing a supplied string. The argument delim is a String, any character in this string is considered to be a delimiter character, and any sequence of delimiter characters acts as a separator between tokens.

path

public static java.lang.String path(Context c)
                             throws org.xml.sax.SAXException
Return an XPath expression that identifies the current node

showNodeset

public static java.lang.String showNodeset(Context c,
                                           NodeSetValue in)
                                    throws org.xml.sax.SAXException
A diagnostic function to print the contents of a node-set

isNull

public static boolean isNull(java.lang.Object x)
                      throws org.xml.sax.SAXException
Test whether an encapsulated Java object is null

setUserData

public static void setUserData(Context c,
                               java.lang.String name,
                               Value value)
                        throws org.xml.sax.SAXException
Save a value associated with the context node

getUserData

public static Value getUserData(Context c,
                                java.lang.String name)
                         throws org.xml.sax.SAXException
Retrieve a value associated with the context node

getContext

public static Context getContext(Context c)
Return the Context object