The issue is that element B can be 50 or fewer strings. And although
100, 200, etc. look like numbers, they are also completely valid
strings. So Daffodil will just keep consuming every line after the first
three numbers as B elements. Daffodil still expects a separator followed
by some C's, but we hit the end of the data and error out saying we were
looking for that separator.
So we need to somehow tell Daffodil to stop looking for B's. One
solution here is to add an assertion to test that each B element does
not look like a not a number. The DFDL expression language doesn't have
a good way to test if a string is a number or not, but a regex pattern
test could work:
<xs:element name="B" type="xs:string" maxOccurs="50"
dfdl:occursCountKind="implicit">
<xs:annotation>
<xs:appinfo source="http://www.ogf.org/dfdl/">
<dfdl:assert testKind="pattern" testPattern=".*[^0-9].*" />
</xs:appinfo>
</xs:annotation>
</xs:element>
This regular expression says that all B element must contains at least
one character that is not a numeric digit. So when Daffodil gets to
"100", the assertion will fail since it is all numbers, and we'll stop
parsing B's and start looking for C's.
- Steve
On 5/10/19 8:00 AM, Costello, Roger L. wrote:
> Hello DFDL community,
>
> My input file consists of exactly 3 integers, each on a new line, followed by
> an
> arbitrary number of strings, again, each on a new line, followed by a number
> of
> integers, the number being determined by the first integer in the file. For
> example:
>
> 6
> 1
> 2
> Banana
> Orange
> Apple
> Grape
> 100
> 200
> 300
> 400
> 500
> 600
>
> Below is my DFDL schema. It generates this error:
>
> *[error] Parse Error: Failed to parse infix separator. Cause: Parse Error:
> Separator '%NL;' not found.*
>
> Why is that error is being generated? How to fix the DFDL schema? /Roger
>
> <xs:elementname="input">
> <xs:complexType>
> <xs:sequencedfdl:separator="%NL;"dfdl:separatorPosition="infix">
> <xs:elementname="A"type="xs:integer"
> minOccurs="3"maxOccurs="3"
> dfdl:occursCountKind="fixed"/>
> <xs:elementname="B"type="xs:string"maxOccurs="50"
> dfdl:occursCountKind="implicit"/>
> <xs:elementname="C"type="xs:integer"maxOccurs="unbounded"
> dfdl:occursCountKind="expression"
> dfdl:occursCount="{ ../A[1] }"/>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
>