Saxon.Api
Class Predicates
-
public class Predicates
This non-instantiable class provides a number of useful implementations of the Predicate
interface, designed for use when navigating streams of XDM items.
Method Summary |
|
---|---|
static IPredicate<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> IPredicate<TInput> | Empty(Step<TInput, TResult> step)
Obtain a predicate that tests whether a supplied |
static IPredicate<XdmAtomicValue> | Eq(XdmAtomicValue value2) Obtain a predicate that tests whether an atomic value compares equal to a supplied atomic value of a comparable type. |
static IPredicate<XdmItem> | Eq(string value)
Obtain a predicate that tests whether the result of applying the XPath |
static <TInput, TResult> IPredicate<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> IPredicate<TInput> | Every(Step<TInput, TResult> step, IPredicate<TResult> condition) Obtain a predicate that tests whether every item in the result of applying a step satisfies the supplied condition. |
static IPredicate<XdmItem> | Exists(Step<XdmItem, XdmItem> step)
Obtain a predicate that tests whether a supplied |
static IPredicate<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 IPredicate<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 IPredicate<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 IPredicate<XdmNode> | HasNamespace(string uri) Obtain a predicate that tests whether an item is a node with a given namespace URI. |
static IPredicate<XdmItem> | IsArray() A predicate to test whether an item is an XDM array. |
static IPredicate<XdmItem> | IsAtomic() A predicate to test whether an item is an atomic value. |
static IPredicate<XdmItem> | IsAttribute() A predicate to test whether an item is an attribute node. |
static IPredicate<XdmItem> | IsComment() A predicate to test whether an item is a comment node. |
static IPredicate<XdmItem> | IsDocument() A predicate to test whether an item is a document node. |
static IPredicate<XdmItem> | IsElement() A predicate to test whether an item is an element node. |
static IPredicate<XdmItem> | IsFunction() A predicate to test whether an item is a function value (this includes maps and arrays). |
static IPredicate<XdmItem> | IsMap() A predicate to test whether an item is an XDM map. |
static IPredicate<XdmItem> | IsNamespace() A predicate to test whether an item is a namespace node. |
static IPredicate<XdmItem> | IsNode() A predicate to test whether an item is a node. |
static IPredicate<XdmItem> | IsProcessingInstruction() A predicate to test whether an item is a processing instruction node. |
static IPredicate<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> IPredicate<TInput> | Not(IPredicate<TInput> condition)
Return an |
static <TInput, TResult> IPredicate<TInput> | Some(Step<TInput, TResult> step, IPredicate<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
AttributeEq
string value)
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:
value2
- 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
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, 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
IPredicate<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 nameReturns:
HasName
string localName)
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 an IPredicate
that is the negation of a supplied IPredicate
.
Parameters:
condition
- The supplied predicateReturns:
Some
IPredicate<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:
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: