Class XPathPatterns
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumRepresentation of an XPath axis.static classLazy list of selected XML nodes.static interfaceCommon interface for XPath navigation operations that can be implemented as motifs.static classRepresentation of an XPath location path.static interfaceRepresentation of an XPath predicate.static interfaceRepresentation of an XPath node test. -
Method Summary
Modifier and TypeMethodDescriptionstatic XPathPatterns.Pathabsolute()Returns an empty absolute location path.static XPathPatterns.TestReturns a node test that is true for any attribute node.static XPathPatterns.Testcomment()Returns a node test that is true for any comment node.static XPathPatterns.Testelement()Returns a node test that is true for any element node.static XPathPatterns.Predicateexists(XPathPatterns.Path path) Returns a predicate that selects from a node-set the elements for which the given path leads to one or more nodes.static XPathPatterns.Predicatelast()Returns a predicate that selects from a node-set the element with the last context position.static XPathPatterns.TestReturns a node test that is true for any node with the given name.static XPathPatterns.TestReturns a node test that is true for any node with the given name.static XPathPatterns.Testnode()Returns a node test that is true for any node.static XPathPatterns.Predicateposition(int index) Returns a predicate that selects from a node-set the element with the given context position.static XPathPatterns.Pathrelative()Returns an empty relative location path.static XPathPatterns.Testtext()Returns a node test that is true for any text node.
-
Method Details
-
node
Returns a node test that is true for any node.The resulting object represents an XPath expression of the form "
node()".- Returns:
- a node test that is true for any node
-
name
Returns a node test that is true for any node with the given name.The resulting object represents an XPath expression of the form "NCName
:NCName", where the part before and after the colon are parsed as a namespace prefix and a local name, respectively. The namespace prefix must be resolved to a namespace URI in application- and context-specific ways before this method can be used.- Parameters:
namespaceURI- a namespace URI, ornullfor a name without a namespacelocalName- a local name- Returns:
- a node test that is true for any node with the namespace URI equal
to
namespaceURIand local name equal tolocalName - Throws:
NullPointerException- iflocalNameis null
-
name
Returns a node test that is true for any node with the given name.The resulting object represents an XPath expression of the form "NCName
:*", where the part before the colon is parsed as a namespace prefix. The namespace prefix must be resolved to a namespace URI in application- and context-specific ways before this method can be used.- Parameters:
namespaceURI- a namespace URI- Returns:
- a node test that is true for any node in the namespace
namespaceURI - Throws:
NullPointerException- ifnamespaceURIis null
-
element
Returns a node test that is true for any element node.The resulting object represents an XPath expression of the form "
*" after an axis specifier whose principal node type is elements.- Returns:
- a node test that is true for any element node
-
attribute
Returns a node test that is true for any attribute node.The resulting object represents an XPath expression of the form "
*" after an axis specifier whose principal node type is attributes.- Returns:
- a node test that is true for any attribute node
-
text
Returns a node test that is true for any text node.The resulting object represents an XPath expression of the form "
text()".- Returns:
- a node test that is true for any text node
-
comment
Returns a node test that is true for any comment node.The resulting object represents an XPath expression of the form "
comment()".- Returns:
- a node test that is true for any comment node
-
exists
Returns a predicate that selects from a node-set the elements for which the given path leads to one or more nodes.- Parameters:
path- the path to check- Returns:
- a predicate that selects-set the elements for which
pathleads to one or more nodes - Throws:
NullPointerException- ifpathis null
-
position
Returns a predicate that selects from a node-set the element with the given context position.If the given position is less or equal to zero, then the resulting predicate will tacitly select no nodes.
The resulting object represents an XPath expression of the form "Number".
- Parameters:
index- the one-based index of the position to be selected- Returns:
- a predicate that selects-set the element with the context position
equal to
index
-
last
Returns a predicate that selects from a node-set the element with the last context position.The resulting object represents an XPath expression of the form "
last()".- Returns:
- a predicate that selects-set the element with the last context position
-
absolute
Returns an empty absolute location path.Absolute location paths start at the document root, regardless of the context in which they are evaluated.
An empty location path does not correspond to any XPath expression; all location paths that can be denoted are non-empty. Empty location paths are useful, however, as the base case in a recursive abstract syntax.
- Returns:
- an empty absolute location path
-
relative
Returns an empty relative location path.Relative location paths start at the context node in which they are evaluated.
An empty location path does not correspond to any XPath expression; all location paths that can be denoted are non-empty. Empty location paths are useful, however, as the base case in a recursive abstract syntax.
- Returns:
- an empty relative location path
-