mbeckerle commented on a change in pull request #157: Add support for type 
aware checking in the TDML runner
URL: https://github.com/apache/incubator-daffodil/pull/157#discussion_r241901592
 
 

 ##########
 File path: daffodil-lib/src/main/scala/org/apache/daffodil/xml/XMLUtils.scala
 ##########
 @@ -716,24 +724,33 @@ object XMLUtils {
     res
   }
 
-  def compareAndReport(trimmedExpected: Node, actualNoAttrs: Node, 
ignoreProcInstr: Boolean = true) = {
-    if (trimmedExpected != actualNoAttrs) {
-      val expString = trimmedExpected.toString
-      val actString = actualNoAttrs.toString
-      if (expString != actString) {
-        val diffs = XMLUtils.computeDiff(trimmedExpected, actualNoAttrs, 
ignoreProcInstr)
-        if (diffs.length > 0) {
-          throw new Exception("""
+  /**
+   * Prepares an XML node for diff comparison
+   **/
+  private def prepareForDiffComparison(n: Node): Node = {
+    val noComments = removeComments(n)
+    val noPCData = convertPCDataToText(noComments)
+    val combinedText = coalesceAllAdjacentTextNodes(noPCData)
+    val noMixedWS = removeMixedWhitespace(combinedText)
+    noMixedWS
+  }
+
+  def compareAndReport(expected: Node, actual: Node, ignoreProcInstr: Boolean 
= true) = {
+    val expectedMinimized = prepareForDiffComparison(expected)
+    val actualMinimized = prepareForDiffComparison(actual)
+    val diffs = XMLUtils.computeDiff(expectedMinimized, actualMinimized, 
ignoreProcInstr)
+    if (diffs.length > 0) {
+      throw new Exception("""
 
 Review comment:
   Generic Exception being thrown. Should this be an exception class that 
indicates by class name that this is a Diff being reported?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to