I think your interpretation is correct.

It may be possible to detect an error if the branch is all fixed length stuff 
and is longer or shorter than the choiceLength.


In fact, I think there is a DFDL language issue here. It's not really a bug as 
much as a missing feature. I think there should be a choiceLengthKind="max" 
meaning padded to the fixed length of the longest branch, and the branches must 
all be all fixed length stuff. Otherwise users have to figure out how long a 
branch is, to figure out the maximum, which is really error prone.


I'm not suggesting you implement this feature right now, but the same logic is 
required to check for the case where the explicit length is not correct (too 
long for all the branches - a SDW warning perhaps, or too-short, which would be 
an SDE) as would be needed to implement my hypothetical "max" feature.


This feature is primarily to support Cobol-style data structures, which often 
make use of this notion of variants which are padded to the max length.


I have no specific example data. You might search web. The Cobol construct that 
gives rise to these sorts of choices is the Cobol keyword REDEFINES. You might 
find examples on web if you search for cobol redefines examples.

________________________________
From: Adams, Joshua <jad...@tresys.com>
Sent: Monday, May 6, 2019 1:21:50 PM
To: dev@daffodil.apache.org
Cc: Sood, Harinder
Subject: choiceLengthKind='explicit'

Wanted to make sure I am understanding the spec for choiceLengthKind correctly:

 - 'explicit' means that the branches of the choice are always filled to the 
fixed
length specified by dfdl:choiceLength, so the ChoiceContent region is fixed
length regardless of which branch appears.

And under choiceLength:

 - Specifies the length of the choice in bytes, so the ChoiceContent region is
fixed length regardless of which branch appears. A ChoiceUnused region
is therefore possible which when unparsing is filled with dfdl:fillByte.

So, essentially this is saying that a choice with choiceLengthKind='explicit' 
has no branches that will exceed the length specified in choiceLength, correct? 
 And, that on unparse, any branch that is less than choiceLength will simply be 
padded by dfdl:fillByte.  Assuming that is correct, it shouldn't take much work 
to get this working in Daffodil.

That being said, is there any sample data around? I searched through the 
daffodil repo as well as some of the schema projects and did not find any.

Josh

Reply via email to