* installer/win32/dia.nsi: Save diagrams by default in "My Pictures";
[dia.git] / doc / docbook.xsl
blobd0f4367b87a7958e23c758b344f6f87164cfee00
1 <?xml version='1.0'?>
2 <!-- vim:set sts=2 shiftwidth=2 syntax=sgml: -->
3 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4 version='1.0'>
6 <xsl:import href="../html/docbook.xsl"/>
7 <xsl:include href="synop.xsl"/>
8 <xsl:include href="lists.xsl"/>
9 <xsl:include href="xref.xsl"/>
11 <!-- Needed for chunker.xsl (for now): -->
12 <xsl:param name="chunker.output.method" select="'text'"/>
13 <xsl:param name="chunker.output.encoding" select="'ISO-8859-1'"/>
15 <xsl:output method="text"
16 encoding="ISO-8859-1"
17 indent="no"/>
19 <!--
20 named templates for bold and italic. call like:
22 <xsl:apply-templates mode="bold" select="node-you-want" />
23 -->
24 <xsl:template mode="bold" match="*">
25 <xsl:variable name="content">
26 <xsl:apply-templates/>
27 </xsl:variable>
28 <xsl:text>\fB</xsl:text>
29 <xsl:value-of select="$content"/>
30 <xsl:text>\fR</xsl:text>
31 </xsl:template>
33 <xsl:template mode="italic" match="*">
34 <xsl:variable name="content">
35 <xsl:apply-templates/>
36 </xsl:variable>
37 <xsl:text>\fI</xsl:text>
38 <xsl:value-of select="$content"/>
39 <xsl:text>\fR</xsl:text>
40 </xsl:template>
42 <xsl:template match="caution|important|note|tip|warning">
43 <xsl:text>&#10;.RS&#10;.Sh "</xsl:text>
44 <!-- capitalize word -->
45 <xsl:value-of
46 select="translate (substring (name(.), 1, 1), 'cintw', 'CINTW')" />
47 <xsl:value-of select="substring (name(), 2)" />
48 <xsl:if test="title">
49 <xsl:text>: </xsl:text>
50 <xsl:value-of select="title[1]"/>
51 </xsl:if>
52 <xsl:text>"&#10;</xsl:text>
53 <xsl:apply-templates/>
54 <xsl:text>&#10;.RE&#10;</xsl:text>
55 </xsl:template>
57 <xsl:template match="refsection|refsect1">
58 <xsl:choose>
59 <xsl:when test="ancestor::refsection">
60 <xsl:text>&#10;.SS "</xsl:text>
61 <xsl:value-of select="title[1]"/>
62 </xsl:when>
63 <xsl:otherwise>
64 <xsl:text>&#10;.SH "</xsl:text>
65 <xsl:value-of select="translate(title[1],'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
66 </xsl:otherwise>
67 </xsl:choose>
68 <xsl:text>"&#10;</xsl:text>
69 <xsl:apply-templates/>
70 </xsl:template>
72 <xsl:template match="refsect2">
73 <xsl:text>&#10;.SS "</xsl:text>
74 <xsl:value-of select="title[1]"/>
75 <xsl:text>"&#10;</xsl:text>
76 <xsl:apply-templates/>
77 </xsl:template>
79 <xsl:template match="refsynopsisdiv">
80 <xsl:text>&#10;.SH "SYNOPSIS"&#10;</xsl:text>
81 <xsl:apply-templates/>
82 </xsl:template>
85 <xsl:template match="para">
86 <xsl:text>&#10;.PP&#10;</xsl:text>
87 <xsl:for-each select="node()">
88 <xsl:choose>
89 <xsl:when test="self::literallayout|self::informaltable|self::screen|
90 self::programlisting|self::itemizedlist|
91 self::orderedlist|self::variablelist|self::simplelist">
92 <xsl:text>&#10;</xsl:text>
93 <xsl:apply-templates select="."/>
94 </xsl:when>
95 <xsl:when test="self::text()">
96 <xsl:if test="starts-with(translate(.,'&#10;',' '), ' ') and
97 preceding-sibling::node()[name(.)!='']">
98 <xsl:text> </xsl:text>
99 </xsl:if>
100 <xsl:variable name="content">
101 <xsl:apply-templates select="."/>
102 </xsl:variable>
103 <xsl:value-of select="normalize-space($content)"/>
104 <xsl:if
105 test="translate(substring(., string-length(.), 1),'&#10;',' ') = ' ' and
106 following-sibling::node()[name(.)!='']">
107 <xsl:text> </xsl:text>
108 </xsl:if>
109 </xsl:when>
110 <xsl:otherwise>
111 <xsl:variable name="content">
112 <xsl:apply-templates select="."/>
113 </xsl:variable>
114 <xsl:value-of select="normalize-space($content)"/>
115 </xsl:otherwise>
116 </xsl:choose>
117 </xsl:for-each>
118 <xsl:text>&#10;</xsl:text>
119 </xsl:template>
121 <xsl:template match="simpara">
122 <xsl:variable name="content">
123 <xsl:apply-templates/>
124 </xsl:variable>
125 <xsl:text>&#10;&#10;</xsl:text>
126 <xsl:value-of select="normalize-space($content)"/>
127 <xsl:text>
128 </xsl:text>
129 </xsl:template>
132 <xsl:template match="refentry">
134 <xsl:variable name="section">
135 <xsl:choose>
136 <xsl:when test="refmeta/manvolnum">
137 <xsl:value-of select="refmeta/manvolnum[1]"/>
138 </xsl:when>
139 <xsl:when test=".//funcsynopsis">3</xsl:when>
140 <xsl:otherwise>1</xsl:otherwise>
141 </xsl:choose>
142 </xsl:variable>
144 <xsl:variable name="name" select="refnamediv/refname[1]"/>
146 <!-- standard man page width is 64 chars; 6 chars needed for the two
147 (x) volume numbers, and 2 spaces, leaves 56 -->
148 <xsl:variable name="twidth" select="(56 - string-length(refmeta/refentrytitle)) div 2"/>
150 <xsl:variable name="reftitle"
151 select="substring(refmeta/refentrytitle, 1, $twidth)"/>
153 <xsl:variable name="title">
154 <xsl:choose>
155 <xsl:when test="refentryinfo/title">
156 <xsl:value-of select="refentryinfo/title"/>
157 </xsl:when>
158 <xsl:when test="../referenceinfo/title">
159 <xsl:value-of select="../referenceinfo/title"/>
160 </xsl:when>
161 </xsl:choose>
162 </xsl:variable>
164 <xsl:variable name="date">
165 <xsl:choose>
166 <xsl:when test="refentryinfo/date">
167 <xsl:value-of select="refentryinfo/date"/>
168 </xsl:when>
169 <xsl:when test="../referenceinfo/date">
170 <xsl:value-of select="../referenceinfo/date"/>
171 </xsl:when>
172 </xsl:choose>
173 </xsl:variable>
175 <xsl:variable name="productname">
176 <xsl:choose>
177 <xsl:when test="refentryinfo/productname">
178 <xsl:value-of select="refentryinfo/productname"/>
179 </xsl:when>
180 <xsl:when test="../referenceinfo/productname">
181 <xsl:value-of select="../referenceinfo/productname"/>
182 </xsl:when>
183 </xsl:choose>
184 </xsl:variable>
186 <!-- replace spaces with underscores in the filename -->
187 <xsl:variable name="filename">
188 <xsl:call-template name="replace-string">
189 <xsl:with-param name="content"
190 select="concat(normalize-space ($name), '.', $section)"/>
191 <xsl:with-param name="replace" select="' '"/>
192 <xsl:with-param name="with" select="'_'"/>
193 </xsl:call-template>
194 </xsl:variable>
196 <xsl:call-template name="write.text.chunk">
197 <xsl:with-param name="filename" select="$filename"/>
198 <xsl:with-param name="content">
199 <xsl:text>.\"Generated by db2man.xsl. Don't modify this, modify the source.
200 .de Sh \" Subsection
202 .if t .Sp
203 .ne 5
205 \fB\\$1\fR
208 .de Sp \" Vertical space (when we can't use .PP)
209 .if t .sp .5v
210 .if n .sp
212 .de Ip \" List item
214 .ie \\n(.$>=3 .ne \\$3
215 .el .ne 3
216 .IP "\\$1" \\$2
218 .TH "</xsl:text>
219 <xsl:value-of select="translate($reftitle,'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
220 <xsl:text>" </xsl:text>
221 <xsl:value-of select="$section"/>
222 <xsl:text> "</xsl:text>
223 <xsl:value-of select="normalize-space($date)"/>
224 <xsl:text>" "</xsl:text>
225 <xsl:value-of select="normalize-space($productname)"/>
226 <xsl:text>" "</xsl:text>
227 <xsl:value-of select="$title"/>
228 <xsl:text>"
229 </xsl:text>
230 <xsl:apply-templates/>
231 <xsl:text>&#10;</xsl:text>
233 <!-- Author section -->
234 <xsl:choose>
235 <xsl:when test="refentryinfo//author">
236 <xsl:apply-templates select="refentryinfo" mode="authorsect"/>
237 </xsl:when>
238 <xsl:when test="/book/bookinfo//author">
239 <xsl:apply-templates select="/book/bookinfo" mode="authorsect"/>
240 </xsl:when>
241 <xsl:when test="/article/articleinfo//author">
242 <xsl:apply-templates select="/article/articleinfo" mode="authorsect"/>
243 </xsl:when>
244 </xsl:choose>
246 </xsl:with-param>
247 </xsl:call-template>
248 <!-- Now generate stub include pages for every page documented in
249 this refentry (except the page itself) -->
250 <xsl:for-each select="refnamediv/refname">
251 <xsl:if test=". != $name">
252 <xsl:call-template name="write.text.chunk">
253 <xsl:with-param name="filename"
254 select="concat(normalize-space(.), '.', $section)"/>
255 <xsl:with-param name="content" select="concat('.so man',
256 $section, '/', $name, '.', $section, '&#10;')"/>
257 </xsl:call-template>
258 </xsl:if>
259 </xsl:for-each>
260 </xsl:template>
262 <xsl:template match="refmeta"></xsl:template>
263 <xsl:template match="title"></xsl:template>
264 <xsl:template match="abstract"></xsl:template>
266 <xsl:template match="articleinfo|bookinfo|refentryinfo" mode="authorsect">
267 <xsl:text>.SH AUTHOR</xsl:text>
268 <xsl:if test="count(.//author)>1">
269 <xsl:text>S</xsl:text>
270 </xsl:if>
271 <xsl:text>&#10;</xsl:text>
273 <xsl:for-each select=".//author">
274 <xsl:if test="position() > 1">
275 <xsl:text>, </xsl:text>
276 </xsl:if>
277 <xsl:variable name="author">
278 <xsl:apply-templates select="."/>
279 </xsl:variable>
280 <xsl:value-of select="normalize-space($author)"/>
281 </xsl:for-each>
282 <xsl:text>.&#10;</xsl:text>
283 <xsl:if test=".//editor">
284 <xsl:text>.br&#10;Man page edited by </xsl:text>
285 <xsl:apply-templates select=".//editor"/>
286 <xsl:text>.&#10;</xsl:text>
287 </xsl:if>
288 </xsl:template>
290 <xsl:template match="author|editor">
291 <xsl:call-template name="person.name"/>
292 <xsl:apply-templates select="./affiliation/address/email" />
293 </xsl:template>
295 <xsl:template match="copyright">
296 <xsl:text>Copyright \(co </xsl:text>
297 <xsl:apply-templates select="./year" />
298 <xsl:text>&#10;.Sp&#10;</xsl:text>
299 </xsl:template>
301 <xsl:template match="email">
302 <xsl:text> &lt;</xsl:text>
303 <xsl:apply-templates/>
304 <xsl:text>&gt;</xsl:text>
305 </xsl:template>
307 <xsl:template match="refnamediv">
308 <xsl:text>.SH NAME&#10;</xsl:text>
309 <xsl:for-each select="refname">
310 <xsl:if test="position()>1">
311 <xsl:text>, </xsl:text>
312 </xsl:if>
313 <xsl:value-of select="."/>
314 </xsl:for-each>
315 <xsl:text> \- </xsl:text>
316 <xsl:value-of select="normalize-space (refpurpose)"/>
317 </xsl:template>
319 <xsl:template match="refentry/refentryinfo"></xsl:template>
321 <xsl:template match="informalexample|screen">
322 <xsl:text>&#10;.IP&#10;</xsl:text>
323 <xsl:apply-templates/>
324 </xsl:template>
326 <xsl:template match="filename|replaceable|varname">
327 <xsl:text>\fI</xsl:text><xsl:apply-templates/><xsl:text>\fR</xsl:text>
328 </xsl:template>
330 <xsl:template match="option|userinput|envar|errorcode|constant|type">
331 <xsl:text>\fB</xsl:text><xsl:apply-templates/><xsl:text>\fR</xsl:text>
332 </xsl:template>
334 <xsl:template match="emphasis">
335 <xsl:choose>
336 <xsl:when test="@role = 'bold' and $emphasis.propagates.style != 0">
337 <xsl:text>\fB</xsl:text><xsl:apply-templates/><xsl:text>\fR</xsl:text>
338 </xsl:when>
339 <xsl:otherwise>
340 <xsl:text>\fI</xsl:text><xsl:apply-templates/><xsl:text>\fR</xsl:text>
341 </xsl:otherwise>
342 </xsl:choose>
343 </xsl:template>
345 <xsl:template match="quote">
346 <xsl:text>``</xsl:text>
347 <xsl:apply-templates/>
348 <xsl:text>''</xsl:text>
349 </xsl:template>
351 <xsl:template match="programlisting|literallayout">
352 <xsl:text>&#10;.nf&#10;</xsl:text>
353 <xsl:apply-templates/>
354 <xsl:text>&#10;.fi&#10;</xsl:text>
355 </xsl:template>
357 <xsl:template match="optional">
358 <xsl:value-of select="$arg.choice.opt.open.str"/>
359 <xsl:apply-templates/>
360 <xsl:value-of select="$arg.choice.opt.close.str"/>
361 </xsl:template>
363 <xsl:template name="do-citerefentry">
364 <xsl:param name="refentrytitle" select="''"/>
365 <xsl:param name="manvolnum" select="''"/>
367 <xsl:apply-templates mode="bold" select="$refentrytitle"/>
368 <xsl:text>(</xsl:text>
369 <xsl:value-of select="$manvolnum"/>
370 <xsl:text>)</xsl:text>
371 </xsl:template>
373 <xsl:template match="citerefentry">
374 <xsl:call-template name="do-citerefentry">
375 <xsl:with-param name="refentrytitle" select="refentrytitle"/>
376 <xsl:with-param name="manvolnum" select="manvolnum"/>
377 </xsl:call-template>
378 </xsl:template>
380 <xsl:template match="ulink">
381 <xsl:variable name="content">
382 <xsl:apply-templates/>
383 </xsl:variable>
384 <xsl:variable name="url" select="@url"/>
385 <xsl:choose>
386 <xsl:when test="$url=$content or $content=''">
387 <xsl:text>\fI</xsl:text>
388 <xsl:value-of select="$url"/>
389 <xsl:text>\fR</xsl:text>
390 </xsl:when>
391 <xsl:otherwise>
392 <xsl:value-of select="$content"/>
393 <xsl:text>: \fI</xsl:text>
394 <xsl:value-of select="$url"/>
395 <xsl:text>\fR</xsl:text>
396 </xsl:otherwise>
397 </xsl:choose>
398 </xsl:template>
400 <!-- Translate some entities to textual equivalents. -->
401 <xsl:template name="replace-string">
402 <xsl:param name="content" select="''"/>
403 <xsl:param name="replace" select="''"/>
404 <xsl:param name="with" select="''"/>
405 <xsl:choose>
406 <xsl:when test="not(contains($content,$replace))">
407 <xsl:value-of select="$content"/>
408 </xsl:when>
409 <xsl:otherwise>
410 <xsl:value-of select="substring-before($content,$replace)"/>
411 <xsl:value-of select="$with"/>
412 <xsl:call-template name="replace-string">
413 <xsl:with-param name="content"
414 select="substring-after($content,$replace)"/>
415 <xsl:with-param name="replace" select="$replace"/>
416 <xsl:with-param name="with" select="$with"/>
417 </xsl:call-template>
418 </xsl:otherwise>
419 </xsl:choose>
420 </xsl:template>
422 <xsl:template name="replace-dash">
423 <xsl:param name="content" select="''"/>
424 <xsl:call-template name="replace-string">
425 <xsl:with-param name="content" select="$content"/>
426 <xsl:with-param name="replace" select="'-'"/>
427 <xsl:with-param name="with" select="'\-'"/>
428 </xsl:call-template>
429 </xsl:template>
431 <xsl:template name="replace-ndash">
432 <xsl:param name="content" select="''"/>
433 <xsl:call-template name="replace-string">
434 <xsl:with-param name="content" select="$content"/>
435 <xsl:with-param name="replace" select="'&#8211;'"/>
436 <xsl:with-param name="with" select="'-'"/>
437 </xsl:call-template>
438 </xsl:template>
440 <xsl:template name="replace-mdash">
441 <xsl:param name="content" select="''"/>
442 <xsl:call-template name="replace-string">
443 <xsl:with-param name="content" select="$content"/>
444 <xsl:with-param name="replace" select="'&#8212;'"/>
445 <xsl:with-param name="with" select="'--'"/>
446 </xsl:call-template>
447 </xsl:template>
449 <xsl:template name="replace-hellip">
450 <xsl:param name="content" select="''"/>
451 <xsl:call-template name="replace-string">
452 <xsl:with-param name="content" select="$content"/>
453 <xsl:with-param name="replace" select="'&#8230;'"/>
454 <xsl:with-param name="with" select="'...'"/>
455 </xsl:call-template>
456 </xsl:template>
458 <xsl:template name="replace-setmn">
459 <xsl:param name="content" select="''"/>
460 <xsl:call-template name="replace-string">
461 <xsl:with-param name="content" select="$content"/>
462 <xsl:with-param name="replace" select="'&#8726;'"/>
463 <xsl:with-param name="with" select="'\\'"/>
464 </xsl:call-template>
465 </xsl:template>
467 <xsl:template name="replace-minus">
468 <xsl:param name="content" select="''"/>
469 <xsl:value-of select="translate($content,'&#8722;','-')"/>
470 </xsl:template>
472 <xsl:template name="replace-nbsp">
473 <xsl:param name="content" select="''"/>
474 <xsl:call-template name="replace-string">
475 <xsl:with-param name="content" select="$content"/>
476 <xsl:with-param name="replace" select="'&#x00a0;'"/>
477 <xsl:with-param name="with" select="'\~'"/>
478 </xsl:call-template>
479 </xsl:template>
481 <xsl:template name="replace-backslash">
482 <xsl:param name="content" select="''"/>
483 <xsl:call-template name="replace-string">
484 <xsl:with-param name="content" select="$content"/>
485 <xsl:with-param name="replace" select="'\'"/>
486 <xsl:with-param name="with" select="'\\'"/>
487 </xsl:call-template>
488 </xsl:template>
490 <!-- if a period character is output at the beginning of a line
491 it will be interpreted as a groff macro, so prefix all periods
492 with "\&", a zero-width space. -->
493 <xsl:template name="replace-period">
494 <xsl:param name="content" select="''"/>
495 <xsl:call-template name="replace-string">
496 <xsl:with-param name="content" select="$content"/>
497 <xsl:with-param name="replace" select="'.'"/>
498 <xsl:with-param name="with" select="'\&#38;.'"/>
499 </xsl:call-template>
500 </xsl:template>
502 <xsl:template name="replace-entities">
503 <xsl:param name="content" select="''"/>
504 <xsl:call-template name="replace-hellip">
505 <xsl:with-param name="content">
506 <xsl:call-template name="replace-minus">
507 <xsl:with-param name="content">
508 <xsl:call-template name="replace-mdash">
509 <xsl:with-param name="content">
510 <xsl:call-template name="replace-ndash">
511 <xsl:with-param name="content">
512 <xsl:call-template name="replace-dash">
513 <xsl:with-param name="content">
514 <xsl:call-template name="replace-setmn">
515 <xsl:with-param name="content">
516 <xsl:call-template name="replace-period">
517 <xsl:with-param name="content">
518 <xsl:call-template name="replace-nbsp">
519 <xsl:with-param name="content">
520 <xsl:call-template name="replace-backslash">
521 <xsl:with-param name="content" select="$content"/>
522 </xsl:call-template>
523 </xsl:with-param>
524 </xsl:call-template>
525 </xsl:with-param>
526 </xsl:call-template>
527 </xsl:with-param>
528 </xsl:call-template>
529 </xsl:with-param>
530 </xsl:call-template>
531 </xsl:with-param>
532 </xsl:call-template>
533 </xsl:with-param>
534 </xsl:call-template>
535 </xsl:with-param>
536 </xsl:call-template>
537 </xsl:with-param>
538 </xsl:call-template>
539 </xsl:template>
541 <xsl:template match="dingbat.characters">
542 <!-- now that I'm using the real serializer, all that dingbat malarky -->
543 <!-- isn't necessary anymore... -->
544 <xsl:param name="dingbat">bullet</xsl:param>
545 <xsl:choose>
546 <xsl:when test="$dingbat='bullet'">\(bu</xsl:when>
547 <xsl:when test="$dingbat='copyright'">\(co</xsl:when>
548 <xsl:when test="$dingbat='trademark'">\(tm</xsl:when>
549 <xsl:when test="$dingbat='trade'">\(tm</xsl:when>
550 <xsl:when test="$dingbat='registered'">\(rg</xsl:when>
551 <xsl:when test="$dingbat='service'">(SM)</xsl:when>
552 <xsl:when test="$dingbat='nbsp'">\~</xsl:when>
553 <xsl:when test="$dingbat='ldquo'">\(lq</xsl:when>
554 <xsl:when test="$dingbat='rdquo'">\(rq</xsl:when>
555 <xsl:when test="$dingbat='lsquo'">`</xsl:when>
556 <xsl:when test="$dingbat='rsquo'">'</xsl:when>
557 <xsl:when test="$dingbat='em-dash'">\(em</xsl:when>
558 <xsl:when test="$dingbat='mdash'">\(em</xsl:when>
559 <xsl:when test="$dingbat='en-dash'">\(en</xsl:when>
560 <xsl:when test="$dingbat='ndash'">\(en</xsl:when>
561 <xsl:otherwise>
562 <xsl:text>\(bu</xsl:text>
563 </xsl:otherwise>
564 </xsl:choose>
565 </xsl:template>
567 <xsl:template match="text()">
568 <xsl:call-template name="replace-entities">
569 <xsl:with-param name="content">
570 <xsl:value-of select="."/>
571 </xsl:with-param>
572 </xsl:call-template>
573 </xsl:template>
575 <xsl:template match="/">
576 <xsl:choose>
577 <xsl:when test="//refentry">
578 <xsl:apply-templates select="//refentry"/>
579 </xsl:when>
580 <xsl:otherwise>
581 <xsl:message>No refentry elements!</xsl:message>
582 </xsl:otherwise>
583 </xsl:choose>
584 </xsl:template>
586 </xsl:stylesheet>