Uploaded image for project: 'Daffodil'
  1. Daffodil
  2. DFDL-1082

DPath: Errors with substring function

XMLWordPrintableJSON

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Normal Normal
    • s15
    • s15
    • None
    • None

      NOTE: this issue is with the "serializatoin-with-dpath2" branch, not the current 0.15.0 branch.

      There seem to be a few problems with the substring function. All tests are located in daffodil-test/src/test/resources/edu/illinois/ncsa/daffodil/section23/dfdl_functions/Functions.tdml and daffodil-test/src/test/scala/edu/illinois/ncsa/daffodil/section23/dfdl_expressions/TestDFDLExpressions.scala

      1. When using the version of substring with 3 arguments, XPath has the 3rd argument as the length of the substring. It looks like the DPath branch is using the 3rd argument as the index of the end of the substring instead. See test_substring_02, test_substring_04, test_substring_06.

      2. With a starting index of 0 or a negative number XPath returns characters in positions greater than 0. The DPath branch gives a StringIndexOutOfBoundsException. See test_substring_03.

      3. XPath rounds numbers using fn:round which rounds to the nearest whole number. It seems like DPath rounded 4.7 to 4 instead of 5 in test_substring_06.

      4. If the starting index is greater than the length of the substring, XPath just returns an empty string. The DPath branch gives a StringIndexOutOfBoundsException. See test_substring_05.

      It doesn't seem like XPath ever gives an out of bounds exception or anything. It is very forgiving and will just return the empty string or whatever portion of the string fits.

              efinnegan Elizabeth Finnegan
              efinnegan Elizabeth Finnegan
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved:

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - Not Specified
                  Not Specified
                  Logged:
                  Time Spent - 37 minutes
                  37m