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/12 13:08:00 UTC
[jira] [Updated] (DAFFODIL-2072) Poor reporting of schema errors
when used as library
[ https://issues.apache.org/jira/browse/DAFFODIL-2072?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Steve Lawrence updated DAFFODIL-2072:
-------------------------------------
Labels: beginner (was: beginner dev-verify)
> Poor reporting of schema errors when used as library
> ----------------------------------------------------
>
> Key: DAFFODIL-2072
> URL: https://issues.apache.org/jira/browse/DAFFODIL-2072
> Project: Daffodil
> Issue Type: Bug
> Components: API
> Affects Versions: 2.3.0
> Reporter: Brandon Sloane
> Priority: Minor
> Labels: beginner
> Attachments: Main.scala, test.dfdl.xsd
>
>
> 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):
> {quote}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.URISchemaSource
> object Main extends App {
> override def main(args: Array[String]): Unit = {
> val dfdlCompiler: Compiler = Daffodil.compiler()
> val model = Misc.getRequiredResource("test.dfdl.xsd")
> val pf: ProcessorFactory = dfdlCompiler.compileSource(URISchemaSource(model).uriForLoading)
> val df: DataProcessor = pf.onPath("/")
> }
> }
> {quote}
> The relevent portion of test.dfdl.xsd is:
> {quote}<xs:element name="top" type="tns:nonexistant" />
> {quote}
> where tns:nonexistant is never defined.
> {quote}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)
> {quote}
> For reference, using the CLI produces the following (good) error:
> {quote}[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(n) 'type definition' component.
> Schema context: file:/home/bsloane/workspace/Test/src/test.dfdl.xsd Location in file:??
> {quote}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)