Description
A user reported an error when unparsing in the array combinator.
The schema looks something like this:
... <xs:sequence> <xs:element name="foo" ... /> <xs:element name="bar" minOccurs="1" maxOccurs="6" dfdl:occursCountKind="implicit"> <xs:complexType> <xs:sequence> <xs:annotation> <xs:appinfo source="http://www.ogf.org/dfdl/"> <dfdl:discriminator>{ expression }</dfdl:discriminator> </xs:appinfo> </xs:annotation> <xs:sequence dfdl:hiddenGroupRef="hiddenGrouPRef" /> <xs:group ref="someGroupWithRequiredElement"/> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> ...
With XML that looks like this:
<foo>...</foo>
So the bar element is an array that requires at least one instance, but the infoset has zero instances. Trying to unparse this resultsin the following:
org.apache.daffodil.exceptions.Abort: Invariant broken: event.isStart.&&(event.node.isInstanceOf[org.apache.daffodil.infoset.DIArray])
org.apache.daffodil.exceptions.Assert$.abort(Assert.scala:129)
org.apache.daffodil.exceptions.Assert$.abort(Assert.scala:129)
org.apache.daffodil.processors.unparsers.ArrayCombinatorUnparser.unparse(ElementKindUnparsers.scala:254)
org.apache.daffodil.processors.unparsers.Unparser$class.unparse1(Unparser.scala:72)
...
The expected result is to return an UnaparseError about expecting a start array event but not getting one. I think the assertion just needs to be changed to an UnparseError, since there is clearly a case where the assertion doesn't hold.