Saxon.Api
Class Predicates
-
public class Predicates
This non-instantiable class provides a number of useful implementations of the System.Predicate
interface, designed for use when navigating streams of XDM items.
Method Summary |
|
---|---|
static <T> Predicate<T> | AllOf (Predicate[]<T> conditions) A predicate to test whether all the supplied predicates are satisfied |
static <T> Predicate<T> | AnyOf (Predicate[]<T> conditions) A predicate to test whether at least one of the supplied predicates are satisfied |
static Predicate<XdmNode> | AttributeEq (string local, string value) Obtain a predicate that tests whether an item is an element node with a given attribute (whose name is in no namespace) whose string value is equal to a given value. |
static <TInput, TResult> Predicate<TInput> | Empty (Step<TInput, TResult> step)
Obtain a predicate that tests whether a supplied |
static Predicate<XdmAtomicValue> | Eq (XdmAtomicValue value) Obtain a predicate that tests whether an atomic value compares equal to a supplied atomic value of a comparable type. |
static Predicate<XdmItem> | Eq (string value)
Obtain a predicate that tests whether the result of applying the XPath |
static <TInput, TResult> Predicate<TInput> | Eq (Step<TInput, TResult> step, string value)
Obtain a predicate that tests whether there is some item in the result of applying
a step,
whose string value is equal to a given string. For example, |
static <TInput, TResult> Predicate<TInput> | Every (Step<TInput, TResult> step, Predicate<TResult> condition) Obtain a predicate that tests whether every item in the result of applying a step satisfies the supplied condition. |
static Predicate<XdmItem> | Exists (Step<XdmItem, XdmItem> step)
Obtain a predicate that tests whether a supplied |
static Predicate<XdmNode> | HasAttribute (string local) Obtain a predicate that tests whether an item is an element node with a given attribute (whose name is in no namespace). |
static Predicate<XdmNode> | HasLocalName (string localName) Obtain a predicate that tests whether an item is a node with a given local name, irrespective of the namespace. |
static Predicate<XdmNode> | HasName (string uri, string localName) Obtain a predicate that tests whether an item is a node with a given namespace URI and local name. |
static Predicate<XdmNode> | HasNamespace (string uri) Obtain a predicate that tests whether an item is a node with a given namespace URI. |
static Predicate<XdmItem> | IsArray () A predicate to test whether an item is an XDM array. |
static Predicate<XdmItem> | IsAtomic () A predicate to test whether an item is an atomic value. |
static Predicate<XdmItem> | IsAttribute () A predicate to test whether an item is an attribute node. |
static Predicate<XdmItem> | IsComment () A predicate to test whether an item is a comment node. |
static Predicate<XdmItem> | IsDocument () A predicate to test whether an item is a document node. |
static Predicate<XdmItem> | IsElement () A predicate to test whether an item is an element node. |
static Predicate<XdmItem> | IsFunction () A predicate to test whether an item is a function value (this includes maps and arrays). |
static Predicate<XdmItem> | IsMap () A predicate to test whether an item is an XDM map. |
static Predicate<XdmItem> | IsNamespace () A predicate to test whether an item is a namespace node. |
static Predicate<XdmItem> | IsNode () A predicate to test whether an item is a node. |
static Predicate<XdmItem> | IsProcessingInstruction () A predicate to test whether an item is a processing instruction node. |
static Predicate<XdmItem> | IsText () A predicate to test whether an item is a text node. |
static Predicate<XdmItem> | MatchesRegex (string regex)
Obtain a predicate that tests whether the result of applying the XPath |
static <TInput> Predicate<TInput> | Not (Predicate<TInput> condition)
Return a |
static <TInput, TResult> Predicate<TInput> | Some (Step<TInput, TResult> step, Predicate<TResult> condition) Obtain a predicate that tests whether there is some item in the result of applying a step that satisfies the supplied condition. |
Method Detail
AllOf
AnyOf
A predicate to test whether at least one of the supplied predicates are satisfied
Parameters:
conditions
- The predicates, one of which must be satisfiedReturns:
AttributeEq
Obtain a predicate that tests whether an item is an element node with a given attribute (whose name is in no namespace) whose string value is equal to a given value.
Parameters:
local
- The required attribute namevalue
- The required attribute valueReturns:
Empty
Obtain a predicate that tests whether a supplied Step
delivers an empty result.
Parameters:
step
- A step to be applied to the item being testedReturns:
Eq
Obtain a predicate that tests whether an atomic value compares equal to a supplied atomic value of a comparable type.
Parameters:
value
- The atomic value to be compared withReturns:
Eq
Obtain a predicate that tests whether the result of applying the XPath string()
function to an item
is equal to a given string.
Parameters:
value
- The string being testedReturns:
Eq
Obtain a predicate that tests whether there is some item in the result of applying
a step,
whose string value is equal to a given string. For example, Eq(attribute("id"), "foo")
matches an element if it has an "id" attribute whose value is "foo".
Parameters:
step
- The step to be evaluatedvalue
- The string to be compared against the items returned by the stepReturns:
Every
Predicate<TResult> condition)
Obtain a predicate that tests whether every item in the result of applying a step satisfies the supplied condition.
For example, every(CHILD, exists(attribute("foo"))
matches an element if each of its child
elements has an attribute whose local name is "foo".
If the step returns an empty sequence the result will always be true.
Parameters:
step
- The step to be evaluatedcondition
- The predicate to be applied to the items returned by the stepReturns:
Exists
Obtain a predicate that tests whether a supplied Step
delivers a non-empty result.
Parameters:
step
- A step to be applied to the item being testedReturns:
HasAttribute
Obtain a predicate that tests whether an item is an element node with a given attribute (whose name is in no namespace).
Parameters:
local
- The required attribute nameReturns:
HasLocalName
Obtain a predicate that tests whether an item is a node with a given local name, irrespective of the namespace.
Parameters:
localName
- The required local name. If the zero-length string is supplied, the predicate
matches nodes with no name, such as namespace nodes for the default namespace.Returns:
HasName
Obtain a predicate that tests whether an item is a node with a given namespace URI and local name.
Parameters:
uri
- The required namespace URI: supply a zero-length string to indicate the null namespacelocalName
- The required local nameReturns:
HasNamespace
Obtain a predicate that tests whether an item is a node with a given namespace URI.
Parameters:
uri
- The required namespace URI: supply a zero-length string to identify the null namespaceReturns:
IsArray
A predicate to test whether an item is an XDM array.
Returns:
IsAtomic
A predicate to test whether an item is an atomic value.
Returns:
IsAttribute
A predicate to test whether an item is an attribute node.
Returns:
IsComment
A predicate to test whether an item is a comment node.
Returns:
IsDocument
A predicate to test whether an item is a document node.
Returns:
IsElement
A predicate to test whether an item is an element node.
Returns:
IsFunction
A predicate to test whether an item is a function value (this includes maps and arrays).
Returns:
IsMap
A predicate to test whether an item is an XDM map.
Returns:
IsNamespace
A predicate to test whether an item is a namespace node.
Returns:
IsNode
A predicate to test whether an item is a node.
Returns:
IsProcessingInstruction
A predicate to test whether an item is a processing instruction node.
Returns:
IsText
A predicate to test whether an item is a text node.
Returns:
MatchesRegex
Obtain a predicate that tests whether the result of applying the XPath string()
function to an item
matches a given regular expression.
Parameters:
regex
- The regular expression (this is a Java regular expression, not an XPath regular expression)Returns:
Not
Return a Predicate
that is the negation of a supplied Predicate
.
Parameters:
condition
- The supplied predicateReturns:
Some
Predicate<TResult> condition)
Obtain a predicate that tests whether there is some item in the result of applying a step that satisfies the supplied condition.
For example, some(CHILD, exists(attribute("foo"))
matches an element if it has a child
element with an attribute whose local name is "foo".
If the step returns an empty sequence the result will always be false.
Parameters:
step
- The step to be evaluatedcondition
- The predicate to be applied to the items returned by the stepReturns:
A predicate to test whether all the supplied predicates are satisfied
Parameters:
conditions
- The predicates that must all be satisfiedReturns: