If you have a sequence (presumably same bug will occur for choice), and it begins with an annotation containing a dfdl:assert with testKind expression, then that is supposed to execute after the sequence children have been evaluated. This is consistent with elements and element refs, where an assert/discriminator with testKind=expression executes AFTER the element itself has been parsed.
This is confusing for sequences and choices because the assert will appear lexically before the rest of the sequence/choice children, but it executes after. (Perhaps we should issue a warning because the workaround - described below - is actually a better & clearer way to write a schema.)
(When testKind=pattern, they execute before)
Same goes for discriminators.
(Errata 3.25: Section 9. Evaluation Order for Statement Annotations)
Currently seems to execute before.
This is low priority because the workaround is easy. Just put the assert inside it's own sequence, and then insert that sequence below all the other things in the enclosing sequence.
You have to do this:
... where the assert was...
... new location for assert ...
So the annotation moves below, but is still first in the sequence that directly contains it, but that sequence is otherwise empty.