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

choice in hidden group unexpected behavior



    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 3.4.0
    • None
    • Middle "End"
    • None


      I'm not 100% certain this is a bug. 

      Given a choice like this:


      <group name="optionalLineEnding">


            <element name="zlString" type="xs:string" 

                   dfdl:lengthKind="explicit" dfdl:length="0" 

                  dfdl:outputValueCalc='{ "" }'






      When this is used as a hiddenGroupRef, my understanding is that the choice should default to the first choice branch, which is an element with an outputValueCalc, so should default to "" which is valid, Then unparse, which will output the terminator. 

      But what I am seeing instead is that it does not output anything. 

      If I replace the 2nd choice branch (the empty sequence) with a zero-length element, but one not having a terminator, then the behavior is as expected, when unparsing, the terminator is output.


            <element name="zlString2" type="xs:string" 

                   dfdl:lengthKind="explicit" dfdl:length="0" 

                  dfdl:outputValueCalc='{ "" }'/>


      With the empty sequence, this unparse is behaving as if the group was not hidden, since there is no <zlString/> element in the infoset, unparsing chooses the other branch that doesn't need there to be a zlString in the infoset; hence, not unparsing a zlString element and hence, no terminator is unparsed. 

      With the element zlString2, the unparse behaves as if it had to make a choice between zlString element, and zlString2 element, and since neither is in the infoset, it chooses the first choice branch because nothing is forcing it to select any specific choice branch, and so it picks the first, unparses that, and we get the terminator we want. 

      So, why this might not be a bug.

      Imagine we had two different uses of the group above. One is hidden, one is not. 

      There's only one implementation of the shared group. 

      So its behavior cannot be different depending on hidden or not. It has to do the same thing either way. 

      This is not the very last thing in the schema. There is more data after this terminator, and more elements in the infoset after this hidden group. 

      Hence, when compiling the schema, the choice branch determination is going to behave here as if the group was NOT hidden. It will choose the empty sequence when there is no zlString element in the infoset, regardless of the fact that the group is hidden, because it has to do the same thing hidden or not hidden.

      So, is this a bug? Do groups need to behave differently if hidden than not? 

      I believe it is a bug for anything to be expecting a zlString in the infoset for unparsing, and analysis in the optimizers of the compiler is faulty if it is treating this choice resolver situation the same, for hidden/not-hidden, as it must not be taking the fact that zlString is hidden into account. 

      So, by that reasoning, this is a bug. 





            Unassigned Unassigned
            mbeckerle Mike Beckerle
            0 Vote for this issue
            2 Start watching this issue