Peter Katlic created DAFFODIL-2879:
--------------------------------------
Summary: Group evaluation throwing ClassCastException for optional
element
Key: DAFFODIL-2879
URL: https://issues.apache.org/jira/browse/DAFFODIL-2879
Project: Daffodil
Issue Type: Bug
Components: Back End
Affects Versions: 3.6.0
Reporter: Peter Katlic
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:
{code:java}
<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>{code}
Sequence schema:
{code:java}
<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>{code}
Uncommenting
{code:java}
<xs:group ref="countGroup"/>{code}
and commenting out
{code:java}
<xs:element name="count" type="xs:int" dfdl:representation="binary"
dfdl:inputValueCalc="{ fn:count(../ex:foo) }"/>{code}
will produce the following error:
{code:java}
java.lang.ClassCastException: class
org.apache.daffodil.runtime1.infoset.DISimple cannot be cast to class
org.apache.daffodil.runtime1.infoset.DIArray{code}
It seems as if the optional is evaluated as a DownArray instead of a
DownElement.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)