Looks like a bug to me.

Upon parsing, the row element should have two children field elements, one "a", 
the other "" (empty string).

On unparse, the separator before this second element is being suppressed, which 
I think it should not given that the field element, which is an unbounded 
array, has occursCountKind 'expression'.

The dfdl:separatorSuppressionPolicy should be ignored here because the only 
element in the sequence is field, and it has dfdl:occursCountKind='expression'

Created ticket https://issues.apache.org/jira/browse/DAFFODIL-2262

________________________________
From: Costello, Roger L. <coste...@mitre.org>
Sent: Monday, December 30, 2019 12:41 PM
To: users@daffodil.apache.org <users@daffodil.apache.org>
Subject: Bug: Daffodil does not have the implied behavior of 
dfdl:separatorSuppression="never" when dfdl:occursCountKind="expression"


Hi Folks,



Section 14.2.2 of the DFDL specification says this:



When dfdl:occursCountKind is 'expression' the number of occurrences is given by 
dfdl:occursCount and exactly that many occurrences are always expected along 
with their separators. The dfdl:separatorSuppressionPolicy is not applicable 
and the implied behaviour is 'never'.



The below schema has dfdl:occursCountKind="expression" and yet I am not 
observing the expected implied behavior of 'never'. That is, with this input:



header1,header2
a,



After parsing and then unparsing I get this:



header1,header2
a



Notice that the comma separator has been suppressed after ‘a’ but the 
specification says that the implied behavior is to never suppress the 
separator. This seems like a bug to me. Do you agree?  /Roger



<xs:element name="input">
    <xs:complexType>
        <xs:sequence dfdl:separator="%NL;" dfdl:separatorPosition="infix">
            <xs:element name="header">
                <xs:complexType>
                    <xs:sequence dfdl:separator="," 
dfdl:separatorPosition="infix"  dfdl:separatorSuppressionPolicy="anyEmpty">
                        <xs:element name="title" maxOccurs="unbounded" 
type="xs:string" />
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
            <xs:element name="row" maxOccurs="unbounded">
                <xs:complexType>
                    <xs:sequence dfdl:separator="," 
dfdl:separatorPosition="infix" dfdl:separatorSuppressionPolicy="anyEmpty">
                        <xs:element name="field" maxOccurs="unbounded" 
type="xs:string"
                            dfdl:occursCount="{ fn:count(../../header/title) }"
                            dfdl:occursCountKind="expression" />
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
        </xs:sequence>
    </xs:complexType>
</xs:element>




Reply via email to