[
https://issues.apache.org/jira/browse/DAFFODIL-2297?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Olabusayo Kilo resolved DAFFODIL-2297.
--------------------------------------
Resolution: Fixed
Fixed in e4cc525f11af07033c2eaf06acc11d86b383233f
Note this change causes regressions in dfdl-nitf, dfdl-vmf and vmf-pmmc-dfdl
> 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: Olabusayo Kilo
> Priority: Major
> Labels: beginner
> Fix For: 4.0.0
>
>
> 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)