Overview

I prototyped a real-time preview environment for TEI/XML using VSCode and XSLT, so this is a memo of the process.

Behavior

An example of the operation is shown below. When you edit and save a TEI/XML file, the browser display is updated.

https://youtu.be/ZParCRUc5AY?si=-aHHi3bIZGWoJYnP

Preparation

Install the following extensions:

When a TEI/XML file is saved, Trigger Task on Save executes the XSLT transformation, and the resulting HTML file is viewed with Live Server.

Repository

Sample code is stored at the following link.

https://github.com/nakamura196/tei-xml-xslt-vscode

Install xslt3 for performing the XSLT transformation.

gcnidptmtceilino-snxtemallh-ltxtsplst:-//sgciotdheub.com/nakamura196/tei-xml-xslt-vscode

settings.json and tasks.json

The .vscode folder contains settings.json and tasks.json.

tasks.json is as follows. It sets up a task to perform XSLT using xsl/make-CETEIcean.xsl.

{}""]vtea{}rssk""""]"}"}"isltca,p,g,po"ayor""""r""r""rn:bpmgx---ercokio"eemssxsoseluisb:[l"a"ls::evopnDl":n:tl$$nes"dee":d3:{{tae:"fm2""["xffal":aM."s:,siit":{ua0Thllli:"lt.re"/eeotbtc0alnm}Dn"ru"h"nlpa"i"nui:e,s"xk,r:eelrf,"envdt"o,-a{e"r:rCmr,umEe"e[T},]XE/MI$Lc{efwaiinlt.ehxBsaXlsS"eL,nTa"m,eNoExtension}.html"

xsl/make-CETEIcean.xsl is the XSL file published by CETEIcean.

https://github.com/TEIC/CETEIcean/blob/master/xslt/make-CETEIcean.xsl

Next, settings.json. It executes the above task when saving XML files under the tei folder.

{}"}tr"iTgrgaenrsTfaosrkmOnXSMaLvew.ittahskXsS"L:T"{:["tei/*.xml"]

With these settings, an HTML file is created in the same folder when a TEI/XML file is saved.

Sample File

An example TEI/XML file is shown below. The styles set in the rendition element are applied through xsl/make-CETEIcean.xsl.

<<<??T/xxETmmIEll<<I-xt/t/>vmmeteteoliexerdnH<<it<xsesef/e/H>b/til=aifneeob>o"dlicnadonhhee<<<lo<cdy<<d=rtrDt/p/s/edt/oe>d/dy"et>eituposDiatdridid>1fpstibuuoengai>vivi.=:cl<<tl<br<usgs<<<gn><><<v0"/>etaliplcprcDDrrrsgp/p/p>"h/Siuec>ie>c>eeeeeDD>p>p>ptwtttSa<cD<escnnnee>>>etwmlhtt/ae/Dcldddcs<<<<PTTnpwteomiptspe>>iiilc!tlllhhcs.>>rto>ic>sttt>>-ibbeiio:tC>>no>ciii-t/assd/eESSn>oool>si/iTatSnnneeiinw-EtmtssgwcIotmsssxr=w.Cr>tcccmeat".oeu>hhhlfnhUtraeee:eeTegnNmmmireFi/aeeedxf--nDk====tai8csea""""omr".mmcccfps?1oussso<lt>r.<rsssoreg0/a""""et/"t<foer>i/xssxfxetameemttllulllla<.eet:ee:rpa>hicclgesodttaerer=oonts/>"rrg=Nxi==="amt"""hmlatpdte/lieet>titr"ppecls>sei"eND:r/>"ai/scf>me/ouotegnsne"Littx>etno-tcihams-odum/tdlebesyeon.<clcrc/heo:dope:rememags/raitrTs/tiejENraoeuIaelnnnCmli:;g/eac<eC>x;u/nEn<nrTmg/deWEa/reneIrterdrckenliteuidithap_inien.ateor"li;n<>lo<>/h.n/ter>rirnetegnl<"de/i>rtteyifpo>en=>f"oarppClEiTcEaItcieoann/.xml"schematypens="http://relaxng.org/ns/structure/1.0"?>

The resulting HTML file converts TEI/XML elements like lb to HTML tei-lb elements, to which CSS and JS files are applied.

The result is displayed as shown below.

Summary

Changing the XSL file will change the preview display content.

For large files, the XSLT transformation may take some time, but I hope this serves as a helpful reference for building TEI/XML editing environments.