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

Group evaluation throwing ClassCastException for optional element

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.6.0
    • 3.7.0
    • Back End
    • None

    Description

      A group is defined with an element using fn:count and referenced inside a sequence of array and optional elements. See the test count_21b in daffodil-test/src/test/resources/org/apache/daffodil/section23/dfdl_functions/Functions.tdml for an example.

      Group schema:

      <xs:group name="countGroup">
        <xs:sequence>
          <xs:element name="count" type="xs:int" dfdl:representation="binary" dfdl:inputValueCalc="{ fn:count(../ex:foo) }"/>
        </xs:sequence>
      </xs:group>

      Sequence schema:

      <xs:element name="arrayOptional">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="array">
              <xs:complexType>
                <xs:sequence>
                  <xs:element name="foo" type="xs:int" minOccurs="2" maxOccurs="2" dfdl:representation="binary"/>
                  <xs:group ref="countGroup"/>
                </xs:sequence>
              </xs:complexType>
            </xs:element>
            <xs:element name="optional">
              <xs:complexType>
                <xs:sequence>
                  <xs:element name="foo" type="xs:int" minOccurs="0" maxOccurs="1" dfdl:representation="binary"/>
                  <!-- throws ClassCastException, possible bug in Daffodil group evaluation -->
                  <!-- <xs:group ref="countGroup"/> -->
                  <xs:element name="count" type="xs:int" dfdl:representation="binary" dfdl:inputValueCalc="{ fn:count(../ex:foo) }"/>
                </xs:sequence>
              </xs:complexType>
            </xs:element>
          </xs:sequence>
        </xs:complexType>
      </xs:element>

      Uncommenting 

      <xs:group ref="countGroup"/>

       and commenting out 

      <xs:element name="count" type="xs:int" dfdl:representation="binary" dfdl:inputValueCalc="{ fn:count(../ex:foo) }"/>

       will produce the following error:

      java.lang.ClassCastException: class org.apache.daffodil.runtime1.infoset.DISimple cannot be cast to class org.apache.daffodil.runtime1.infoset.DIArray

      It seems as if the optional is evaluated as a DownArray instead of a DownElement.

      Attachments

        Activity

          People

            Unassigned Unassigned
            pkatlic Peter Katlic
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: