The binary Daffodil releases contain a /bin directory with two scripts: daffodil.bat for Windows and daffodil for Linux. These files must be executed on the command line. The general usage is:
daffodil [GLOBAL_OPTIONS] <subcommand> [SUBCOMMAND_OPTIONS]
The available subcommands are:
Setting environment variables may be necessary to allow imports, includes, and running TDML files to work.
DAFFODIL_CLASSPATHDaffodil will search its classpath for includes and imports, jars containing schemas, and some TDML files. To tell Daffodil to look for files in additional directories, set the DAFFODIL_CLASSPATH environment variable, for example:
export DAFFODIL_CLASSPATH="/path/to/imports/:/path/to/includes/"
In addition to defining directories to search for imports and includes, you can add a CatalogManager.properties file to DAFFODIL_CLASSPATH to direct Daffodil to a relative path location of a user XML Catalog.
DAFFODIL_JAVA_OPTSIf you need to specify java options specific to Daffodil, you can set the DAFFODIL_JAVA_OPTS environment variable. If not specified, the JAVA_OPTS environment variable will be used. If that is not specified, reasonable defaults for Daffodil will be used.
DAFFODIL_TDML_API_INFOSETSIf you need to specify which API (legacy or both (SAX and legacy)) should be called when running TDML files with the test subcommand, you can set the DAFFODIL_TDML_API_INFOSETS environment variable to either scala or all. If that environment variable is not specified, then Daffodil will default to scala, using the legacy API and only creating a Scala infoset. Otherwise, if all is specified, Daffodil will use both the SAX and Legacy APIs and will create infosets from all the available Infoset Outputters: Scala, JDOM, W3CDOM, JSON and XML Text, to ensure correctness. Since the default option only creates one infoset, it is more efficient, which can speed up TDML tests.
CCIf you need to specify which C compiler should be called when running TDML files with the test subcommand using Daffodil's codegen-c backend, you can set the CC environment variable. If that environment variable is not specified, then Daffodil will call the first C compiler driver command it finds within the PATH environment variable from the following list: "zig cc", "cc", "clang", "gcc" (in that order). The reason for "zig cc" coming first is because zig cc uses a sophisticated caching system to avoid recompiling the same C source files, which can speed up TDML tests.
-v, --verboseEnable verbose mode and increment verbosity level. Each additional -v provides a new level of information.
--versionDisplay Daffodil's version.
-h, --helpDisplay a help message.
Parse a file, using either a DFDL schema or a saved parser.
daffodil parse (-s <schema> [-r <root>] | -P <parser>)
[PARSE_OPTS] [infile]
-c, --config FILEXML file containing configuration items, such as external variables or Daffodil tunables. See Configuration for details on the file format.
-D VARIABLE=VALUEVariables to be used when parsing. A namespace may be specified by prefixing VARIABLE with {NAMESPACE}, for example:
-D{http://example.com}var1=var
-d, --debug [FILE]Enable the interactive debugger. See the Interactive Debugger documentation for more information.
The optional FILE argument contains a list of debugger commands that are provided to the debugger as if they were typed by the user.
This option cannot be used with the --trace option.
-I, --infoset-type TYPEInfoset type to output. TYPE must be one of xml, scala-xml, json, jdom, sax, or null. Defaults to xml if not provided.
-o, --output FILEOutput file to write the infoset to. If the option is not given or FILE is -, the infoset is written to standard output.
-P, --parser FILEUse a previously saved parser inside FILE, created using the save-parser subcommand. This option cannot be used with the --schema option or with the --validate option set to on.
-r, --root ROOTThe root element to use. This must be one of the top-level elements of the DFDL schema defined with --schema. This requires the --schema option to be defined. Defaults to the schema's first top-level element if not provided. A namespace may be specified by prefixing ROOT with {NAMESPACE}.
-s, --schema FILEThe annotated DFDL schema to use to create the parser. This option cannot be used with the --parser option.
--streamRather than throwing an error when left over data exists after a parse, repeat the parse with the remaining data. Parsing repeats until end of data is reached, an error occurs, or no data is consumed. Output infosets are separated by a NUL character.
--nostreamStop after the first parse, throwing an error if left over data exists. This is the default behavior.
-T TUNABLE=VALUETunable configuration options to change Daffodil's behavior. See Configuration for the list of tunable parameters.
-t, --traceEnable a trace mode. This mode prints out helpful information during every stage of parsing.
This option cannot be used with the --debug option.
-V, --validate MODEThe validation mode. MODE must be one of on, limited, off, or a validator plugin name. Defaults to off if not provided. Validator plugins are provided by SPI and are referenced here using the name defined by the plugin. MODE cannot be on when used with the --parser option.
[INFILE]Input file to parse. If not specified, or is a value of -, reads from standard input. If supplied, the input file must be the last option on the command line.
-h, --helpDisplay a help message.
daffodil parse -s csv.dfdl.xsd test_file.csv
Unparse an infoset file, using either a DFDL schema or a saved parser.
daffodil unparse (-s <schema> [-r <root>] | -P <parser>)
[UNPARSE_OPTS] [infile]
-c, --config FILEXML file containing configuration items, such as external variables or Daffodil tunables. See Configuration for details on the file format.
-D VARIABLE=VALUEVariables to be used when unparsing. A namespace may be specified by prefixing VARIABLE with {NAMESPACE}, for example:
-D{http://example.com}var1=var
-d, --debug [FILE]Enable the interactive debugger. See the Interactive Debugger documentation for more information.
The optional FILE argument contains a list of debugger commands that are provided to the debugger as if they were typed by the user.
This option cannot be used with the --trace option.
-I, --infoset-type TYPEInfoset type to unparse. TYPE must be one of xml, scala-xml, json, jdom, or sax. Defaults to xml if not provided.
-o, --output FILEOutput file to write the data to. If the option is not given or FILE is -, the data is written to standard output.
-P, --parser FILEUse a previously saved parser inside FILE, created using the save-parser subcommand. This option cannot be used with the --schema option or with the --validate option set to on.
-r, --root ROOTThe root element to use. This must be one of the top-level elements of the DFDL schema defined with --schema. This requires the --schema option to be defined. Defaults to the schema's first top-level element if not provided. A namespace may be specified by prefixing ROOT with {NAMESPACE}.
-s, --schema FILEThe annotated DFDL schema to use to create the parser. This option cannot be used with the --parser option.
--streamSplit the input data at NUL characters and unparse each chunk separately to the same output file.
--nostreamTreat the entire input data as one infoset. This is the default behavior.
-T TUNABLE=VALUETunable configuration options to change Daffodil's behavior. See Configuration for the list of tunable parameters.
-t, --traceEnable a trace mode. This mode prints out helpful information during every stage of parsing.
This option cannot be used with the --debug option.
-V, --validate MODEThe validation mode. MODE must be one of on, limited, off, or a validator plugin name. Defaults to off if not provided. Validator plugins are provided by SPI and are referenced here using the name defined by the plugin. MODE cannot be on when used with the --parser option.
[INFILE]Input file to unparse. If not specified, or is a value of -, reads from standard input. If supplied, the input file must be the last option on the command line.
-h, --helpDisplay a help message.
daffodil unparse -s csv.dfdl.xsd test_file.infoset
Save a parser that can be reused for parsing and unparsing.
daffodil save-parser -s <schema> [-r <root>]
[SAVE_PARSER_OPTS] [outfile]
-c, --config FILEXML file containing configuration items, such as external variables or Daffodil tunables. See Configuration for details on the file format.
-D VARIABLE=VALUEVariables to be used when parsing or unparsing. A namespace may be specified by prefixing VARIABLE with {NAMESPACE}, for example:
-D{http://example.com}var1=var
-r, --root ROOTThe root element to use. This must be one of the top-level elements of the DFDL schema defined with --schema. This requires the --schema option to be defined. Defaults to the schema's first top-level element if not provided. A namespace may be specified by prefixing ROOT with {NAMESPACE}.
-s, --schema FILEThe annotated DFDL schema to use to create the parser. This option must be supplied.
-T TUNABLE=VALUETunable configuration options to change Daffodil's behavior. See Configuration for the list of tunable parameters.
[OUTFILE]Output file to save the parser to. If the option is not given or is -, the parser is saved to standard output. If supplied, the output file must be the last option on the command line.
-h, --helpDisplay a help message.
daffodil save-parser -s csv.dfdl.xsd csv_parser.xml
List or execute tests in a TDML file.
daffodil test [TEST_OPTS] <tdmlfile> [testnames...]
-d, --debug [FILE]Enable the interactive debugger. See the Interactive Debugger documentation for more information.
The optional FILE argument contains a list of debugger commands that are provided to the debugger as if they were typed by the user.
This option cannot be used with the --trace option.
-I, --implementation <implementation>Implementation to run TDML tests. Choose daffodil or daffodilC. Defaults to daffodil.
-i, --infoIncrement test result information output level, one level for each -i.
-l, --listShow names and descriptions of test cases in a TDML file instead of running them.
-r, --regexTreat TESTNAMES... as regular expressions.
-t, --traceEnable a trace mode. This mode prints out helpful information during every stage of parsing.
This option cannot be used with the --debug option.
TDMLFILETest Data Markup Language (TDML) file.
[TESTNAMES...]Name(s) of test cases in the TDML file. If not given, all tests in TDMLFILE are run.
-h, --helpDisplay a help message.
daffodil test csv.tdml
Run a performance test (parse or unparse), using either a DFDL schema or a saved parser.
daffodil performance (-s <schema> [-r <root>] | -P <parser>)
[PERFORMANCE_OPTS] <infile>
-c, --config FILEXML file containing configuration items, such as external variables or Daffodil tunables. See Configuration for details on the file format.
-D VARIABLE=VALUEVariables to be used when parsing or unparsing. VARIABLE can be prefixed with {NAMESPACE} to define which namespace the variable belongs in, for example:
-D{http://example.com}var1=var
-I, --infoset-type TYPEInfoset type to output or unparse. TYPE must be one of xml, scala-xml, json, jdom, sax, or null. Defaults to xml if not provided. Note that null is not valid if the --unparse option is provided.
-N, --number NUMBERThe total number of files to process. Defaults to 1.
-P, --parser FILEUse a previously saved parser inside FILE, created using the save-parser subcommand. This option cannot be used with the --schema option or with the --validate option set to on.
-r, --root ROOTThe root element to use. This must be one of the top-level elements of the DFDL schema defined with --schema. This requires the --schema option to be defined. Defaults to the schema's first top-level element if not provided. A namespace may be specified by prefixing ROOT with {NAMESPACE}.
-s, --schema FILEThe annotated DFDL schema to use to create the parser. This option cannot be used with the --parser option.
-t, --threads THREADSThe number of threads to use. Defaults to 1.
-T TUNABLE=VALUETunable configuration options to change Daffodil's behavior. See Configuration for the list of tunable parameters.
-u, --unparsePerform unparse instead of parse for performance test.
-V, --validate MODEThe validation mode. MODE must be one of on, limited, off, or a validator plugin name. Defaults to off if not provided. Validator plugins are provided by SPI and are referenced here using the name defined by the plugin. MODE cannot be on when used with the --parser option.
INFILEInput file or directory containing input files to parse or unparse. Required argument.
-h, --helpDisplay a help message.
daffodil performance -s csv.dfdl.xsd -N 1000 -t 5 test_file.csv
Generate C code from a DFDL schema to parse or unparse data.
daffodil generate <language> [SUBCOMMAND_OPTS]
--- there is only one choice for <language> at this time ---
daffodil generate c -s <schema> [-r <root>]
[GENERATE_OPTIONS] [outdir]
-c, --config FILEXML file containing configuration items, such as external variables or Daffodil tunables. See Configuration for details on the file format.
-r, --root ROOTThe root element to use. This must be one of the top-level elements of the DFDL schema defined with --schema. This requires the --schema option to be defined. Defaults to the schema's first top-level element if not provided. A namespace may be specified by prefixing ROOT with {NAMESPACE}.
-s, --schema FILEThe annotated DFDL schema to use to generate C code. This option must be supplied.
-T TUNABLE=VALUETunable configuration options to change Daffodil's behavior. See Configuration for the list of tunable parameters.
[OUTDIR]The output directory in which to create or replace a c subdirectory containing the generated C code. If the option is not given, a c subdirectory within the current directory will be created/replaced. If supplied, the output directory must be the last option on the command line.
-h, --helpDisplay a help message.
daffodil generate c -s csv.dfdl.xsd