[
https://issues.apache.org/jira/browse/DAFFODIL-2660?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17519011#comment-17519011
]
Mike Beckerle commented on DAFFODIL-2660:
-----------------------------------------
The OGF DFDL Workgroup call on 2022-04-07 discussed this and decided that
conservatively only "." should be allowed as an expression in
assert/discriminator and that "." refers to the value of the prefix length
viewing that prefix as a quasi-element.
Since a type can be used both as a prefixLengthType and as the type of an
element in the same schema, when that type is used as a regular element's type
the "." refers to the value of the element. When used as a prefixLengthType the
"." refers to the value of the prefix.
For the DFDL workgroup, this will be written up and considered for inclusion as
an Erratum on the DFDL v1.0 spec.
> prefixLengthType needs to evaluate asserts before using the prefix value
> ------------------------------------------------------------------------
>
> Key: DAFFODIL-2660
> URL: https://issues.apache.org/jira/browse/DAFFODIL-2660
> Project: Daffodil
> Issue Type: Bug
> Components: Back End, Diagnostics
> Affects Versions: 3.2.1
> Reporter: Mike Beckerle
> Priority: Major
> Fix For: 3.4.0
>
>
> We want to use lengthKind 'prefixed' and avoid the complexity of
> dfdl:outputValueCalc and dfdl:lengthKind 'explicit' with a length expression.
> But... using prefixed is much less robust, because the prefix value is
> currently used to pull data (when parsing) and assertions expressed on the
> prefixLengthType seem to never be evaluated.
> E.g., below we have a prefixed-length field named 'payload'.
> The range is only 0 to 32768, but this assert never executes.
> {code:java}
> ...
> <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> {code}
> The assert needs to execute before the prefix value is used as a length.
--
This message was sent by Atlassian Jira
(v8.20.1#820001)