You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@daffodil.apache.org by "Steve Lawrence (Jira)" <ji...@apache.org> on 2023/06/21 14:10:00 UTC

[jira] [Updated] (DAFFODIL-2297) Runtime SDE - zero-length binary integer gets no value. Should be a parse error

     [ https://issues.apache.org/jira/browse/DAFFODIL-2297?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Steve Lawrence updated DAFFODIL-2297:
-------------------------------------
    Fix Version/s: 3.5.1
                       (was: 3.5.0)

> Runtime SDE - zero-length binary integer gets no value.  Should be a parse error
> --------------------------------------------------------------------------------
>
>                 Key: DAFFODIL-2297
>                 URL: https://issues.apache.org/jira/browse/DAFFODIL-2297
>             Project: Daffodil
>          Issue Type: Bug
>          Components: Back End
>    Affects Versions: 2.5.0
>            Reporter: Mike Beckerle
>            Assignee: Mike Beckerle
>            Priority: Major
>              Labels: beginner
>             Fix For: 3.5.1
>
>
> I have a schema which has a padding field that can have between 0 and 5 bits in it.
> The number of padding bits is controlled by an external variable which defaults to 2.
> If I set it to 0 bits, I get an error:
> {code:java}
> Runtime Schema Definition Error: Expression Evaluation Error: Element {}spare does not have a value.{code}
> That comes from this definition:
> {code:java}
> <xs:element name="spare" type="vmfgi:padding" dfdl:length="{ $l16common:l16WordPaddingBits }"/>{code}
> The type vmfgi:padding has an assert that checks that the padding field contains the value 0.
>  
> {code:java}
> <xs:simpleType name="padding" dfdl:lengthKind="explicit">
>   <xs:annotation>
>    <xs:appinfo source="http://www.ogf.org/dfdl/">
>      <dfdl:assert test="{ . eq 0 }" />
>    </xs:appinfo>
>   </xs:annotation>
>  <xs:restriction base="xs:unsignedInt">
>    <xs:enumeration value="0" />
>  </xs:restriction>
> </xs:simpleType>{code}
> Arguably, there shouldn't be an assert here. Just the restriction that it is 0 valued.
> But ignoring that for a minute. If I did need this padding element to have a value, it will get a value if there are any bits parsed, but it has no value at all if the length is zero bits.
> That requires me to model these spare fields as a complex type so that I can have a choice between no spare field, and having one, based on the padding bits value being 0 or greater than zero.
> I could do that. But arguably, a zero-bit-long integer should have value 0 shouldn't it? That certainly would simplify things.
> I have requested a clarification from the DFDL Workgroup. However, a runtime SDE for this clearly seems wrong. The failure should be either a parse error because zero bits is not a legal representation, or there should be no error and the integer value should be 0.
>  
>  
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)