document #316

Action 242 part 1 - valueLength and contentLength clarifications

Added by Michael Beckerle over 2 years ago. Updated about 1 year ago.

Status:submitted Start date:08/02/2016
Priority:Normal Due date:
Assignee:- % Done:


Target version:DFDL v1.0
Document Type:Proposed Recommendation


(From the email thread in discussion of Action 242. There are 3 separate issue trackers associated with Action 242's resolution. This is the first one.)

1) we need the concept of valueLength of a complexType which excludes the ElementUnused region, so that contentLength of a complexType can include the ElementUnused region.

The example that motivates this is from PCAP where there are length fields that aren't the exact length while unparsing but contain other factors:

<element name="len" type="xs:int" dfdl:outputValueCalc="{ fn:max(dfdl:valueLength(../ctElem, 'bytes'), 60) }" .../>
<element name="ctElem" dfdl:length="{ ../len }" .../>

In the above, we have a complex type element that has a minimum length of 60. So when unparsing if the actual length of the choice/sequence that is the model group of the ctElem is of length less than 60, we need to fill out the ElementUnused region of the DFDL grammar so as to achieve the min length of 60 bytes.

If the dfdl:outputValueCalc of the len element was to call dfdl:contentLength, then we would have a circularity.

Erratum 5.18 clarifies that length expressions are evaluated when unparsing to produce the target length that is used for pad/fill.

This concept must be extended to complex types so that it also addresses the ElementUnused region that can follow the model group of a complex type.

To clarify all this I suggest the DFDL data grammar must be changed as follows:

ComplexNormalRep = LeftFraming PrefixLength ComplexContent RightFraming # Unchanged. Just here for context
ComplexContent = ComplexValue ElementUnused
ComplexValue = Sequence | Choice

The above change basically moves ELementUnused out of the ComplexNormalRep production into a separate ComplexContent production, and distinguishes ComplexValue from ComplexContent.

With the above grammar rule changes, I believe the spec as modified for Erratum 5.18 will be correct. (Everyplace where lengthKind explicit is lumped in with prefixed etc must be broken out, as it is a different case. )

2) Spec says escapeCharacter, escapeBlockStart, and excapeBlockEnd contribute to the content length of an element. (Note: escapeEscapeCharacter is missing this stipulation and should be made consistent.)

However, I believe this is incorrect. These all contribute to the value length, that is to say, they appear within the "SimpleValue | NilLogicalValue" region of the grammar.

3) Definition of dfdl:valueLength must be changed to specify that it returns the length of the ComplexValue region for complex types, and excludes any filling of the ElementUnused region.

The definition of dfdl:contentLength is acceptable as is.

Related issues

related to DFDL WG - document #196: dfdl:valueLength function - unclear what it does public comment 09/26/2013


Updated by Michael Beckerle about 1 year ago

  • Target version set to DFDL v1.0

Also available in: Atom PDF