> It may be possible to detect an error if the branch is all fixed > length stuff and is longer or shorter than the choiceLength.
Is it an error if a choice branch is shorter than dfdl:choiceLength? The specification mentions ChoiceUnused, which makes me think that's fine and unused unused data is just skipped on parse, and fillByte is used on unparse. Related to that, and while mentioning features that might be good to have, another feature that could be useful is some sort strict/lax policy for complex elements and choices that have specified lengths where the children do not consume the entire length. There are some cases where you might want to throw an SDE or validation error when used data is skipped and silently ignored. Maybe something like dfdl:unusedRegionPolicy with possible values if "allow", "error", "report", etc.. - Steve On 5/6/19 2:21 PM, Beckerle, Mike wrote: > 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 <[email protected]> > Sent: Monday, May 6, 2019 1:21:50 PM > To: [email protected] > 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 >
