Skip to content

Introduction to Daffodil VS Code Extension

lrbarber edited this page Dec 12, 2025 · 73 revisions
Introduction to the
Apache Daffodil Extension
for
Visual Studio Code

The Mission:
Make Daffodil Coding & Debugging Easier




The Command Line Interface with existing Daffodil debugging capability is non-intuitive and difficult to master







The Solution:
Integrate Daffodil with VS Code

  • Source Level Debugging
  • Breakpoints
  • Single Stepping
  • Syntax Highlighting
  • Context Aware Code Completion Assistance
  • Data view & Location Tracking
  • Interactive Infoset Viewing
The How:





  • VS Code plug-in extension
  • DAPodil interface server
  • Ωedit & Data Editor
  • Apache Daffodil w/ integrated Debugger




The Caveats:



  • No new functionality has been added to Daffodil’s integrated debugger
  • VS Code simply provides a simpler, more intuitive user interface
  • Not all debugger capabilities are available via VS Code.
  • The code being executed within Daffodil is a parser that it constructed based upon the provided schema.
  • There is not a one-to-one correspondence between the schema structure and that of the parser. This means that there is not a one-to-one correspondence between the lines in the schema and what Daffodil executes when the user asks the debugger to “step”.
  • There will be instances where the “step” does not result in movement of the indicator showing current location within the schema. This is similar to, but more exaggerated than, debugging code compiled with optimization enabled.
  • Additionally, data shown in the infoset may appear in chunks and/or may be removed when the parser backtracks if a parse branch is found to be incorrect.

Don’t worry if you’re new to IDE use and don’t know what any of this means. We’ll cover it in detail later.

IDE Basics

Integrated Development Environment
A single program that integrates all the steps of software development
  • Editing
  • Compiling
  • Execution
  • Debugging
  • Version Control
IDE Basics

Integrated Development Environment
A single program that integrates all the steps of software development
  • Editing
  • Compiling
  • Execution
  • Debugging
  • Version Control
IDE Basics

Integrated Development Environment
A single program that integrates all the steps of software development
  • Editing
  • Compiling
  • Execution
  • Debugging
  • Version Control
IDE Basics

Integrated Development Environment
A single program that integrates all the steps of software development
  • Editing
  • Compiling
  • Execution
  • Debugging
  • Version Control
IDE Basics

Integrated Development Environment
A single program that integrates all the steps of software development
  • Editing
  • Compiling
  • Execution
  • Debugging
  • Version Control
Install VS Code



  • Free and built on open source
  • Available for Windows, Linux, macOS and web browsers




Click Image for Download Page:Supported platforms
Installing the Daffodil Extension

  1. In VS Code, click on the Extensions Icon.






Installing the Daffodil Extension

  1. In VS Code, click on the Extensions Icon
  2. Then enter “daffodil” in the search box




Installing the Daffodil Extension

  1. In VS Code, click on the Extensions Icon.
  2. Then enter “daffodil” in the search box
  3. Click on the Apache Daffodil tile



Installing the Daffodil Extension

  1. In VS Code, click on the Extensions Icon.
  2. Then enter “daffodil” in the search box
  3. Click on the Apache Daffodil tile
  4. Click on the Install button


Installing the Daffodil Extension

  1. In VS Code, click on the Extensions Icon.
  2. Then enter “daffodil” in the search box
  3. Click on the Apache Daffodil tile
  4. Click on the Install button
  5. Upon installation, the Install button will be replaced by Disable & Uninstall buttons
Configuring for First Use
Create a working directory
  • Sample data file
  • Sample schema file



Free sample schemas here
This example uses a Daffdile logo saved as a PNG file
Configuring for First Use
Open the working directory


  1. Click File
  2. Click Open Folder
  3. Navigate to & Select your folder




Note that if you wind up working on multiple DFDL projects in different folders, you will need to configure each folder with its own launch.json file

Another important issue to note when choosing working directories is that VSCode, like many IDEs, seems to not like projects that are on paths reachable via symlinks. Using symlinks in paths is highly likely to cause problems and thus should be avoided.

Configuring for First Use
Configuring Launch.json file

  • Open the Launch Config Wizard
    • Press Ctrl + Shift + P
    • In the search bar that opens, begin entering: "Daffodil"
    • When the list shows Daffdodil Debug: Configure launch.json, select it
commandpalletedaff
  • The Launch Config Wizard will open in a new tab.






Note that the debugger should run with the default settings. You may simply scroll down to the bottom of the configuration wizard and click the SAVE button, then close the wizard.
If you run into a problem, the most likely problem is that you have not yet opened a working folder/directory. If VS Code opens settings.json instead of launch.json make sure that you have created and opened the intended folder/directory. The second most likely culprit is a port conflict and you can simply reopen the configuration wizard and change the port settings and save the new configuration.

Configuring for First Use
Launch Config Wizard

  • Launch config: The file can hold multiple configurations.
    • 1. Enter a name for the new configuration
         or
      2. Select a previous configuration from the drop-down list

Configuring for First Use
Launch Config Wizard
Main Schema File/Input Data File
The input files can be hard coded into the configuration by clicking the Browse button and navigating to the file and clicking on it

Leave the ${command:AskForSchemaName}/${command:AskForDataName} values and you will be prompted for the file names each time you execute a parse. This option can be useful if you will be testing with a variety of input files, rather than running the same files repeatedly

Configuring for First Use
Launch Config Wizard
Root Element
For simple schemas, this field may be left set to undefined
Configuring for First Use
Launch Config Wizard
Debugger Settings
  • Port - Port used for communication between VS Code & Daffodil Debugger.
  • Version (Daffodil version) - Specify the version of Daffodil to be used while debugging.
  • Timeout - Limit on communication failure before error declared.
  • Log File - Specify name & location of the log file.
  • Log Level - specify the level of information to be logged.
  • Use Existing Server - ignore - Used only for backend server developers
  • Stop On Entry - Essentially sets a breakpoint on the first line.
  • Trace - logging of internal communications
Configuring for First Use
Launch Config Wizard
Classpath
  • Complex schemas often require multiple locations and JAR files. The debugger needs to know where to find these additional files
Infoset
  • Infoset Format - Select XML or JSON for the ouput
  • Output Type - store output to a file or stream to console
  • Output Infoset Path - specify the location for the output file
Configuring for First Use
Launch Config Wizard
  • Open Data Editor - Display contents of file being parsed. Defaults to Hex, but many configurable settings. Tracks position in file and allows modification of data.
  • Open Infoset Diff View - Can show the difference between output results of the current and previous parse.
  • Open Infoset View - Displays the partial resulting output of the file parsing. Note that parser often backtracks when portions of the parse are determined to be incorrect.
Debugging for the first time for Visual Studio Code
Make sure you have open data editor on debug start checked in launch config wizard commandpalletedaff
Configuring for First Use
Launch Config Wizard
TDML Options
  • Drop down list of valid TDML Actions.
  • Desired filename for the TDML file.
Configuring for First Use
Launch Config Wizard
Data Editor Configuration
  • Omega-edit port - allows user to specify which port will be used for communication between VS Code & the backend server.
  • Name/location of the log file which records communication between VS Code and the backend server.
  • Drop down list of the valid log levels.
Configuring for First Use
Launch Config Wizard
Don't forget to save your configuration settings!

If you have a problem saving your settings, verify that you have opened a valid working folder.
Debugging for the first time for Visual Studio Code
Click on play button to start a DFDL schema debugging session commandpalletedaff
Debugging for the first time for Visual Studio Code
You will see the data editor pop up! commandpalletedaff
Generate TDML Temporary File
In launch config wizard, set TDML action to generate, and save.

Note: You can go back to previously set configs and edit them and save those changes
Generate TDML Temporary File
Run the corresponding DFDL debug extension from prior step.

Generate Temporary TDML File
Press the continue button to produce the infoset.

Generate Temporary TDML File
When the infoset generates, a temporary TDML schema will generate.

Create TDML File
Close all windows except the DFDL schema window. Click “Create TDML File” in the command view panel or "Daffodil Debug: Create TDML File" in the command palette.

Create TDML File
Enter a name for the TDML file, click “Save TDML File. Save the TDML in the current project folder, folder that's currently open in VS Code.

Create TDML File
Close the DFDL schema in the editor window. Click the explore tab to verify file is in project folder.

Execute TDML File
Open the TDML file.

Execute TDML File
After the TDML file opens, select the “Execute TDML” option from the dropdown, or “Execute TDML” in the command view panel, or "Daffodil Debug: Execute TDML" in the command palette.

Execute TDML File
Select the name of the test case to execute.

Execute TDML File
The DFDL schema and a new infoset will utilize the values from the TDML file.

Clone this wiki locally