You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@daffodil.apache.org by "Steve Lawrence (Jira)" <ji...@apache.org> on 2021/08/09 14:58:00 UTC

[jira] [Created] (DAFFODIL-2553) dfdl:occursCountKind aborts with invalid path expression to array

Steve Lawrence created DAFFODIL-2553:
----------------------------------------

             Summary: dfdl:occursCountKind aborts with invalid path expression to array
                 Key: DAFFODIL-2553
                 URL: https://issues.apache.org/jira/browse/DAFFODIL-2553
             Project: Daffodil
          Issue Type: Bug
          Components: Front End
    Affects Versions: 2.4.0
            Reporter: Steve Lawrence


This invalid schema causes an abort when trying to compile:
{code:xml}
<?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>
{code}

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:
{code}
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)
...
{code}

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. 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)