Package net.sf.saxon.s9api.streams
Class Steps
- java.lang.Object
-
- net.sf.saxon.s9api.streams.Steps
-
public class Steps extends java.lang.Object
This non-instantiable class provides a number of useful implementations of theStep
interface, used to navigate XDM trees, typically as an argument toXdmValue.select(net.sf.saxon.s9api.streams.Step<T>)
.
-
-
Constructor Summary
Constructors Constructor Description Steps()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Step<XdmNode>
ancestor()
Obtain aStep
to navigate from a node to its ancestors, in reverse document order (that is, nearest ancestor first, root node last)static Step<XdmNode>
ancestor(java.lang.String localName)
Obtain aStep
that navigates from a node to its ancestor elements having a specified local name, irrespective of the namespace.static Step<XdmNode>
ancestor(java.lang.String uri, java.lang.String localName)
Return aStep
that navigates from a node to its ancestors having a specified namespace URI and local name, in reverse document order (that is, nearest ancestor first, root node last)static Step<XdmNode>
ancestor(java.util.function.Predicate<? super XdmNode> filter)
Obtain aStep
that filters the nodes found on the ancestor axis using a suppliedPredicate
.static Step<XdmNode>
ancestorOrSelf()
Obtain aStep
to navigate from a node to its ancestors, in reverse document order, with the node itself returned at the start of the sequence (that is, origin node first, root node last)static Step<XdmNode>
ancestorOrSelf(java.lang.String localName)
Obtain aStep
that navigates from a node to its ancestor elements having a specified local name, irrespective of the namespace.static Step<XdmNode>
ancestorOrSelf(java.lang.String uri, java.lang.String localName)
Obtain aStep
that navigates from a node to its ancestors-or-self having a specified namespace URI and local name, in reverse document order (that is, nearest ancestor first, root node last)static Step<XdmNode>
ancestorOrSelf(java.util.function.Predicate<? super XdmNode> filter)
Obtain aStep
that filters the nodes found on the ancestor-or-self axis using a suppliedPredicate
.static Step<XdmAtomicValue>
atomize()
Obtain aStep
that atomizes an item to produce a stream of atomic values.static Step<XdmNode>
attribute()
Obtain aStep
to navigate from a node to its attributesstatic Step<XdmNode>
attribute(java.lang.String localName)
Obtain aStep
that navigates from a node to its attributes having a specified local name, irrespective of the namespacestatic Step<XdmNode>
attribute(java.lang.String uri, java.lang.String localName)
Return aStep
that navigates from a node to its attribute having a specified namespace URI and local namestatic Step<XdmNode>
attribute(java.util.function.Predicate<? super XdmNode> filter)
Obtain aStep
that filters the nodes found on the attribute axis using a suppliedPredicate
.static Step<XdmAtomicValue>
castAs(ItemType type)
A step equivalent to the XPath "cast as" operator: the supplied item is atomized if necessary, and the resulting atomic values are cast to the required typestatic Step<XdmNode>
child()
Obtain aStep
to navigate from a node to its childrenstatic Step<XdmNode>
child(java.lang.String localName)
Obtain aStep
that navigates from a node to the element children having a specified local name, irrespective of the namespacestatic Step<XdmNode>
child(java.lang.String uri, java.lang.String localName)
Obtain aStep
that navigates from a node to the element children having a specified namespace URI and local namestatic Step<XdmNode>
child(java.util.function.Predicate<? super XdmNode> filter)
Obtain aStep
that filters the nodes found on the child axis using a suppliedPredicate
.static Step<XdmNode>
descendant()
Obtain aStep
to navigate from a node to its descendants, which are returned in document orderstatic Step<XdmNode>
descendant(java.lang.String localName)
Obtain aStep
that navigates from a node to the descendant elements having a specified local name, irrespective of the namespace.static Step<XdmNode>
descendant(java.lang.String uri, java.lang.String localName)
Obtain aStep
that navigates from a node to the element descendants having a specified namespace URI and local name.static Step<XdmNode>
descendant(java.util.function.Predicate<? super XdmNode> filter)
Obtain a Step that filters the nodes found on the descendant axis using a suppliedPredicate
.static Step<XdmNode>
descendantOrSelf()
Obtain aStep
to navigate from a node to its descendants, which are returned in document order, preceded by the origin node itselfstatic Step<XdmNode>
descendantOrSelf(java.lang.String localName)
Obtain aStep
that navigates from a node to the descendant-or-self elements having a specified local name, irrespective of the namespace.static Step<XdmNode>
descendantOrSelf(java.lang.String uri, java.lang.String localName)
Obtain aStep
that navigates from a node to the descendant-or-self elements having a specified namespace URI and local name.static Step<XdmNode>
descendantOrSelf(java.util.function.Predicate<? super XdmNode> filter)
Obtain a Step that filters the nodes found on the descendant-or-self axis using a suppliedPredicate
.static Step<XdmNode>
following()
Obtain aStep
to navigate from a node to its following nodes (excluding descendants), which are returned in document orderstatic Step<XdmNode>
following(java.lang.String localName)
Obtain aStep
that navigates from a node to the following elements having a specified local name, irrespective of the namespace.static Step<XdmNode>
following(java.lang.String uri, java.lang.String localName)
Obtain aStep
that navigates from a node to the following elements having a specified namespace URI and local name.static Step<XdmNode>
following(java.util.function.Predicate<? super XdmNode> filter)
Obtain a Step that filters the nodes found on the following axis using a suppliedPredicate
.static Step<XdmNode>
followingSibling()
Obtain aStep
to navigate from a node to its following siblings, which are returned in document orderstatic Step<XdmNode>
followingSibling(java.lang.String localName)
Obtain aStep
that navigates from a node to the following sibling elements having a specified local name, irrespective of the namespace.static Step<XdmNode>
followingSibling(java.lang.String uri, java.lang.String localName)
Obtain aStep
that navigates from a node to the following sibling elements having a specified namespace URI and local name.static Step<XdmNode>
followingSibling(java.util.function.Predicate<? super XdmNode> filter)
Obtain a Step that filters the nodes found on the following sibling axis using a suppliedPredicate
.static Step<XdmNode>
id(XdmNode doc)
Obtain a Step whose effect is to interpret the supplied item as an xs:ID value and return the nodes (in a given document) that have that string as their ID.static Step<XdmNode>
namespace()
Obtain aStep
to navigate from a node to its namespace nodesstatic Step<XdmNode>
namespace(java.lang.String localName)
Obtain aStep
that navigates from a node to its namespaces having a specified local name.static Step<XdmNode>
namespace(java.util.function.Predicate<? super XdmNode> filter)
Obtain aStep
that filters the nodes found on the namespace axis using a suppliedPredicate
.static <U extends XdmItem>
Step<U>nothing()
Obtain a Step that always returns an empty sequence, whatever the inputstatic Step<XdmNode>
parent()
Obtain aStep
to navigate from a node to its parentstatic Step<XdmNode>
parent(java.lang.String localName)
Obtain aStep
that navigates from a node to the parent element provided it has a specified local name, irrespective of the namespacestatic Step<XdmNode>
parent(java.lang.String uri, java.lang.String localName)
Obtain aStep
that navigates from a node to the parent element provided it has a specified namespace URI and local namestatic Step<XdmNode>
parent(java.util.function.Predicate<? super XdmNode> filter)
Obtain aStep
that filters the node found on the parent axis using a suppliedPredicate
.static Step<? extends XdmNode>
path(java.lang.String... steps)
Construct a simple path consisting solely of simple child, attribute, descendant, root, and parent steps.static Step<? extends XdmNode>
path(Step<? extends XdmNode>... steps)
Construct a path as a compositeStep
from a sequence of steps composed togetherstatic Step<XdmNode>
preceding()
Obtain aStep
to navigate from a node to its preceding nodes (excluding ancestors), which are returned in reverse document orderstatic Step<XdmNode>
preceding(java.lang.String localName)
Obtain aStep
that navigates from a node to the preceding elements having a specified local name.static Step<XdmNode>
preceding(java.lang.String uri, java.lang.String localName)
Obtain aStep
that navigates from a node to the preceding elements having a specified namespace URI and local name.static Step<XdmNode>
preceding(java.util.function.Predicate<? super XdmNode> filter)
Obtain a Step that filters the nodes found on the preceding axis using a suppliedPredicate
.static Step<XdmNode>
precedingSibling()
Obtain aStep
to navigate from a node to its preceding siblings, which are returned in reverse document orderstatic Step<XdmNode>
precedingSibling(java.lang.String localName)
Obtain aStep
that navigates from a node to the preceding sibling elements having a specified local name, irrespective of the namespace.static Step<XdmNode>
precedingSibling(java.lang.String uri, java.lang.String localName)
Obtain aStep
that navigates from a node to the preceding sibling elements having a specified namespace URI and local name.static Step<XdmNode>
precedingSibling(java.util.function.Predicate<? super XdmNode> filter)
Obtain a Step that filters the nodes found on the preceding sibling axis using a suppliedPredicate
.static Step<XdmNode>
root()
Obtain aStep
that selects the root node of the containing document (which may or may not be a document node)static Step<XdmNode>
self()
Obtain aStep
to navigate from a node to itself (useful only if applying a predicate)static Step<XdmNode>
self(java.lang.String localName)
Obtain aStep
that navigates from a node to itself provided it is an element with a specified local name, irrespective of the namespacestatic Step<XdmNode>
self(java.lang.String uri, java.lang.String localName)
Obtain aStep
that navigates from a node to itself provided it has a specified namespace URI and local namestatic Step<XdmNode>
self(java.util.function.Predicate<? super XdmNode> filter)
Obtain aStep
that filters the node found on the self axis using a suppliedPredicate
.static Step<XdmNode>
text()
Obtain aStep
that returns text nodes found on the child axis.static Step<XdmAtomicValue>
tokenize()
Obtain a Step whose effect is to tokenize the supplied item on whitespace boundaries, returning a sequence of strings asXdmAtomicValue
instances.
-
-
-
Method Detail
-
root
public static Step<XdmNode> root()
Obtain aStep
that selects the root node of the containing document (which may or may not be a document node)- Returns:
- a step that delivers the root node of the tree containing the step's origin.
-
atomize
public static Step<XdmAtomicValue> atomize()
Obtain aStep
that atomizes an item to produce a stream of atomic values. (Atomizing a node will usually produce a single atomic value, but in the case of schema-typed nodes using a list type, there may be more than one atomic value. Atomizing an array also returns multiple atomic values)- Returns:
- a step that performs atomization
-
castAs
public static Step<XdmAtomicValue> castAs(ItemType type)
A step equivalent to the XPath "cast as" operator: the supplied item is atomized if necessary, and the resulting atomic values are cast to the required type- Parameters:
type
- the target type of the cast- Returns:
- a step that returns the result of the cast
-
nothing
public static <U extends XdmItem> Step<U> nothing()
Obtain a Step that always returns an empty sequence, whatever the input- Type Parameters:
U
- the static item type of the result of the step- Returns:
- a Step that always returns an empty sequence
-
ancestor
public static Step<XdmNode> ancestor()
Obtain aStep
to navigate from a node to its ancestors, in reverse document order (that is, nearest ancestor first, root node last)- Returns:
- a Step that selects all nodes on the ancestor axis
-
ancestor
public static Step<XdmNode> ancestor(java.lang.String localName)
Obtain aStep
that navigates from a node to its ancestor elements having a specified local name, irrespective of the namespace. The nodes are returned in reverse document order (that is, nearest ancestor first, root node last)- Parameters:
localName
- the local name of the ancestors to be selected by theStep
, or "*" to select all ancestors that are element nodes- Returns:
- a
Step
, which selects the ancestors of a supplied node that have the required local name.
-
ancestor
public static Step<XdmNode> ancestor(java.lang.String uri, java.lang.String localName)
Return aStep
that navigates from a node to its ancestors having a specified namespace URI and local name, in reverse document order (that is, nearest ancestor first, root node last)- Parameters:
uri
- the namespace URI of the ancestors to be selected by theStep
localName
- the local name of the ancestors to be selected by theStep
: supply a zero-length string to indicate the null namespace- Returns:
- a
Step
, which selects the ancestors (at most one) of a supplied node that have the required local name and namespace URI.
-
ancestor
public static Step<XdmNode> ancestor(java.util.function.Predicate<? super XdmNode> filter)
Obtain aStep
that filters the nodes found on the ancestor axis using a suppliedPredicate
. Nodes are returned in reverse document order (that is, nearest ancestor first, root node last)The function call
ancestor(predicate)
is equivalent toANCESTOR.where(predicate)
.- Parameters:
filter
- the predicate to be applied- Returns:
- a
Step
that filters the nodes found on the ancestor axis using a suppliedPredicate
.
-
ancestorOrSelf
public static Step<XdmNode> ancestorOrSelf()
Obtain aStep
to navigate from a node to its ancestors, in reverse document order, with the node itself returned at the start of the sequence (that is, origin node first, root node last)- Returns:
- a Step that selects all nodes on the ancestor-or-self axis
-
ancestorOrSelf
public static Step<XdmNode> ancestorOrSelf(java.lang.String localName)
Obtain aStep
that navigates from a node to its ancestor elements having a specified local name, irrespective of the namespace. The nodes are returned in reverse document order (that is, nearest ancestor first, root node last), and include the node itself- Parameters:
localName
- the local name of the ancestors to be selected by theStep
, or "*" to select all ancestor-or-self nodes that are element nodes- Returns:
- a
Step
, which selects the ancestors-or-self of a supplied node that have the required local name.
-
ancestorOrSelf
public static Step<XdmNode> ancestorOrSelf(java.lang.String uri, java.lang.String localName)
Obtain aStep
that navigates from a node to its ancestors-or-self having a specified namespace URI and local name, in reverse document order (that is, nearest ancestor first, root node last)- Parameters:
uri
- the namespace URI of the ancestors to be selected by theStep
: supply a zero-length string to indicate the null namespacelocalName
- the local name of the ancestors to be selected by theStep
- Returns:
- a
Step
, which selects the ancestors-or-self of a supplied node that have the required local name and namespace URI.
-
ancestorOrSelf
public static Step<XdmNode> ancestorOrSelf(java.util.function.Predicate<? super XdmNode> filter)
Obtain aStep
that filters the nodes found on the ancestor-or-self axis using a suppliedPredicate
. Nodes are returned in reverse document order (that is, origin node first, root node last)The function call
ancestorOrSelf(predicate)
is equivalent toANCESTOR_OR_SELF.where(predicate)
.- Parameters:
filter
- the predicate to be applied- Returns:
- a
Step
that filters the nodes found on the ancestor-or-self axis using a suppliedPredicate
.
-
attribute
public static Step<XdmNode> attribute()
Obtain aStep
to navigate from a node to its attributes- Returns:
- a Step that selects all nodes on the ancestor axis
-
attribute
public static Step<XdmNode> attribute(java.lang.String localName)
Obtain aStep
that navigates from a node to its attributes having a specified local name, irrespective of the namespace- Parameters:
localName
- the local name of the attributes to be selected by theStep
, or "*" to select all attributes- Returns:
- a
Step
, which selects the attributes of a supplied node that have the required local name.
-
attribute
public static Step<XdmNode> attribute(java.lang.String uri, java.lang.String localName)
Return aStep
that navigates from a node to its attribute having a specified namespace URI and local name- Parameters:
uri
- the namespace URI of the attributes to be selected by theStep
: supply a zero-length string to indicate the null namespacelocalName
- the local name of the attributes to be selected by theStep
- Returns:
- a
Step
, which selects the attributes (at most one) of a supplied node that have the required local name and namespace URI.
-
attribute
public static Step<XdmNode> attribute(java.util.function.Predicate<? super XdmNode> filter)
Obtain aStep
that filters the nodes found on the attribute axis using a suppliedPredicate
. The function callattribute(predicate)
is equivalent toATTRIBUTE.where(predicate)
.- Parameters:
filter
- the predicate to be applied- Returns:
- a
Step
that filters the nodes found on the attribute axis using a suppliedPredicate
.
-
child
public static Step<XdmNode> child()
Obtain aStep
to navigate from a node to its children- Returns:
- a Step that selects all nodes on the child axis
-
child
public static Step<XdmNode> child(java.lang.String localName)
Obtain aStep
that navigates from a node to the element children having a specified local name, irrespective of the namespace- Parameters:
localName
- the local name of the child elements to be selected by the Step, or "*" to select all children that are element nodes- Returns:
- a
Step
, which selects the element children of a supplied node that have the required local name.
-
child
public static Step<XdmNode> child(java.lang.String uri, java.lang.String localName)
Obtain aStep
that navigates from a node to the element children having a specified namespace URI and local name- Parameters:
uri
- the namespace URI of the child elements to be selected by theStep
: supply a zero-length string to indicate the null namespacelocalName
- the local name of the child elements to be selected by theStep
- Returns:
- a
Step
, which selects the element children of a supplied node that have the required local name and namespace URI.
-
child
public static Step<XdmNode> child(java.util.function.Predicate<? super XdmNode> filter)
Obtain aStep
that filters the nodes found on the child axis using a suppliedPredicate
. The function callchild(predicate)
is equivalent toCHILD.where(predicate)
. For example,child(isElement())
returns a Step that selects the element node children of a given node.- Parameters:
filter
- the predicate to be applied- Returns:
- a Step that filters the nodes found on the child axis using a supplied
Predicate
.
-
descendant
public static Step<XdmNode> descendant()
Obtain aStep
to navigate from a node to its descendants, which are returned in document order- Returns:
- a Step that selects all nodes on the descendant axis
-
descendant
public static Step<XdmNode> descendant(java.lang.String localName)
Obtain aStep
that navigates from a node to the descendant elements having a specified local name, irrespective of the namespace. These are returned in document order.- Parameters:
localName
- the local name of the descendant elements to be selected by theStep
, or "*" to select all descendants that are element nodes- Returns:
- a
Step
, which selects the element descendants of a supplied node that have the required local name.
-
descendant
public static Step<XdmNode> descendant(java.lang.String uri, java.lang.String localName)
Obtain aStep
that navigates from a node to the element descendants having a specified namespace URI and local name. These are returned in document order.- Parameters:
uri
- the namespace URI of the descendant elements to be selected by theStep
: supply a zero-length string to indicate the null namespacelocalName
- the local name of the descendant elements to be selected by theStep
- Returns:
- a
Step
, which selects the element descendants of a supplied node that have the required local name and namespace URI.
-
descendantOrSelf
public static Step<XdmNode> descendantOrSelf()
Obtain aStep
to navigate from a node to its descendants, which are returned in document order, preceded by the origin node itself- Returns:
- a Step that selects all nodes on the descendant-or-self axis
-
descendant
public static Step<XdmNode> descendant(java.util.function.Predicate<? super XdmNode> filter)
Obtain a Step that filters the nodes found on the descendant axis using a suppliedPredicate
. The function calldescendant(predicate)
is equivalent toDESCENDANT.where(predicate)
. For example,descendant(isElement())
returns a Step that selects the element node descendants of a given node, whiledescendant(exists(attribute("id")))
selects those that have an attribute named "id". These are returned in document order.- Parameters:
filter
- the predicate to be applied- Returns:
- a Step that filters the nodes found on the descendant axis using a supplied Predicate.
-
descendantOrSelf
public static Step<XdmNode> descendantOrSelf(java.lang.String localName)
Obtain aStep
that navigates from a node to the descendant-or-self elements having a specified local name, irrespective of the namespace. These are returned in document order, preceded by the origin node itself if it matches the conditions.- Parameters:
localName
- the local name of the descendant-or-self elements to be selected by theStep
, or "*" to select all descendant-or-self nodes that are element nodes- Returns:
- a
Step
, which selects the element children of a supplied node that have the required local name.
-
descendantOrSelf
public static Step<XdmNode> descendantOrSelf(java.lang.String uri, java.lang.String localName)
Obtain aStep
that navigates from a node to the descendant-or-self elements having a specified namespace URI and local name. These are returned in document order, preceded by the origin node itself if it matches the conditions.- Parameters:
uri
- the namespace URI of the descendant-or-self elements to be selected by theStep
: supply a zero-length string to indicate the null namespacelocalName
- the local name of the descendant-or-self elements to be selected by theStep
- Returns:
- a
Step
, which selects the element descendants-or-self of a supplied node that have a given local name and namespace URI.
-
descendantOrSelf
public static Step<XdmNode> descendantOrSelf(java.util.function.Predicate<? super XdmNode> filter)
Obtain a Step that filters the nodes found on the descendant-or-self axis using a suppliedPredicate
. The function calldescendant(predicate)
is equivalent toDESCENDANT.where(predicate)
. For example,descendant(isElement())
returns a Step that selects the element node descendants of a given node, whiledescendant(exists(attribute("id")))
selects those that have an attribute named "id". These are returned in document order.- Parameters:
filter
- the predicate to be applied- Returns:
- a Step that filters the nodes found on the descendant-or-self axis using a supplied Predicate.
-
following
public static Step<XdmNode> following()
Obtain aStep
to navigate from a node to its following nodes (excluding descendants), which are returned in document order- Returns:
- a Step that selects all nodes on the following axis
-
following
public static Step<XdmNode> following(java.lang.String localName)
Obtain aStep
that navigates from a node to the following elements having a specified local name, irrespective of the namespace. These are returned in document order.- Parameters:
localName
- the local name of the following elements to be selected by theStep
, or "*" to select all following nodes that are elements- Returns:
- a
Step
, which selects the following elements of a supplied node that have the required local name.
-
following
public static Step<XdmNode> following(java.lang.String uri, java.lang.String localName)
Obtain aStep
that navigates from a node to the following elements having a specified namespace URI and local name. These are returned in document order.- Parameters:
uri
- the namespace URI of the following elements to be selected by theStep
: supply a zero-length string to indicate the null namespacelocalName
- the local name of the following elements to be selected by theStep
- Returns:
- a
Step
, which selects the following elements of a supplied node that have the required local name and namespace URI.
-
following
public static Step<XdmNode> following(java.util.function.Predicate<? super XdmNode> filter)
Obtain a Step that filters the nodes found on the following axis using a suppliedPredicate
. The function callfollowingSibling(predicate)
is equivalent toFOLLOWING_SIBLING.where(predicate)
. For example,followingSibling(isElement())
returns aStep
that selects the following sibling elements of a given node, whilefollowingSibling(exists(attribute("id")))
selects those that have an attribute named "id". These are returned in document order.- Parameters:
filter
- the predicate to be applied- Returns:
- a
Step
that filters the nodes found on the following axis using a suppliedPredicate
.
-
followingSibling
public static Step<XdmNode> followingSibling()
Obtain aStep
to navigate from a node to its following siblings, which are returned in document order- Returns:
- a Step that selects all nodes on the following-sibling axis
-
followingSibling
public static Step<XdmNode> followingSibling(java.lang.String localName)
Obtain aStep
that navigates from a node to the following sibling elements having a specified local name, irrespective of the namespace. These are returned in document order.- Parameters:
localName
- the local name of the following sibling elements to be selected by theStep
, or "*" to select all following siblings that are element nodes- Returns:
- a
Step
, which selects the following sibling elements of a supplied node that have the required local name.
-
followingSibling
public static Step<XdmNode> followingSibling(java.lang.String uri, java.lang.String localName)
Obtain aStep
that navigates from a node to the following sibling elements having a specified namespace URI and local name. These are returned in document order.- Parameters:
uri
- the namespace URI of the following sibling elements to be selected by theStep
: supply a zero-length string to indicate the null namespacelocalName
- the local name of the following sibling elements to be selected by theStep
- Returns:
- a
Step
, which selects the following sibling elements of a supplied node that have the required local name and namespace URI.
-
followingSibling
public static Step<XdmNode> followingSibling(java.util.function.Predicate<? super XdmNode> filter)
Obtain a Step that filters the nodes found on the following sibling axis using a suppliedPredicate
. The function callfollowingSibling(predicate)
is equivalent toFOLLOWING_SIBLING.where(predicate)
. For example,followingSibling(isElement())
returns aStep
that selects the following sibling elements of a given node, whilefollowingSibling(exists(attribute("id")))
selects those that have an attribute named "id". These are returned in document order.- Parameters:
filter
- the predicate to be applied- Returns:
- a
Step
that filters the nodes found on the following sibling axis using a suppliedPredicate
.
-
namespace
public static Step<XdmNode> namespace()
Obtain aStep
to navigate from a node to its namespace nodes- Returns:
- a Step that selects all nodes on the namespace axis
-
namespace
public static Step<XdmNode> namespace(java.lang.String localName)
Obtain aStep
that navigates from a node to its namespaces having a specified local name. The local name of a namespace node corresponds to the prefix used in the namespace binding.- Parameters:
localName
- the local name (representing the namespace prefix) of the namespace nodes to be selected by theStep
, or "*" to select all namespaces- Returns:
- a
Step
, which selects the namespaces of a supplied node that have a given local name (prefix).
-
namespace
public static Step<XdmNode> namespace(java.util.function.Predicate<? super XdmNode> filter)
Obtain aStep
that filters the nodes found on the namespace axis using a suppliedPredicate
. The function callnamespace(predicate)
is equivalent tonamespace().where(predicate)
. For example,namespace(eq("http://www.w3.org/1999/XSL/Transform")
selects a namespace node that binds a prefix to the XSLT namespace.- Parameters:
filter
- the predicate to be applied- Returns:
- a
Step
that filters the nodes found on the namespace axis using a suppliedPredicate
.
-
parent
public static Step<XdmNode> parent()
Obtain aStep
to navigate from a node to its parent- Returns:
- a Step that selects all nodes on the parent axis (of which there is at most one)
-
parent
public static Step<XdmNode> parent(java.lang.String localName)
Obtain aStep
that navigates from a node to the parent element provided it has a specified local name, irrespective of the namespace- Parameters:
localName
- the local name of the parent element to be selected by the Step, or "*" to select the parent node provided it is an element- Returns:
- a
Step
, which selects the parent of a supplied node provided it is an element with the required local name.
-
parent
public static Step<XdmNode> parent(java.lang.String uri, java.lang.String localName)
Obtain aStep
that navigates from a node to the parent element provided it has a specified namespace URI and local name- Parameters:
uri
- the namespace URI of the parent element to be selected by theStep
: supply a zero-length string to indicate the null namespacelocalName
- the local name of the parent element to be selected by theStep
- Returns:
- a
Step
, which selects the parent element of a supplied node provided it is an element with the required local name and namespace URI.
-
parent
public static Step<XdmNode> parent(java.util.function.Predicate<? super XdmNode> filter)
Obtain aStep
that filters the node found on the parent axis using a suppliedPredicate
. The function callparent(predicate)
is equivalent toparent().where(predicate)
. For example,parent(isElement())
returns a Step that selects the parent node provided it is an element- Parameters:
filter
- the predicate to be applied- Returns:
- a Step that filters the nodes found on the parent axis using a supplied
Predicate
.
-
precedingSibling
public static Step<XdmNode> precedingSibling()
Obtain aStep
to navigate from a node to its preceding siblings, which are returned in reverse document order- Returns:
- a Step that selects all nodes on the preceding-sibling axis
-
precedingSibling
public static Step<XdmNode> precedingSibling(java.lang.String localName)
Obtain aStep
that navigates from a node to the preceding sibling elements having a specified local name, irrespective of the namespace. These are returned in reverse document order.- Parameters:
localName
- the local name of the preceding sibling elements to be selected by theStep
, or "*" to select all descendants that are element nodes- Returns:
- a
Step
, which selects the preceding sibling elements of a supplied node that have the required local name.
-
precedingSibling
public static Step<XdmNode> precedingSibling(java.lang.String uri, java.lang.String localName)
Obtain aStep
that navigates from a node to the preceding sibling elements having a specified namespace URI and local name. These are returned in reverse document order.- Parameters:
uri
- the namespace URI of the preceding sibling elements to be selected by theStep
: supply a zero-length string to indicate the null namespacelocalName
- the local name of the preceding sibling elements to be selected by theStep
- Returns:
- a
Step
, which selects the preceding sibling elements of a supplied node that have the required local name and namespace URI.
-
precedingSibling
public static Step<XdmNode> precedingSibling(java.util.function.Predicate<? super XdmNode> filter)
Obtain a Step that filters the nodes found on the preceding sibling axis using a suppliedPredicate
. The function callprecedingSibling(predicate)
is equivalent toprecedingSibling().where(predicate)
. For example,precedingSibling(isElement())
returns aStep
that selects the preceding sibling elements of a given node, whileprecedingSibling(exists(attribute("id")))
selects those that have an attribute named "id". These are returned in reverse document order.- Parameters:
filter
- the predicate to be applied- Returns:
- a
Step
that filters the nodes found on the following sibling axis using a suppliedPredicate
.
-
preceding
public static Step<XdmNode> preceding()
Obtain aStep
to navigate from a node to its preceding nodes (excluding ancestors), which are returned in reverse document order- Returns:
- a Step that selects all nodes on the preceding axis
-
preceding
public static Step<XdmNode> preceding(java.lang.String localName)
Obtain aStep
that navigates from a node to the preceding elements having a specified local name. These are returned in reverse document order.- Parameters:
localName
- the local name of the preceding elements to be selected by theStep
, or "*" to select all descendants that are element nodes- Returns:
- a
Step
, which selects the preceding elements of a supplied node that have the required local name.
-
preceding
public static Step<XdmNode> preceding(java.lang.String uri, java.lang.String localName)
Obtain aStep
that navigates from a node to the preceding elements having a specified namespace URI and local name. These are returned in reverse document order.- Parameters:
uri
- the namespace URI of the preceding elements to be selected by theStep
: supply a zero-length string to indicate the null namespacelocalName
- the local name of the preceding sibling elements to be selected by theStep
- Returns:
- a
Step
, which selects the preceding sibling elements of a supplied node that have the required local name and namespace URI.
-
preceding
public static Step<XdmNode> preceding(java.util.function.Predicate<? super XdmNode> filter)
Obtain a Step that filters the nodes found on the preceding axis using a suppliedPredicate
. The function callpreceding(predicate)
is equivalent toPRECEDING.where(predicate)
. For example,preceding(isElement())
returns aStep
that selects the preceding elements of a given node, whilepreceding(exists(attribute("id")))
selects those that have an attribute named "id". These are returned in reverse document order.- Parameters:
filter
- the predicate to be applied- Returns:
- a
Step
that filters the nodes found on the following sibling axis using a suppliedPredicate
.
-
self
public static Step<XdmNode> self()
Obtain aStep
to navigate from a node to itself (useful only if applying a predicate)- Returns:
- a Step that selects all nodes on the self axis (that is, the node itself)
-
self
public static Step<XdmNode> self(java.lang.String localName)
Obtain aStep
that navigates from a node to itself provided it is an element with a specified local name, irrespective of the namespace- Parameters:
localName
- the local name of the element to be selected by the Step, or "*" to select the node provided that it is an element node- Returns:
- a
Step
, which selects the supplied node provided it has a given local name.
-
self
public static Step<XdmNode> self(java.lang.String uri, java.lang.String localName)
Obtain aStep
that navigates from a node to itself provided it has a specified namespace URI and local name- Parameters:
uri
- the namespace URI of the element to be selected by theStep
: supply a zero-length string to indicate the null namespacelocalName
- the local name of the element to be selected by theStep
- Returns:
- a
Step
, which selects the supplied node provided it is an element with a given local name and namespace URI.
-
self
public static Step<XdmNode> self(java.util.function.Predicate<? super XdmNode> filter)
Obtain aStep
that filters the node found on the self axis using a suppliedPredicate
. The function callself(predicate)
is equivalent toSELF.where(predicate)
. For example,self(isElement())
returns a Step that selects the supplied node provided it is an element- Parameters:
filter
- the predicate to be applied- Returns:
- a Step that filters the nodes found on the parent axis using a supplied
Predicate
.
-
text
public static Step<XdmNode> text()
Obtain aStep
that returns text nodes found on the child axis. The function calltext()
is equivalent tochild().where(isText())
. For example,self(isElement())
returns a Step that selects the supplied node provided it is an element- Returns:
- a Step that returns the text nodes found on the child axis.
-
path
@SafeVarargs public static Step<? extends XdmNode> path(Step<? extends XdmNode>... steps)
Construct a path as a compositeStep
from a sequence of steps composed together- Parameters:
steps
- the constituent steps in the path- Returns:
- a composite step
-
path
public static Step<? extends XdmNode> path(java.lang.String... steps)
Construct a simple path consisting solely of simple child, attribute, descendant, root, and parent steps. For example,path("div3", "head", "@style")
selects the same nodes as the XPath 2.0 expressionchild::*:div3/child::*:head/attribute::*:style
.- Parameters:
steps
- a sequence of strings. Each string must be one of the following:- A plain NCName (for example "item") selects child nodes by matching local-name (the namespace is ignored)
- An NCName preceded by "@" (for example, "@code"), selects attribute nodes by matching local-name (again, ignoring any namespace)
- The string "*" selects all child elements, regardless of name
- The string "/" selects the root node of the tree, provided it is a document node
- The string ".." selects the parent node
- The string "//" selects all descendant-or-self nodes (note, this does not involve finding the root of the tree: it corresponds to a binary '//' operator in XPath, not to an initial '//')
For more complex paths, see
path(Step...)
- Returns:
- a composite Step representing this sequence of steps
- Throws:
java.lang.IllegalArgumentException
- if any of the strings is invalid according to these rules.
-
tokenize
public static Step<XdmAtomicValue> tokenize()
Obtain a Step whose effect is to tokenize the supplied item on whitespace boundaries, returning a sequence of strings asXdmAtomicValue
instances.Note: the tokenize step, when applied to a string with leading and trailing whitespace, has the effect of removing this whitespace. In addition to its primary role, the function can therefore be useful for trimming the content of a single string.
Usage example:
child().where(some(attribute("id").then(tokenize())).eq("a123"))
selects child elements that have an attribute named "id" whose value contains the token "a123".- Returns:
- a Step whose effect is to take a supplied item and split its string value into a sequence of xs:string instances
-
id
public static Step<XdmNode> id(XdmNode doc)
Obtain a Step whose effect is to interpret the supplied item as an xs:ID value and return the nodes (in a given document) that have that string as their ID.- Parameters:
doc
- the root node (document node) of the document within which the ID value should be sought- Returns:
- a Step whose effect is to take a supplied item and split its string value into a sequence of xs:string instances
-
-