com.icl.saxon.om
Class Navigator
java.lang.Object
com.icl.saxon.om.Navigator
public class Navigator
extends java.lang.Object
Navigator provides helper classes for navigating a tree, irrespective
of its implementation
static int | getNumberAny(NodeInfo node, Pattern count, Pattern from, Context context) - Get node number (level="any").
|
static Vector | getNumberMulti(NodeInfo node, Pattern count, Pattern from, Context context) - Get node number (level="multiple").
|
static int | getNumberSimple(NodeInfo node) - Get simple node number.
|
static int | getNumberSimple(NodeInfo node, Context context) - Get simple node number.
|
static int | getNumberSingle(NodeInfo node, Pattern count, Pattern from, Context context) - Get node number (level="single").
|
static String | getPath(NodeInfo node) - Get an absolute XPath expression that identifies a given node within its document
|
static boolean | isAncestor(NodeInfo node, NodeInfo other) - Determine whether this node is an ancestor of another node
|
static boolean | isWhite(String content) - Determine if a string is all-whitespace
|
getNumberAny
public static int getNumberAny(NodeInfo node,
Pattern count,
Pattern from,
Context context)
throws XPathException
Get node number (level="any").
Return one plus the number of previous nodes in the
document that match the supplied pattern
count
- Pattern that identifies which nodes should be counted. Default (null) is the element
name if the current node is an element, or "node()" otherwise.from
- Pattern that specifies where counting starts from. Default (null) is the root node.
Only nodes after the first (most recent) node that matches the 'from' pattern are counted.
- one plus the number of nodes that precede the current node, that match the count pattern,
and that follow the first node that matches the from pattern if specified.
getNumberMulti
public static Vector getNumberMulti(NodeInfo node,
Pattern count,
Pattern from,
Context context)
throws XPathException
Get node number (level="multiple").
Return a vector giving the hierarchic position of this node. See the XSLT spec for details.
count
- Pattern that identifies which nodes (ancestors and their previous siblings)
should be counted. Default (null) is the element
name if the current node is an element, or "node()" otherwise.from
- Pattern that specifies where counting starts from. Default (null) is the root node.
Only nodes below the first (most recent) node that matches the 'from' pattern are counted.
- a vector containing for each ancestor-or-self that matches the count pattern and that
is below the nearest node that matches the from pattern, an Integer which is one greater than
the number of previous siblings that match the count pattern.
getNumberSimple
public static int getNumberSimple(NodeInfo node)
Get simple node number. This is defined as one plus the number of previous siblings of the
same node type and name. It is not accessible directly in XSL. This version doesn't require
the context, and therefore doesn't remember previous results
getNumberSimple
public static int getNumberSimple(NodeInfo node,
Context context)
throws XPathException
Get simple node number. This is defined as one plus the number of previous siblings of the
same node type and name. It is not accessible directly in XSL.
context
- Used for remembering previous result, for performance
getNumberSingle
public static int getNumberSingle(NodeInfo node,
Pattern count,
Pattern from,
Context context)
throws XPathException
Get node number (level="single"). If the current node matches the supplied pattern, the returned
number is one plus the number of previous siblings that match the pattern. Otherwise,
return the element number of the nearest ancestor that matches the supplied pattern.
count
- Pattern that identifies which nodes should be counted. Default (null) is the element
name if the current node is an element, or "node()" otherwise.from
- Pattern that specifies where counting starts from. Default (null) is the root node.
(This parameter does not seem useful but is included for the sake of XSLT conformance.)
- the node number established as follows: go to the nearest ancestor-or-self that
matches the 'count' pattern and that is a descendant of the nearest ancestor that matches the
'from' pattern. Return one plus the nunber of preceding siblings of that ancestor that match
the 'count' pattern. If there is no such ancestor, return 0.
getPath
public static String getPath(NodeInfo node)
Get an absolute XPath expression that identifies a given node within its document
isAncestor
public static boolean isAncestor(NodeInfo node,
NodeInfo other)
Determine whether this node is an ancestor of another node
node
- the putative ancestor nodeother
- the other node (the putative descendant of this node)
- true of this node is an ancestor of the other node
isWhite
public static boolean isWhite(String content)
Determine if a string is all-whitespace