Passive TeX

Here are some files which form a demonstration of LaTeX reading XSL Formatting Objects and processing them to produce nice pages. They rely heavily on earlier work by David Carlisle (his typehtml for typesetting HTML files), and on my JadeTeX for processing DSSSL via Jade. David has also contributed a place-holder package for dealing with UTF-8 encoding. It is expected that all the components will be replaced in the near future.

How does it work? Taking the XML version of the TEI Lite guidelines (teiu5.xml, with DTD teixlite.dtd), we apply an XSL stylesheet (see my page of TEI style sheets), and run it through James Clarks' XT XSL processor (version of 19990926 or later):

  java com.jclark.xsl.sax.Driver teiu5.xml tei.xsl teiu5.fo
(assuming you have xt.jar, xp.jar and sax.jar on your CLASSPATH ). This creates the new XML file teiu5.fo. We now run a special TeX on this
 pdftex  "&fotex" teiu5.fo
which creates teiu5.pdf. Voila! Actually, we need to do
 pdftex "&fotex" teiu5.fo
again, to resolve page-number references in the table of contents. For a comparison with an HTML rendering of the same document (using XSL again), see teiu5.html on my TEI page.

How did we make fotex.fmt? With the command

  pdftex -ini "&pdflatex" pdffotex.ini
For this you need fotex.ltx, pdffotex.ini, typexml.sty, mathml.ltx, unicode.sty, ucharacters.sty, dummyels.sty, mlnames.sty, and utfeight.sty, as well as version 6.65 or later of the hyperref package (actually, you just need hyperref.sty and hpdftex.def).

These files are available zipped up.

NOTE: TeX has a limit on the length of line it can read, and some .fo files you generate may cause TeX to die with an message about increasing buf_size. If you get that, edit your texmf.cnf file, increase the size of buf_size (mine is 200000), and remake pdflatex.fmt and then fotex.fmt.

Extensions

PassiveTeX interprets MathML natively (see sample file below), but I have supported some wrapper `equation' commands to make sense of this in the fotex namespace. I also support a bookmark element in the the fotex namespace, used to make PDF bookmarks. Usage is like this:
<xsl:template match="div2">
     <xsl:apply-templates select="head"/>
     <fotex:bookmark  
	xmlns:fotex="http://www.tug.org/fotex" 
	fotex-bookmark-level="2"
	fotex-bookmark-label="{@id}">
        <xsl:value-of select="head"/>
     </fotex:bookmark>
  </fo:block>
</xsl:template>

Other samples

  • A physics paper (latexexa.xml) containing a fair amount of MathML markup, originally translated from LaTeX into XML. It is used extensively as an example in the LaTeX Web Companion. Here we see it converted to latexexa.pdf using latexexa.xsl
  • James Tauber prepared a simple XSL spec (darkness.xsl) for Joseph Conrad's Heart of Darkness, which I ran to PDF as darkness.pdf

    Concerns and problems

    Some points to bear in mind

    1. Obviously, the XSL FO spec is only a draft. I expect to have to redo much of this when the real thing comes out.
    2. This is very much an initial, undocumented hack, to check whether the idea works. Expect something more polished shortly
    3. You need a modern TeX setup (like teTeX or TeX Live) to get to grips with it.
    4. Many flow objects and characteristics are not dealt with yet. But a fair few are; this is not entirely a toy. I will add support for more things rapidly.
    5. I do not have any objective check that what I think XSL FOs are supposed to do is actually right :-}
    6. I have only worked so far with the TEI Lite (XML version) and Docbook DTDs, and probably misinterpreted half of what they say.
    7. The TEI XSL stylesheet is a rapid, rough and ready, bit of work. I am gradually modularizing and parameterizing it.

    I will be very glad to discuss details with anyone. Contact me (Sebastian Rahtz) as sebastian.rahtz@oucs.ox.ac.uk

    Last updated $Date: 1999/12/21 12:25:31 $