So, to your earlier question, an element of an array can have an expression that refers to other elements relative to its own index.
The function dfdl:occursIndex() returns the index "i" of the current innermost array element. (Array elements can be nested. This index is of the currently innermost array element that is in scope around the expression.) This can be used to refer to the same positioned element in another array, a prior sibling, or when unparsing, even a subsequent sibling. ________________________________ From: Costello, Roger L. <[email protected]> Sent: Sunday, December 23, 2018 5:23:29 PM To: [email protected] Subject: How does array[i] refer to the i'th item in another array? Hello DFDL community, My DFDL schema has this array: <xs:element name="Section_Header" maxOccurs="unbounded" dfdl:occursCountKind="expression" dfdl:occursCount="{../../Headers/File_Header/Number_of_Sections_in_the_Section_Table}"> Each <Section_Header> element contains information about a following <Section> element. Later in the schema is an array of <Section> elements. The array must have the same number of elements as Section_Header. I can easily specify the number of occurrences of this second array: <xs:element name="Section" maxOccurs="unbounded" dfdl:occursCountKind="expression" dfdl:occursCount="{ fn:count(../Section_Header) }"> I would like to reference elements within <Section_Header>. For example, there is a <Size_of_Raw_Data> element that I would like to use: If the i'th <Section_Header> element has <Size_of_Raw_Data>100</Size_of_Raw_Data>, then the i'th <Section> element must have a size of 100 bytes. How does the i'th <Section> element refer to the i'th <Section_Header> element? I think that I need something like this: <xs:element name="Section" maxOccurs="unbounded" dfdl:occursCountKind="expression" dfdl:occursCount="{ fn:count(../Section_Header) }" type="xs:hexBinary" dfdl:lengthKind="explicit" dfdl:lengthUnits="bytes" dfdl:length="../Section_Header[i]/Size_of_Raw_Data"/> Of course, the above value of dfdl:length is not correct, as [i] is not defined. So, how to do this? /Roger
