public final class Nodes extends Object
| Modifier and Type | Method and Description |
|---|---|
static Map<QName,String> |
getAttributes(Node n)
Obtains an element's attributes as Map.
|
static Map<QName,String> |
getAttributes(Node n,
Predicate<Attr> attributeFilter)
Obtains an element's attributes as Map.
|
static NodeList |
getChildNodes(Node n)
Helper deals with the
getChildNodes implementation of Attr. |
static String |
getMergedNestedText(Node n)
Tries to merge all direct Text and CDATA children of the given
Node and concatenates their value.
|
static QName |
getQName(Node n)
Extracts a Node's name, namespace URI (if any) and prefix as a
QName.
|
static Node |
normalizeWhitespace(Node original)
Creates a new Node (of the same type as the original node) that
is similar to the orginal but doesn't contain any empty text or
CDATA nodes and where all textual content including attribute
values or comments are trimmed and normalized.
|
static Node |
stripElementContentWhitespace(Node original)
Creates a new Node (of the same type as the original node) that
is similar to the orginal but doesn't contain any text or CDATA
nodes that only consist of whitespace.
|
static Node |
stripWhitespace(Node original)
Creates a new Node (of the same type as the original node) that
is similar to the orginal but doesn't contain any empty text or
CDATA nodes and where all textual content including attribute
values or comments are trimmed.
|
public static QName getQName(Node n)
n - the nodepublic static String getMergedNestedText(Node n)
n - the nodepublic static Map<QName,String> getAttributes(Node n)
n - the nodepublic static Map<QName,String> getAttributes(Node n, Predicate<Attr> attributeFilter)
n - the nodeattributeFilter - is used to suppress unwanted attributes. Only attributes where the filter's test returns
true are returnedpublic static Node stripWhitespace(Node original)
original - the original nodepublic static Node normalizeWhitespace(Node original)
"normalized" in this context means all whitespace characters are replaced by space characters and consecutive whitespace characaters are collapsed.
original - the original nodepublic static Node stripElementContentWhitespace(Node original)
This doesn't have any effect if applied to a text or CDATA node itself.
original - the original nodepublic static NodeList getChildNodes(Node n)
getChildNodes implementation of Attr.
For non-Attr nodes this method simply returns n.getChildNodes. For the special case of an
Attr with a null value this returns a NodeList with an empty Text element
containing a empty string rather than a NodeList containing a single null Node.
n - the node to obtain the children ofCopyright © 2001–2025 XMLUnit. All rights reserved.