A Visual Studio Code

Visual Studio Code is a free code editor. It runs in Windows, Linux and macOS. In the TEI community though, other code editor, oXygen, has became de facto the xml editor thanks to the smooth integration with TEI. We are proposing VSCode because it is a free option, that can be enough for the first steps into encoding a text with TEI.

In order to have in VSCode some of the features which come by default in oXygen we need to install a couple of extensions.

  1. Download VSCode from https://code.visualstudio.com
  2. Install extensions: Preferences -> Extensions -> Search extensions in Marketplace [Scholarly XML | XML Tools | xslt-transform] -> install

Important short-cut in VSCode: Ctrl/Cmd+Shift+P brings up the Command Palette. It looks like a search box where you can type in the functionality of VSCode that you need: Ctrl/Cmd+Shift+P + start typing “exten…”, hit enter at the result “Extensions: install extension” and access the extension panel.

A.1 Schema validator

Extension’s name: Scholarly XML

Validates XML with the associated RELAX NG schema. It adds also features such as autocomplete, suggestions for elements, etc. With a general TEI schema linked (tei_all.rng), it shows the TEI documentation. You can even wrap selected text with tags Ctrl/Cmd + e (same key short-cut as in oXygen).

To validate, your XML file needs to be associated to a RELAX NG schema via the xml instruction <?xml-model?>. The following lines need to be added at the beginnig of your XML file:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-model
  href="https://vault.tei-c.org/P5/current/xml/tei/custom/schema/relaxng/tei_all.rng"
  schematypens="http://relaxng.org/ns/structure/1.0"
  type="application/xml"?>

For example, start typing < for elements suggestions. See the extension (click on it) documentation for more details.

A.2 XPath Evaluation

Extension’s name: XML Tools

XPath is a query language for selecting nodes from an XML document. The node is selected by following a path or steps.

  1. Invoke the Command Palette with Ctrl/Cmd+Shift+P
  2. Start typing “XPath…”.
  3. Select “XML Tools: Evaluate XPath”. (It is also possible to get the current path)
  4. Type the XPath expression and hit enter.
  5. The results are in the output pane.

For example, the XPath expression //lg[@type="terceto"][1]//l selects the verses in the first tercet.

A.3 XSLT transformation

Extension’s name: xslt-transform

The extension has 2 dependencies on third-party software, that is, it needs other software to run the transformations: Java and an XSLT processor (which runs on Java) are required.

Make sure you have both available in your machine. See the subsections for more details about how to proceed with the command line (8.1.5.1), installing Java (8.2.1), and downloading the processor Saxon (8.2.2).

A.3.1 Install the Extension: xslt-transform

  • Preferences > extension [search for]: xslt-transform > install

  • Point the xslt.processor setting to a valid Saxon processor in .jar format.

    • Extensions > installed > xslt-transform > extension settings > add the full path to saxon .jar
  • Run the command xslt.transform in an active editor with xml content

    • View > Command Palette (shift+cmd+p) [start writing: xslt:run..] > select .xsl file from directory > enter

    • Save results (add extension according to the transformation used (txt, xml, html))