summaryrefslogtreecommitdiffstats
path: root/docs/manual/style/latex/latex.xsl
blob: 862d063f1c209dbe3bac1c0d2203a0ddfb9347c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
<?xml version="1.0" encoding="ISO-8859-1"?>

<!--
 Copyright 2003-2004 The Apache Software Foundation

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
-->

<xsl:stylesheet version="1.0"
              xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output 
  method="text"
  encoding="ISO-8859-1"
  indent="no"
/>

<!-- Read the localized messages from the specified language file -->
<xsl:variable name="messages" select="document('../lang/en.xml')/messages"/>

<!-- Get the guts of the stylesheets -->
<xsl:include href="manualpage.xsl" />
<xsl:include href="common.xsl" />
<xsl:include href="html.xsl" />
<xsl:include href="synopsis.xsl" />
<xsl:include href="moduleindex.xsl" />
<xsl:include href="directiveindex.xsl" />
<xsl:include href="faq.xsl" />
<xsl:include href="quickreference.xsl" />

<xsl:template match="sitemap">
<xsl:text>
\documentclass[10pt]{book}
\usepackage{times}
\usepackage{longtable}
\usepackage{style/latex/atbeginend}
%\usepackage[pdftex]{color}
\usepackage[colorlinks=true,letterpaper=true,linkcolor=blue,urlcolor=blue]{hyperref}

% Let LaTeX be lenient about very-bad line wrapping.
\tolerance=9999 
\emergencystretch=60pt

% Adjust margins to a reasonable level
\topmargin 0pt
\advance \topmargin by -\headheight
\advance \topmargin by -\headsep
\textheight 8.9in
\oddsidemargin 0pt
\evensidemargin \oddsidemargin
\marginparwidth 0.5in
\textwidth 6.5in

% Keep paragraphs flush left (rather than the default of indenting
% the first line) and put a space between paragraphs.
\setlength{\parindent}{0ex}
\addtolength{\parskip}{1.2ex}

% Shrink the inter-item spaces
\AfterBegin{itemize}{\setlength{\itemsep}{0em}}

\pagestyle{headings}

\hypersetup{
    pdftitle={</xsl:text>
<xsl:value-of select="$messages/message[@name='apache']" />
<xsl:text> </xsl:text>
<xsl:value-of select="$messages/message[@name='http-server']" />
<xsl:text> </xsl:text>
<xsl:value-of select="$messages/message[@name='documentation']" />
<xsl:text> </xsl:text>
<xsl:value-of select="$messages/message[@name='version']" />
<xsl:text>},
    pdfauthor={Apache Software Foundation}
  }

\title{</xsl:text>
<xsl:value-of select="$messages/message[@name='apache']" />
<xsl:text> </xsl:text>
<xsl:value-of select="$messages/message[@name='http-server']" />
<xsl:text> </xsl:text>
<xsl:value-of select="$messages/message[@name='documentation']" />
<xsl:text> </xsl:text>
<xsl:value-of select="$messages/message[@name='version']" />
<xsl:text>}
\author{Apache Software Foundation}
\date{\today}

\begin{document}
\frontmatter
\maketitle

\section*{About The PDF Documentation}

This is an early release of the PDF version of the Apache
Documentation.  It is converted from XML source files, and may contain
some errors and inconsistencies.  If you have difficulty reading a
part of this file, please consult instead the HTML version of the
documentation on the Apache HTTP Server website.

\tableofcontents
\mainmatter
</xsl:text>

<xsl:for-each select="category">
  <xsl:text>\chapter{</xsl:text>
  <xsl:apply-templates select="title" mode="printcat"/>
  <xsl:text>}
</xsl:text>
    <xsl:apply-templates/>
</xsl:for-each>

<xsl:text>\end{document}</xsl:text>
</xsl:template>

<xsl:template match="page">
<xsl:text>\include{</xsl:text>
<xsl:choose>
<xsl:when test="contains(@href,'.')">
  <xsl:value-of select="substring-before(@href,'.')"/>
</xsl:when>
<xsl:otherwise>
  <xsl:value-of select="concat(@href,'index')"/>
</xsl:otherwise>
</xsl:choose>
<xsl:text>}
</xsl:text>
</xsl:template>

<xsl:template match="category/title" mode="printcat">
<xsl:apply-templates/>
</xsl:template>

<xsl:template match="category/title"></xsl:template>

<xsl:template match="modulefilelist">
<xsl:apply-templates/>
</xsl:template>

<xsl:template match="modulefile">
<xsl:text>\include{mod/</xsl:text>
<xsl:value-of select="substring-before(.,'.')"/>
<xsl:text>}
</xsl:text>
</xsl:template>

<xsl:template match="summary">
<xsl:apply-templates/>
</xsl:template>

<xsl:template name="replace-string">
  <xsl:param name="text"/>
  <xsl:param name="replace"/>
  <xsl:param name="with"/>
    
  <xsl:choose>
    <xsl:when test="not(contains($text,$replace))">
      <xsl:value-of select="$text"/>
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="substring-before($text,$replace)"/>
      <xsl:value-of select="$with"/>
      <xsl:call-template name="replace-string">
        <xsl:with-param name="text" select="substring-after($text,$replace)"/>
        <xsl:with-param name="replace" select="$replace"/>
        <xsl:with-param name="with" select="$with"/>
       </xsl:call-template>
     </xsl:otherwise>
   </xsl:choose>
</xsl:template>

<!-- ==================================================================== -->
<!-- Take care of all the LaTeX special characters.                       -->
<!-- Silly multi-variable technique used to avoid deep recursion.         -->
<!-- ==================================================================== -->
<xsl:template match="text()">
<xsl:call-template name="ltescape">
  <xsl:with-param name="string" select="."/>
</xsl:call-template>
</xsl:template>


<xsl:template name="ltescape">
<xsl:param name="string"/>

<xsl:variable name="result1">
 <xsl:choose>
 <xsl:when test="contains($string, '\')">
   <xsl:call-template name="replace-string">
    <xsl:with-param name="replace" select="'\'"/>
    <xsl:with-param name="with" select="'\textbackslash '"/>
    <xsl:with-param name="text" select="normalize-space($string)"/>
   </xsl:call-template>
 </xsl:when>
 <xsl:otherwise>
   <xsl:value-of select="$string"/>
 </xsl:otherwise>
 </xsl:choose>
</xsl:variable>

<xsl:variable name="result2">
 <xsl:choose>
 <xsl:when test="contains($result1, '$')">
   <xsl:call-template name="replace-string">
    <xsl:with-param name="replace" select="'$'"/>
    <xsl:with-param name="with" select="'\$'"/>
    <xsl:with-param name="text" select="$result1"/>
   </xsl:call-template>
 </xsl:when>
 <xsl:otherwise>
   <xsl:value-of select="$result1"/>
 </xsl:otherwise>
 </xsl:choose>
</xsl:variable>

<xsl:variable name="result3">
 <xsl:choose>
 <xsl:when test="contains($result2, '{')">
   <xsl:call-template name="replace-string">
    <xsl:with-param name="replace" select="'{'"/>
    <xsl:with-param name="with" select="'\{'"/>
    <xsl:with-param name="text" select="$result2"/>
   </xsl:call-template>
 </xsl:when>
 <xsl:otherwise>
   <xsl:value-of select="$result2"/>
 </xsl:otherwise>
 </xsl:choose>
</xsl:variable>

<xsl:variable name="result4">
 <xsl:choose>
 <xsl:when test="contains($result3, '}')">
   <xsl:call-template name="replace-string">
    <xsl:with-param name="replace" select="'}'"/>
    <xsl:with-param name="with" select="'\}'"/>
    <xsl:with-param name="text" select="$result3"/>
   </xsl:call-template>
 </xsl:when>
 <xsl:otherwise>
   <xsl:value-of select="$result3"/>
 </xsl:otherwise>
 </xsl:choose>
</xsl:variable>

<!-- The '[' and ']' characters don't, in general, need to be
  escaped.  But there are times when it is ambiguous whether
  [ is the beginning of an optional argument or a literal '['.
  Hence, it is safer to protect the literal ones with {}. -->
<xsl:variable name="result5">
 <xsl:choose>
 <xsl:when test="contains($result4, '[')">
   <xsl:call-template name="replace-string">
    <xsl:with-param name="replace" select="'['"/>
    <xsl:with-param name="with" select="'{[}'"/>
    <xsl:with-param name="text" select="$result4"/>
   </xsl:call-template>
 </xsl:when>
 <xsl:otherwise>
   <xsl:value-of select="$result4"/>
 </xsl:otherwise>
 </xsl:choose>
</xsl:variable>

<xsl:variable name="result6">
 <xsl:choose>
 <xsl:when test="contains($result5, ']')">
   <xsl:call-template name="replace-string">
    <xsl:with-param name="replace" select="']'"/>
    <xsl:with-param name="with" select="'{]}'"/>
    <xsl:with-param name="text" select="$result5"/>
   </xsl:call-template>
 </xsl:when>
 <xsl:otherwise>
   <xsl:value-of select="$result5"/>
 </xsl:otherwise>
 </xsl:choose>
</xsl:variable>

<xsl:variable name="result7">
 <xsl:choose>
 <xsl:when test="contains($result6, '&quot;')">
   <xsl:call-template name="replace-string">
    <xsl:with-param name="replace" select="'&quot;'"/>
    <xsl:with-param name="with" select="'\texttt{&quot;}'"/>
    <xsl:with-param name="text" select="$result6"/>
   </xsl:call-template>
 </xsl:when>
 <xsl:otherwise>
   <xsl:value-of select="$result6"/>
 </xsl:otherwise>
 </xsl:choose>
</xsl:variable>


    <xsl:call-template name="replace-string">
    <xsl:with-param name="replace" select="'_'"/>
    <xsl:with-param name="with" select="'\_'"/>
    <xsl:with-param name="text">
      <xsl:call-template name="replace-string">
      <xsl:with-param name="replace" select="'#'"/>
      <xsl:with-param name="with" select="'\#'"/>
      <xsl:with-param name="text">
        <xsl:call-template name="replace-string">
        <xsl:with-param name="replace" select="'%'"/>
        <xsl:with-param name="with" select="'\%'"/>
        <xsl:with-param name="text">
          <xsl:call-template name="replace-string">
          <xsl:with-param name="replace" select="'&gt;'"/>
          <xsl:with-param name="with" select="'\textgreater{}'"/>
          <xsl:with-param name="text">
            <xsl:call-template name="replace-string">
            <xsl:with-param name="replace" select="'&lt;'"/>
            <xsl:with-param name="with" select="'\textless{}'"/>
            <xsl:with-param name="text">
              <xsl:call-template name="replace-string">
              <xsl:with-param name="replace" select="'~'"/>
              <xsl:with-param name="with" select="'\textasciitilde{}'"/>
              <xsl:with-param name="text">
                <xsl:call-template name="replace-string">
                <xsl:with-param name="replace" select="'^'"/>
                <xsl:with-param name="with" select="'\^{}'"/>
                <xsl:with-param name="text">
                    <xsl:call-template name="replace-string">
                    <xsl:with-param name="replace" select="'&amp;'"/>
                    <xsl:with-param name="with" select="'\&amp;'"/>
                    <xsl:with-param name="text" select="$result7"/>
                    </xsl:call-template>
                </xsl:with-param>
                </xsl:call-template>
              </xsl:with-param>
              </xsl:call-template>
            </xsl:with-param>
            </xsl:call-template>
          </xsl:with-param>
          </xsl:call-template>
        </xsl:with-param>
        </xsl:call-template>
      </xsl:with-param>
      </xsl:call-template>
    </xsl:with-param>
    </xsl:call-template>

</xsl:template>

</xsl:stylesheet>