The most common use cases come from COBOL REDEFINES where a typical union of record types is made the fixed length of the longest one. Everything in such data is typically fixed length. These are also almost always going to have dfdl:choiceDispatchKey - because it is typical that there is a field to distinguish the various record formats.
C language unions have the same behavior, but those aren't often used to define record structures in files, whereas in COBOL they almost always ARE used to define record structures in files. ________________________________ From: Costello, Roger L. <coste...@mitre.org> Sent: Monday, June 3, 2019 1:54:43 PM To: users@daffodil.apache.org Subject: Got a good use case for dfdl:choiceLengthKind? Hello DFDL community, I am trying to understand choiceLengthKind. Do you have a compelling use case for it? I tried the following for dfdl:choiceLengthKind="explicit" The input contains a person’s name. If the name is less than 10 characters, then it’s just the firstname. Otherwise, it’s the firstname and last name. <xs:element name="input"> <xs:complexType> <xs:choice dfdl:choiceLengthKind="explicit"> <xs:element name="firstname" type="xs:string" dfdl:choiceLength="10" /> <xs:element name="firstname-lastname" type="xs:string" dfdl:choiceLength="20" /> </xs:choice> </xs:complexType> </xs:element> For reasons I do not understand, the first choice (the firstname element) is always selected. This input: John Produces this XML: <input> <firstname>John</firstname> </input> And this input: John Alexander Smith Produces this XML: <input> <firstname>John Alexander Smith</firstname> </input> Why is that? /Roger