Package net.sf.saxon.pattern.nodetest
Interface NodeTest
- All Superinterfaces:
NodePredicate
- All Known Implementing Classes:
AnyGNodeType,AnyJNodeType,AnyXNodeType,CombinedNodeTest,DocumentNodeType,ErrorType,GNodeType,JNodeType,MultipleNodeKindTest,NamedXNodeType,NodeKindType,NodeTestStar,PortableNamedXNodeType,RootJNodeType,SchemaAttributeType,SchemaElementType,SelectorTest,SpecificJNodeType,XNodeType
A
NodeTest represents the XPath construct of the same name: specifically,
it represents what can appear after the (explicit or implicit) "::" in a step in
a path expression.
NodeTests are also used to support XSLT pattern matching.
Node tests used in axis step overlap with node types used in ItemType syntax. In previous
Saxon versions, the NodeTest class served both purposes: it represented both a node
test used in an axis step, and a node type used in (say) an as attribute. From Saxon 13
these two concept are separated. The NodeTest class has become an interface,
and node tests that are also item types are represented by subclasses of GNodeType:
an abstract class that implements the NodeTest interface.
Some node tests have different semantics depending on whether they are selecting within an XTree or a JTree, and in some cases this cannot be decided until evaluation time.
-
Method Summary
Modifier and TypeMethodDescriptionasXNodeTest(Configuration config) Get an XNodeTest that will match any XNode that this NodeTest matches: that is, eliminate the possibility of matching a JNode.explainMismatch(Item item, TypeHierarchy th) Get extra diagnostic information about why a supplied item does not conform to this item type, if available.default Stringexport()doubleDetermine the default priority to use if this node-test appears as a match pattern for a template with no explicit priority attribute.Get an item type that all matching nodes must satisfyExtract a QNameTest (the strongest one possible) that must be satisfied by a node if it is to satisfy this NodeTestgetUType()Get a UType that all matching nodes must satisfybooleanDetermine whether the content type (if present) is nillablebooleanTest whether this node test is satisfied by a given node.Get a concise string representation of this node test for use in diagnostics
-
Method Details
-
getDefaultPriority
double getDefaultPriority()Determine the default priority to use if this node-test appears as a match pattern for a template with no explicit priority attribute.- Returns:
- the default priority for the pattern
-
getQNameTest
QNameTest getQNameTest()Extract a QNameTest (the strongest one possible) that must be satisfied by a node if it is to satisfy this NodeTest- Returns:
- the strongest possible QNameTest
-
getItemType
ItemType getItemType()Get an item type that all matching nodes must satisfy- Returns:
- an item type
-
asXNodeTest
Get an XNodeTest that will match any XNode that this NodeTest matches: that is, eliminate the possibility of matching a JNode. -
getUType
UType getUType()Get a UType that all matching nodes must satisfy- Returns:
- a UType
-
test
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.- Specified by:
testin interfaceNodePredicate- Parameters:
node- the node to be matched- Returns:
- true if the node test is satisfied by the supplied node, false otherwise
-
isNillable
boolean isNillable()Determine whether the content type (if present) is nillable- Returns:
- true if the content test (when present) can match nodes that are nilled
-
explainMismatch
Get extra diagnostic information about why a supplied item does not conform to this item type, if available. If extra information is returned, it should be in the form of a complete sentence, minus the closing full stop. No information should be returned for obvious cases.- Parameters:
item- the item that doesn't match this typeth- the type hierarchy cache- Returns:
- optionally, a message explaining why the item does not match the type
-
toShortString
String toShortString()Get a concise string representation of this node test for use in diagnostics- Returns:
- a suitably abbreviated respresention of the node test
-
export
-