com.icl.saxon.functions

Class Extensions

public class Extensions extends 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).

Method Summary
static NodeSetValueafter(Context context, NodeSetValue ns1, NodeSetValue ns2)
Find all the nodes in ns1 that are after the first node in ns2.
static StringbaseUri(Context c)
Return the base URI of the context node
static NodeSetValuebefore(Context context, NodeSetValue ns1, NodeSetValue ns2)
Find all the nodes in ns1 that are before the last node in ns2.
static NodeEnumerationclosure(Context c, NodeEnumeration enm, Expression expr)
Evaluate the transitive closure of a node-set expression
static NodeEnumerationdifference(Context c, NodeEnumeration p1, NodeEnumeration p2)
Return the difference of two node-sets
static NodeEnumerationdistinct(Context context, NodeEnumeration in)
Given a node-set, return a subset that includes only nodes with distinct string-values
static NodeEnumerationdistinct(Context context, NodeEnumeration in, Expression exp)
Given a node-set, return a subset that includes only nodes with distinct string-values for the supplied expression
static Valueeval(Context c, Expression expr)
Evaluate the stored expression supplied in the first argument
static Valueevaluate(Context c, String expr)
Evaluate the expression supplied in the first argument as a string
static booleanexists(Context context, NodeEnumeration nsv, Expression expression)
Test whether node-set contains a node that satisfies a given condition
static Valueexpression(Context c, String expr)
Return an object representing a stored expression, from the string supplied in the first argument.
static booleanforAll(Context context, NodeEnumeration nsv, Expression expression)
Test whether all nodes in a node-set satisfy a given condition
static ContextgetContext(Context c)
Return the Context object
static StringgetPseudoAttribute(Context c, String name)
Get a pseudo-attribute of a processing instruction.
static ValuegetUserData(Context c, String name)
Retrieve a value associated with the context node
static booleanhasSameNodes(Context context, NodeEnumeration p1, NodeEnumeration p2)
Determine whether two node-sets contain the same nodes
static NodeSetValuehighest(Context c, NodeEnumeration nsv)
Get the node with maximum numeric value of the string-value of each of a set of nodes
static NodeEnumerationhighest(Context context, NodeEnumeration nsv, Expression expression)
Get the maximum numeric value of a stored expression over a set of nodes
static NodeEnumerationintersection(Context c, NodeEnumeration p1, NodeEnumeration p2)
Return the intersection of two node-sets
static booleanisNull(Object x)
Test whether an encapsulated Java object is null
static ValueIF(Value test, Value thenValue, Value elseValue)
Return the value of the second argument if the first is true, or the third argument otherwise.
static NodeEnumerationleading(Context context, NodeEnumeration in, Expression exp)
Get the nodes that satisfy the given expression, up to and excluding the first one (in document order) that doesn't
static doublelineNumber(Context c)
Return the line number of the context node.
static NodeSetValuelowest(Context c, NodeEnumeration nsv)
Get the node with minimum numeric value of the string-value of each of a set of nodes
static NodeEnumerationlowest(Context context, NodeEnumeration nsv, Expression expression)
Get the node with minimum numeric value of a stored expression over a set of nodes
static doublemax(NodeEnumeration nsv)
Get the maximum numeric value of the string-value of each of a set of nodes
static doublemax(Context context, NodeEnumeration nsv, Expression expression)
Get the maximum numeric value of a stored expression over a set of nodes
static doublemin(NodeEnumeration nsv)
Get the minimum numeric value of the string-value of each of a set of nodes
static doublemin(Context context, NodeEnumeration nsv, Expression expression)
Get the minimum numeric value of a stored expression over a set of nodes
static NodeSetValuenodeset(Context c, Value frag)
Alternative spelling (allows "nodeset()")
static NodeSetValuenodeSet(Context c, Value frag)
Convert a result tree fragment to a node-set.
static Stringpath(Context c)
Return an XPath expression that identifies the current node
static voidpauseTracing(Context c)
static NodeEnumerationrange(Context context, double start, double finish)
Return a node-set whose nodes have string-values "1", "2", ...
static voidresumeTracing(Context c)
static voidsetUserData(Context c, String name, Value value)
Save a value associated with the context node
static StringshowNodeset(Context c, NodeSetValue in)
A diagnostic function to print the contents of a node-set
static doublesum(Context context, NodeEnumeration nsv, Expression expression)
Total a stored expression over a set of nodes
static StringsystemId(Context c)
Return the system identifier of the context node
static NodeEnumerationtokenize(Context context, String s)
Return a node-set by tokenizing a supplied string.
static NodeEnumerationtokenize(Context context, String s, String delim)
Return a node-set by tokenizing a supplied string.

Method Detail

after

public static NodeSetValue after(Context context, NodeSetValue ns1, NodeSetValue ns2)
Find all the nodes in ns1 that are after the first node in ns2. Return empty set if ns2 is empty,

baseUri

public static String baseUri(Context c)
Return the base URI of the context node

before

public static NodeSetValue before(Context context, NodeSetValue ns1, NodeSetValue ns2)
Find all the nodes in ns1 that are before the last node in ns2. Return empty set if ns2 is empty,

closure

public static NodeEnumeration closure(Context c, NodeEnumeration enm, Expression expr)
Evaluate the transitive closure of a node-set expression

difference

public static NodeEnumeration difference(Context c, NodeEnumeration p1, NodeEnumeration p2)
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

distinct

public static NodeEnumeration distinct(Context context, NodeEnumeration in)
Given a node-set, return a subset that includes only nodes with distinct string-values

distinct

public static NodeEnumeration distinct(Context context, NodeEnumeration in, Expression exp)
Given a node-set, return a subset that includes only nodes with distinct string-values for the supplied expression

eval

public static Value eval(Context c, Expression expr)
Evaluate the stored expression supplied in the first argument

evaluate

public static Value evaluate(Context c, String expr)
Evaluate the expression supplied in the first argument as a string

exists

public static boolean exists(Context context, NodeEnumeration nsv, Expression expression)
Test whether node-set contains a node that satisfies a given condition

expression

public static Value expression(Context c, String expr)
Return an object representing a stored expression, from the string supplied in the first argument.

forAll

public static boolean forAll(Context context, NodeEnumeration nsv, Expression expression)
Test whether all nodes in a node-set satisfy a given condition

getContext

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

getPseudoAttribute

public static String getPseudoAttribute(Context c, String name)
Get a pseudo-attribute of a processing instruction. Return an empty string if the context node is not a processing instruction, or if the pseudo-attribute is not present. Character references and built-in entity references are expanded

getUserData

public static Value getUserData(Context c, String name)
Retrieve a value associated with the context node

hasSameNodes

public static boolean hasSameNodes(Context context, NodeEnumeration p1, NodeEnumeration p2)
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

highest

public static NodeSetValue highest(Context c, NodeEnumeration nsv)
Get the node with maximum numeric value of the string-value of each of a set of nodes

highest

public static NodeEnumeration highest(Context context, NodeEnumeration nsv, Expression expression)
Get the maximum numeric value of a stored expression over a set of nodes

intersection

public static NodeEnumeration intersection(Context c, NodeEnumeration p1, NodeEnumeration p2)
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

isNull

public static boolean isNull(Object x)
Test whether an encapsulated Java object is null

IF

public 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. 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)

leading

public static NodeEnumeration leading(Context context, NodeEnumeration in, Expression exp)
Get the nodes that satisfy the given expression, up to and excluding the first one (in document order) that doesn't

lineNumber

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

lowest

public static NodeSetValue lowest(Context c, NodeEnumeration nsv)
Get the node with minimum numeric value of the string-value of each of a set of nodes

lowest

public static NodeEnumeration lowest(Context context, NodeEnumeration nsv, Expression expression)
Get the node with minimum numeric value of a stored expression over a set of nodes

max

public static double max(NodeEnumeration nsv)
Get the maximum numeric value of the string-value of each of a set of nodes

max

public static double max(Context context, NodeEnumeration nsv, Expression expression)
Get the maximum numeric value of a stored expression over a set of nodes

min

public static double min(NodeEnumeration nsv)
Get the minimum numeric value of the string-value of each of a set of nodes

min

public static double min(Context context, NodeEnumeration nsv, Expression expression)
Get the minimum numeric value of a stored expression over a set of nodes

nodeset

public static NodeSetValue nodeset(Context c, Value frag)
Alternative spelling (allows "nodeset()")

nodeSet

public static NodeSetValue nodeSet(Context c, Value frag)
Convert a result tree fragment to a node-set. This simply marks a result tree fragment as being available for general use.

path

public static String path(Context c)
Return an XPath expression that identifies the current node

pauseTracing

public static void pauseTracing(Context c)

range

public static NodeEnumeration range(Context context, double start, double finish)
Return a node-set whose nodes have string-values "1", "2", ... "n"

resumeTracing

public static void resumeTracing(Context c)

setUserData

public static void setUserData(Context c, String name, Value value)
Save a value associated with the context node

showNodeset

public static String showNodeset(Context c, NodeSetValue in)
A diagnostic function to print the contents of a node-set

sum

public static double sum(Context context, NodeEnumeration nsv, Expression expression)
Total a stored expression over a set of nodes

systemId

public static String systemId(Context c)
Return the system identifier of the context node

tokenize

public static NodeEnumeration tokenize(Context context, String s)
Return a node-set by tokenizing a supplied string. Tokens are delimited by any sequence of whitespace characters.

tokenize

public static NodeEnumeration tokenize(Context context, String s, String delim)
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.