dfdl:prefixLengthType with dfdl:assert on it

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>

Hi Mike Unfortunately I can't test this with IBM DFDL, as one of our limitations is that you can't specify assert or discriminator on a global element or global type, and by definition a prefix length type must be global [:-)] . However, although the DFDL spec does not explicitly say that assert or discriminator can be used on such a simple type, that's not the way the spec usually works; it usually says when you can't do something. So, given that there is no wording to say you can't, both are allowed. Regards Steve Hanson IBM Integration, Hursley, UK Architect, IBM DFDL Co-Chair, OGF DFDL Working Group smh@uk.ibm.com<mailto:smh@uk.ibm.com> tel:+44-7717-378890 Note: I work Tuesday to Friday -----Original Message----- From: Mike Beckerle <mbeckerle@apache.org<mailto:Mike%20Beckerle%20%3cmbeckerle@apache.org%3e>> Reply-To: mbeckerle@apache.org<mailto:mbeckerle@apache.org> To: DFDL-WG <dfdl-wg@ogf.org<mailto:DFDL-WG%20%3cdfdl-wg@ogf.org%3e>> Subject: [EXTERNAL] [DFDL-WG] dfdl:prefixLengthType with dfdl:assert on it Date: Tue, 15 Feb 2022 17:02:31 -0500 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/<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> -- dfdl-wg mailing list dfdl-wg@ogf.org<mailto:dfdl-wg@ogf.org> https://www.ogf.org/mailman/listinfo/dfdl-wg

I think we have to perhaps specify what a path expression like "." means if on the simple type definition used as a prefixLengthType. It doesn't refer to the element itself, but to the "quasi-element" (that's what we call them internally to Daffodil) which is the prefix value itself. At least that's what I need it to refer to for the example to work and cause an assertion failure on bad prefix values. On Wed, Feb 16, 2022 at 12:36 PM Steve Hanson <smh@uk.ibm.com> wrote:
Hi Mike
Unfortunately I can't test this with IBM DFDL, as one of our limitations is that you can't specify assert or discriminator on a global element or global type, and by definition a prefix length type must be global [image: :-)]. However, although the DFDL spec does not explicitly say that assert or discriminator *can* be used on such a simple type, that's not the way the spec usually works; it usually says when you *can't* do something. So, given that there is no wording to say you can't, both are allowed.
Regards
Steve Hanson
IBM Integration, Hursley, UK Architect, IBM DFDL Co-Chair, OGF DFDL Working Group smh@uk.ibm.com tel:+44-7717-378890 Note: I work Tuesday to Friday
-----Original Message----- *From*: Mike Beckerle <mbeckerle@apache.org <Mike%20Beckerle%20%3cmbeckerle@apache.org%3e>> *Reply-To*: mbeckerle@apache.org *To*: DFDL-WG <dfdl-wg@ogf.org <DFDL-WG%20%3cdfdl-wg@ogf.org%3e>> *Subject*: [EXTERNAL] [DFDL-WG] dfdl:prefixLengthType with dfdl:assert on it *Date*: Tue, 15 Feb 2022 17:02:31 -0500
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>
--
dfdl-wg mailing list
dfdl-wg@ogf.org

Yes good point about relative paths. Need to cover what '..' means too. IBM DFDL also uses a dummy element for handling the prefix length case. I will add to next WG call agenda. Regards Steve Hanson IBM Integration, Hursley, UK Architect, IBM DFDL Co-Chair, OGF DFDL Working Group smh@uk.ibm.com<mailto:smh@uk.ibm.com> tel:+44-7717-378890 Note: I work Tuesday to Friday -----Original Message----- From: Mike Beckerle <mbeckerle@apache.org<mailto:Mike%20Beckerle%20%3cmbeckerle@apache.org%3e>> Reply-To: mbeckerle@apache.org<mailto:mbeckerle@apache.org> To: Steve Hanson <smh@uk.ibm.com<mailto:Steve%20Hanson%20%3csmh@uk.ibm.com%3e>> Cc: dfdl-wg@ogf.org <dfdl-wg@ogf.org<mailto:%22dfdl-wg@ogf.org%22%20%3cdfdl-wg@ogf.org%3e>> Subject: [EXTERNAL] Re: [DFDL-WG] dfdl:prefixLengthType with dfdl:assert on it Date: Wed, 16 Feb 2022 12:52:51 -0500 I think we have to perhaps specify what a path expression like "." means if on the simple type definition used as a prefixLengthType. It doesn't refer to the element itself, but to the "quasi-element" (that's what ZjQcmQRYFpfptBannerStart This Message Is From an External Sender This message came from outside your organization. ZjQcmQRYFpfptBannerEnd I think we have to perhaps specify what a path expression like "." means if on the simple type definition used as a prefixLengthType. It doesn't refer to the element itself, but to the "quasi-element" (that's what we call them internally to Daffodil) which is the prefix value itself. At least that's what I need it to refer to for the example to work and cause an assertion failure on bad prefix values. On Wed, Feb 16, 2022 at 12:36 PM Steve Hanson <smh@uk.ibm.com<mailto:smh@uk.ibm.com>> wrote: Hi Mike Unfortunately I can't test this with IBM DFDL, as one of our limitations is that you can't specify assert or discriminator on a global element or global type, and by definition a prefix length type must be global[:-)]. However, although the DFDL spec does not explicitly say that assert or discriminatorcan be used on such a simple type, that's not the way the spec usually works; it usually says when youcan't do something. So, given that there is no wording to say you can't, both are allowed. Regards Steve Hanson IBM Integration, Hursley, UK Architect, IBM DFDL Co-Chair, OGF DFDL Working Group smh@uk.ibm.com<mailto:smh@uk.ibm.com> tel:+44-7717-378890 Note: I work Tuesday to Friday -----Original Message----- From: Mike Beckerle <mbeckerle@apache.org<mailto:Mike%20Beckerle%20%3cmbeckerle@apache.org%3e>> Reply-To: mbeckerle@apache.org<mailto:mbeckerle@apache.org> To: DFDL-WG <dfdl-wg@ogf.org<mailto:DFDL-WG%20%3cdfdl-wg@ogf.org%3e>> Subject: [EXTERNAL] [DFDL-WG] dfdl:prefixLengthType with dfdl:assert on it Date: Tue, 15 Feb 2022 17:02:31 -0500 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/<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> -- dfdl-wg mailing list dfdl-wg@ogf.org<mailto:dfdl-wg@ogf.org> https://www.ogf.org/mailman/listinfo/dfdl-wg<https://www.ogf.org/mailman/listinfo/dfdl-wg>
participants (2)
-
Mike Beckerle
-
Steve Hanson