Next: , Previous: Customisation, Up: Top

Appendix A Why XSLT?

In Output Formats, Richard Stallman writes:

If you are a programmer and would like to contribute to the GNU project by implementing additional output formats for Texinfo, that would be excellent. But please do not write a separate translator texi2foo for your favorite format foo! That is the hard way to do the job, and makes extra work in subsequent maintenance, since the Texinfo language is continually being enhanced and updated. Instead, the best approach is modify makeinfo to generate the new format.

Stallman had good reason for this advice: An extension of makeinfo makes very fast conversions possible, maintaining is easier at first sight, and availability for the Texinfo community is more direct.

But despite that, I ignored the advice for my Texinfo to LaTeX converter. The reason is that makeinfo has a rather good XML export. XML itself is perfectly suited to be transformed into an arbitrary output format. It's drop-dead simple to use XSLT in order to do the conversion. My full-featured implementation is only 142kB large, although XSLT is a verbose XML dialect full of redundancies. By the way, 12% of the code are GPL notices, and 22% are translation snippets for non-English languages.

But even maintenance is at least not more difficult with XSLT. New macros, for example, must be added to makeinfo as they have to be added to texi2latex. The parser is in both cases already available. Even better, extensions that require a look at the whole document are a lot easier in XSLT.

On the downside, the use of XSLT makes texi2latex slow. And of course it needs extra installation. This means that it is impossible to call texi2latex in the default make run, for example. It's just a way to get beautiful printouts and “static” PDFs, that's all.