Uploaded image for project: 'Daffodil'
  1. Daffodil
  2. DAFFODIL-2297

Runtime SDE - zero-length binary integer gets no value. Should be a parse error

    XMLWordPrintableJSON

Details

    • Bug
    • Status: In Progress
    • Major
    • Resolution: Unresolved
    • 2.5.0
    • 4.0.0
    • Back End

    Description

      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:

      Runtime Schema Definition Error: Expression Evaluation Error: Element {}spare does not have a value.

      That comes from this definition:

      <xs:element name="spare" type="vmfgi:padding" dfdl:length="{ $l16common:l16WordPaddingBits }"/>

      The type vmfgi:padding has an assert that checks that the padding field contains the value 0.

       

      <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>

      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.

       

       

       

      Attachments

        Activity

          People

            okilo@tresys.com Olabusayo Kilo
            mbeckerle Mike Beckerle
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: