Uploaded image for project: 'Daffodil'
  1. Daffodil
  2. DAFFODIL-2374

Choice with dispatch on variable getting reset when parsing potentially nil elements

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.7.0
    • 3.0.0
    • Back End
    • None

    Description

      Ran into this while developing schemas for a customer.

      The schema for this scenario looks something like this:

      <dfdl:defineVariable name="var" defaultValue="false" />

      ....

      <dfdl:setVariable ref="var" value="true" />

      ...

      <xs:choice dfdl:choiceDispatchKey="{ $var }">

        <xs:sequence dfdl:choiceBranchKey="true">

          <xs:element name="name" type="xs:string" nillable="true">

        </xs:sequence>

      </xs:choice>

       

      What I believe is happening is that the nillable element is creates a mark in PState, which then gets reset as this element in the data is not nil. This causes PState to reset back to the mark, which also triggers any variables that were changed in the current scope to reset. In this case, the changes that have been tracked is the setVariable on var and the readVariable on var for the choice dispatch. So when reset gets called the variable is getting reset back to its initial default state of false.

       

      I believe the fix for this is to simply push a new list to the changedVariablesStack whenever we create a new mark and pop the stack after resetting any changed variables, but I have not spent a lot of time on it. It fixes the issue I have and does not break any existing tests though.

      Attachments

        Activity

          People

            Unassigned Unassigned
            jadams_tresys Josh Adams
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: