[ 
https://issues.apache.org/jira/browse/DAFFODIL-2802?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17713659#comment-17713659
 ] 

Mike Beckerle commented on DAFFODIL-2802:
-----------------------------------------

In a discussion on 2023-04-18, mike beckerle observed that in the tdml file, 
dfdl:separatorSuppressionPolicy="never" on the inner sequence should not be 
ignored.

Note that the dfdl:occursCountKind for the ie3 element is 'implicit' (from the 
default format). 

The optional ie3 element has minOccurs 0, maxOccurs 1, and since that is NOT 
the only thing in the sequence, it requires a separator.

The interpretation of the DFDL spec goes like this:

Section 14.2.3 on unparsing separators with suppression says:

    _When dfdl:occursCountKind is 'implicit' the occurrences in the augmented 
Infoset are output along with their separators, according to the 
dfdl:separatorSuppressionPolicy of the sequence._

Now, there are no occurrences of ie3, and so the phrasing of the above suggests 
that therefore nothing is output, but the latter part of the sentence, about 
examining the separatorSuppressionPolicy needs to be taken into consideration. 

If 'never' is the policy, then since the ie3 optional element is potentially 
trailing within its group (it's declared last, and note that this is ONLY about 
the sequence INSIDE the array, not the sequence containing the array) the table 
below says 

    _Unparse N occurrences ~ unparse (maxOccurs -- N) trailing zero-length 
occurrences_

N is zero, so this reduces to we should unparse 1 trailing zero-length 
occurance, and as this is infix separated, and this is not the only thing in 
the sequence (2nd child) that means it will unparse the infix separator and 
then nothing more (i.e., a zero length occurrence). 

This unparse of the infix separator is not happening. 

So the analysis is somehow incorrect. The fact that the ie3 element is 
optional, not repeating, is possibly a source of the issue since the DFDL spec 
language refers to "array" and we often distinguish array from optional when 
that distinction is required. In this case we need to collapse the 
optional/array distinction and treat ie3 as an array with 'never' separator 
suppression. 

In this case the language in the DFDL spec is not completely clear, but it 
seems that an optional trailing element within a sequence needs to be treated 
no differently from a multi-element "array".

 

 

 

> Array with optional element followed by scalar optional element drops 
> separator
> -------------------------------------------------------------------------------
>
>                 Key: DAFFODIL-2802
>                 URL: https://issues.apache.org/jira/browse/DAFFODIL-2802
>             Project: Daffodil
>          Issue Type: Bug
>          Components: Back End
>    Affects Versions: 3.4.0
>            Reporter: Olabusayo Kilo
>            Priority: Blocker
>             Fix For: 3.5.0
>
>         Attachments: TestSeparatorSuppression.scala, suppressedseparator.tdml
>
>
> An array with a trailing optional element followed by a scalar optional 
> element loses a separator when both elements are missing during an unparse. 
> The trace indicates, there's a 
> SuppressableSeparatorUnparserSuspendableOperation for the scalar element (se5 
> in the example schema). My initial guess was that the last element in the 
> array was being treated as a trailing element, but we need it to not be 
> treated that way.
>  
> For completeness, you get the following error from TDML on the 2nd test
> {noformat}
> output data length 12 for '/1/2/3.5//6
> ' doesn't match expected length 13 for '/1/2/3.5///6
> '{noformat}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to