@@ -19,7 +19,7 @@ package software.purpledragon.xml.compare
19
19
import software .purpledragon .xml .compare .options .DiffOption ._
20
20
import software .purpledragon .xml .compare .options .DiffOptions
21
21
22
- import scala .xml .{Node , Text }
22
+ import scala .xml .{Atom , Node }
23
23
24
24
/**
25
25
* Utility for comparing XML documents.
@@ -79,8 +79,9 @@ object XmlCompare {
79
79
}
80
80
81
81
private def compareText (left : Node , right : Node , options : DiffOptions , path : Seq [String ]): XmlDiff = {
82
- val leftText = left.child.collect({ case t : Text => t }).map(_.text.trim).mkString
83
- val rightText = right.child.collect({ case t : Text => t }).map(_.text.trim).mkString
82
+ def extractText (node : Node ): String = node.child.collect({ case a : Atom [_] => a }).map(_.text.trim).mkString
83
+ val leftText = extractText(left)
84
+ val rightText = extractText(right)
84
85
85
86
if (leftText != rightText) {
86
87
XmlDiffers (" different text" , leftText, rightText, extendPath(path, left))
@@ -90,8 +91,8 @@ object XmlCompare {
90
91
}
91
92
92
93
private def compareChildren (left : Node , right : Node , options : DiffOptions , path : Seq [String ]): XmlDiff = {
93
- val leftChildren = left.child.filterNot(_ .isInstanceOf [Text ])
94
- val rightChildren = right.child.filterNot(_ .isInstanceOf [Text ])
94
+ val leftChildren = left.child.filterNot(c => c .isInstanceOf [Atom [_] ])
95
+ val rightChildren = right.child.filterNot(c => c .isInstanceOf [Atom [_] ])
95
96
96
97
if (leftChildren.size != rightChildren.size) {
97
98
XmlDiffers (" different child count" , leftChildren.size, rightChildren.size, extendPath(path, left))
0 commit comments