To follow-up on my question ...
If I try to compute the value of the length field during unparsing:
<xs:element name="length" type="xs:nonNegativeInteger"
dfdl:lengthKind="explicit"
dfdl:length="2"
dfdl:lengthUnits="bytes"
dfdl:outputValueCalc="{dfdl:contentLength(../personInfo, 'bytes')}"
/>
then I get a "circularly deadlocked" error during unparsing:
[error] Runtime Schema Definition Error: Expressions/Unparsers are circularly
deadlocked (mutually defined):
- SimpleTypeRetryUnparserSuspendableOperation for length
- target length for personInfo expr <EvaluatableExpression eName='personInfo'
expr='{../length}' />
/Roger
From: Roger L Costello <[email protected]>
Sent: Monday, March 29, 2021 9:32 AM
To: [email protected]
Subject: Seeking an example that illustrates the need for dfdl:contentLength
Hi Folks,
My (binary) input file consists of:
* Two bytes (little endian) indicating the length of the following person
data
* Person info, consisting of:
* Person name, null terminated
* Person digital identifier, 20 hex digits
At the end of this message is my DFDL schema. It parses the input fine. Parsing
generates this XML:
<SimpleDataFormat>
<length>29</length>
<personInfo>
<name>John Doe</name>
<digital-id>AE6E4D1209F17B460503904FAD297B31E9CF6362</digital-id>
</personInfo>
</SimpleDataFormat>
It also unparses fine.
There was no need to use contentLength. How can I modify/add-to the example so
that contentLength must be used to properly unparse? I want the example to
require this:
<xs:element name="length" type="xs:nonNegativeInteger"
dfdl:lengthKind="explicit"
dfdl:length="2"
dfdl:lengthUnits="bytes"
dfdl:outputValueCalc='{ dfdl:contentLength(../personInfo) }'
/>
<xs:element name="personInfo"
dfdl:lengthKind="explicit"
dfdl:length="{../length}"
>
...
</xs:element>
Here is my current DFDL schema:
<xs:element name="SimpleDataFormat"
dfdl:lengthKind="implicit"
>
<xs:complexType>
<xs:sequence>
<xs:element name="length" type="xs:nonNegativeInteger"
dfdl:lengthKind="explicit"
dfdl:length="2"
dfdl:lengthUnits="bytes"
/>
<xs:element name="personInfo"
dfdl:lengthKind="explicit"
dfdl:length="{../length}"
>
<xs:complexType>
<xs:sequence>
<xs:element name="name" type="xs:string"
dfdl:encoding="ASCII"
dfdl:terminator="%NUL;"
dfdl:emptyValueDelimiterPolicy="terminator"
dfdl:lengthKind="delimited"
/>
<xs:element name="digital-id" type="xs:hexBinary"
dfdl:lengthKind="explicit"
dfdl:length="20"
dfdl:lengthUnits="bytes"
/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>