This is an automated email from the ASF dual-hosted git repository.

olabusayo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/daffodil.git


The following commit(s) were added to refs/heads/main by this push:
     new 066a4d803 Only provide valid line/col info from Xerces
066a4d803 is described below

commit 066a4d803cad0fcf8f54b6c39ef8b68bd758eafd
Author: olabusayoT <[email protected]>
AuthorDate: Tue Nov 5 16:23:35 2024 -0500

    Only provide valid line/col info from Xerces
    
    - currently we output the line/col info directly from Xerces even if it's 
-1. We update the code to provide none if line/col <= 0 with test
    - we also fix the doublespace when there is no diagnosticDebugName provided 
for schema context
    - we looked into implementing a locator, and it was more trouble than it 
was worth since Xerces doesn't provide it to us
    
    DAFFODIL-2953
---
 .../scala/org/apache/daffodil/cli/cliTest/TestCLISaveParser.scala    | 2 +-
 .../src/main/scala/org/apache/daffodil/lib/api/Diagnostic.scala      | 5 +++--
 .../org/apache/daffodil/lib/exceptions/SchemaFileLocatable.scala     | 4 ++--
 .../org/apache/daffodil/section00/general/TestResolver.tdml          | 1 +
 4 files changed, 7 insertions(+), 5 deletions(-)

diff --git 
a/daffodil-cli/src/test/scala/org/apache/daffodil/cli/cliTest/TestCLISaveParser.scala
 
b/daffodil-cli/src/test/scala/org/apache/daffodil/cli/cliTest/TestCLISaveParser.scala
index a802adb91..8b8a0cd9f 100644
--- 
a/daffodil-cli/src/test/scala/org/apache/daffodil/cli/cliTest/TestCLISaveParser.scala
+++ 
b/daffodil-cli/src/test/scala/org/apache/daffodil/cli/cliTest/TestCLISaveParser.scala
@@ -327,7 +327,7 @@ class TestCLISaveParser {
     withTempFile { parser =>
       runCLI(args"save-parser -s $schema $parser") { cli =>
         cli.expectErr("[error]")
-        cli.expectErr(s"Schema context:  Location line 32 column 74 in 
${schema.normalize()}")
+        cli.expectErr(s"Schema context: Location line 32 column 74 in 
${schema.normalize()}")
       }(ExitCode.UnableToCreateProcessor)
     }
   }
diff --git 
a/daffodil-lib/src/main/scala/org/apache/daffodil/lib/api/Diagnostic.scala 
b/daffodil-lib/src/main/scala/org/apache/daffodil/lib/api/Diagnostic.scala
index 74a55bbdb..b382541c3 100644
--- a/daffodil-lib/src/main/scala/org/apache/daffodil/lib/api/Diagnostic.scala
+++ b/daffodil-lib/src/main/scala/org/apache/daffodil/lib/api/Diagnostic.scala
@@ -178,8 +178,9 @@ abstract class Diagnostic protected (
   protected def schemaContextString =
     if (schemaContext.isEmpty) ""
     else {
-      val pn = schemaContext.get.diagnosticDebugName
-      "\nSchema context: %s%s".format(pn, schemaLocationsString)
+      val ddn = schemaContext.get.diagnosticDebugName
+      val pn = if (ddn.nonEmpty) " " + ddn else ""
+      "\nSchema context:%s%s".format(pn, schemaLocationsString)
     }
 
   private def dataLocationString =
diff --git 
a/daffodil-lib/src/main/scala/org/apache/daffodil/lib/exceptions/SchemaFileLocatable.scala
 
b/daffodil-lib/src/main/scala/org/apache/daffodil/lib/exceptions/SchemaFileLocatable.scala
index 9357aacc1..86b8a2cd9 100644
--- 
a/daffodil-lib/src/main/scala/org/apache/daffodil/lib/exceptions/SchemaFileLocatable.scala
+++ 
b/daffodil-lib/src/main/scala/org/apache/daffodil/lib/exceptions/SchemaFileLocatable.scala
@@ -123,8 +123,8 @@ class XercesSchemaFileLocation(
   val xercesError: SAXParseException,
   val schemaFileLocation: SchemaFileLocation
 ) extends SchemaFileLocation(
-    Option(xercesError.getLineNumber.toString),
-    Option(xercesError.getColumnNumber.toString),
+    (if (xercesError.getLineNumber > 0) 
Some(xercesError.getLineNumber.toString) else None),
+    (if (xercesError.getColumnNumber > 0) 
Some(xercesError.getColumnNumber.toString) else None),
     schemaFileLocation.diagnosticFile,
     schemaFileLocation.toString,
     schemaFileLocation.diagnosticDebugName
diff --git 
a/daffodil-test/src/test/resources/org/apache/daffodil/section00/general/TestResolver.tdml
 
b/daffodil-test/src/test/resources/org/apache/daffodil/section00/general/TestResolver.tdml
index 6d5eddc85..7176b7710 100644
--- 
a/daffodil-test/src/test/resources/org/apache/daffodil/section00/general/TestResolver.tdml
+++ 
b/daffodil-test/src/test/resources/org/apache/daffodil/section00/general/TestResolver.tdml
@@ -38,6 +38,7 @@
       <tdml:error>Schema Definition Error</tdml:error>
       <tdml:error>Unable to resolve</tdml:error>
       <tdml:error>this/does/not/exist/schema.dfdl.xsd</tdml:error>
+      <tdml:error>Schema context: Location in</tdml:error>
     </tdml:errors>
   </tdml:parserTestCase>
 

Reply via email to