Package net.sf.saxon.pattern
Class NodeSelector
java.lang.Object
net.sf.saxon.pattern.NodeTest
net.sf.saxon.pattern.NodeSelector
- All Implemented Interfaces:
NodePredicate
,ItemType
,ItemTypeWithSequenceTypeCache
A NodeTest that wraps a general Predicate applied to nodes.
This is needed for C#, where it is not possible for a method such as NodeInfo.iterateAxis(int, NodePredicate)
to accept either a NodeTest object or a Predicate supplied as a lambda expression. To supply a predicate, it is
therefore necessary to wrap it in a NodeSelector
.
-
Method Summary
Modifier and TypeMethodDescriptiondouble
Determine the default priority to use if this node-test appears as a match pattern for a template with no explicit priority attribute.getUType()
Get the correspondingUType
.boolean
matches
(int nodeKind, NodeName name, SchemaType annotation) Test whether this node test is satisfied by a given node.static NodeSelector
Create a NodeTest based on a supplied predicate.boolean
Test whether this node test is satisfied by a given node.Methods inherited from class net.sf.saxon.pattern.NodeTest
copy, explainMismatch, getAtomizedItemType, getBasicAlphaCode, getContentType, getFingerprint, getGenre, getMatcher, getMatchingNodeName, getPrimitiveItemType, getPrimitiveType, getRequiredNodeNames, isAtomicType, isAtomizable, isNillable, isPlainType, matches, one, oneOrMore, toShortString, zeroOrMore, zeroOrOne
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.sf.saxon.type.ItemType
getFullAlphaCode, getNormalizedDefaultPriority, toExportString
-
Method Details
-
of
Create a NodeTest based on a supplied predicate. The NodeTest selects a node if the predicate returns true.- Parameters:
predicate
- the supplied predicate (a boolean function of a node)- Returns:
- a NodeTest matching the selected nodes
-
test
Description copied from class:NodeTest
Test whether this node test is satisfied by a given node. This alternative method is used in the case of nodes where calculating the fingerprint is expensive, for example DOM or JDOM nodes. The default implementation calls the methodNodeTest.matches(int, NodeName, SchemaType)
- Specified by:
test
in interfaceNodePredicate
- Overrides:
test
in classNodeTest
- Parameters:
node
- the node to be matched- Returns:
- true if the node test is satisfied by the supplied node, false otherwise
-
getDefaultPriority
public double getDefaultPriority()Description copied from class:NodeTest
Determine the default priority to use if this node-test appears as a match pattern for a template with no explicit priority attribute.- Specified by:
getDefaultPriority
in interfaceItemType
- Specified by:
getDefaultPriority
in classNodeTest
- Returns:
- the default priority for the pattern
-
matches
Description copied from class:NodeTest
Test whether this node test is satisfied by a given node. This method is only fully supported for a subset of NodeTests, because it doesn't provide all the information needed to evaluate all node tests. In particular (a) it can't be used to evaluate a node test of the form element(N,T) or schema-element(E) where it is necessary to know whether the node is nilled, and (b) it can't be used to evaluate a node test of the form document-node(element(X)). This in practice means that it is used (a) to evaluate the simple node tests found in the XPath 1.0 subset used in XML Schema, and (b) to evaluate node tests where the node kind is known to be an attribute.- Specified by:
matches
in classNodeTest
- Parameters:
nodeKind
- The kind of node to be matchedname
- identifies the expanded name of the node to be matched. The value should be null for a node with no name.annotation
- The actual content type of the node. Null means no constraint.- Returns:
- true if the node matches this node test
-
getUType
Description copied from interface:ItemType
Get the correspondingUType
. A UType is a union of primitive item types.- Returns:
- the smallest UType that subsumes this item type
-