Hello DFDL community,
I found an exchange between Steve Lawrence and Lukasz Wiechec back in 2016 that
seems to suggest a possible solution to my question.
I created this group:
<xs:group name="current_Occurs_Count_Hidden_Group">
<xs:sequence>
<xs:element name="current_Occurs_Count" type="xs:nonNegativeInteger"
dfdl:inputValueCalc="{ dfdl:occursCount() }" />
</xs:sequence>
</xs:group>
I referenced that group from an element within the repeatable <Section_Wrapper>
element:
<xs:element name="Section_Wrapper"
maxOccurs="unbounded"
dfdl:occursCountKind="expression"
dfdl:occursCount="{
../Headers/File_Header/Number_of_Sections_in_the_Section_Table}">
<xs:complexType>
<xs:sequence>
<xs:sequence
dfdl:hiddenGroupRef="current_Occurs_Count_Hidden_Group" />
<xs:element name="Section" type="xs:hexBinary"
dfdl:lengthKind="explicit"
dfdl:lengthUnits="bytes"
dfdl:length="../../Section_Table/Section[position() eq
../current_Occurs_Count]/Size_of_Raw_Data" />
</xs:sequence>
</xs:complexType>
</xs:element>
However, that yields this error message:
'../../Section_Table/Section[position() eq
../current_Occurs_Count]/Size_of_Raw_Data' is not a valid value of union type
'DFDLNonNegativeInteger_Or_DFDLExpression'.
I don't know what that error message means.
What to do?
/Roger
From: Costello, Roger L.
Sent: Sunday, December 23, 2018 5:23 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