Skip to content

XQuery Script Execution

Josh Johnson edited this page Jan 29, 2016 · 4 revisions

Wait a Second!
You must have a folder opened in Code to use this feature.

  1. Define an XQuery execution engine using the xmlTools.xqueryExecutionEngine setting. This setting should be the full path to a command line XQuery engine (such as AltovaXML or BaseX).

    Example Configuration for AltovaXML 2008

    {
        "xmlTools.xqueryExecutionEngine": "C:\\Program Files (x86)\\Altova\\AltovaXML2008\\AltovaXML.exe"
    }
  2. Define the requisite command line parameters for your tool of choice using the xmlTools.xqueryExecutionArguments setting. You can use $(script) to reference the full path to the XQuery script, $(input) to reference to full path to the input XML file, and $(project) to reference the full path to the currently-opened workspace/project folder.

    Example Configuration for AltovaXML 2008

    {
        "xmlTools.xqueryExecutionEngine": "C:\\Program Files (x86)\\Altova\\AltovaXML2008\\AltovaXML.exe",
        "xmlTools.xqueryExecutionArguments": [
            "-xquery", "$(script)",
            "-in", "$(input)"
            "-out", "$(input).output.xml"
        ]
    }
  3. Open a folder in Code containing your XQuery script, then run the XML Tools: Execute XQuery command. You will be prompted to select an XML file in your workspace to use as an input file. A message will be written to the status bar while XML Tools waits for the spawned process to end.

💡 Pro Tip
The output of the execution engine is captured via the stdout for your operating system.
If the process exits with any code other than 0, any content written to stdout is shown as an error message. If the content from stdout contains a line number, the error prompt will contain a button to take you to the line in question.