Skip to content

Startup Guide for New Users ‐ Draft

hdalsania edited this page Jan 24, 2025 · 1 revision
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 Visual Studio

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





  • VSCode 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
  • VisualStudio simply provides a simpler, more intuitive user interface
  • Not all debugger capabilities are available via VisualStudio.
  • 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 Visual Studio 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 Visual Studio Code, click on the Extensions Icon.






Installing the Daffodil Extension

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




Installing the Daffodil Extension

  1. In Visual Studio 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 Visual Studio 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 Visual Studio 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 it's own launch.json file

Configuring for First Use
Configuring Launch.json file

  • Open the Launch Config Wizard
    • Press Ctrl + k
    • Then press p
    • In the search bar that opens, begin entering: "Daffodil"
    • When the list shows Daffdodil Debug: Configure launch.json, select it
  • 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. 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 oiption can be usefull 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 VSCode & Daffodil Debugger.
  • Log File - Specify name & locaion of the log file.
  • Log Level - specify the level of information to be logged.
  • Use Existing Server - ignore
  • 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