Description
This invalid schema causes an abort when trying to compile:
<?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:dfdl="http://www.ogf.org/dfdl/dfdl-1.0/"> <xs:include schemaLocation="org/apache/daffodil/xsd/DFDLGeneralFormat.dfdl.xsd"/> <xs:annotation> <xs:appinfo source="http://www.ogf.org/dfdl/"> <dfdl:format ref="GeneralFormat" lengthKind="delimited" /> </xs:appinfo> </xs:annotation> <xs:element name="root"> <xs:complexType> <xs:sequence> <xs:element name="arr1" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="field1" type="xs:string" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="arr2" type="xs:string" maxOccurs="unbounded" dfdl:occursCountKind="expression" dfdl:occursCount="{ xs:unsignedLong(../arr1[DNE]/field1) }" /> </xs:sequence> </xs:complexType> </xs:element> </xs:schema>
The dfdl:occursCount expression has an invalid path--the DNE index step does not exist. But instead of getting a helpful error message, we get this abort when compiling:
org.apache.daffodil.exceptions.Abort: Invariant broken: RelativePathExpression.this.steps2.apply(0).isInstanceOf[org.apache.daffodil.dpath.Up]
org.apache.daffodil.exceptions.Assert$.abort(Assert.scala:137)
org.apache.daffodil.dpath.RelativePathExpression.adjustedSteps$lzycompute(Expression.scala:820)
org.apache.daffodil.dpath.RelativePathExpression.adjustedSteps(Expression.scala:813)
org.apache.daffodil.dpath.RelativePathExpression.compiledDPath$lzycompute(Expression.scala:827)
at org.apache.daffodil.exceptions.Assert$.abort(Assert.scala:137)
at org.apache.daffodil.dpath.RelativePathExpression.adjustedSteps$lzycompute(Expression.scala:820)
at org.apache.daffodil.dpath.RelativePathExpression.adjustedSteps(Expression.scala:813)
at org.apache.daffodil.dpath.RelativePathExpression.compiledDPath$lzycompute(Expression.scala:827)
at org.apache.daffodil.dpath.RelativePathExpression.compiledDPath(Expression.scala:826)
at org.apache.daffodil.dpath.PredicateExpression.compiledDPath$lzycompute(Expression.scala:1294)
at org.apache.daffodil.dpath.PredicateExpression.compiledDPath(Expression.scala:1294)
at org.apache.daffodil.dpath.NamedStep.downwardStep$lzycompute(Expression.scala:1181)
at org.apache.daffodil.dpath.NamedStep.downwardStep(Expression.scala:1176)
at org.apache.daffodil.dpath.NamedStep.compiledDPath$lzycompute(Expression.scala:1167)
at org.apache.daffodil.dpath.NamedStep.compiledDPath(Expression.scala:1166)
at org.apache.daffodil.dpath.RelativePathExpression.$anonfun$compiledDPath$3(Expression.scala:828)
...
This seems to be specific to the dfdl:occursCount expression. We should get an error about invalid path step "DNE".
I've tested this same bad expression with dfdl:inputValueCalc and dfdl:length, and get an appropriate error message. Changing DNE to 1 also allows the schema compile.