You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@daffodil.apache.org by GitBox <gi...@apache.org> on 2018/12/14 22:00:45 UTC

[GitHub] stevedlawrence commented on a change in pull request #157: Add support for type aware checking in the TDML runner

stevedlawrence 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_r241903583
 
 

 ##########
 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:
   Yep, a better Exception makes sense. Will do.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services