[DFDL-WG] dfdl:prefixLengthType with dfdl:assert on it

Mike Beckerle mbeckerle at apache.org
Tue Feb 15 17:02:31 EST 2022


I believe the DFDL spec does not specify whether the prefixLengthType for
an element of lengthKind 'prefixed' can have assertions, and
if those assertions are evaluated, and when.

Consider this example below. We really want the assert on the bufferPayload
type to be evaluated before the length computed from the prefix is used as
a length because we'd like good diagnostic behavior that points out that
the prefix value is way out of realistic range.

In many formats we see 4-byte length prefixes, but the range of values for
specific fields is relatively tiny, often even just 1 to 100. Enforcing
this via the assert expressed on the prefixLengthType's simpleType
definition makes this easy.

I could go either way on whether a prefixLengthType can carry a
discriminator. But an assert should definitely be allowed.

        ...
        <complexType>
          <sequence>
            <element name="payload" type="xs:hexBinary"
                     dfdl:lengthKind="prefixed"
                     dfdl:prefixIncludesPrefixLength="no"
                     dfdl:prefixLengthType="p8:bufferPayload"/>
          </sequence>
        </complexType>
        ...


<simpleType name="bufferPayload">
  <annotation>
    <appinfo source="http://www.ogf.org/dfdl/">      <dfdl:assert>{
dfdl:checkConstraints(.) }</dfdl:assert>
    </appinfo>
  </annotation>
  <restriction base="p8:unsignedLong">
    <minInclusive value="0"/>
    <maxInclusive value="32768"/>
  </restriction>
</simpleType>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.ogf.org/pipermail/dfdl-wg/attachments/20220215/f4f9c154/attachment.html>


More information about the dfdl-wg mailing list