Ahhhhh! With the use of the "-V limited" option the second approach you presented is spot-on perfect. Thank you Steve! Now I need to completely rework things (which is a good thing).
/Roger -----Original Message----- From: Steve Lawrence <slawre...@apache.org> Sent: Thursday, August 4, 2022 10:07 AM To: users@daffodil.apache.org Subject: [EXT] Re: Why am I getting this error when I use the nilValue in the data? The issue in this case is that the lengthPattern does not include your nilValue. So in your first example, the pattern length does not match anything, your MessageIdentifier is essentially the empty string, and so there's is nothing to check for the nil value. Things go off the rails from there. One simple fix is to modify the lengthPattern to match your nilValue, for example: dfdl:lengthPattern="[A-Z]{2,20}|-" So it matches your A-Z string OR a single hyphen. That said, related to your other question about well-formed vs valid, a maybe better way to write this would be to not use lengthPattern at all and just rely on normal delimiter scanning to find the second field. But then add a restriction to ensure the field is A-Z, for example: <xs:element name="MessageIdentifier" nillable="true" dfdl:nilKind="literalValue" dfdl:nilValue="-"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:pattern value="[A-Z]{2,20}"/> </xs:restriction> </xs:simpleType> </xs:element> Now the schema supports a distinction between well-formed and valid, and the pattern does not need to care about what makes the field nil. - Steve On 8/3/22 1:30 PM, Roger L Costello wrote: > Hi Folks, > > I have a field that is 2-20 characters in length. If no data is available, > then > the field is to be populated with a hyphen. Below is my element declaration > for > the field (it’s the middle element). When I run the DFDL schema with this > input: > > John Doe/-/Sally Smith > > I get this error message: > > [error] Parse Error: Failed to parse infix separator. Cause: Parse Error: > Separator '/' not found > > Why am I getting that error? /Roger > > <xs:element name="Test"> > <xs:complexType> > <xs:sequence dfdl:separator="/" dfdl:separatorPosition="infix"> > <xs:element name="A" type="xs:string" /> > <xs:element name="MessageIdentifier" type="xs:string" > nillable="true" > dfdl:nilKind="literalValue" > dfdl:nilValue="-" > dfdl:lengthKind="pattern" > dfdl:lengthPattern="[A-Z]{2,20}"> > </xs:element> > <xs:element name="B" type="xs:string" /> > </xs:sequence> > </xs:complexType> > </xs:element> >