XSLT[18] is well‐known for its capabilities to convert from one XML vocabulary into another. Nevertheless, XSLT allows to output text‐based content, too. Starting with XSLT 2.0 that became a W3C standard in 2007, its powerful query language XPath, grouping mechanisms and regular expressions make XSLT an interesting alternative for converting XML to LaTeX.

To output LaTeX in XSLT is quite simple. You need to add <xsl:output method="text"/> to your stylesheet. Then you can start writing your accustomed templates and associate XML nodes with TeX output. Here is a minimal example to demonstrate this method.

&lt;?xml version="1.0" encoding="UTF‑8"?&gt;
&lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
            &lt;xsl:output method="text"/&gt;
            &lt;xsl:template match="/article"&gt;

However, to program a full‐fledged XML to LaTeX transformation will not remain as simple as the template above suggests. Templates to convert figures, tables and other elements will add up. Programming a transformation of MathML to TeX formulas will considerably be one of the biggest tasks. For anything in your XML documents that cannot be covered by standard LaTeX, you need to implement additional TeX packages that provide the required functionality. Depending on the Unicode support of your TeX engine, you also need to map Unicode characters such as ω (Greek Small Letter Omega U+03C9) to the corresponding TeX command \omega.

Given the extensibility of XSLT via imports and includes, it’s easier to reuse the code and override it for other projects. But that’s only true when the source XML does not change. For example, when you change from CALS to HTML tables, you basically find yourself completely rewriting your code. In any case, adapting your stylesheet to handle multiple XML vocabularies would impose a challenge.

[18] W3C (2017) XSL Transformations (XSLT) Version 3.0. Available at https://www.w3.org/TR/xslt-30/ (Accessed: May 30, 2023)