[
https://issues.apache.org/jira/browse/DAFFODIL-2324?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17691755#comment-17691755
]
Steve Lawrence commented on DAFFODIL-2324:
------------------------------------------
It's possible this has been fixed, though I don't recall that change. Here's
the logic where we figure out what the default branch is:
https://github.com/apache/daffodil/blob/main/daffodil-core/src/main/scala/org/apache/daffodil/core/runtime1/ChoiceTermRuntime1Mixin.scala#L94-L121
Looking at that, it seems like maybe we need a test where it should be picking
the optDefault or optOpen branches because they appear first in the choice, but
because an optEmpty is found in a later branch it is selected instead.
I'm not familiar enough with this code to know what makes a branch empty vs
open vs canUnparseIfHidden, though. Maybe the empty group ref should just
changed to an empty sequence, e.g. <sequence />. But maybe that's straying too
far from the original test, which did have true/false hidden group refs like
this.
[~mbeckerle] or [~jadams], any ideas? You two are more familiar with
open/closed/empty stuff I think.
> Unparser choice branch selection not conformant to DFDL standard
> ----------------------------------------------------------------
>
> Key: DAFFODIL-2324
> URL: https://issues.apache.org/jira/browse/DAFFODIL-2324
> Project: Daffodil
> Issue Type: Bug
> Components: Back End
> Affects Versions: 2.5.0
> Reporter: Mike Beckerle
> Assignee: Mike McGann
> Priority: Major
>
> Erratum 5.60 of the DFDL spec clarifies how choice branch selection works.
> Our current schemas that use presence bits flags use a structure like this:
> {code:java}
> <choice>
> <sequence>
> <sequence dfdl:hiddenGroupRef="PI_true"/>
>
> <sequence>
> <element name="foo" minOccurs="0" ...../>
> <element name="bar" minOccurs="0" ..../>
> </sequence>
>
> <sequence dfdl:hiddenGroupRef="PI_false"/>
>
> </choice>{code}
> We depend on the fact that by default this chooses the PI_false hidden group
> when the incoming infoset event is not for a foo nor bar element.
> The DFDL spec says (with the Erratum/Clarification) that if we want PI_false
> to be chosen, then we must flip the order of these two choice branches.
> Daffodil is currently preferring the "more empty" of the two branches, and so
> seleting PI_false, rather than just taking the first possibly empty branch.
> Once we fix this behavior to conform to the spec., we will have to update
> DFDL schemas that use this behavior, and actually flip these branches.
> Based on that, we may want to put a compatibility flag into daffodil. Or
> perhaps a feature to generate a warning whenever there is more than one empty
> choice branch that *could* be selected, if the current functionality selects
> a default branch that is not the first possibly empty branch thena warning
> would be issued indicating that the branches should be reordered.
> The only schema I know of that is sensitive to this bug is mil-std-6017/VMF
> (and variants thereof).
>
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)