-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate class
A namespace context that is aware of this Impl's configured namespaces, as well as a chained context.private static class
A simple variable resolver mapping variable names to their respective index in an XPath expression. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal Impl
Add some elements to the set of matched elementsfinal Impl
Add some elements to the set of matched elements(package private) final Impl
(package private) final Impl
addElements
(Element... e) (package private) final Impl
addNodeList
(NodeList list) (package private) final Impl
addNodeLists
(List<NodeList> lists) (package private) final Impl
(package private) final Impl
addUniqueElements
(Element... e) final Impl
Add content after each element in the set of matched elements.final Impl
Add content after each element in the set of matched elements.final Impl
Add content after each element in the set of matched elements.final Impl
Add content after each element in the set of matched elements.final Impl
andSelf()
Add the previous set of matched elements to the current one.final Impl
Append content to the end of each element's content in the set of matched elements.final Impl
Append content to the end of each element's content in the set of matched elements.final Impl
Append content to the end of each element's content in the set of matched elements.final Impl
Append content to the end of each element's content in the set of matched elements.final String
Get an attribute from the first element in the set of matched elements, ornull
if the first element does not have that attribute.final <T> T
Get a converted attribute from the first element in the set of matched elements, ornull
if the first element does not have that attribute.final Impl
Set an attribute on all elements in the set of matched elements.final Impl
Set an attribute on all elements in the set of matched elements.Get an attribute from all elements in the set of matched elementsfinal <T> List
<T> Get a converted attribute from all elements in the set of matched elementsprivate final Impl
axis
(boolean all, Filter until, Filter filter, Function<Node, Node> iterate, Consumer<List<Element>> finisher) final Impl
Add content before each element in the set of matched elements.final Impl
Add content before each element in the set of matched elements.final Impl
Add content before each element in the set of matched elements.final Impl
Add content before each element in the set of matched elements.final String
cdata()
Get the CDATA content of the first element in the set of matched elements, ornull
if there are no matched elements.final String
cdata
(int index) Get the CDATA content at a given index in the current set of matched elements.final <T> T
Get the converted CDATA content of the first element in the set of matched elements, ornull
if there are no matched elements.final Impl
Set some CDATA content to all elements in the set of matched elements (possibly replacing existing content).final Impl
Set some CDATA content to all elements in the set of matched elements (possibly replacing existing content).cdatas()
Get all CDATA content of the elements in the set of matched elements.cdatas
(int... indexes) Get all CDATA content of the elements at given indexes in the set of matched elements.final <T> List
<T> Get all converted CDATA content of the elements in the set of matched elements.final Impl
child()
Find the first child of each element in the current set of matched elements.final Impl
child
(int index) Find the child at a given index of each element in the current set of matched elements.final Impl
Find the first matching child of each element in the current set of matched elementsfinal Impl
Find the first matching child of each element in the current set of matched elementsfinal Impl
children()
Find all children of each element in the current set of matched elements.final Impl
children
(int... indexes) Find all children of each element at given indexes in the current set of matched elements.final Impl
Find all children of each element in the current set of matched elements.final Impl
Find all children of each element in the current set of matched elements.final String
content()
Get the XML content of the first element in the set of matched elements, ornull
if there are no matched elements.final String
content
(int index) Get the XML content at a given index in the current set of matched elements.final Impl
Add some JAXB-marshallable XML content to all elements in the set of matched elements (possibly replacing existing content).final Impl
Add some XML content to all elements in the set of matched elements (possibly replacing existing content).final Impl
Add some XML content to all elements in the set of matched elements (possibly replacing existing content).private final String
contents()
Get all XML content of the elements in the set of matched elements.contents
(int... indexes) Get all XML content of the elements at given indexes in the set of matched elements.final Impl
copy()
Get a copy of theMatch
wrapper.final Document
document()
Get the underlying document of the set of matched elements.each()
Get all elements in the set of matched elements in a list of matches, every match representing one elementfinal Impl
Execute several callbacks for every element in the current set of matched elements.final Impl
Execute a callback for every element in the current set of matched elements.final Impl
Execute several callbacks for every element in the current set of matched elements.final Match
empty()
Removes all content from all elements in the set of matched elements.private final void
final Impl
eq
(int... indexes) Reduce the current set of matched elements to the elements at the given indexes.boolean
final Impl
Reduce the current set of matched elements.final Impl
Reduce the current set of matched elements.final Impl
find()
Find all descendants of each element in the current set of matched elements.final Impl
Find all descendants of each element in the current set of matched elements.final Impl
Find all descendants of each element in the current set of matched elements.final Impl
first()
Get the first in a set of matched elements.get()
Get an the set of matched elementsfinal Element
get
(int index) Get an element from the set of matched elements at a given indexget
(int... indexes) Get some elements from the set of matched elements at the given indexesfinal Impl
Reduce the set of matched element to those who have a descendant that matches a selector.final Impl
Reduce the set of matched element to those who have a descendant that matches a filter.int
hashCode()
final String
id()
Get the first id valuefinal String
id
(int index) Get an id value at a given index in the current set of matched elements.final <T> T
Get the first converted id valueids()
Get a list of id values in the current set of matched elements.ids
(int... indexes) Get a list of id values at given indexes in the current set of matched elements.final <T> List
<T> Get a list of converted id values in the current set of matched elements.final boolean
Check if at least one element in the set of matched elements satisfies a selector.final boolean
Check if at least one element in the set of matched elements satisfies a filter.final boolean
isEmpty()
Whether there are any matched elements in the set of matched elementsprivate final boolean
final boolean
Whether there are any matched elements in the set of matched elementsprivate boolean
isRoot()
Temporary utility method to indicate whether the root element is among the matched elementsiterator()
final Impl
last()
Get the last in a set of matched elements.final Impl
leaf()
Reduce the set of matched elements to the ones that are leaf elementsfinal <E> List
<E> Map the set of matched elements to a list of somethingfinal Match
Reduce the set of matched elements by filtering out those whose attribute content doesn't match a given regexfinal Match
Reduce the set of matched elements by filtering out those whose attribute content doesn't match a given regex(keepMatches = true)
, or those whose text content matches a given regex(keepMatches = false)
final Impl
Reduce the set of matched elements by filtering out those whose tag name doesn't match a given regexfinal Impl
Reduce the set of matched elements by filtering out those whose tag name doesn't match a given regex(keepMatches = true)
, or those whose tag name matches a given regex(keepMatches = false)
final Impl
Reduce the set of matched elements by filtering out those whose text content doesn't match a given regexfinal Impl
Reduce the set of matched elements by filtering out those whose text content doesn't match a given regex(keepMatches = true)
, or those whose text content matches a given regex(keepMatches = false)
final Match
Get a new Match with added namespace configuration for subsequent XPath callsfinal String
Get the namespace prefix of the first element in the current set of matched elements.final String
namespacePrefix
(int index) Get a namespace prefix of the element at a given index in the current set of matched elements.Get a list of namespace prefixes of the elements in the current set of matched elements.namespacePrefixes
(int... indexes) Get a list of namespace prefixes of the elements at given indexes in the current set of matched elements.final Match
namespaces
(Map<String, String> map) Get a new Match with added namespace configuration for subsequent XPath callsfinal String
Get the namespace URI of the first element in the current set of matched elements.final String
namespaceURI
(int index) Get a namespace URI of the element at a given index in the current set of matched elements.Get a list of namespace URIs of the elements in the current set of matched elements.namespaceURIs
(int... indexes) Get a list of namespace URIs of the elements at given indexes in the current set of matched elements.final Impl
next()
Get the immediate next sibling of every element in set of matched elements.private final Impl
final Impl
Get the immediate next sibling of every element in set of matched elements, matching a selectorfinal Impl
Get the immediate next sibling of every element in set of matched elements, matching a filterfinal Impl
nextAll()
Get all next siblings of every element in a set of matched elementsfinal Impl
Get all next siblings of every element in a set of matched elements, matching a selectorfinal Impl
Get all next siblings of every element in a set of matched elements, matching a filterfinal Impl
Get all next siblings of every element in a set of matched elements until the provided selector matchesfinal Impl
Get all next siblings of every element in a set of matched elements, matching a selector, until the provided selector matchesfinal Impl
Get all next siblings of every element in a set of matched elements, matching a filter, until the provided selector matchesfinal Impl
Get all next siblings of every element in a set of matched elements until the provided filter matchesfinal Impl
Get all next siblings of every element in a set of matched elements, matching a selector until the provided filter matchesfinal Impl
Get all next siblings of every element in a set of matched elements, matching a filter until the provided filter matchesfinal Impl
Remove elements from the set of matched elements.final Impl
Remove elements from the set of matched elements.final Impl
parent()
Get the immediate parent elements of every element in a set of matched elementsfinal Impl
Get the immediate parent elements of every element in a set of matched elements, matching a selectorfinal Impl
Get the immediate parent elements of every element in a set of matched elements, matching a filterfinal Impl
parents()
Get all ancestor elements of every element in a set of matched elementsprivate final Impl
final Impl
Get all ancestor elements of every element in a set of matched elements, matching a selectorfinal Impl
Get all ancestor elements of every element in a set of matched elements, matching a filterfinal Impl
parentsUntil
(String until) Get all ancestors of every element in a set of matched elements until the provided selector matchesfinal Impl
parentsUntil
(String until, String selector) Get all ancestors of every element in a set of matched elements, matching a selector, until the provided selector matchesfinal Impl
parentsUntil
(String until, Filter filter) Get all ancestors of every element in a set of matched elements, matching a filter, until the provided selector matchesfinal Impl
parentsUntil
(Filter until) Get all ancestors of every element in a set of matched elements until the provided filter matchesfinal Impl
parentsUntil
(Filter until, String selector) Get all ancestors of every element in a set of matched elements, matching a selector until the provided filter matchesfinal Impl
parentsUntil
(Filter until, Filter filter) Get all ancestors of every element in a set of matched elements, matching a filter until the provided filter matchesfinal Impl
Prepend content to the beginning of each element's content in the set of matched elements.final Impl
Prepend content to the beginning of each element's content in the set of matched elements.final Impl
Prepend content to the beginning of each element's content in the set of matched elements.final Impl
Prepend content to the beginning of each element's content in the set of matched elements.final Impl
prev()
Get the immediate previous sibling of every element in set of matched elements.private final Impl
final Impl
Get the immediate previous sibling of every element in set of matched elements, matching a selectorfinal Impl
Get the immediate previous sibling of every element in set of matched elements, matching a filterfinal Impl
prevAll()
Get all previous siblings of every element in a set of matched elementsfinal Impl
Get all previous siblings of every element in a set of matched elements, matching a selectorfinal Impl
Get all previous siblings of every element in a set of matched elements, matching a filterfinal Impl
Get all previous siblings of every element in a set of matched elements until the provided selector matchesfinal Impl
Get all previous siblings of every element in a set of matched elements, matching a selector, until the provided selector matchesfinal Impl
Get all previous siblings of every element in a set of matched elements, matching a filter, until the provided selector matchesfinal Impl
Get all previous siblings of every element in a set of matched elements until the provided filter matchesfinal Impl
Get all previous siblings of every element in a set of matched elements, matching a selector until the provided filter matchesfinal Impl
Get all previous siblings of every element in a set of matched elements, matching a filter until the provided filter matchesfinal Impl
remove()
Removes all elements from their parent nodes in the set of matched elements.final Impl
Removes all elements from their parent nodes in the set of matched elements, matching a selectorfinal Impl
Removes all elements from their parent nodes in the set of matched elements, matching a filterprivate final void
final Impl
removeAttr
(String name) Remove an attribute from all elements in the set of matched elements.final Match
Rename all tags in the set of matched elements to some new tag namefinal Match
Rename all tags in the set of matched elements to some new tag namefinal Impl
replaceWith
(String content) Replace all elements in the set of matched elements with some new content.final Impl
replaceWith
(Content content) Replace all elements in the set of matched elements with some new content.final Impl
replaceWith
(Match... content) Replace all elements in the set of matched elements with some new content.final Impl
replaceWith
(Element... content) Replace all elements in the set of matched elements with some new content.final Impl
reverse()
Reverse the order of the set of matched elementsfinal Impl
siblings()
Get all siblings of every element in a set of matched elementsfinal Impl
Get all siblings of every element in a set of matched elements, matching a selectorfinal Impl
Get all siblings of every element in a set of matched elements, matching a filterfinal int
size()
Get the number of matched elements in the set of matched elementsfinal Impl
slice
(int start) Reduce the set of matched elements by specifying a range of indexesfinal Impl
slice
(int start, int end) Reduce the set of matched elements by specifying a range of indexessort
(Comparator<Element> comparator) Allows to sort the result with the given comparator.final String
tag()
Get the tag name of the first element in the current set of matched elements.final String
tag
(int index) Get a tag name of the element at a given index in the current set of matched elements.tags()
Get a list of tag names of the elements in the current set of matched elements.tags
(int... indexes) Get a list of tag names of the elements at given indexes in the current set of matched elements.final String
text()
Get the text content of the first element in the set of matched elements, ornull
if there are no matched elements.final String
text
(int index) Get the text content at a given index in the current set of matched elements.final <T> T
Get the converted text content of the first element in the set of matched elements, ornull
if there are no matched elements.final Impl
Set some text content to all elements in the set of matched elements (possibly replacing existing content).final Impl
Set some text content to all elements in the set of matched elements (possibly replacing existing content).texts()
Get all text content of the elements in the set of matched elements.texts
(int... indexes) Get all text content of the elements at given indexes in the set of matched elements.final <T> List
<T> Get all converted text content of the elements in the set of matched elements.toString()
final Impl
Transform all elements in the set of matched elements.final Impl
transform
(InputStream transformer) Transform all elements in the set of matched elements.final Impl
Transform all elements in the set of matched elements.final Impl
Transform all elements in the set of matched elements.final Impl
Transform all elements in the set of matched elements.final Impl
Transform all elements in the set of matched elements.final Impl
transform
(Transformer transformer) Transform all elements in the set of matched elements.final <T> List
<T> Unmarshal the current set of matched elements into a JAXB-annotated type.final <T> List
<T> Unmarshal the current set of matched elements at given indexes into a JAXB-annotated type.final <T> T
unmarshalOne
(Class<T> type) Unmarshal the first element in the current set of matched elements into a JAXB-annotated type.final <T> T
unmarshalOne
(Class<T> type, int index) Unmarshal the element at a given index in the current set of matched elements into a JAXB-annotated type.final Impl
unwrap()
Removes all elements in the set of matched elements from their parentsfinal Impl
Wrap all elements from their parent nodes in the set of matched elements in a new parent elementfinal Impl
Wrap all elements in the set of matched elements in a new parent elementfinal Match
Write the set of matched elements into a filefinal Match
write
(OutputStream stream) Write the set of matched elements into a streamfinal Match
Write the set of matched elements into a writerfinal String
xpath()
Get an XPath expression describing the first element in the current set of matched elementsfinal String
xpath
(int index) Get an XPath expression describing the element at a given index in the current set of matched elementsfinal Impl
Match all elements given a certain XPath expression applied to each element in the current set of matched elements.final Impl
Match all elements given a certain XPath expression applied to each element in the current set of matched elements.xpaths()
Get a list of XPath expressions describing the elements in the current set of matched elementsxpaths
(int... indexes) Get a list of XPath expressions describing the elements at the given indexes in the current set of matched elementsMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
document
-
elements
-
previousMatch
-
namespaces
-
SIMPLE_SELECTOR
A selector pattern that can be evaluated using standard DOM API
-
-
Constructor Details
-
Impl
-
Impl
-
-
Method Details
-
addNodeLists
-
addNodeList
-
addUniqueElements
-
addUniqueElements
-
addElements
-
addElements
-
iterator
-
namespace
Description copied from interface:Match
Get a new Match with added namespace configuration for subsequent XPath callsThis is a convenience method for
Match.namespaces(java.util.Map)
-
namespaces
Description copied from interface:Match
Get a new Match with added namespace configuration for subsequent XPath calls- Specified by:
namespaces
in interfaceMatch
- Parameters:
map
- A mapping between prefix and namespace URI- Returns:
- A modified
Match
-
namespaceURI
Description copied from interface:Match
Get the namespace URI of the first element in the current set of matched elements.This is the same as calling
namespaceURI(0)
This only works if the underlying document is namespace-aware
- Specified by:
namespaceURI
in interfaceMatch
- See Also:
-
namespaceURI
Description copied from interface:Match
Get a namespace URI of the element at a given index in the current set of matched elements.This only works if the underlying document is namespace-aware
- Specified by:
namespaceURI
in interfaceMatch
- See Also:
-
namespaceURIs
Description copied from interface:Match
Get a list of namespace URIs of the elements in the current set of matched elements.This only works if the underlying document is namespace-aware
- Specified by:
namespaceURIs
in interfaceMatch
- See Also:
-
namespaceURIs
Description copied from interface:Match
Get a list of namespace URIs of the elements at given indexes in the current set of matched elements.This only works if the underlying document is namespace-aware
- Specified by:
namespaceURIs
in interfaceMatch
- See Also:
-
namespacePrefix
Description copied from interface:Match
Get the namespace prefix of the first element in the current set of matched elements.This is the same as calling
namespaceURI(0)
- Specified by:
namespacePrefix
in interfaceMatch
-
namespacePrefix
Description copied from interface:Match
Get a namespace prefix of the element at a given index in the current set of matched elements.- Specified by:
namespacePrefix
in interfaceMatch
-
namespacePrefixes
Description copied from interface:Match
Get a list of namespace prefixes of the elements in the current set of matched elements.- Specified by:
namespacePrefixes
in interfaceMatch
-
namespacePrefixes
Description copied from interface:Match
Get a list of namespace prefixes of the elements at given indexes in the current set of matched elements.- Specified by:
namespacePrefixes
in interfaceMatch
-
document
Description copied from interface:Match
Get the underlying document of the set of matched elements.This will also return a document if there are no elements in the set of matched elements, either because a new document has been created previously, or the set of matched elements has been reduced to an empty set.
-
get
Description copied from interface:Match
Get an element from the set of matched elements at a given indexNegative indexes are possible, too.
-
-1
corresponds to the last element in the set of matched elements. -
-2
corresponds to the second-last element, etc.
-
-
get
Description copied from interface:Match
Get some elements from the set of matched elements at the given indexesNegative indexes are possible, too.
-
-1
corresponds to the last element in the set of matched elements. -
-2
corresponds to the second-last element, etc.
-
-
get
Description copied from interface:Match
Get an the set of matched elements -
size
public final int size()Description copied from interface:Match
Get the number of matched elements in the set of matched elements -
isEmpty
public final boolean isEmpty()Description copied from interface:Match
Whether there are any matched elements in the set of matched elements -
isNotEmpty
public final boolean isNotEmpty()Description copied from interface:Match
Whether there are any matched elements in the set of matched elements- Specified by:
isNotEmpty
in interfaceMatch
-
add
Description copied from interface:Match
Add some elements to the set of matched elements -
add
Description copied from interface:Match
Add some elements to the set of matched elements -
reverse
Description copied from interface:Match
Reverse the order of the set of matched elements -
andSelf
Description copied from interface:Match
Add the previous set of matched elements to the current one. This works after any of these methods (including all overloaded variants):Match.child()
Match.children()
Match.find()
Match.next()
Match.nextAll()
Match.nextUntil(Filter)
Match.parent()
Match.parents()
Match.parentsUntil(Filter)
Match.prev()
Match.prevAll()
Match.prevUntil(Filter)
Match.siblings()
Match.eq(int...)
, and then add the removed elements again, usingMatch.andSelf()
. -
child
Description copied from interface:Match
Find the first child of each element in the current set of matched elements.This is the same as calling
child(0)
. -
child
Description copied from interface:Match
Find the first matching child of each element in the current set of matched elementsThe selector provided to this method supports the following features:
- * can be used to select everything
- tag names can be used to select XML elements by tag
names (see
Element.getElementsByTagName(String)
. Tag names are namespace-unaware. This means that existing namespaces will be ignored
- CSS selectors cannot be used (yet) to select XML
elements from this method. Use
Match.find(String)
instead - XPath cannot be used. Use
Match.xpath(String)
instead - Namespaces cannot be used. Use
Match.xpath(String)
withMatch.namespaces(Map)
instead
-
child
Description copied from interface:Match
Find the first matching child of each element in the current set of matched elements -
child
Description copied from interface:Match
Find the child at a given index of each element in the current set of matched elements. -
children
Description copied from interface:Match
Find all children of each element in the current set of matched elements. -
children
Description copied from interface:Match
Find all children of each element at given indexes in the current set of matched elements. -
children
Description copied from interface:Match
Find all children of each element in the current set of matched elements.The selector provided to this method supports the following features:
- * can be used to select everything
- tag names can be used to select XML elements by tag
names (see
Element.getElementsByTagName(String)
. Tag names are namespace-unaware. This means that existing namespaces will be ignored
- CSS selectors cannot be used (yet) to select XML
elements from this method. Use
Match.find(String)
instead - XPath cannot be used. Use
Match.xpath(String)
instead - Namespaces cannot be used. Use
Match.xpath(String)
withMatch.namespaces(Map)
instead
-
children
Description copied from interface:Match
Find all children of each element in the current set of matched elements.The callback
Context
is populated like this:-
Context.match()
- the matched element whose children are searched -
Context.matchIndex()
- the index of the matched element whose children are searched -
Context.element()
- the child candidate that is being filtered -
Context.elementIndex()
- the index within its parent of the child candidate that is being filtered
-
-
each
Description copied from interface:Match
Get all elements in the set of matched elements in a list of matches, every match representing one element -
each
Description copied from interface:Match
Execute a callback for every element in the current set of matched elements. -
each
Description copied from interface:Match
Execute several callbacks for every element in the current set of matched elements. -
each
Description copied from interface:Match
Execute several callbacks for every element in the current set of matched elements. -
filter
Description copied from interface:Match
Reduce the current set of matched elements.The selector provided to this method supports the following features:
- * can be used to select everything
- tag names can be used to select XML elements by tag
names (see
Element.getElementsByTagName(String)
. Tag names are namespace-unaware. This means that existing namespaces will be ignored
- CSS selectors cannot be used (yet) to select XML
elements from this method. Use
Match.find(String)
instead - XPath cannot be used. Use
Match.xpath(String)
instead - Namespaces cannot be used. Use
Match.xpath(String)
withMatch.namespaces(Map)
instead
-
filter
Description copied from interface:Match
Reduce the current set of matched elements.The callback
Context
is populated like this:-
Context.match()
- the matched element being filtered -
Context.matchIndex()
- the index of the matched element being filtered
-
-
filter0
-
eq
Description copied from interface:Match
Reduce the current set of matched elements to the elements at the given indexes. If the given indexes are not in the range of indexes, the resulting set will be empty.Negative indexes are possible, too.
-
-1
corresponds to the last element in the set of matched elements. -
-2
corresponds to the second-last element, etc.
-
-
find
Description copied from interface:Match
Find all descendants of each element in the current set of matched elements. -
find
Description copied from interface:Match
Find all descendants of each element in the current set of matched elements.The selector provided to this method supports the following features:
- * can be used to select everything
- tag names can be used to select XML elements by tag
names (see
Element.getElementsByTagName(String)
Tag names are namespace-unaware. This means that existing namespaces will be ignored - CSS selectors can be used to select XML elements
using XPath (see
CSS2XPath.css2xpath(String)
)
- XPath cannot be used. Use
Match.xpath(String)
instead - Namespaces cannot be used. Use
Match.xpath(String)
withMatch.namespaces(Map)
instead
-
isRoot
private boolean isRoot()Temporary utility method to indicate whether the root element is among the matched elements -
find
Description copied from interface:Match
Find all descendants of each element in the current set of matched elements.The callback
Context
is populated like this:-
Context.match()
- the matched element whose descendants are searched -
Context.matchIndex()
- the index of the matched element whose descendants are searched -
Context.element()
- the descendant candidate that is being filtered -
Context.elementIndex()
- the iteration index of the descendant candidate that is being filtered
-
-
xpath
Description copied from interface:Match
Match all elements given a certain XPath expression applied to each element in the current set of matched elements.The XPath expression is evaluated using standard
XPath
. It must not contain any variables. UseMatch.xpath(String, Object...)
instead, if you wish to use variables. Note that only matched elements will be considered in the results. You cannot match attributes or text nodes, for instance. Examples:- Match all elements :
xpath("//*")
- Match all books :
xpath("/library/books/book")
- Match all book ID's :
xpath("//book").ids()
- Match all book names :
xpath("//book/name").texts()
- Match all book ID's :
xpath("//book/@id")
- Match all book names :
xpath("//book/name/text()")
Using jOOX with Namespaces
Namespace declarations are supported in XPath expressions. If you wish to use namespace-specific XPath elements, call
Match.namespace(String, String)
prior toMatch.xpath(String)
Using jOOX with Xalan
If Xalan is on your classpath, jOOX will automatically load xalan's namespace and function extensions. All functionality supported by http://exslt.org will be available in your XPath expressions. Some examples:
- Match the book with the highest ID :
xpath("//book[number(@id) = math:max(//book/@id)]")
- Match books written by Orwell :
xpath("//book[java:org.joox.test.Functions.byOrwellWithNodes(.)]
- Match all elements :
-
xpath
Description copied from interface:Match
Match all elements given a certain XPath expression applied to each element in the current set of matched elements.The XPath expression is evaluated using standard
XPath
. It may contain numerical variables, declared as$1
,$2
, etc, starting with$1
. Other variables, such as$myVar
are not supported. You must provide at least one variable in thevariables
argument for every variable index. Note that only matched elements will be considered in the results. You cannot match attributes or text nodes, for instance. Examples:- Match all elements with id greater than 5:
xpath("//*[@id > $1]", 5)
- Match all books with more than two authors and one author is
"George Orwell" :
xpath("/library/books/book[count(authors/author) > $1][authors/author[text() = $2]]", 2, "George Orwell")
- Match all book ID's :
xpath("//book/@id")
- Match all book names :
xpath("//book/name/text()")
Using jOOX with Namespaces
Namespace declarations are supported in XPath expressions. If you wish to use namespace-specific XPath elements, call
Match.namespace(String, String)
prior toMatch.xpath(String)
Using jOOX with Xalan
If Xalan is on your classpath, jOOX will automatically load xalan's namespace and function extensions. All functionality supported by http://exslt.org will be available in your XPath expressions. Some examples:
- Match the book with the highest ID :
xpath("//book[number(@id) = math:max(//book/@id)]")
- Match books written by Orwell :
xpath("//book[java:org.joox.test.Functions.byOrwellWithNodes(.)]
- Match all elements with id greater than 5:
-
first
Description copied from interface:Match
Get the first in a set of matched elements. -
has
Description copied from interface:Match
Reduce the set of matched element to those who have a descendant that matches a selector.The selector provided to this method supports the following features:
- * can be used to select everything
- tag names can be used to select XML elements by tag
names (see
Element.getElementsByTagName(String)
. Tag names are namespace-unaware. This means that existing namespaces will be ignored
- CSS selectors cannot be used (yet) to select XML
elements from this method. Use
Match.find(String)
instead - XPath cannot be used. Use
Match.xpath(String)
instead - Namespaces cannot be used. Use
Match.xpath(String)
withMatch.namespaces(Map)
instead
-
has
Description copied from interface:Match
Reduce the set of matched element to those who have a descendant that matches a filter.The callback
Context
is populated like this:-
Context.match()
- the matched element whose descendants are searched -
Context.matchIndex()
- the index of the matched element whose descendants are searched -
Context.element()
- the descendant candidate that is being filtered -
Context.elementIndex()
- the iteration index of the descendant candidate that is being filtered
-
-
is
Description copied from interface:Match
Check if at least one element in the set of matched elements satisfies a selector.The selector provided to this method supports the following features:
- * can be used to select everything
- tag names can be used to select XML elements by tag
names (see
Element.getElementsByTagName(String)
. Tag names are namespace-unaware. This means that existing namespaces will be ignored
- CSS selectors cannot be used (yet) to select XML
elements from this method. Use
Match.find(String)
instead - XPath cannot be used. Use
Match.xpath(String)
instead - Namespaces cannot be used. Use
Match.xpath(String)
withMatch.namespaces(Map)
instead
-
is
Description copied from interface:Match
Check if at least one element in the set of matched elements satisfies a filter.The callback
Context
is populated like this:-
Context.match()
- the matched element being checked -
Context.matchIndex()
- the index of the matched element being checked
-
-
last
Description copied from interface:Match
Get the last in a set of matched elements. -
map
Description copied from interface:Match
Map the set of matched elements to a list of something -
next
Description copied from interface:Match
Get the immediate next sibling of every element in set of matched elements. -
next
Description copied from interface:Match
Get the immediate next sibling of every element in set of matched elements, matching a selectorThe selector provided to this method supports the following features:
- * can be used to select everything
- tag names can be used to select XML elements by tag
names (see
Element.getElementsByTagName(String)
. Tag names are namespace-unaware. This means that existing namespaces will be ignored
- CSS selectors cannot be used (yet) to select XML
elements from this method. Use
Match.find(String)
instead - XPath cannot be used. Use
Match.xpath(String)
instead - Namespaces cannot be used. Use
Match.xpath(String)
withMatch.namespaces(Map)
instead
-
next
Description copied from interface:Match
Get the immediate next sibling of every element in set of matched elements, matching a filterThe callback
Context
is populated like this:-
Context.match()
- the matched element whose next sibling is searched -
Context.matchIndex()
- the index of the matched element whose next sibling is searched -
Context.element()
- the next sibling that is being filtered -
Context.elementIndex()
- 1
-
-
nextAll
Description copied from interface:Match
Get all next siblings of every element in a set of matched elements -
nextAll
Description copied from interface:Match
Get all next siblings of every element in a set of matched elements, matching a selectorThe selector provided to this method supports the following features:
- * can be used to select everything
- tag names can be used to select XML elements by tag
names (see
Element.getElementsByTagName(String)
. Tag names are namespace-unaware. This means that existing namespaces will be ignored
- CSS selectors cannot be used (yet) to select XML
elements from this method. Use
Match.find(String)
instead - XPath cannot be used. Use
Match.xpath(String)
instead - Namespaces cannot be used. Use
Match.xpath(String)
withMatch.namespaces(Map)
instead
-
nextAll
Description copied from interface:Match
Get all next siblings of every element in a set of matched elements, matching a filterThe callback
Context
is populated like this:-
Context.match()
- the matched element whose next siblings are searched -
Context.matchIndex()
- the index of the matched element whose next siblings are searched -
Context.element()
- the next siblings that is being filtered -
Context.elementIndex()
- the relative index of the next siblings that are being filtered
-
-
nextUntil
Description copied from interface:Match
Get all next siblings of every element in a set of matched elements until the provided selector matchesThe selector provided to this method supports the following features:
- * can be used to select everything
- tag names can be used to select XML elements by tag
names (see
Element.getElementsByTagName(String)
. Tag names are namespace-unaware. This means that existing namespaces will be ignored
- CSS selectors cannot be used (yet) to select XML
elements from this method. Use
Match.find(String)
instead - XPath cannot be used. Use
Match.xpath(String)
instead - Namespaces cannot be used. Use
Match.xpath(String)
withMatch.namespaces(Map)
instead
-
nextUntil
Description copied from interface:Match
Get all next siblings of every element in a set of matched elements until the provided filter matchesThe callback
Context
is populated like this:-
Context.match()
- the matched element whose next siblings are searched -
Context.matchIndex()
- the index of the matched element whose next siblings are searched -
Context.element()
- the next siblings that is being filtered -
Context.elementIndex()
- the relative index of the next siblings that are being filtered
-
-
nextUntil
Description copied from interface:Match
Get all next siblings of every element in a set of matched elements, matching a selector, until the provided selector matchesThe selector provided to this method supports the following features:
- * can be used to select everything
- tag names can be used to select XML elements by tag
names (see
Element.getElementsByTagName(String)
. Tag names are namespace-unaware. This means that existing namespaces will be ignored
- CSS selectors cannot be used (yet) to select XML
elements from this method. Use
Match.find(String)
instead - XPath cannot be used. Use
Match.xpath(String)
instead - Namespaces cannot be used. Use
Match.xpath(String)
withMatch.namespaces(Map)
instead
-
nextUntil
Description copied from interface:Match
Get all next siblings of every element in a set of matched elements, matching a filter, until the provided selector matchesThe callback
Context
is populated like this:-
Context.match()
- the matched element whose next siblings are searched -
Context.matchIndex()
- the index of the matched element whose next siblings are searched -
Context.element()
- the next siblings that is being filtered -
Context.elementIndex()
- the relative index of the next siblings that are being filtered
-
-
nextUntil
Description copied from interface:Match
Get all next siblings of every element in a set of matched elements, matching a selector until the provided filter matchesThe callback
Context
is populated like this:-
Context.match()
- the matched element whose next siblings are searched -
Context.matchIndex()
- the index of the matched element whose next siblings are searched -
Context.element()
- the next siblings that is being filtered -
Context.elementIndex()
- the relative index of the next siblings that are being filtered
-
-
nextUntil
Description copied from interface:Match
Get all next siblings of every element in a set of matched elements, matching a filter until the provided filter matchesThe callback
Context
is populated like this:-
Context.match()
- the matched element whose next siblings are searched -
Context.matchIndex()
- the index of the matched element whose next siblings are searched -
Context.element()
- the next siblings that is being filtered -
Context.elementIndex()
- the relative index of the next siblings that are being filtered
-
-
next
-
not
Description copied from interface:Match
Remove elements from the set of matched elements.The selector provided to this method supports the following features:
- * can be used to select everything
- tag names can be used to select XML elements by tag
names (see
Element.getElementsByTagName(String)
. Tag names are namespace-unaware. This means that existing namespaces will be ignored
- CSS selectors cannot be used (yet) to select XML
elements from this method. Use
Match.find(String)
instead - XPath cannot be used. Use
Match.xpath(String)
instead - Namespaces cannot be used. Use
Match.xpath(String)
withMatch.namespaces(Map)
instead
-
not
Description copied from interface:Match
Remove elements from the set of matched elements.The callback
Context
is populated like this:-
Context.match()
- the matched element being checked -
Context.matchIndex()
- the index of the matched element being checked
-
-
parent
Description copied from interface:Match
Get the immediate parent elements of every element in a set of matched elements -
parent
Description copied from interface:Match
Get the immediate parent elements of every element in a set of matched elements, matching a selectorThe selector provided to this method supports the following features:
- * can be used to select everything
- tag names can be used to select XML elements by tag
names (see
Element.getElementsByTagName(String)
. Tag names are namespace-unaware. This means that existing namespaces will be ignored
- CSS selectors cannot be used (yet) to select XML
elements from this method. Use
Match.find(String)
instead - XPath cannot be used. Use
Match.xpath(String)
instead - Namespaces cannot be used. Use
Match.xpath(String)
withMatch.namespaces(Map)
instead
-
parent
Description copied from interface:Match
Get the immediate parent elements of every element in a set of matched elements, matching a filterThe callback
Context
is populated like this:-
Context.match()
- the matched element whose parent is searched -
Context.matchIndex()
- the index of the matched element whose parent is searched -
Context.element()
- the parent that is being filtered -
Context.elementIndex()
- 1
-
-
parents
Description copied from interface:Match
Get all ancestor elements of every element in a set of matched elements -
parents
Description copied from interface:Match
Get all ancestor elements of every element in a set of matched elements, matching a selectorThe selector provided to this method supports the following features:
- * can be used to select everything
- tag names can be used to select XML elements by tag
names (see
Element.getElementsByTagName(String)
. Tag names are namespace-unaware. This means that existing namespaces will be ignored
- CSS selectors cannot be used (yet) to select XML
elements from this method. Use
Match.find(String)
instead - XPath cannot be used. Use
Match.xpath(String)
instead - Namespaces cannot be used. Use
Match.xpath(String)
withMatch.namespaces(Map)
instead
-
parents
Description copied from interface:Match
Get all ancestor elements of every element in a set of matched elements, matching a filterThe callback
Context
is populated like this:-
Context.match()
- the matched element whose parents are searched -
Context.matchIndex()
- the index of the matched element whose parents are searched -
Context.element()
- the parent that is being filtered -
Context.elementIndex()
- the relative index of the parent that is being filtered
-
-
parentsUntil
Description copied from interface:Match
Get all ancestors of every element in a set of matched elements until the provided selector matchesThe selector provided to this method supports the following features:
- * can be used to select everything
- tag names can be used to select XML elements by tag
names (see
Element.getElementsByTagName(String)
. Tag names are namespace-unaware. This means that existing namespaces will be ignored
- CSS selectors cannot be used (yet) to select XML
elements from this method. Use
Match.find(String)
instead - XPath cannot be used. Use
Match.xpath(String)
instead - Namespaces cannot be used. Use
Match.xpath(String)
withMatch.namespaces(Map)
instead
- Specified by:
parentsUntil
in interfaceMatch
- See Also:
-
parentsUntil
Description copied from interface:Match
Get all ancestors of every element in a set of matched elements until the provided filter matchesThe callback
Context
is populated like this:-
Context.match()
- the matched element whose parents are searched -
Context.matchIndex()
- the index of the matched element whose parents are searched -
Context.element()
- the parent that is being filtered -
Context.elementIndex()
- the relative index of the parent that is being filtered
- Specified by:
parentsUntil
in interfaceMatch
-
-
parentsUntil
Description copied from interface:Match
Get all ancestors of every element in a set of matched elements, matching a selector, until the provided selector matchesThe selector provided to this method supports the following features:
- * can be used to select everything
- tag names can be used to select XML elements by tag
names (see
Element.getElementsByTagName(String)
. Tag names are namespace-unaware. This means that existing namespaces will be ignored
- CSS selectors cannot be used (yet) to select XML
elements from this method. Use
Match.find(String)
instead - XPath cannot be used. Use
Match.xpath(String)
instead - Namespaces cannot be used. Use
Match.xpath(String)
withMatch.namespaces(Map)
instead
- Specified by:
parentsUntil
in interfaceMatch
- See Also:
-
parentsUntil
Description copied from interface:Match
Get all ancestors of every element in a set of matched elements, matching a filter, until the provided selector matchesThe callback
Context
is populated like this:-
Context.match()
- the matched element whose parents are searched -
Context.matchIndex()
- the index of the matched element whose parents are searched -
Context.element()
- the parent that is being filtered -
Context.elementIndex()
- the relative index of the parent that is being filtered
- Specified by:
parentsUntil
in interfaceMatch
- See Also:
-
-
parentsUntil
Description copied from interface:Match
Get all ancestors of every element in a set of matched elements, matching a selector until the provided filter matchesThe callback
Context
is populated like this:-
Context.match()
- the matched element whose parents are searched -
Context.matchIndex()
- the index of the matched element whose parents are searched -
Context.element()
- the parent that is being filtered -
Context.elementIndex()
- the relative index of the parent that is being filtered
- Specified by:
parentsUntil
in interfaceMatch
- See Also:
-
-
parentsUntil
Description copied from interface:Match
Get all ancestors of every element in a set of matched elements, matching a filter until the provided filter matchesThe callback
Context
is populated like this:-
Context.match()
- the matched element whose parents are searched -
Context.matchIndex()
- the index of the matched element whose parents are searched -
Context.element()
- the parent that is being filtered -
Context.elementIndex()
- the relative index of the parent that is being filtered
- Specified by:
parentsUntil
in interfaceMatch
-
-
parents
-
prev
Description copied from interface:Match
Get the immediate previous sibling of every element in set of matched elements. -
prev
Description copied from interface:Match
Get the immediate previous sibling of every element in set of matched elements, matching a selectorThe selector provided to this method supports the following features:
- * can be used to select everything
- tag names can be used to select XML elements by tag
names (see
Element.getElementsByTagName(String)
. Tag names are namespace-unaware. This means that existing namespaces will be ignored
- CSS selectors cannot be used (yet) to select XML
elements from this method. Use
Match.find(String)
instead - XPath cannot be used. Use
Match.xpath(String)
instead - Namespaces cannot be used. Use
Match.xpath(String)
withMatch.namespaces(Map)
instead
-
prev
Description copied from interface:Match
Get the immediate previous sibling of every element in set of matched elements, matching a filterThe callback
Context
is populated like this:-
Context.match()
- the matched element whose previous sibling is searched -
Context.matchIndex()
- the index of the matched element whose previous sibling is searched -
Context.element()
- the previous sibling that is being filtered -
Context.elementIndex()
- 1
-
-
prevAll
Description copied from interface:Match
Get all previous siblings of every element in a set of matched elements -
prevAll
Description copied from interface:Match
Get all previous siblings of every element in a set of matched elements, matching a selectorThe selector provided to this method supports the following features:
- * can be used to select everything
- tag names can be used to select XML elements by tag
names (see
Element.getElementsByTagName(String)
. Tag names are namespace-unaware. This means that existing namespaces will be ignored
- CSS selectors cannot be used (yet) to select XML
elements from this method. Use
Match.find(String)
instead - XPath cannot be used. Use
Match.xpath(String)
instead - Namespaces cannot be used. Use
Match.xpath(String)
withMatch.namespaces(Map)
instead
-
prevAll
Description copied from interface:Match
Get all previous siblings of every element in a set of matched elements, matching a filterThe callback
Context
is populated like this:-
Context.match()
- the matched element whose previous siblings are searched -
Context.matchIndex()
- the index of the matched element whose previous siblings are searched -
Context.element()
- the previous siblings that is being filtered -
Context.elementIndex()
- the relative index of the previous siblings that are being filtered
-
-
prevUntil
Description copied from interface:Match
Get all previous siblings of every element in a set of matched elements until the provided selector matchesThe selector provided to this method supports the following features:
- * can be used to select everything
- tag names can be used to select XML elements by tag
names (see
Element.getElementsByTagName(String)
. Tag names are namespace-unaware. This means that existing namespaces will be ignored
- CSS selectors cannot be used (yet) to select XML
elements from this method. Use
Match.find(String)
instead - XPath cannot be used. Use
Match.xpath(String)
instead - Namespaces cannot be used. Use
Match.xpath(String)
withMatch.namespaces(Map)
instead
-
prevUntil
Description copied from interface:Match
Get all previous siblings of every element in a set of matched elements until the provided filter matchesThe callback
Context
is populated like this:-
Context.match()
- the matched element whose previous siblings are searched -
Context.matchIndex()
- the index of the matched element whose previous siblings are searched -
Context.element()
- the previous siblings that is being filtered -
Context.elementIndex()
- the relative index of the previous siblings that are being filtered
-
-
prevUntil
Description copied from interface:Match
Get all previous siblings of every element in a set of matched elements, matching a selector, until the provided selector matchesThe selector provided to this method supports the following features:
- * can be used to select everything
- tag names can be used to select XML elements by tag
names (see
Element.getElementsByTagName(String)
. Tag names are namespace-unaware. This means that existing namespaces will be ignored
- CSS selectors cannot be used (yet) to select XML
elements from this method. Use
Match.find(String)
instead - XPath cannot be used. Use
Match.xpath(String)
instead - Namespaces cannot be used. Use
Match.xpath(String)
withMatch.namespaces(Map)
instead
-
prevUntil
Description copied from interface:Match
Get all previous siblings of every element in a set of matched elements, matching a filter, until the provided selector matchesThe callback
Context
is populated like this:-
Context.match()
- the matched element whose previous siblings are searched -
Context.matchIndex()
- the index of the matched element whose previous siblings are searched -
Context.element()
- the previous siblings that is being filtered -
Context.elementIndex()
- the relative index of the previous siblings that are being filtered
-
-
prevUntil
Description copied from interface:Match
Get all previous siblings of every element in a set of matched elements, matching a selector until the provided filter matchesThe callback
Context
is populated like this:-
Context.match()
- the matched element whose previous siblings are searched -
Context.matchIndex()
- the index of the matched element whose previous siblings are searched -
Context.element()
- the previous siblings that is being filtered -
Context.elementIndex()
- the relative index of the previous siblings that are being filtered
-
-
prevUntil
Description copied from interface:Match
Get all previous siblings of every element in a set of matched elements, matching a filter until the provided filter matchesThe callback
Context
is populated like this:-
Context.match()
- the matched element whose previous siblings are searched -
Context.matchIndex()
- the index of the matched element whose previous siblings are searched -
Context.element()
- the previous siblings that is being filtered -
Context.elementIndex()
- the relative index of the previous siblings that are being filtered
-
-
prev
-
axis
-
siblings
Description copied from interface:Match
Get all siblings of every element in a set of matched elements -
siblings
Description copied from interface:Match
Get all siblings of every element in a set of matched elements, matching a selectorThe selector provided to this method supports the following features:
- * can be used to select everything
- tag names can be used to select XML elements by tag
names (see
Element.getElementsByTagName(String)
. Tag names are namespace-unaware. This means that existing namespaces will be ignored
- CSS selectors cannot be used (yet) to select XML
elements from this method. Use
Match.find(String)
instead - XPath cannot be used. Use
Match.xpath(String)
instead - Namespaces cannot be used. Use
Match.xpath(String)
withMatch.namespaces(Map)
instead
-
siblings
Description copied from interface:Match
Get all siblings of every element in a set of matched elements, matching a filterThe callback
Context
is populated like this:-
Context.match()
- the matched element whose siblings are searched -
Context.matchIndex()
- the index of the matched element whose siblings are searched -
Context.element()
- the sibling that is being filtered -
Context.elementIndex()
- the relative index of the sibling that is being filtered. This is less than zero if it is a previous sibling or more than zero if it is a subsequent sibling, compared to the element inContext.match()
-
-
slice
Description copied from interface:Match
Reduce the set of matched elements by specifying a range of indexesThis is the same as calling
slice(start, Integer.MAX_VALUE)
-
slice
Description copied from interface:Match
Reduce the set of matched elements by specifying a range of indexes -
matchText
Description copied from interface:Match
Reduce the set of matched elements by filtering out those whose text content doesn't match a given regexThis is the same as calling
matchText(regex, true)
-
matchText
Description copied from interface:Match
Reduce the set of matched elements by filtering out those whose text content doesn't match a given regex(keepMatches = true)
, or those whose text content matches a given regex(keepMatches = false)
-
matchTag
Description copied from interface:Match
Reduce the set of matched elements by filtering out those whose tag name doesn't match a given regexThis is the same as calling
matchText(regex, true)
-
matchTag
Description copied from interface:Match
Reduce the set of matched elements by filtering out those whose tag name doesn't match a given regex(keepMatches = true)
, or those whose tag name matches a given regex(keepMatches = false)
-
matchAttr
Description copied from interface:Match
Reduce the set of matched elements by filtering out those whose attribute content doesn't match a given regexThis is the same as calling
matchAttr(name, valueRegex, true)
-
matchAttr
Description copied from interface:Match
Reduce the set of matched elements by filtering out those whose attribute content doesn't match a given regex(keepMatches = true)
, or those whose text content matches a given regex(keepMatches = false)
-
leaf
Description copied from interface:Match
Reduce the set of matched elements to the ones that are leaf elements -
after
Description copied from interface:Match
Add content after each element in the set of matched elements. -
after
Description copied from interface:Match
Add content after each element in the set of matched elements.The callback
Context
is populated like this:-
Context.match()
- the matched element being appended after -
Context.matchIndex()
- the index of the matched element being appended after
-
-
after
Description copied from interface:Match
Add content after each element in the set of matched elements.If the added content is already contained in this document, then it is moved. Otherwise, it is cloned. If there are several elements in the set of matched elements, then the added content is duplicated.
-
after
Description copied from interface:Match
Add content after each element in the set of matched elements.If the added content is already contained in this document, then it is moved. Otherwise, it is cloned. If there are several elements in the set of matched elements, then the added content is duplicated.
-
before
Description copied from interface:Match
Add content before each element in the set of matched elements. -
before
Description copied from interface:Match
Add content before each element in the set of matched elements.The callback
Context
is populated like this:-
Context.match()
- the matched element being prepended before -
Context.matchIndex()
- the index of the matched element being prepended before
-
-
before
Description copied from interface:Match
Add content before each element in the set of matched elements.If the added content is already contained in this document, then it is moved. Otherwise, it is cloned. If there are several elements in the set of matched elements, then the added content is duplicated.
-
before
Description copied from interface:Match
Add content before each element in the set of matched elements.If the added content is already contained in this document, then it is moved. Otherwise, it is cloned. If there are several elements in the set of matched elements, then the added content is duplicated.
-
append
Description copied from interface:Match
Append content to the end of each element's content in the set of matched elements. -
append
Description copied from interface:Match
Append content to the end of each element's content in the set of matched elements.The callback
Context
is populated like this:-
Context.match()
- the matched element being appended to -
Context.matchIndex()
- the index of the matched element being appended to
-
-
append
Description copied from interface:Match
Append content to the end of each element's content in the set of matched elements.If the added content is already contained in this document, then it is moved. Otherwise, it is cloned. If there are several elements in the set of matched elements, then the added content is duplicated.
-
append
Description copied from interface:Match
Append content to the end of each element's content in the set of matched elements.If the added content is already contained in this document, then it is moved. Otherwise, it is cloned. If there are several elements in the set of matched elements, then the added content is duplicated.
-
prepend
Description copied from interface:Match
Prepend content to the beginning of each element's content in the set of matched elements. -
prepend
Description copied from interface:Match
Prepend content to the beginning of each element's content in the set of matched elements.The callback
Context
is populated like this:-
Context.match()
- the matched element being prepended to -
Context.matchIndex()
- the index of the matched element being prepended to
-
-
prepend
Description copied from interface:Match
Prepend content to the beginning of each element's content in the set of matched elements.If the added content is already contained in this document, then it is moved. Otherwise, it is cloned. If there are several elements in the set of matched elements, then the added content is duplicated.
-
prepend
Description copied from interface:Match
Prepend content to the beginning of each element's content in the set of matched elements.If the added content is already contained in this document, then it is moved. Otherwise, it is cloned. If there are several elements in the set of matched elements, then the added content is duplicated.
-
attr
Description copied from interface:Match
Get an attribute from the first element in the set of matched elements, ornull
if the first element does not have that attribute.jOOX is namespace-unaware. The supplied attribute name will be compared against all attributes, matching the first one that has the given name.
-
attr
Description copied from interface:Match
Get a converted attribute from the first element in the set of matched elements, ornull
if the first element does not have that attribute.jOOX is namespace-unaware. The supplied attribute name will be compared against all attributes, matching the first one that has the given name.
-
attrs
Description copied from interface:Match
Get an attribute from all elements in the set of matched elementsjOOX is namespace-unaware. The supplied attribute name will be compared against all attributes, matching the first one that has the given name.
-
attrs
Description copied from interface:Match
Get a converted attribute from all elements in the set of matched elementsjOOX is namespace-unaware. The supplied attribute name will be compared against all attributes, matching the first one that has the given name.
-
attr
Description copied from interface:Match
Set an attribute on all elements in the set of matched elements. Ifvalue
is null, then the attribute is removed. If the attribute already exists, then it is replaced. -
attr
Description copied from interface:Match
Set an attribute on all elements in the set of matched elements. Ifvalue
returns null, then the attribute is removed. If the attribute already exists, then it is replaced.The callback
Context
is populated like this:-
Context.match()
- the matched element being attributed -
Context.matchIndex()
- the index of the matched element being attributed
-
-
removeAttr
Description copied from interface:Match
Remove an attribute from all elements in the set of matched elements. This is the same as callingattr(name, null)
.- Specified by:
removeAttr
in interfaceMatch
-
content
Description copied from interface:Match
Get the XML content of the first element in the set of matched elements, ornull
if there are no matched elements.This is the same as calling
content(0)
-
content
Description copied from interface:Match
Get the XML content at a given index in the current set of matched elements. -
contents
Description copied from interface:Match
Get all XML content of the elements in the set of matched elements. -
contents
Description copied from interface:Match
Get all XML content of the elements at given indexes in the set of matched elements. -
content
-
content
Description copied from interface:Match
Add some XML content to all elements in the set of matched elements (possibly replacing existing content). If the supplied content is invalid XML or plain text, then it will be added as text just as withMatch.text(String)
-
content
Description copied from interface:Match
Add some JAXB-marshallable XML content to all elements in the set of matched elements (possibly replacing existing content). -
content
Description copied from interface:Match
Add some XML content to all elements in the set of matched elements (possibly replacing existing content). If the supplied content is invalid XML or plain text, then it will be added as text just as withMatch.text(String)
The callback
Context
is populated like this:-
Context.match()
- the matched element being added to -
Context.matchIndex()
- the index of the matched element being added to
-
-
text
Description copied from interface:Match
Get the text content of the first element in the set of matched elements, ornull
if there are no matched elements.This is the same as calling
text(0)
-
text
Description copied from interface:Match
Get the text content at a given index in the current set of matched elements. -
text
Description copied from interface:Match
Get the converted text content of the first element in the set of matched elements, ornull
if there are no matched elements. -
texts
Description copied from interface:Match
Get all text content of the elements in the set of matched elements. -
texts
Description copied from interface:Match
Get all text content of the elements at given indexes in the set of matched elements. -
texts
Description copied from interface:Match
Get all converted text content of the elements in the set of matched elements. -
text
Description copied from interface:Match
Set some text content to all elements in the set of matched elements (possibly replacing existing content). -
text
Description copied from interface:Match
Set some text content to all elements in the set of matched elements (possibly replacing existing content).The callback
Context
is populated like this:-
Context.match()
- the matched element being added to -
Context.matchIndex()
- the index of the matched element being added to
-
-
cdata
Description copied from interface:Match
Get the CDATA content of the first element in the set of matched elements, ornull
if there are no matched elements.This is the same as calling
cdata(0)
orMatch.text()
. -
cdata
Description copied from interface:Match
Get the CDATA content at a given index in the current set of matched elements.This is the same as
Match.text(int)
. -
cdata
Description copied from interface:Match
Get the converted CDATA content of the first element in the set of matched elements, ornull
if there are no matched elements.This is the same as
Match.text(Class)
. -
cdatas
Description copied from interface:Match
Get all CDATA content of the elements in the set of matched elements.This is the same as
Match.texts()
. -
cdatas
Description copied from interface:Match
Get all CDATA content of the elements at given indexes in the set of matched elements.This is the same as
Match.texts(int...)
. -
cdatas
Description copied from interface:Match
Get all converted CDATA content of the elements in the set of matched elements.This is the same as
Match.texts(Class)
. -
cdata
Description copied from interface:Match
Set some CDATA content to all elements in the set of matched elements (possibly replacing existing content).Unlike
Match.text(Content)
, this generates aNode.CDATA_SECTION_NODE
. -
cdata
Description copied from interface:Match
Set some CDATA content to all elements in the set of matched elements (possibly replacing existing content).The callback
Context
is populated like this:Context.match()
- the matched element being added toContext.matchIndex()
- the index of the matched element being added to
Unlike
Match.text(Content)
, this generates aNode.CDATA_SECTION_NODE
. -
empty
Description copied from interface:Match
Removes all content from all elements in the set of matched elements. -
remove
Description copied from interface:Match
Removes all elements from their parent nodes in the set of matched elements. -
remove
Description copied from interface:Match
Removes all elements from their parent nodes in the set of matched elements, matching a selectorThe selector provided to this method supports the following features:
- * can be used to select everything
- tag names can be used to select XML elements by tag
names (see
Element.getElementsByTagName(String)
. Tag names are namespace-unaware. This means that existing namespaces will be ignored
- CSS selectors cannot be used (yet) to select XML
elements from this method. Use
Match.find(String)
instead - XPath cannot be used. Use
Match.xpath(String)
instead - Namespaces cannot be used. Use
Match.xpath(String)
withMatch.namespaces(Map)
instead
-
remove
Description copied from interface:Match
Removes all elements from their parent nodes in the set of matched elements, matching a filterThe callback
Context
is populated like this:-
Context.match()
- the matched element being removed -
Context.matchIndex()
- the index of the matched element being removed
-
-
remove
-
empty
-
wrap
Description copied from interface:Match
Wrap all elements from their parent nodes in the set of matched elements in a new parent elementThe resulting set of matched elements contains the newly wrapped elements
-
wrap
Description copied from interface:Match
Wrap all elements in the set of matched elements in a new parent elementThe resulting set of matched elements contains the newly wrapped elements
-
unwrap
Description copied from interface:Match
Removes all elements in the set of matched elements from their parentsThe resulting set of matched elements contains the newly unwrapped elements
-
replaceWith
Description copied from interface:Match
Replace all elements in the set of matched elements with some new content.- Specified by:
replaceWith
in interfaceMatch
-
replaceWith
Description copied from interface:Match
Replace all elements in the set of matched elements with some new content.- Specified by:
replaceWith
in interfaceMatch
-
replaceWith
Description copied from interface:Match
Replace all elements in the set of matched elements with some new content.If the added content is already contained in this document, then it is moved. Otherwise, it is cloned. If there are several elements in the set of matched elements, then the added content is duplicated.
- Specified by:
replaceWith
in interfaceMatch
-
replaceWith
Description copied from interface:Match
Replace all elements in the set of matched elements with some new content.If the added content is already contained in this document, then it is moved. Otherwise, it is cloned. If there are several elements in the set of matched elements, then the added content is duplicated.
- Specified by:
replaceWith
in interfaceMatch
-
rename
Description copied from interface:Match
Rename all tags in the set of matched elements to some new tag name -
rename
Description copied from interface:Match
Rename all tags in the set of matched elements to some new tag name -
isFast
-
copy
Description copied from interface:Match
-
xpath
Description copied from interface:Match
Get an XPath expression describing the first element in the current set of matched elementsThis is the same as calling
xpath(0)
-
xpath
Description copied from interface:Match
Get an XPath expression describing the element at a given index in the current set of matched elements -
xpaths
Description copied from interface:Match
Get a list of XPath expressions describing the elements in the current set of matched elements -
xpaths
Description copied from interface:Match
Get a list of XPath expressions describing the elements at the given indexes in the current set of matched elements -
tag
Description copied from interface:Match
Get the tag name of the first element in the current set of matched elements.This is the same as calling
tag(0)
-
tag
Description copied from interface:Match
Get a tag name of the element at a given index in the current set of matched elements. -
tags
Description copied from interface:Match
Get a list of tag names of the elements in the current set of matched elements. -
tags
Description copied from interface:Match
Get a list of tag names of the elements at given indexes in the current set of matched elements. -
id
Description copied from interface:Match
Get the first id valueThis is the same as calling
id(0)
-
id
Description copied from interface:Match
Get an id value at a given index in the current set of matched elements.This is the same as calling
eq(index).attr("id")
-
id
Description copied from interface:Match
Get the first converted id value -
ids
Description copied from interface:Match
Get a list of id values in the current set of matched elements.This is the same as calling
attrs("id")
-
ids
Description copied from interface:Match
Get a list of id values at given indexes in the current set of matched elements. -
ids
Description copied from interface:Match
Get a list of converted id values in the current set of matched elements. -
write
Description copied from interface:Match
Write the set of matched elements into a writerIf the set contains more or less than
1
element, this will result in writing non-well-formed XML- Specified by:
write
in interfaceMatch
- Throws:
IOException
-
write
Description copied from interface:Match
Write the set of matched elements into a streamIf the set contains more or less than
1
element, this will result in writing non-well-formed XML- Specified by:
write
in interfaceMatch
- Throws:
IOException
-
write
Description copied from interface:Match
Write the set of matched elements into a fileIf the set contains more or less than
1
element, this will result in writing non-well-formed XML- Specified by:
write
in interfaceMatch
- Throws:
IOException
-
unmarshal
Description copied from interface:Match
Unmarshal the current set of matched elements into a JAXB-annotated type. -
unmarshal
Description copied from interface:Match
Unmarshal the current set of matched elements at given indexes into a JAXB-annotated type. -
unmarshalOne
Description copied from interface:Match
Unmarshal the first element in the current set of matched elements into a JAXB-annotated type.This is the same as calling
unmarshalOne(type, 0)
- Specified by:
unmarshalOne
in interfaceMatch
-
unmarshalOne
Description copied from interface:Match
Unmarshal the element at a given index in the current set of matched elements into a JAXB-annotated type.This is the same as calling
unmarshalOne(type, 0)
- Specified by:
unmarshalOne
in interfaceMatch
-
transform
Description copied from interface:Match
Transform all elements in the set of matched elements.This will apply a given
Transformer
to every element in the set of matched elements. Every element in the set of matched elements will be replaced by its correspondingResult
obtained from thetransformer
.Example Input:
<books> <book id="1"/> <book id="2"/> </books>
Example XSLT:
<?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="book"> <book id=""> <xsl:apply-templates/> </book> </xsl:template> <xsl:template match="@*|*"> <xsl:copy> <xsl:apply-templates select="*|@*"/> </xsl:copy> </xsl:template> </xsl:stylesheet>
Apply transformation:
// Applies transformation to the document element: $(document).transform("increment.xsl"); // Applies transformation to every book element: $(document).find("book").transform("increment.xsl");
Result:
<books> <book id="2"/> <book id="3"/> </books>
-
transform
Description copied from interface:Match
Transform all elements in the set of matched elements. -
transform
Description copied from interface:Match
Transform all elements in the set of matched elements. -
transform
Description copied from interface:Match
Transform all elements in the set of matched elements. -
transform
Description copied from interface:Match
Transform all elements in the set of matched elements. -
transform
Description copied from interface:Match
Transform all elements in the set of matched elements. -
transform
Description copied from interface:Match
Transform all elements in the set of matched elements. -
sort
Description copied from interface:Match
Allows to sort the result with the given comparator. -
toString
-
hashCode
public int hashCode() -
equals
-