Skip to content

Commit

Permalink
Merge pull request #171 from PascalSchumacher/remove_redundant_instan…
Browse files Browse the repository at this point in the history
…ceOf_checks

org.w3c.dom.CDATASection extends org.w3c.dom.Text, so remove instance…
  • Loading branch information
bodewig authored Jan 1, 2020
2 parents 525f7f9 + 838efd9 commit 06dd7b6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import java.util.AbstractMap;
import java.util.Map;

import org.w3c.dom.CDATASection;
import org.w3c.dom.Element;
import org.w3c.dom.Text;
import org.w3c.dom.Node;
Expand Down Expand Up @@ -113,7 +112,7 @@ private static Map.Entry<Integer, Node> findNonText(NodeList nl, int current, in
}

private static boolean isText(Node n) {
return n instanceof Text || n instanceof CDATASection;
return n instanceof Text;
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
*/
package org.xmlunit.diff;

import org.w3c.dom.CDATASection;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.Text;
Expand Down Expand Up @@ -110,6 +109,6 @@ private Node getFirstEligibleChild(Node parent) {
}

private static boolean isText(Node n) {
return n instanceof Text || n instanceof CDATASection;
return n instanceof Text;
}
}
7 changes: 3 additions & 4 deletions xmlunit-core/src/main/java/org/xmlunit/util/Nodes.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import javax.xml.XMLConstants;
import javax.xml.namespace.QName;
import org.w3c.dom.Attr;
import org.w3c.dom.CDATASection;
import org.w3c.dom.CharacterData;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
Expand Down Expand Up @@ -58,7 +57,7 @@ public static QName getQName(Node n) {
public static String getMergedNestedText(Node n) {
StringBuilder sb = new StringBuilder();
for (Node child : new IterableNodeList(n.getChildNodes())) {
if (child instanceof Text || child instanceof CDATASection) {
if (child instanceof Text) {
String s = child.getNodeValue();
if (s != null) {
sb.append(s);
Expand Down Expand Up @@ -148,7 +147,7 @@ private static void handleWsRec(Node n, boolean normalize) {
for (Node child : new IterableNodeList(n.getChildNodes())) {
handleWsRec(child, normalize);
if (!(n instanceof Attr)
&& (child instanceof Text || child instanceof CDATASection)
&& (child instanceof Text)
&& child.getNodeValue().length() == 0) {
toRemove.add(child);
}
Expand Down Expand Up @@ -200,7 +199,7 @@ private static void stripECW(Node n) {
for (Node child : new IterableNodeList(n.getChildNodes())) {
stripECW(child);
if (!(n instanceof Attr)
&& (child instanceof Text || child instanceof CDATASection)
&& (child instanceof Text)
&& child.getNodeValue().trim().length() == 0) {
toRemove.add(child);
}
Expand Down

0 comments on commit 06dd7b6

Please sign in to comment.