Thx Steve.

I'll give it a shot.
Will probably have some follow up questions when I reach that bridge.

Attila


On Wed, Jul 21, 2021 at 9:52 AM Steve Lawrence <slawre...@apache.org> wrote:

> You cannot dynamically set maxOccurs--that has to be either a static
> number or "unbounded". This is a restriction of XML Schema that DFDL is
> based off of.
>
> But Daffodil does support what you're trying to do . First, you'll want
> to set maxOccurs="unbounded" (since we don't know how many parameter
> instances there might be). Bbut then we can use the
> dfdl:occursCountKind="expression" and dfdl:occursCount properties to
> evaluate an expression at parse time to set the number of occurrences to
> the value of the third field. For example:
>
>   ...
>   <xs:element name="field3" type="xs:int" ... />
>   <xs:element name="parameters" type="..." maxOccurs="unbounded"
>     dfdl:occursCountKind="expression"
>     dfdl:occursCount="{ ../field3 }" ... />
>   ...
>
> So we parse field3 to an integer and then use that value in an
> expression to determine the number of occurrences of the parameters array.
>
>
> On 7/21/21 8:04 AM, Horvath, Attila J CTR (USA) wrote:
> > ALCON - see attached PDF version of this message
> >
> > I have a Character Separated Values [CSV] ASCII input file where:
> >
> > - fields are ASCII STX character [0x02] separated
> >
> >    - variable number of fields per below
> >
> > - records are ASCII DC4 character [0x14] terminated
> >
> > - file is ASCII EOT character [0x04] terminated
> >
> > In following sample excerpt, highlighted in YELLOW is last record of
> data file.
> >
> > 3rd field [31 30] specifies 10 fields to follow each STX [0x02]
> delimited,
> >
> > followed by record and file terminators [0x14 0x04] respectively...
> >
> > Is it possible to read the 3rd field ['10'], save it via
> [*_dfdl:lengthKind_*
> > and/or *_dfdl:defineVariable_*] as "NUM_FIELDS" and pass that value to
> > 'maxOccurs' attribute on per record basis?
> >
> > EG:...
> >
> > <xs:element name="parameters" maxOccurs=NUM_FIELDS minOccurs="1">
> >
> > ...
> >
> > </xs:element>
> >
> > Thx in advance
> >
> > Attila
> >
>
>

Reply via email to