The bat file wasn't quite right - it printed "Succeeded with no validation
errors" even when there were errors. Here's the correct way to do it:
---------------------------------------------
@ECHO OFF
call echo.
call echo validate that instance.txt is a valid instance of the data format
call ../../../dfdl/bin/daffodil.bat --version
call ../../../dfdl/bin/daffodil.bat parse -s data-format.dfdl.xsd --validate=on
-I null instance.txt
if %errorlevel% == 0 (
echo Validation Succeeded
) else (
echo Validation Failed
)
---------------------------------------------
/Roger
-----Original Message-----
From: Costello, Roger L. <[email protected]>
Sent: Wednesday, April 29, 2020 2:20 PM
To: [email protected]
Subject: Re: Can Daffodil do just validation (not parse to XML/JSON)?
Thank you Steve! That works great.
Here is my validate.bat file (for those interested):
---------------------------------------------
@ECHO OFF
call echo.
call echo validate that instance.txt is a valid instance of the data format
call ../../../dfdl/bin/daffodil.bat --version
call ../../../dfdl/bin/daffodil.bat parse -s data-format.dfdl.xsd --validate=on
-I null instance.txt
if errorlevel 0 echo Succeeded with no validation errors 1>&2
---------------------------------------------
/Roger
-----Original Message-----
From: Steve Lawrence <[email protected]>
Sent: Wednesday, April 29, 2020 2:05 PM
To: [email protected]
Subject: [EXT] Re: Can Daffodil do just validation (not parse to XML/JSON)?
Daffodil currently only outputs anything if there are problems (e.g.
parse fails, validation error found). Silence means success.
Daffodil does change the exit code depending on success/failure. Zero
means success, 1 means failure.
So if you want a success message, you can check the return code and
print a message when it's zero. I'm not a Windows person, but I /think/
adding this to the end of the bat file should work:
if errorlevel 0 echo Succeeded with no validation errors 1>&2
On 4/29/20 1:54 PM, Costello, Roger L. wrote:
> Steve wrote:
>
>> This causes no infoset to be output
>> when the parse completes.
>
> Eek! Deafening silence when the input conforms to the DFDL schema. Is there a
> way for Daffodil to generate a "valid" message when the input conforms to the
> DFDL schema? If not, perhaps it could be generated by the Windows bat file
> that I am using to run Daffodil; anyone know how to do that?
>
> /Roger
>
> -----Original Message-----
> From: Steve Lawrence <[email protected]>
> Sent: Monday, April 27, 2020 9:23 AM
> To: [email protected]
> Subject: [EXT] Re: Can Daffodil do just validation (not parse to XML/JSON)?
>
> Sort of. Daffodil will always create an internal infoset, which is
> necessary for all the parsing and validation logic.
>
> And Daffodil will always follow the codepath to output that infoset when
> the parse completes. However, in addition to outputting to XML or JSON
> we have a special InfosetOutputter that doesn't actually output
> anything, called the NullInfosetOutputter. To use this with the CLI, you
> can add "-I null" to your arguments, e.g.
>
> daffodil parse -s foo.dfdl.xsd --validate=on -I null inputData.bin
>
> This causes no infoset to be output when the parse completes. If there
> were validation errors, they will be printed to stderr and the exit code
> will be 1.
>
> On 4/27/20 9:07 AM, Costello, Roger L. wrote:
>> Hi Folks,
>>
>> So, a standards organization created a description of a data format. They
>> expressed that description using DFDL.
>>
>> Then, I created an instance of the data format. Now I'd like to know if my
>> instance is valid, i.e., does it conform to the DFDL description that the
>> standards organization created. I'm not interested in outputting an XML or
>> JSON representation of the instance. I simply want to know if my instance is
>> valid. I want the output to be either yes it's valid, or no it's not valid.
>> (Analogously, an XML Schema validator can output a detailed infoset or it
>> can output simply valid/invalid) Can Daffodil do this?
>>
>> /Roger
>>
>