You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@daffodil.apache.org by "Dave Thompson (Jira)" <ji...@apache.org> on 2023/09/29 14:31:00 UTC
[jira] [Closed] (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 ]
Dave Thompson closed DAFFODIL-2072.
-----------------------------------
Verified the specified commit (commit aee45959c71168fb678b830fb6c286c27488aec4) is included in the latest pull from the daffodil repository.
Verified, via review, changes identified in the commit comment were implemented.
Verified the affected daffodil subproject sbt test suites executed successfully including the modified and added tests.
> 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
> Assignee: Olabusayo Kilo
> Priority: Minor
> Labels: beginner
> Fix For: 3.5.1
>
> 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.20.10#820010)