Closed mbeckerle closed 4 years ago
Actually, PCAP should be rewritten to use choices with choiceDispatchKey and choiceBranchKey exclusively. There's no reason for backtracking/discrimination at all in this sort of format.
Using choiceDispatchKey is always the preferred style. PCAP was not done this way initially just because Daffodil didn't have the choiceDispatchKey feature implemented in DFDL at the time PCAP schema was first created.
In general, example schemas should all be revisited for this issue.
Fixed in 86df108e881e634ff7e9ae19eb96c80f2293fa89
I observed that many things with discriminators are coded like this:
So, it's quite unintuitive, but that discriminator will be executed AFTER the rest of the sequence. That is: Daffodil does not hoist discriminators expressed this way so they execute as early as possible. It just does them after.
DFDL was designed to allow discriminators to reach into the model group/complex type where they are expressed, so that they can discriminate on elements within the structure where the discriminator is expressed. These are parse-time forward+downward references as far as the lexical appearance of the discriminator is concerned.
To get the discriminator to run BEFORE the rest of the sequence, which is typically what you want from a discriminator, you must nest it within ANOTHER sequence inside the first like so:
I am going to suggest that Daffodil issue warnings about the former style (which can also occur on choices), since it is so unintuitive.
But for PCAP, all the discrimnators have to change.