
Another question: For asserts and discriminators with testKind pattern, if a given annotation point in the schema has both, do we execute the pattern discrminators first or use schema definition order? If the latter, do we still evaluate the pattern discriminators even if the pattern asserts fail? On Wed, Jan 8, 2025 at 1:36 PM Mike Beckerle <mbeckerle@apache.org> wrote:
Given this DFDL annotation on an xs:sequence
<xs:appinfo source="http://www.ogf.org/dfdl/"> <dfdl:assert test="..." /> <dfdl:discriminator test="..." /> <dfdl:assert test="..." /> </xs:appinfo>
The spec seems silent about the evaluation order among these 3 statement annotations. Let's call them A, B, C.
First, the spec makes it clear that the discriminator B could be evaluated earlier than either assertion, and even before some of the sequence content. This is to allow optimization by a DFDL implementation. The spec is also clear that even if the parse of the sequence content fails, discriminator B is evaluated (with the infoset being the state at the time of the failure). Again this is to ensure the behavior matches that of an optimizing DFDL implementation.
But let's assume an implementation does no such optimization.
I believe these evaluation orders are legal for the 3 statements after the sequence content has been parsed:
A, B, C - if A fails, we do know B must still be evaluated.
B, A, C - this is the minimum sort of hoist/optimization, doing the discriminator before the asserts.
Questions:
1) Are any other orders of evaluation allowed?
2) If evaluation of A fails, do we still evaluate assertion C? (My hope is the answer here is no, because that allows consecutive asserts to build on each other's assumptions. But the spec is unclear.)
3) Can users depend on the failure of A to generate a message output? (ex: if the assert has a message attribute, can we state that this message will somehow be exhibited or logged by the implementation, unless the failure is suppressed by backtracking at a point of uncertainty)
If A fails, the spec does say that B must still be evaluated.
But if A fails, will C be evaluated?
Mike Beckerle Apache Daffodil PMC | daffodil.apache.org OGF DFDL Workgroup Co-Chair | www.ogf.org/ogf/doku.php/standards/dfdl/dfdl Owl Cyber Defense | www.owlcyberdefense.com