Unfortunately our current API does not support this.

Our API probably wants to change so that Diagnostic.toString() returns the current diagnostic (i.e. mode + message + context), but Diagnostics.getMessage() only returns the message portion without the schema context or mode. And API users can access the other portions with other getters.

I've opened DAFFODIL-2984 to track this issue:

https://issues.apache.org/jira/browse/DAFFODIL-2984

On 2025-03-19 11:18 AM, Claude Mamo wrote:
Hi Daffodil community,

Is there a way to pull out the assert validation message from org.apache.daffodil.japi.Diagnostic without having to resort to regex? For example, if run this code:

List<Diagnostic> diagnostics = ...;
Diagnostic diagnostic = diagnostics.get(0);
System.out.println(diagnostic.getMessage());

The following is printed:

Validation Error: *My validation message*
Schema context: element reference D03B:OUTORD Location line 89 column 31 in / tmp/3406381247300519120/EDIFACT-Interchange-ae1cbc28-d4ff-35f3-99cb- f9e0915197e1.dfdl.xsd
Data location was preceding byte 130

I'd like only to print "My validation message". A Smooks community member had reported this issue a while back and now I'm hitting the same problem.

Thanks,

Claude

Reply via email to