Hi all! I am having a strange behavior with Apache Daffodil and would like to check with you if this is normal.
Here is the XSD (named Foo.dfdl.xsd): START =================== <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:dfdl="http://www.ogf.org/dfdl/dfdl-1.0/" xmlns:foo="https://www.foo.com" targetNamespace="https://www.foo.com" elementFormDefault="unqualified"> <xs:include schemaLocation="org/apache/daffodil/xsd/DFDLGeneralFormat.dfdl.xsd" /> <xs:annotation> <xs:appinfo source="http://www.ogf.org/dfdl/"> <dfdl:format ref="foo:GeneralFormat" /> </xs:appinfo> </xs:annotation> <xs:element name="ret" type="foo:Foo" /> <xs:complexType name="Foo"> <xs:sequence dfdl:separator="%NL;"> <xs:element name="a" type="xs:string" minOccurs="0" dfdl:length="1" dfdl:lengthKind="explicit"> <xs:annotation> <xs:appinfo source="http://www.ogf.org/dfdl/"> <dfdl:discriminator testKind="pattern" testPattern="a" /> </xs:appinfo> </xs:annotation> </xs:element> <xs:element name="bar" type="foo:Bar" minOccurs="0" maxOccurs="2" /> <xs:element name="z" type="xs:string" minOccurs="0" dfdl:length="1" dfdl:lengthKind="explicit"> <xs:annotation> <xs:appinfo source="http://www.ogf.org/dfdl/"> <dfdl:discriminator testKind="pattern" testPattern="z" /> </xs:appinfo> </xs:annotation> </xs:element> </xs:sequence> </xs:complexType> <xs:complexType name="Bar"> <xs:sequence dfdl:separator="%NL;"> <xs:element name="b" type="xs:string" minOccurs="0" dfdl:length="1" dfdl:lengthKind="explicit"> <xs:annotation> <xs:appinfo source="http://www.ogf.org/dfdl/"> <dfdl:discriminator testKind="pattern" testPattern="b" /> </xs:appinfo> </xs:annotation> </xs:element> <xs:element name="c" type="xs:string" minOccurs="0" dfdl:length="1" dfdl:lengthKind="explicit"> <xs:annotation> <xs:appinfo source="http://www.ogf.org/dfdl/"> <dfdl:discriminator testKind="pattern" testPattern="c" /> </xs:appinfo> </xs:annotation> </xs:element> <xs:element name="d" type="xs:string" minOccurs="0" dfdl:length="1" dfdl:lengthKind="explicit"> <xs:annotation> <xs:appinfo source="http://www.ogf.org/dfdl/"> <dfdl:discriminator testKind="pattern" testPattern="d" /> </xs:appinfo> </xs:annotation> </xs:element> </xs:sequence> </xs:complexType> </xs:schema> END =================== Here is a sample file to be parsed (named foo.txt): START =================== a b c z END =================== Here is the final output of the command: daffodil -t parse --schema Foo.dfdl.xsd foo.txt START =================== <?xml version="1.0" encoding="UTF-8" ?> <foo:ret xmlns:foo="https://www.foo.com"> <a>a</a> <bar> <b>b</b> <c>c</c> </bar> </foo:ret> diff: No differences failure: Parse Error: Separator '%NL;' not found Schema context: sequence[1] Location line 19 column 6 in file:/Users/pgrandjean/Development/ti-scalaxb-ticketing/src/main/resources/dfdl/Foo.dfdl.xsd Data location was preceding byte 6 ----------------------------------------------------------------- 21 <?xml version="1.0" encoding="UTF-8" ?> <foo:ret xmlns:foo="https://www.foo.com"> <a>a</a> <bar> <b>b</b> <c>c</c> </bar> </foo:ret> [warning] Left over data. Consumed 48 bit(s) with at least 16 bit(s) remaining. END =================== The line with "z" is not parsed and Apache Daffodil complains it cannot find separator %NL at Foo level (= line 19) What I would expect: - Bar.d cannot be parsed => OK since it is optional, only one instance of Bar parsed (instead of 2) - End type Bar parsing & go back to Foo type - parse %NL - parse z If I remove maxOccurs="2" from element Foo.bar, then it works. Could you please help me understand? Patrick.