Hi Mike,
* Simply modify the length of the logical data. Now your pre-existing
length is incorrect and must be computed.
So, you are saying that (for unparsing) the value of the <length> element
should be computed from the size of the <personInfo> element, right?
But, but, but, ...
How to set (for parsing) dfdl:length for the <personInfo> element?
dfdl:length="{../length}" gives a "circularly deadlocked" error.
/Roger
From: Beckerle, Mike <[email protected]>
Sent: Monday, March 29, 2021 11:46 AM
To: [email protected]
Subject: [EXT] Re: Seeking an example that illustrates the need for
dfdl:contentLength
Simply modify the length of the logical data. Now your pre existing length is
incorrect and must be computed.
Or start from just the logical data. How did you get the length in the first
place?
It required knowledge that the string is delimited by a single nul byte, as
opposed to having a prefixed length, or having its length implied by the
overall length minus 20 which is the length of the identifier.
You have to know the format to compute the length.
________________________________
From: Roger L Costello <[email protected]<mailto:[email protected]>>
Sent: Monday, March 29, 2021 7:32:01 AM
To: [email protected]<mailto:[email protected]>
<[email protected]<mailto:[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>