<?xml version="1.0"?>
<!DOCTYPE TEI.2 SYSTEM "http://www.oucs.ox.ac.uk/dtds/tei-oucs.dtd" [
 <!ENTITY properties SYSTEM "properties.xml">
]>
<TEI.2>
  <teiHeader>
    <fileDesc>
      <titleStmt>
        <title>PassiveTeX</title>
      </titleStmt>
      <publicationStmt>
        <p> </p>
      </publicationStmt>
      <sourceDesc>
        <p></p>
      </sourceDesc>
    </fileDesc>
    <revisionDesc>
      <list>
        <item><date>2003/03/06</date>version 1.24 </item>
        <item><date>2003/02/14</date>version 1.23 </item>
        <item><date>2003/02/04</date>version 1.22 </item>
        <item><date>2002/09/16</date>version 1.21 </item>
        <item><date>2002/09/14</date>version 1.20 </item>
        <item><date>2002/08</date>version 1.19 </item>
        <item><date>2002/06/25</date>version 1.18 </item>
        <item><date>2002/02/08</date>version 1.12 </item>
        <item><date>2001/12/04</date>version 1.11 </item>
        <item><date>2001/12/02</date>version 1.10 </item>
        <item><date>2001/11/29</date>version 1.9 </item>
        <item><date>2001/11/19</date>version 1.8 </item>
        <item><date>2001/06/19</date>version 1.7 </item>
        <item><date>2001/04/02</date>version 1.6 </item>
        <item><date>2001/01/04</date>version 1.4 </item>
        <item><date>2000/12/10</date>version 1.3 </item>
        <item><date>2000/11/23</date>version 1.3 </item>
        <item><date>2000/10/04</date>version 1.1 </item>
        <item><date>2000/09/13</date>A couple of changes to property list</item>
        <item><date>2000/09/12</date>Notes on memory sizes</item>
        <item><date>2000/06/24</date>Checking links</item>
        <item><date>2000/05/30</date>Added conformance and dependency notes</item>
        <item><date>2000/02/07</date>Second version</item>
        <item><date>1999/08/08</date>First version, authored in TEI XML</item>
      </list>
    </revisionDesc>
  </teiHeader>
  <text>
<front>
<titlePage>
<docTitle>
 <titlePart type="main">PassiveTeX</titlePart>
</docTitle>
<docAuthor>Sebastian Rahtz</docAuthor>
<docDate>March 2003</docDate>
</titlePage>
</front>
<body>
<div>
<head>Summary</head>
<list type="unordered">
<item>
PassiveTeX is a library of TeX macros which can be used to process an XML
document which results from an XSL transformation to formatting objects. 
</item>
<item>
PassiveTeX provides a rapid development environment for experimenting
with XSL FO, using a reliable pre-existing formatter
</item>
<item>
Running PassiveTeX with the pdfTeX variant of TeX generates high-quality
PDF files in a single operation.
</item>
<item>
PassiveTeX shows how TeX can remain the formatter of choice for XML, while
hiding the details of its operation from the user.
</item>
</list>
</div>
<div><head>How does it work?</head>
<p>
PassiveTeX relies heavily on work by David Carlisle
(his namespace-aware XML parser written in 
TeX, <code>xmltex</code>), and was developed from my
<xref url="http://www.tug.org/applications/jadetex/">JadeTeX</xref>
macros for processing DSSSL via Jade.
</p>
<p>
Taking the XML version of the TEI Lite guidelines
(<xref url="test/teiu5.xml">teiu5.xml</xref>, with DTD
<xref url="/Lite/DTD/teixlite.dtd">teixlite.dtd</xref>), we apply an XSL stylesheet
(see my page of <xref url="/Stylesheets/teixsl.html">TEI style sheets</xref>),
and run it through Mike Kay's Saxon XSL processor:
<eg>
  java com.icl.saxon.StyleSheet -o teiu5.fo teiu5.xml tei.xsl 
</eg>
(assuming you have <code>saxon.jar</code> and <code>sax.jar</code>
on your CLASSPATH). This creates the new XML file
<xref url="test/teiu5.fo">teiu5.fo</xref>. We now run XMLTeX on this
<eg>
 pdfxmltex teiu5.fo
</eg>
which creates <xref url="test/teiu5.pdf">teiu5.pdf</xref>. Voila! 
Actually, we need to do
<eg>
 pdfxmltex teiu5.fo
</eg>
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 <xref url="/Lite/teiu5.html">teiu5.html</xref>
on the TEI pages. </p>
</div>
<div>
<head>Installation</head>
<p>
The PassiveTeX macros should be downloaded (as a ZIP file,
<xptr url="passivetex.zip"/>), unpacked, and installed in a TeX system (eg in 
<code>texmf/tex/latex/passivetex</code>) in the normal place where you put
macros. Consult your local documentation or local expert if you do not know
how to install a new package; on a web2c-based system, don't forget to
	  run <code>mktexlsr</code> when you have the files in place,
	  to update the file lookup table.
</p>
<p>
What about that <code>pdfxmltex</code> command we saw in the last section? 
You don't have it on your system? You need to download 
xmltex from <xref url="http://www.ctan.org">CTAN</xref>
and install it in the your TeX system.
install it in the your TeX system.
It too is just a set of TeX macro packages. 
<hi>IMPORTANT NOTE. You need a
copy of xmltex.tex latex than 2001/11/30.</hi></p>

<p>
Now you can use xmltex on a file called (eg) <code>teiu5.fo</code> in one of two ways:
<list type="ordered">
<item>Build an <code>xmltex</code> format file for pdfTeX with
<eg>
pdftex -ini "&amp;pdflatex" pdfxmltex.ini
</eg>
and process your file with
<eg>
pdflatex "&amp;pdfxmltex" teiu5.fo
</eg>
The command <code>pdfxmltex</code> used above is just a script
which does
<eg>
tex -fmt=pdfxmltex -progname=pdfxmltex
</eg>
Or,
</item>
<item>
Make a wrapper file called (eg) <code>teiu5.tex</code> looking like this:
<eg>
\def\xmlfile{teiu5.fo}
\input xmltex
</eg>
and run pdfTeX on it as normal with
<eg>
pdflatex teiu5.tex
</eg> 
</item>
</list>
Do not worry, <code>xmltex</code> knows how to find the PassiveTeX macros as
it needs them. You will likely need to increase TeX memory
values (in the file <code>texmf.cnf</code> if you use a Web2c-based TeX);
I use:
<eg>
main_memory = 2500000
param_size = 1500
stack_size = 1500
hash_extra = 50000
string_vacancies = 45000
pool_free = 47500
nest_size = 500
save_size = 10000
pool_size = 500000
max_strings = 55000
</eg>
</p>

<p>
For reference, the PassiveTeX package consists of the following files:
<list>
<item>The core xmltex `style' files for XSL FO XML:
<eg>
 fotex.xmt
 fotex.sty
</eg>
</item>
<item>
Support for direct formatting of TEI XML with xmltex
<eg>
 tei.xmt        
 teixml.sty
</eg>
</item>
<item>
Some support files, shared with JadeTeX:
<eg>
 unicode.sty
 ucharacters.sty
 mlnames.sty 
 dummyels.sty
 nomulticol.sty
</eg>
</item>
</list>
</p>
<p>
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
<code>texmf.cnf</code> file,  increase the size of <code>buf_size</code> (mine is
200000), and remake any format files.
</p>
<div><head>LaTeX package dependencies</head>
<p>This setup assumes you have a decent modern TeX setup. The TeX Live 6 CD-ROM
is what I use, and it is up to date 
(see <xptr url="http://www.tug.org/texlive/"/>).
</p>
<p> Here is a
	    list of the packages loaded in a typical run of
	    PassiveTeX, with their version numbers where known:
<table  rend="rules">
<row><cell>  amsbsy.sty </cell><cell>   1999/11/29 v1.2d</cell></row>
<row><cell>amsfonts.sty </cell><cell>   1997/09/17 v2.2e</cell></row>
<row><cell>  amsgen.sty </cell><cell>   1999/11/30 v2.0</cell></row>
<row><cell> amsmath.sty </cell><cell>   2000/03/29 v2.08 AMS math features</cell></row>
<row><cell>  amsopn.sty </cell><cell>   1999/12/14 v2.01 operator names</cell></row>
<row><cell> amssymb.sty </cell><cell>   1996/11/03 v2.2b</cell></row>
<row><cell> amstext.sty </cell><cell>   1999/11/15 v2.0</cell></row>
<row><cell>   array.sty </cell><cell>   1998/05/13 v2.3m Tabular extension package (FMi)</cell></row>
<row><cell> article.cls </cell><cell>   1999/09/10 v1.4a Standard LaTeX document class</cell></row>
<row><cell>      bm.sty </cell><cell>   1999/07/05 v1.0g Bold Symbol Support (DPC/FMi)</cell></row>
<row><cell>   color.sty </cell><cell>   1999/02/16 v1.0i Standard LaTeX Color (DPC)</cell></row>
<row><cell> fontenc.sty </cell><cell>   (version not available)</cell></row>
<row><cell>graphics.sty </cell><cell>   1999/02/16 v1.0l Standard LaTeX Graphics (DPC,SPQR)</cell></row>
<row><cell>graphicx.sty </cell><cell>   1999/02/16 v1.0f Enhanced LaTeX Graphics (DPC,SPQR)</cell></row>
<row><cell> hpdftex.def </cell><cell>   2000/05/08 v6.70f Hyperref driver for pdfTeX</cell></row>
<row><cell>hyperref.sty </cell><cell>   2000/05/08 v6.70f Hypertext links for LaTeX</cell></row>
<row><cell>  ifthen.sty </cell><cell>   1999/09/10 v1.1b Standard LaTeX ifthen package (DPC)</cell></row>
<row><cell>  keyval.sty </cell><cell>   1999/03/16 v1.13 key=value parser (DPC)</cell></row>
<row><cell>longtable.sty </cell><cell>   1998/05/13 v4.09 Multi-page Table package (DPC)</cell></row>
<row><cell>multicol.sty </cell><cell>   1999/10/21 v1.5w multicolumn formatting (FMi)</cell></row>
<row><cell> nameref.sty </cell><cell>   2000/05/08 v2.18 Cross-referencing by name of section</cell></row>
<row><cell>  ot1phv.fd </cell><cell>   2000/01/12 PSNFSS-v8.1 scalable font definitions for OT1/phv.</cell></row>
<row><cell>  pd1enc.def </cell><cell>   2000/05/08 v6.70f Hyperref: PDFDocEncoding definition (HO)</cell></row>
<row><cell>  pifont.sty </cell><cell>   2000/01/12 PSNFSS-v8.1 Pi font support (SPQR) </cell></row>
<row><cell>rotating.sty </cell><cell>   1997/09/26, v2.13 Rotation package</cell></row>
<row><cell>  size10.clo </cell><cell>   1999/09/10 v1.4a Standard LaTeX file (size option)</cell></row>
<row><cell>stmaryrd.sty </cell><cell>   1994/03/03 St Mary's Road symbol package</cell></row>
<row><cell>   t1enc.def </cell><cell>   1999/12/08 v1.9x Standard LaTeX file</cell></row>
<row><cell>   t1phv.fd </cell><cell>   2000/01/12 PSNFSS-v8.1 scalable font definitions for T1/phv.</cell></row>
<row><cell>   t1ptm.fd </cell><cell>   2000/01/12 PSNFSS-v8.1 font definitions for T1/ptm.</cell></row>
<row><cell>  t2acmr.fd </cell><cell>   1999/01/07 v1.0 Computer Modern Cyrillic font definitions</cell></row>
<row><cell>  t2aenc.def </cell><cell>   1999/11/29 v1.0c Cyrillic encoding definition file</cell></row>
<row><cell>   t3enc.def </cell><cell>   (version not available)</cell></row>
<row><cell>textcomp.sty </cell><cell>   1999/12/08 v1.9x Standard LaTeX package</cell></row>
<row><cell>   times.sty </cell><cell>   2000/01/12 PSNFSS-v8.1 Times font as default roman (SPQR) </cell></row>
<row><cell>    tipa.sty </cell><cell>   1996/06/10 TIPA version 1.0</cell></row>
<row><cell>    trig.sty </cell><cell>   1999/03/16 v1.09 sin cos tan (DPC)</cell></row>
<row><cell>  ts1cmr.fd </cell><cell>   1999/05/25 v2.5h Standard LaTeX font definitions</cell></row>
<row><cell>  ts1enc.def </cell><cell>   1998/06/12 v3.0d (jk/car/fm) Standard LaTeX file</cell></row>
<row><cell>  ts1ptm.fd </cell><cell>   2000/01/12 PSNFSS-v8.1 font definitions for TS1/ptm.</cell></row>
<row><cell>    ulem.sty </cell><cell>   1997/04/21</cell></row>
<row><cell>    umsa.fd </cell><cell>   1995/01/05 v2.2e AMS font definitions</cell></row>
<row><cell>    umsb.fd </cell><cell>   1995/01/05 v2.2e AMS font definitions</cell></row>
<row><cell>    upsy.fd </cell><cell>   2000/01/12 PSNFSS-v8.1 font definitions for U/psy.</cell></row>
<row><cell>    upzd.fd </cell><cell>   2000/01/12 PSNFSS-v8.1 font definitions for U/pzd.</cell></row>
<row><cell>     url.sty </cell><cell>   1999/03/28  ver 1.5x  Verb mode for urls, etc.</cell></row>
<row><cell>  Ustmry.fd </cell><cell>  (version not available)</cell></row>
<row><cell>   uwasy.fd </cell><cell>   1999/05/13 v1.0iWasy-2 symbol font definitions</cell></row>
<row><cell> wasysym.sty </cell><cell>   1999/05/13 v1.0i Wasy-2 symbol support package</cell></row>
</table>
</p>
</div>
</div>
<div>
<head>LICENSE</head>
<p>Copyright 2003 Sebastian Rahtz/Oxford University 
(sebastian.rahtz@oucs.ox.ac.uk)</p>

<p>Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and any associated documentation files (the
``Software''), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:</p>

<p>The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.</p>
   </div>

<div>
<head>Extensions</head>
<p>
PassiveTeX interprets MathML natively (elements must use the MathML namespace).
I also support a <code>bookmark</code> element in the
<code>fotex</code> namespace, used to make PDF bookmarks. Usage is like this:
<eg>
&lt;xsl:template match="div2">
     &lt;xsl:apply-templates select="head"/>
     &lt;fotex:bookmark  
	xmlns:fotex="http://www.tug.org/fotex" 
	fotex-bookmark-level="2"
	fotex-bookmark-label="{@id}">
        &lt;xsl:value-of select="head"/>
     &lt;/fotex:bookmark>
  &lt;/fo:block>
&lt;/xsl:template>
</eg>
</p>
</div>


<div>
<head>Notes on conformance to the XSL specification</head>
&properties;
</div>

<div>
<head>Sample files</head>
<p>
<list>
<item> The TEI Lite description (<xref
url="test/teiu5.xml">teiu5.xml</xref>) converted PDF as <xref
url="test/teiu5.pdf">teiu5.pdf</xref></item>
<item> A TEI test file  (<xref
url="test/exercise.xml">exercise.xml</xref>) 
converted to PDF as <xref
url="test/exercise.pdf">exercise.pdf</xref></item>
<item> A physics paper (<xref url="test/teimath.xml">teimath.xml</xref>) containing a fair
     amount of MathML markup, originally
     translated from LaTeX into XML.
     It is used extensively as an example in the
     <xref url="http://cseng.awl.com/bookpage.taf?ISBN=0-201-43311-7&amp;ptype=0&amp;catid=&amp;navmin=&amp;ctype=author&amp;catpage=&amp;seriesid=">LaTeX Web Companion</xref>.
Here we see it
      converted to <xref url="test/teimath.pdf">teimath.pdf</xref> using
      <xref url="test/teimath.xsl">test/teimath.xsl</xref></item>
<item> James Tauber prepared a simple XSL spec (<xref
url="test/darkness.xsl">darkness.xsl</xref>) for Joseph Conrad's 
<xref url="test/darkness.xml"><emph>Heart of
Darkness</emph></xref>, which I ran to PDF as <xref
url="test/darkness.pdf">darkness.pdf</xref></item>
</list>
</p>
</div>
  
<div>
<head>Concerns and problems</head>
<p>
Some points to bear in mind
<list type="ordered">
  <item> This is an experimental system to check whether the
       idea works. Expect something more polished eventually.</item>
  <item> You need a modern TeX setup (like
    <xref url="http://www.tug.org/teTeX/">teTeX</xref> or
   <xref url="http://www.tug.org/texlive/">TeX Live</xref>) 
to get to grips with it.</item>
  <item> Quite a few flow objects and characteristics are not dealt with yet.
       I will add support for more things as needed or requested.</item>
  <item> I do not have any objective check that what I think XSL FOs are
       supposed to do is actually right :-}</item>
  <item> I have only worked so far with the TEI Lite (XML version) and
    Docbook DTDs,  and probably misinterpreted half of what they say.</item>
</list>
</p>
</div>

<div>
<head>Things for LaTeX users to remember</head>
<p>
<list type="unordered">
<item> No use is made of LaTeX high-level constructs. No sections,
  no lists, no cross-refs, no bibliographies; on the other hand, 
 some extensions in the <code>fotex:</code> namespace are supported 
(eg to get Acrobat bookmarks)
</item>
<item> XSL FO's underlying character set is Unicode; by default,
  entities are mapped to their Unicode position;
</item>
<item> All vertical and horizontal space is explicit in the
  specification
</item>
<item> Page and line breaking is left to TeX: the rest is up to you.
</item>
</list>
</p>
</div>

<div>
<head>Future directions</head>
<p>
<list type="unordered">
<item>Complete the MathML handling</item>
<item>Handle more variety in property values (eg colors, fonts) </item>
<item>Deal with more complex tables</item>
<item>Support SVG. How?
 <list type="unordered">
   <item>By direct intepretation and mapping to raw PDF</item>
   <item>By translation to MetaPost, and spawning a MetaPost process</item>
   <item>By pre-processing to existing TeX graphics languages</item>
 </list>
In any case, SVG fragments need to be recognized directly to perform in-line
graphical functions (setting text at an angle?)
</item>
<item>Use Unicode-based TeX variant (Omega) to handle non-Latin material
more naturally</item>
</list>
</p>
<p>
I will be very glad to discuss details with anyone. Contact me (Sebastian Rahtz) as
<xref url="mailto:sebastian.rahtz@oucs.ox.ac.uk">sebastian.rahtz@oucs.ox.ac.uk</xref>
</p>
</div>
</body>
</text>
</TEI.2>

