[ 
https://issues.apache.org/jira/browse/DAFFODIL-2277?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17037576#comment-17037576
 ] 

Mike Beckerle commented on DAFFODIL-2277:
-----------------------------------------

Actually this issue also appears for elements where both assert/discrim with 
testKind expression, AND setVariable are executed AFTER the element is parsed.

The rationale for this was to allow a kind of forward+downward reference from 
discriminator expressions so that authors could express the complex structure 
with the fields upon which one discriminates embedded within that structure.

(Digresssion about choiceDispatchKey - If we're going to allow limited 
forward+downward reference from discriminators, then we should allow the same 
from choiceDispatchKey expressions, which are explicitly limited to 
backward-only reference.  If the semantics of choiceDispatchKey were to 
evaluate each branch in order, and then AFTER that evaluate the choice dispatch 
key expression and see if it matches the choice branch key value(s) for that 
branch, if so, select the branch..... Also allow for optimizations that 
evaluate the choiceDispatchKey expression earlier than that.... That would be 
consistent with the power we currently give discriminator expressions. 

This still wouldn't solve the forward-reference on parse problem (Seen in 
Link16 format) more generally though - where reference would be allowed forward 
even past the scope of the element/model group.)

The concrete set of warnings applies to statement annotations that are 
setVariable or are assert/discriminator with testKind 'expression'.

The specific deprecation is if these statement annotations appear lexically 
before, but are going to execute after:
 * directly on an element
 * directly on a choice
 * directly on a sequence which has other non-annotation children

Silencing the deprecation warning would either be implementation dependent 
(tunable) or would require the author to use the workaround.

 

> Warning needed for misplaced discriminators
> -------------------------------------------
>
>                 Key: DAFFODIL-2277
>                 URL: https://issues.apache.org/jira/browse/DAFFODIL-2277
>             Project: Daffodil
>          Issue Type: Bug
>          Components: Front End
>    Affects Versions: 2.5.0
>            Reporter: Mike Beckerle
>            Priority: Major
>             Fix For: 2.6.0
>
>
> Daffodil should issue a warning, possibly even an SDE, about misplaced 
> discriminators:
> I observed that many things with discriminators are coded like this:
>  ```
>  <xs:sequence>
>  <xs:annotation><xs:appinfo source="http://www.ogf.org/dfdl/";>
>  <dfdl:discriminator ....../>
>  </xs:appinfo></xs:annotation>
>  ....rest of sequence...
>  </xs:sequence>
>  ```
>  So, it's quite unintuitive, but that discriminator will be executed AFTER 
> the rest of the sequence.
>  I'm not sure why we decided that is how DFDL should work, but 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:
>  ```
>  <xs:sequence>
>  <xs:sequence>
>  <xs:annotation><xs:appinfo source="http://www.ogf.org/dfdl/";>
>  <dfdl:discriminator ....../>
>  </xs:appinfo></xs:annotation>
>  </xs:sequence>
>  ....rest of sequence...
>  </xs:sequence>
>  ```
>  Daffodil should 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.
> See: [https://github.com/DFDLSchemas/PCAP/issues/4]



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to