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

Steve Lawrence commented on DAFFODIL-1217:
------------------------------------------

The requirement mentioned in the code states:

> To avoid ambiguity when parsing, optional elements and variable-occurrence 
> arrays
> where the minimum number of occurrences is zero cannot have alignment 
> properties
> different from the items that follow them. It is a schema definition error 
> otherwise.

The check takes place in the 
[checkForAlignmentAmbiguity|https://github.com/apache/daffodil/blob/main/daffodil-core/src/main/scala/org/apache/daffodil/core/dsom/ElementBase.scala#L1337-L1353]
 function.

I see two reasons why this test might be failing. 

1. In the mentioned function, we only perform the check on an element if 
"isOptional" is true. In this test, the element is an array with minOccurs="0", 
which is not considered optional. To fix this, we can probably just change the 
check to look for "minOccurs == 0" instead of "isOptional".
2. In the mentioned function, we look at "laterSiblings" and see if any have a 
different alignment than the current element. However, "laterSiblings" only 
looks at lexical siblings. It does not look at elements that could logically 
appear after this one. In this test, that is what happens--the min zero 
occurrence array is the last child of a complex type, and the element with a 
different alignment is the first sibling of its parent. So laterSiblings is 
empty and the check passes.

I'm not sure how easy it is to fix item 2. In fact, I wonder if we even should? 
Maybe it is correct to only inspect lexical siblings for this check? Keep in 
mind, this check isn't even a requirement in the current specification since 
actual formats like MIL-STD-2045 require optional elements to be followed by 
elements with different alignment.

> Alignment test not appropriately issuing warning for optional occurrence.
> -------------------------------------------------------------------------
>
>                 Key: DAFFODIL-1217
>                 URL: https://issues.apache.org/jira/browse/DAFFODIL-1217
>             Project: Daffodil
>          Issue Type: Bug
>          Components: Diagnostics, Usability
>            Reporter: Taylor Wise
>            Priority: Major
>              Labels: verified
>             Fix For: 3.5.0
>
>
> The expected warning according to the test is the following:
> element.e is an optional element or a variable-occurrence array and its 
> alignment (2) is not the same as element.one's alignment (1)
> No error or warning is received.
> edu.illinois.ncsa.daffodil.section12.aligned_data  
> under the 'new' folder: test_alignmentOptionalElem03()



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

Reply via email to