Description
When used as a library, Daffodil does not produce a meaningfull error when provided with an invalid schema file.
Consider the following Scala program (Main.scala):
package com.tresys.test
import org.apache.daffodil.sapi.Daffodil
import org.apache.daffodil.sapi.Compiler
import org.apache.daffodil.util.Misc
import org.apache.daffodil.sapi.ProcessorFactory
import org.apache.daffodil.sapi.DataProcessor
import org.apache.daffodil.api.URISchemaSourceobject Main extends App {
override def main(args: Array[String]): Unit =Unknown macro: { val dfdlCompiler}}
The relevent portion of test.dfdl.xsd is:
<xs:element name="top" type="tns:nonexistant" />
where tns:nonexistant is never defined.
Executing Main.scala produces the following error:
Exception in thread "main" org.apache.daffodil.exceptions.Abort: Usage error: ProcessorFactory.this.isError.unary_!
org.apache.daffodil.exceptions.Assert$.abort(Assert.scala:129)
org.apache.daffodil.compiler.ProcessorFactory.$anonfun$onPath$1(Compiler.scala:131)
scala.util.DynamicVariable.withValue(DynamicVariable.scala:58)
org.apache.daffodil.ExecutionMode$.$anonfun$usingCompilerMode$1(ExecutionMode.scala:64)
at org.apache.daffodil.exceptions.Assert$.abort(Assert.scala:129)
at org.apache.daffodil.compiler.ProcessorFactory.$anonfun$onPath$1(Compiler.scala:131)
at scala.util.DynamicVariable.withValue(DynamicVariable.scala:58)
at org.apache.daffodil.ExecutionMode$.$anonfun$usingCompilerMode$1(ExecutionMode.scala:64)
at org.apache.daffodil.compiler.ProcessorFactory.onPath(Compiler.scala:130)
at org.apache.daffodil.sapi.ProcessorFactory.onPath(Daffodil.scala:273)
at com.tresys.test.Main$.main(Main.scala:16)
at com.tresys.test.Main.main(Main.scala)
For reference, using the CLI produces the following (good) error:
[error] Schema Definition Error: Error loading schema due to org.xml.sax.SAXParseException; systemId: file:/home/bsloane/workspace/Test/src/test.dfdl.xsd; lineNumber: 35; columnNumber: 51; src-resolve: Cannot resolve the name 'tns:nonexistant' to a 'type definition' component.
Schema context: file:/home/bsloane/workspace/Test/src/test.dfdl.xsd Location in file:??