I found a solution that seems to work. See below. Any suggestions for improving it is welcome.
<xs:element name="test"> <xs:complexType> <xs:sequence> <!-- The decimal value of the first bit of the input should be wrapped in an <A> tag if the decimal value of the next 4 bits equals 7 and the decimal value of the 4 bits after that equals 9, or the decimal value of the next 4 bits equals 7 and the decimal value of the 4 bits after that equals 10, otherwise the first bit of the input should be wrapped in a <B> tag. The below is not looking ahead. Assume the input is ACD. If C is not equal to 7 and D is not equal to 9 or 10, then we realize that we made an error, back up, and try the next branch of the choice. --> <xs:choice> <xs:sequence> <xs:element name='A' type="unsignedint1"/> <xs:element name='C' type="unsignedint4"> <xs:annotation> <xs:appinfo source="http://www.ogf.org/dfdl/"> <dfdl:assert>{. eq 7}</dfdl:assert> </xs:appinfo> </xs:annotation> </xs:element> <xs:element name='D' type="unsignedint4"> <xs:annotation> <xs:appinfo source="http://www.ogf.org/dfdl/"> <dfdl:assert>{(. eq 9) or (. eq 10)}</dfdl:assert> </xs:appinfo> </xs:annotation> </xs:element> </xs:sequence> <xs:sequence> <xs:element name='B' type="unsignedint1"/> <xs:element name='C' type="unsignedint4"/> <xs:element name='D' type="unsignedint4"/> </xs:sequence> </xs:choice> </xs:sequence> </xs:complexType> </xs:element> -----Original Message----- From: Roger L Costello <coste...@mitre.org> Sent: Thursday, June 13, 2024 7:10 AM To: users@daffodil.apache.org Subject: Warning: Counterintuitive placement detected Hi Folks, I need my DFDL to look-ahead: The decimal value of the first bit of the input should be wrapped in an <A> tag if the decimal value of the next 4 bits equals 7 and the decimal value of the 4 bits after that equals 9, or the decimal value of the next 4 bits equals 7 and the decimal value of the 4 bits after that equals 10, otherwise the first bit of the input should be wrapped in a <B> tag. Below is my attempt at implementing this. Daffodil gives this warning message: Schema Definition Warning: Counterintuitive placement detected. Wrap the discriminator or assert in an empty sequence to evaluate before the contents. (id: discouragedDiscriminatorPlacement) Here is my DFDL: <xs:element name="test"> <xs:complexType> <xs:sequence> <xs:choice> <xs:sequence> <xs:annotation> <xs:appinfo source="http://www.ogf.org/dfdl/"> <dfdl:discriminator testKind="pattern" testPattern="(.x7x9)|(.x7xA)" /> </xs:appinfo> </xs:annotation> <xs:element name='A' type="unsignedint1"/> </xs:sequence> <xs:sequence> <xs:element name='B' type="unsignedint1"/> </xs:sequence> </xs:choice> <xs:element name='C' type="unsignedint4"/> <xs:element name='D' type="unsignedint4"/> </xs:sequence> </xs:complexType> </xs:element>