Package org.xmlunit.diff
Class MultiLevelByNameAndTextSelector
- java.lang.Object
-
- org.xmlunit.diff.MultiLevelByNameAndTextSelector
-
- All Implemented Interfaces:
ElementSelector
public class MultiLevelByNameAndTextSelector extends Object implements ElementSelector
ElementSelectorthat allows two elements to be compared if their name (including namespace URI, if any) and textual content is the same at a certain level of nesting.This means
ElementSelectors.byNameAndTextandMultiLevelByNameAndTextSelector(1)should lead to the same results.Any attribute values are completely ignored. Only works on elements with exactly one child element at each level.
This class mostly exists as an example for custom ElementSelectors and may need to be combined inside a
conditionalSelectorin order to be useful for the document as a whole.
-
-
Constructor Summary
Constructors Constructor Description MultiLevelByNameAndTextSelector(int levels)Uses element names and the text nestedlevelschild elements deeper into the element to compare elements.MultiLevelByNameAndTextSelector(int levels, boolean ignoreEmptyTexts)Uses element names and the text nestedlevelschild elements deeper into the element to compare elements.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancanBeCompared(Element controlElement, Element testElement)Determine whether the two elements from the control and test XML can be compared.
-
-
-
Constructor Detail
-
MultiLevelByNameAndTextSelector
public MultiLevelByNameAndTextSelector(int levels)
Uses element names and the text nestedlevelschild elements deeper into the element to compare elements.Does not ignore empty text nodes.
- Parameters:
levels- level of nesting to use when looking up the text
-
MultiLevelByNameAndTextSelector
public MultiLevelByNameAndTextSelector(int levels, boolean ignoreEmptyTexts)Uses element names and the text nestedlevelschild elements deeper into the element to compare elements.- Parameters:
levels- level of nesting to use when looking up the textignoreEmptyTexts- whether whitespace-only textnodes should be ignored.
-
-
Method Detail
-
canBeCompared
public boolean canBeCompared(Element controlElement, Element testElement)
Description copied from interface:ElementSelectorDetermine whether the two elements from the control and test XML can be compared.- Specified by:
canBeComparedin interfaceElementSelector- Parameters:
controlElement- element of the control XMLtestElement- element of the test XML- Returns:
- true if the two elements can be compared
-
-