You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@daffodil.apache.org by "Mike Beckerle (Jira)" <ji...@apache.org> on 2022/03/13 04:43:00 UTC

[jira] [Created] (DAFFODIL-2672) type unions don't get proper length

Mike Beckerle created DAFFODIL-2672:
---------------------------------------

             Summary: type unions don't get proper length
                 Key: DAFFODIL-2672
                 URL: https://issues.apache.org/jira/browse/DAFFODIL-2672
             Project: Daffodil
          Issue Type: Bug
          Components: Middle &quot;End&quot;
    Affects Versions: 3.2.1
            Reporter: Mike Beckerle


Consider this:

 

 
{code:java}
<dfdl:format ... lengthKind="implicit".../>

<element name="seconds" type="tns:second"
  dfdl:lengthKind="explicit" dfdl:length="6"
  dfdl:lengthUnits="bits" dfdl:alignment="1"
  dfdl:alignmentUnits="bits"/>

<simpleType name="second">
  <union>
  <simpleType>
    <restriction base="tns:checkedInt">
      <maxInclusive value="59"/>
    </restriction>
  </simpleType>
  <simpleType>
    <restriction base="tns:checkedInt">
      <enumeration value="63"/>
    </restriction>
  </simpleType>
  </union>
</simpleType> {code}
The above, the parser ends up going for a 32-bit integer, when the intention is for it to parse a 6 bit integer.

 

This, however, works:

 
{code:java}
<element name="seconds" type="tns:second"
dfdl:lengthUnits="bits" dfdl:alignment="1"
dfdl:alignmentUnits="bits"/>

<simpleType name="second" dfdl:lengthKind="explicit" dfdl:length="6">
  <union>
  <simpleType>
    <restriction base="tns:checkedInt">
      <maxInclusive value="59"/>
    </restriction>
  </simpleType>
  <simpleType>
    <restriction base="tns:checkedInt">
      <enumeration value="63"/>
    </restriction>
  </simpleType>
  </union>
</simpleType> {code}
So it seems that the combining of properties when the type is a union does not propagate the element's properties and combine them with the properties on each of the union types. Rather, the simpleType ends up ignoring the element's properties which specify explicit length of 6 bits, and instead takes the default format length of 32 (because this is a xs:unsignedInt ultimately). 

 



--
This message was sent by Atlassian Jira
(v8.20.1#820001)