Moving docs tree to docs-xml to make room for generated docs in the release tarball.
[samba.git] / docs-xml / xslt / docbook2pearson.xsl
1 <?xml version='1.0'?>
2 <!-- 
3         Convert DocBook to XML validating against the Pearson DTD
4
5         (C) Jochen Hein
6         (C) Jelmer Vernooij <jelmer@samba.org>                  2004
7 -->
8 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
9         xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"
10         exclude-result-prefixes="doc"
11         version="1.1">
12
13         <!-- TODO <entry></entry> -> <entry><p/></entry> -->
14
15         <xsl:output method="xml"
16                 encoding="UTF-8"
17                 doctype-public="-//Pearson//DTD Books//DE"
18                 doctype-system="http://www.pearson.de/pearson.dtd"
19                 indent="yes"
20                 omit-xml-declaration="no"
21                 standalone="no"/>
22
23         <!-- Warn about DocBook elements that are not converted -->
24         <xsl:template match="*">
25                 <xsl:message>
26                         <xsl:text>No template matches </xsl:text>
27                         <xsl:value-of select="name(.)"/>
28                         <xsl:text>.</xsl:text>
29                 </xsl:message>
30         </xsl:template>
31
32         <!--  
33         ====================================================================  
34         -->
35         <!-- Establish strip/preserve whitespace rules -->
36
37         <xsl:preserve-space elements="*"/>
38
39         <xsl:strip-space elements="
40                 abstract affiliation anchor answer appendix area areaset areaspec
41                 artheader article audiodata audioobject author authorblurb authorgroup
42                 beginpage bibliodiv biblioentry bibliography biblioset blockquote book
43                 bookbiblio bookinfo callout calloutlist caption caution
44                 city pubdate publisher publishername"/>
45
46         <xsl:template name="transform.id.attribute">
47                 <xsl:if test="@id != ''">
48                         <xsl:attribute name="id">
49                                 <xsl:value-of select="@id"/>
50                         </xsl:attribute>
51                 </xsl:if>
52         </xsl:template>
53
54         <xsl:template match="/" mode="default">
55                 <xsl:processing-instruction  
56                         name="xml-stylesheet">href="pearson.css"  
57                         type="text/css"</xsl:processing-instruction>
58                 <xsl:text>
59                 </xsl:text>
60                 <xsl:comment>
61                         <xsl:text>Transformed with pearson.xsl by Jochen Hein</xsl:text>
62                 </xsl:comment>
63                 <xsl:text>
64                 </xsl:text>
65                 <!-- Releaseinfo einbauen? -->
66                 <xsl:comment>
67                         <xsl:apply-templates select=".//releaseinfo" mode="comment"/>
68                 </xsl:comment>
69                 <xsl:text>
70                 </xsl:text>
71                 <xsl:apply-templates/>
72         </xsl:template>
73
74         <xsl:template match="book">
75                 <book>
76                         <xsl:apply-templates/>
77                 </book>
78         </xsl:template>
79
80         <xsl:template match="bookinfo">
81                 <bookinfo>
82                         <xsl:apply-templates/>
83                 </bookinfo>
84         </xsl:template>
85
86         <xsl:template match="author">
87                 <author>
88                         <xsl:apply-templates/>
89                 </author>
90         </xsl:template>
91
92         <xsl:template match="editor">
93                 <editor>
94                         <xsl:apply-templates/>
95                 </editor>
96         </xsl:template>
97
98         <xsl:template match="chapter">
99                 <chapter>
100                         <xsl:call-template name="transform.id.attribute"/>
101                         <xsl:apply-templates/>
102                 </chapter>
103         </xsl:template>
104
105         <xsl:template match="chapter/title/command">
106                 <xsl:apply-templates/>
107         </xsl:template>
108
109         <xsl:template match="index">
110        <xsl:comment> XXX insert index here </xsl:comment>
111    </xsl:template>
112
113    <xsl:template match="preface">
114            <preface>
115                    <xsl:call-template name="transform.id.attribute"/>
116                    <xsl:apply-templates/>
117            </preface>
118    </xsl:template>
119
120    <xsl:template match="section|sect1|sect2|sect3|sect4">
121            <sect>
122                    <xsl:call-template name="transform.id.attribute"/>
123                    <xsl:apply-templates/>
124            </sect>
125    </xsl:template>
126
127    <xsl:template match="partintro">
128            <xsl:copy>
129                    <xsl:apply-templates select="@*|node()"/>
130            </xsl:copy>
131    </xsl:template>
132
133    <xsl:template match="part">
134            <appendix>
135                    <xsl:apply-templates/>
136            </appendix>
137    </xsl:template>
138
139    <xsl:template match="appendix[1]">
140            <appendix>
141                    <chapter>
142                            <xsl:call-template name="transform.id.attribute"/>
143                            <xsl:apply-templates/>
144                    </chapter>
145                    <xsl:for-each select="following-sibling::appendix">
146                            <chapter>
147                                    <xsl:call-template name="transform.id.attribute"/>
148                                    <xsl:apply-templates/>
149                            </chapter>
150                    </xsl:for-each>
151            </appendix>
152    </xsl:template>
153
154    <xsl:template match="appendix[position() != 1]">
155    </xsl:template>
156
157    <xsl:template match="title">
158            <title><xsl:apply-templates/></title>
159    </xsl:template>
160
161         <xsl:param name="notpchilds" select="'variablelist itemizedlist orderedlist'"/>
162
163         <xsl:template match="para"> 
164                 <!-- loop thru all elements: -->
165                 <xsl:for-each select="*|text()">
166                         <xsl:choose>
167                                 <xsl:when test="string-length(name(.)) > 0 and contains($notpchilds,name(.))">
168                                         <xsl:message><xsl:text>Removing from p:</xsl:text><xsl:value-of select="name(.)"/></xsl:message>
169                                         <xsl:apply-templates select="."/>
170                                 </xsl:when>
171                                 <xsl:otherwise>
172                                         <xsl:call-template name="hstartpara"/>
173                                 </xsl:otherwise>
174                         </xsl:choose>
175                 </xsl:for-each>
176         </xsl:template>
177
178         <!-- Do open paragraph when previous sibling was not a valid p child -->
179         <xsl:template name="hstartpara">
180                 <xsl:if test="not(preceding-sibling::*[1]) or (contains($notpchilds,name(preceding-sibling::*[1])) and not(string-length(name(.)) > 0))">
181                         <p>
182                                 <xsl:apply-templates select="."/>
183                                 <xsl:for-each select="following-sibling::*[not(contains($notpchilds,name(.)) and string-length(name(.)) > 0)]">
184                                         <xsl:apply-templates select="."/>
185                                 </xsl:for-each>
186                         </p>
187                 </xsl:if>
188         </xsl:template>
189
190         <xsl:template name="hsubpara">
191                 <xsl:param name="data"/>
192                 <xsl:apply-templates select="$data"/>
193                 <xsl:if test="$data[following-sibling::*[1]]">
194                         <xsl:param name="next" select="$data[following-sibling::*[1]]"/>
195                         <xsl:message><xsl:value-of select="name(.)"/></xsl:message>
196                         <xsl:if test="$next and (not(contains($notpchilds,name($next))) or $next[text()])">
197                                 <xsl:message><xsl:text>Followed by : </xsl:text><xsl:value-of select="name($next)"/></xsl:message>
198                                 <xsl:call-template name="hsubpara">
199                                         <xsl:with-param name="data" select="$next"/>
200                                 </xsl:call-template>
201                                 <xsl:message><xsl:text>Done Followed by : </xsl:text><xsl:value-of select="name($next)"/></xsl:message>
202                         </xsl:if>
203                 </xsl:if>
204         </xsl:template>
205
206         <xsl:template match="tip">
207                 <tip><xsl:apply-templates/></tip>
208         </xsl:template>
209
210    <xsl:template match="warning|important|caution">
211            <stop><xsl:apply-templates/></stop>
212    </xsl:template>
213
214    <xsl:template match="note">
215            <info><xsl:apply-templates/></info>
216    </xsl:template>
217
218    <xsl:template match="emphasis">
219            <xsl:variable name="role" select="@role"/>
220
221            <xsl:choose>
222                    <xsl:when test="$role='italic'">
223                            <i><xsl:apply-templates/></i>
224                    </xsl:when>
225                    <xsl:otherwise>
226                            <em><xsl:apply-templates/></em>
227                    </xsl:otherwise>
228            </xsl:choose>
229    </xsl:template>
230
231    <xsl:template match="ulink">
232            <xsl:apply-templates/>
233            <footnote><p><url><xsl:value-of select="@ulink"/></url></p></footnote>
234         </xsl:template>
235
236    <xsl:template match="email">
237            <url>mailto:<xsl:apply-templates/></url>
238    </xsl:template>
239
240    <xsl:template match="indexterm">
241            <ie><xsl:apply-templates/></ie>
242    </xsl:template>
243
244    <xsl:template match="primary">
245            <t><xsl:apply-templates/></t>
246    </xsl:template>
247
248    <xsl:template match="secondary">
249            <t><xsl:apply-templates/></t>
250    </xsl:template>
251
252    <xsl:template match="citerefentry">
253            <xsl:value-of select="refentrytitle"/><xsl:text>(</xsl:text><xsl:value-of select="manvolnum"/><xsl:text>)</xsl:text>
254    </xsl:template>
255
256    <xsl:template match="formalpara">
257            <xsl:apply-templates/>
258    </xsl:template>
259
260    <xsl:template match="substeps">
261            <xsl:apply-templates/>
262    </xsl:template>
263
264    <xsl:template match="see|seealso">
265            <synonym><xsl:apply-templates/></synonym>
266    </xsl:template>
267
268    <xsl:template  
269            match="footnote"><footnote><xsl:apply-templates/></footnote></xsl:template>
270
271    <xsl:template match="command">
272            <code><xsl:apply-templates/></code>
273    </xsl:template>
274
275    <xsl:template match="function">
276            <code><xsl:apply-templates/></code>
277    </xsl:template>
278
279    <xsl:template match="systemitem">
280
281            <!-- xsl:if test="@role != '' and @role != 'signal'">
282            <xsl:message>
283                    Warning: role attribute is <xsl:value-of select="@role"/>
284            </xsl:message>
285    </xsl:if -->
286    <code><xsl:apply-templates/></code>
287    </xsl:template>
288
289    <xsl:template match="sgmltag">
290            <code><xsl:apply-templates/></code>
291    </xsl:template>
292
293    <xsl:template match="filename">
294            <code><xsl:apply-templates/></code>
295    </xsl:template>
296
297    <xsl:template match="errorcode">
298            <code><xsl:apply-templates/></code>
299    </xsl:template>
300
301    <xsl:template match="errortype">
302            <code><xsl:apply-templates/></code>
303    </xsl:template>
304
305    <xsl:template match="returnvalue">
306            <code><xsl:apply-templates/></code>
307    </xsl:template>
308
309    <xsl:template match="glosslist|glossary">
310            <dl><xsl:apply-templates/></dl>
311    </xsl:template>
312
313    <xsl:template match="glossentry">
314            <dlitem><xsl:apply-templates/></dlitem>
315    </xsl:template>
316
317    <xsl:template match="glossentry/acronym">
318            <dt><xsl:apply-templates/></dt>
319    </xsl:template>
320
321    <xsl:template match="acronym">
322            <b><xsl:apply-templates/></b>
323    </xsl:template>
324
325    <xsl:template match="glossterm">
326            <dt><xsl:apply-templates/></dt>
327    </xsl:template>
328
329    <xsl:template match="glossdef">
330            <dd><xsl:apply-templates/></dd>
331    </xsl:template>
332
333    <xsl:template match="itemizedlist">
334            <ul><xsl:apply-templates/></ul>
335    </xsl:template>
336
337    <xsl:template match="varlistentry/term">
338            <dt><xsl:apply-templates/></dt>
339    </xsl:template>
340
341    <xsl:template match="varlistentry/listitem">
342            <dd><xsl:apply-templates/></dd>
343    </xsl:template>
344
345    <xsl:template match="varlistentry">
346            <dlitem>
347                         <xsl:apply-templates/>
348            </dlitem>
349    </xsl:template>
350
351    <xsl:template match="variablelist">
352            <dl><xsl:apply-templates/></dl>
353    </xsl:template>
354
355    <xsl:template match="simplelist">
356            <ul>
357                    <xsl:for-each select="member">
358                            <li><p><xsl:apply-templates/></p></li>
359                    </xsl:for-each>
360            </ul>
361    </xsl:template>
362
363    <xsl:template match="orderedlist">
364            <xsl:variable name="numeration" select="@numeration"/>
365            <ol>
366                    <xsl:if test="$numeration != ''">
367                            <xsl:attribute name="type">
368                                    <xsl:value-of select="$numeration"/>
369                            </xsl:attribute>
370                    </xsl:if>
371                    <xsl:apply-templates/>
372            </ol>
373    </xsl:template>
374
375    <xsl:template match="listitem">
376            <li><xsl:apply-templates/></li>
377    </xsl:template>
378
379    <xsl:template match="firstterm">
380            <em><xsl:apply-templates/></em>
381    </xsl:template>
382
383    <xsl:template match="literal/systemitem">
384            <em><xsl:apply-templates/></em>
385    </xsl:template>
386
387    <xsl:template match="superscript">
388            <sup><xsl:apply-templates/></sup>
389    </xsl:template>
390
391    <xsl:template match="productname">
392            <xsl:apply-templates/>
393    </xsl:template>
394
395    <xsl:template match="keycombo">
396
397            <xsl:variable name="action" select="@action"/>
398            <xsl:variable name="joinchar">
399
400                    <xsl:choose>
401
402                            <xsl:when test="$action='seq'">
403                                    <xsl:text> </xsl:text></xsl:when>
404                            <xsl:when test="$action='simul'">+</xsl:when>
405                            <xsl:when test="$action='press'">-</xsl:when>
406                            <xsl:when test="$action='click'">-</xsl:when>
407                            <xsl:when test="$action='double-click'">-</xsl:when>
408                            <xsl:when test="$action='other'"></xsl:when>
409                            <xsl:otherwise>-</xsl:otherwise>
410                    </xsl:choose>
411            </xsl:variable>
412
413            <xsl:for-each select="*">
414                    <xsl:if test="position()>1"><xsl:value-of  
415                                    select="$joinchar"/></xsl:if>
416                    <xsl:apply-templates select="."/>
417            </xsl:for-each>
418
419    </xsl:template>
420
421
422    <xsl:template match="keycap">
423            <key><xsl:apply-templates/></key>
424    </xsl:template>
425
426    <xsl:template match="keycap/replaceable">
427            <xsl:apply-templates/>
428    </xsl:template>
429
430
431
432    <xsl:template match="menuchoice">
433            <xsl:variable name="shortcut" select="./shortcut"/>
434            <xsl:call-template name="process.menuchoice"/>
435            <xsl:if test="$shortcut">
436                    <xsl:text> (</xsl:text>
437                    <xsl:apply-templates select="$shortcut"/>
438                    <xsl:text>)</xsl:text>
439            </xsl:if>
440    </xsl:template>
441
442    <xsl:template name="process.menuchoice">
443            <xsl:param name="nodelist"  
444                    select="guibutton|guiicon|guilabel|guimenu|guimenuitem|guisubmenu|interface"/><!-- not(shortcut) -->
445            <xsl:param name="count" select="1"/>
446
447            <xsl:choose>
448                    <xsl:when test="$count>count($nodelist)"></xsl:when>
449                    <xsl:when test="$count=1">
450                            <xsl:apply-templates select="$nodelist[$count=position()]"/>
451                            <xsl:call-template name="process.menuchoice">
452                                    <xsl:with-param name="nodelist" select="$nodelist"/>
453                                    <xsl:with-param name="count" select="$count+1"/>
454                            </xsl:call-template>
455                    </xsl:when>
456                    <xsl:otherwise>
457                            <xsl:variable name="node" select="$nodelist[$count=position()]"/>
458                            <xsl:choose>
459                                    <xsl:when test="name($node)='guimenuitem'
460                                            or name($node)='guisubmenu'">
461                                            <xsl:text>-&gt;</xsl:text>
462                                    </xsl:when>
463                                    <xsl:otherwise>+</xsl:otherwise>
464                            </xsl:choose>
465                            <xsl:apply-templates select="$node"/>
466                            <xsl:call-template name="process.menuchoice">
467                                    <xsl:with-param name="nodelist" select="$nodelist"/>
468                                    <xsl:with-param name="count" select="$count+1"/>
469                            </xsl:call-template>
470                    </xsl:otherwise>
471            </xsl:choose>
472    </xsl:template>
473
474
475    <xsl:template match="guimenu">
476            <guiitem><xsl:apply-templates/></guiitem>
477    </xsl:template>
478
479    <xsl:template match="guimenuitem">
480            <guiitem><xsl:apply-templates/></guiitem>
481    </xsl:template>
482
483         <xsl:template match="guiicon">
484            <guiitem><xsl:apply-templates/></guiitem>
485    </xsl:template>
486
487    <xsl:template match="guilabel">
488            <guiitem><xsl:apply-templates/></guiitem>
489    </xsl:template>
490
491    <xsl:template match="guibutton">
492            <guiitem><xsl:apply-templates/></guiitem>
493    </xsl:template>
494
495    <xsl:template name="transform.epigraph">
496            <xsl:apply-templates select="para"/>
497            <xsl:apply-templates select="attribution"/>
498    </xsl:template>
499
500    <xsl:template match="epigraph">
501            <chapterintro><motto><xsl:call-template  
502                                    name="transform.epigraph"/></motto></chapterintro>
503    </xsl:template>
504
505    <xsl:template match="section/epigraph">
506            <motto><xsl:call-template name="transform.epigraph"/></motto>
507    </xsl:template>
508
509    <xsl:template match="epigraph/para">
510            <p><em><xsl:apply-templates/></em></p>
511    </xsl:template>
512    <xsl:template match="attribution">
513            <p><i><xsl:apply-templates/></i></p>
514    </xsl:template>
515
516    <xsl:template match="errorname">
517            <i><xsl:apply-templates/></i>
518    </xsl:template>
519
520    <xsl:template match="constant">
521            <b><xsl:apply-templates/></b>
522    </xsl:template>
523
524    <xsl:template match="envar">
525            <code><xsl:apply-templates/></code>
526    </xsl:template>
527
528    <xsl:template match="literal">
529            <code><xsl:apply-templates/></code>
530    </xsl:template>
531
532    <xsl:template match="option">
533            <code><xsl:apply-templates/></code>
534    </xsl:template>
535
536    <xsl:template match="parameter">
537            <code><xsl:apply-templates/></code>
538    </xsl:template>
539
540    <xsl:template match="application">
541            <b><xsl:apply-templates/></b>
542    </xsl:template>
543
544    <xsl:template match="screen/userinput">
545            <b><xsl:apply-templates/></b>
546    </xsl:template>
547
548    <xsl:template match="screen/prompt">
549            <xsl:apply-templates/>
550    </xsl:template>
551
552    <xsl:template match="prompt">
553            <code><xsl:apply-templates/></code>
554    </xsl:template>
555
556    <xsl:template match="userinput">
557            <code><b><xsl:apply-templates/></b></code>
558    </xsl:template>
559
560    <xsl:template match="computeroutput">
561            <code><xsl:apply-templates/></code>
562    </xsl:template>
563
564    <xsl:template match="screen/computeroutput">
565            <xsl:apply-templates/>
566    </xsl:template>
567
568    <xsl:template match="replaceable">
569            <i><xsl:apply-templates/></i>
570    </xsl:template>
571
572    <xsl:template match="userinput/replaceable">
573            <i><xsl:apply-templates/></i>
574    </xsl:template>
575
576    <xsl:template match="citation"
577            xmlns:xlink="http://www.w3.org/1999/xlink">
578
579            <xsl:variable name="target" select="."/>
580            <xsl:variable name="targets" select="id($target)"/>
581
582            <!-- xsl:call-template name="check.id.unique">
583            <xsl:with-param name="linkend" select="$target"/>
584    </xsl:call-template -->
585
586    <xsl:choose>
587            <xsl:when test="count($targets) = 0">
588                    <xsl:message>
589                            <xsl:text>Citation of nonexistent id: </xsl:text>
590                            <xsl:value-of select="."/>
591                    </xsl:message>
592                    <xsl:text>[??? </xsl:text>
593                    <xsl:value-of select="."/>
594                    <xsl:text>]</xsl:text>
595            </xsl:when>
596            <xsl:otherwise>
597                    <xsl:text>[</xsl:text><xsl:value-of  
598                            select="."/><xsl:text>]</xsl:text>
599            </xsl:otherwise>
600    </xsl:choose>
601
602    </xsl:template>
603
604    <xsl:template match="figure">
605            <figure>
606                    <xsl:call-template name="transform.id.attribute"/>
607                    <xsl:apply-templates/>
608            </figure>
609    </xsl:template>
610
611    <xsl:template match="graphic">
612            <xsl:message>
613                    <xsl:text>Obsolete tag "graphic" found.</xsl:text>
614            </xsl:message>
615
616            <figureref>
617                    <xsl:attribute name="fileref">
618                            <xsl:value-of select="@fileref"/>
619                    </xsl:attribute>
620            </figureref>
621    </xsl:template>
622
623    <xsl:template match="mediaobject">
624            <xsl:apply-templates/>
625    </xsl:template>
626
627    <xsl:template match="imageobject">
628            <xsl:apply-templates/>
629    </xsl:template>
630
631    <xsl:template match="imagedata">
632            <xsl:variable name="scale" select="@scale"/>
633            <figureref>
634                    <xsl:attribute name="fileref">
635                            <xsl:value-of select="@fileref"/>
636                    </xsl:attribute>
637                    <xsl:if test="$scale != ''">
638                            <xsl:attribute name="scale"><xsl:value-of  
639                                            select="$scale"/>%</xsl:attribute>
640                    </xsl:if>
641            </figureref>
642    </xsl:template>
643
644    <xsl:template match="example">
645            <screen>
646                    <xsl:call-template name="transform.id.attribute"/>
647                    <xsl:apply-templates/>
648            </screen>
649    </xsl:template>
650
651    <xsl:template match="listing">
652            <screen>
653                    <xsl:call-template name="transform.id.attribute"/>
654                    <xsl:apply-templates/>    </screen>
655    </xsl:template>
656
657    <xsl:template name="check.title.not.empty">
658            <xsl:variable name="title" select="."/>
659            <xsl:if test="$title=''">
660                    <xsl:message>title tag is empty!</xsl:message>
661            </xsl:if>
662    </xsl:template>
663
664    <xsl:template match="figure/title">
665            <xsl:call-template name="check.title.not.empty"/>
666            <description><xsl:apply-templates/></description>
667    </xsl:template>
668    <xsl:template match="listing/title">
669            <xsl:call-template name="check.title.not.empty"/>
670            <description><xsl:apply-templates/></description>
671    </xsl:template>
672    <xsl:template match="example/title">
673            <xsl:call-template name="check.title.not.empty"/>
674            <description><xsl:apply-templates/></description>
675    </xsl:template>
676
677    <xsl:template match="literallayout">
678            <screentext><xsl:apply-templates/></screentext>
679    </xsl:template>
680    <xsl:template match="screen">
681            <screentext><xsl:apply-templates/></screentext>
682    </xsl:template>
683
684    <xsl:template match="programlisting">
685            <listing>
686                    <xsl:if test="title != ''">
687                            <description><xsl:value-of select="title"/></description>
688                    </xsl:if>
689                    <listingcode>
690                            <xsl:apply-templates/>
691                    </listingcode>
692                 </listing>
693    </xsl:template>
694
695    <!-- Tabellen -->
696    <xsl:template match="table">
697            <table>
698                    <xsl:call-template name="transform.id.attribute"/>
699                    <xsl:apply-templates/>
700            </table>
701    </xsl:template>
702    <xsl:template match="table/title">
703            <description><xsl:apply-templates/></description>
704    </xsl:template>
705
706    <xsl:template match="tgroup">
707            <tgroup>
708                    <xsl:attribute name="cols">
709                            <xsl:value-of select="@cols"/></xsl:attribute>
710                    <xsl:apply-templates/>
711            </tgroup>
712    </xsl:template>
713    <xsl:template match="thead">
714            <thead><xsl:apply-templates/></thead>
715    </xsl:template>
716    <xsl:template match="tbody">
717            <tbody><xsl:apply-templates/></tbody>
718    </xsl:template>
719    <xsl:template match="row">
720            <row><xsl:apply-templates/></row>
721    </xsl:template>
722    <xsl:template match="entry">
723            <entry><p><xsl:apply-templates/></p></entry>
724    </xsl:template>
725    <xsl:template match="colspec">
726            <colspec><xsl:copy-of select="@*"/><xsl:apply-templates/></colspec>
727    </xsl:template>
728
729    <!-- xref nach pearson-equivalent - Einige Ideen stammen von Norm -->
730
731    <xsl:template name="object.id">
732            <xsl:param name="object" select="."/>
733            <xsl:choose>
734                    <xsl:when test="$object/@id">
735                            <xsl:value-of select="$object/@id"/>
736                    </xsl:when>
737                    <xsl:otherwise>
738                            <xsl:value-of select="generate-id($object)"/>
739                    </xsl:otherwise>
740            </xsl:choose>
741    </xsl:template>
742
743    <xsl:template name="anchor">
744            <xsl:param name="node" select="."/>
745            <xsl:param name="conditional" select="1"/>
746            <xsl:variable name="id">
747                    <xsl:call-template name="object.id">
748                            <xsl:with-param name="object" select="$node"/>
749                    </xsl:call-template>
750            </xsl:variable>
751            <xsl:if test="$conditional = 0 or $node/@id">
752                    <a name="{$id}"/>
753            </xsl:if>
754    </xsl:template>
755
756    <xsl:template name="check.id.unique">
757            <xsl:param name="linkend"></xsl:param>
758            <xsl:if test="$linkend != ''">
759                    <xsl:variable name="targets" select="id($linkend)"/>
760                    <xsl:variable name="target" select="$targets[1]"/>
761
762                    <xsl:if test="count($targets)=0">
763                            <xsl:message>
764                                    <xsl:text>Error: no ID for constraint linkend: </xsl:text>
765                                    <xsl:value-of select="$linkend"/>
766                                    <xsl:text>.</xsl:text>
767                            </xsl:message>
768                    </xsl:if>
769
770                    <xsl:if test="count($targets)>1">
771                            <xsl:message>
772                                    <xsl:text>Warning: multiple "IDs" for constraint linkend:  
773                                    </xsl:text>
774                                    <xsl:value-of select="$linkend"/>
775                                    <xsl:text>.</xsl:text>
776                            </xsl:message>
777                    </xsl:if>
778            </xsl:if>
779    </xsl:template>
780
781    <xsl:template match="xref|link"
782            xmlns:xlink="http://www.w3.org/1999/xlink">
783            <xsl:variable name="linkend" select="@linkend"/>
784            <xsl:variable name="targets" select="id(@linkend)"/>
785            <xsl:variable name="target" select="$targets[1]"/>
786            <xsl:variable name="refelem" select="local-name($target)"/>
787
788            <xsl:call-template name="check.id.unique">
789                    <xsl:with-param name="linkend" select="$linkend"/>
790            </xsl:call-template>
791
792            <xsl:call-template name="anchor"/>
793
794            <xsl:choose>
795                    <xsl:when test="count($targets) = 0">
796                            <xsl:message>
797                                    <xsl:text>XRef to nonexistent id: </xsl:text>
798                                    <xsl:value-of select="@linkend"/>
799                            </xsl:message>
800                            <xsl:text>[??? </xsl:text>
801                            <xsl:value-of select="@linkend"/>
802                            <xsl:text>]</xsl:text>
803                    </xsl:when>
804                    <xsl:when test="count($targets) > 1">
805                            <xsl:message>Uh, multiple linkends
806                                    <xsl:value-of select="@linkend"/>
807                            </xsl:message>
808                    </xsl:when>
809            </xsl:choose>
810
811            <xsl:choose>
812                    <xsl:when test='$refelem = "chapter" or $refelem = "preface"'>
813                            <xsl:text>Kapitel </xsl:text>
814                    </xsl:when>
815                    <xsl:when test='$refelem = "section" or $refelem = "sect1" or $refelem = "sect2" or $refelem = "sect3" or $refelem = "sect4"'>
816                            <xsl:text>Abschnitt </xsl:text>
817                    </xsl:when>
818                    <xsl:when test='$refelem = "figure"'>
819                            <xsl:text>Abbildung </xsl:text>
820                    </xsl:when>
821                    <xsl:when test='$refelem = "example"'>
822                            <!-- xsl:choose>
823                            <xsl:when test="$target/@role='listing'">
824                                    <xsl:text>Listing </xsl:text>
825                            </xsl:when>
826                            <xsl:otherwise -->
827                                    <xsl:text>Listing </xsl:text>
828                                    <!-- /xsl:otherwise>
829                            </xsl:choose -->
830                    </xsl:when>
831                    <xsl:when test='$refelem = "table"'>
832                            <xsl:text>Tabelle </xsl:text>
833                    </xsl:when>
834                    <xsl:when test='$refelem = "appendix"'>
835                            <xsl:text>Anhang </xsl:text>
836                    </xsl:when>
837                    <xsl:otherwise>
838                            <xsl:if test="$refelem != ''">
839                                    <xsl:message>
840                                            <xsl:text>Cant't handle xref to </xsl:text>
841                                            <xsl:value-of select="$refelem"/>
842                                            <xsl:text>:</xsl:text>
843                                            <xsl:value-of select="@linkend"/>
844                                    </xsl:message>
845                                    <xsl:text>(??? $refelem)</xsl:text>
846                            </xsl:if>
847                    </xsl:otherwise>
848            </xsl:choose>
849
850            <xref>
851                    <xsl:attribute name="xlink:href"
852                            xmlns:xlink="http://www.w3.org/1999/xlink">
853                            <!-- xsl:attribute name="id" -->
854                            <xsl:value-of select="@linkend"/>
855                    </xsl:attribute>
856            </xref>
857    </xsl:template>
858
859    <xsl:template match="quote">"<xsl:apply-templates/>"</xsl:template>
860    <!-- xsl:template  
861    match="quote"><quote><xsl:apply-templates/></quote></xsl:template -->
862
863
864    <xsl:template match="othername">
865            <xsl:text>(</xsl:text><xsl:apply-templates/><xsl:text>)</xsl:text>0
866    </xsl:template>
867    <xsl:template match="firstname">
868            <xsl:apply-templates/><xsl:text> </xsl:text>
869    </xsl:template>
870    <xsl:template match="surname">
871            <xsl:apply-templates/>
872    </xsl:template>
873    <xsl:template match="copyright">
874            <!-- empty -->
875    </xsl:template>
876    <xsl:template match="edition">
877            <!-- empty -->
878    </xsl:template>
879    <xsl:template match="publisher">
880            <!-- empty -->
881    </xsl:template>
882    <xsl:template match="pubdate">
883            <xsl:apply-templates/>
884    </xsl:template>
885    <xsl:template match="isbn">
886            ISBN <xsl:apply-templates/>
887    </xsl:template>
888
889    <!-- Literaturverzeichnis -->
890    <xsl:template match="bibliography">
891            <sect>
892                    <xsl:apply-templates/>
893            </sect>
894    </xsl:template>
895
896    <xsl:template name="process.bibliomixed">
897
898            <xsl:variable name="bibid" select="id(@id)"/>
899            <dlitem><dt>[<xsl:value-of select="@id"/>]</dt>
900                    <dd><p><xsl:apply-templates select=".//title"/>,
901                                    <xsl:if test="count(.//subtitle)>0">
902                                            <xsl:apply-templates select=".//subtitle"/>,
903                                    </xsl:if>
904                                    <xsl:apply-templates select=".//author"/>
905                                    <xsl:apply-templates select=".//publisher"/>
906                                    <xsl:apply-templates select=".//pubdate"/>
907                                    <xsl:if test="count(.//isbn)>0">
908                                            <xsl:text>, </xsl:text>
909                                            <xsl:apply-templates select=".//isbn"/>
910                                    </xsl:if>
911                                    <xsl:text>.</xsl:text></p>
912                            <xsl:call-template name="process.abstract" select=".//abstract"/>
913                    </dd>
914            </dlitem>
915    </xsl:template>
916
917    <xsl:template match="bibliomixed[1]">
918            <dl><xsl:call-template name="process.bibliomixed"/>
919                    <xsl:for-each select="following-sibling::bibliomixed">
920                            <xsl:call-template name="process.bibliomixed"/>
921                    </xsl:for-each>
922            </dl>
923    </xsl:template>
924
925
926    <xsl:template match="bibliomixed/title">
927            <i><xsl:apply-templates/></i>
928    </xsl:template>
929
930    <xsl:template match="biblioentry/title">
931            <i><xsl:apply-templates/></i>
932    </xsl:template>
933
934    <xsl:template match="bibliomixed/subtitle">
935            <xsl:apply-templates/>
936    </xsl:template>
937
938    <xsl:template match="bibliomixed/publisher">
939            <xsl:apply-templates/>
940    </xsl:template>
941
942    <xsl:template match="publishername">
943            <xsl:apply-templates/>,
944    </xsl:template>
945    <xsl:template match="publisher/address">
946            <xsl:apply-templates/>
947    </xsl:template>
948    <xsl:template match="city">
949            <xsl:apply-templates/>,
950    </xsl:template>
951
952    <xsl:template name="process.abstract">
953            <xsl:apply-templates select="abstract//para"/>
954    </xsl:template>
955    <xsl:template match="bibliomixed">
956            <!-- empty -->
957    </xsl:template>
958
959    <xsl:template match="chapterinfo">
960            <!-- empty -->
961    </xsl:template>
962
963    <xsl:template match="sectioninfo">
964            <!-- empty -->
965    </xsl:template>
966
967    <xsl:template match="prefaceinfo">
968            <!-- empty -->
969    </xsl:template>
970
971    <xsl:template match="appendixinfo">
972            <!-- empty -->
973    </xsl:template>
974
975    <xsl:template match="releaseinfo">
976            <xsl:comment><xsl:apply-templates/></xsl:comment>
977    </xsl:template>
978
979    <xsl:template match="releaseinfo" mode="comment">
980            <xsl:text>
981            </xsl:text>
982            <xsl:apply-templates/>
983    </xsl:template>
984
985    <xsl:template match="trademark">
986            <xsl:apply-templates/>
987    </xsl:template>
988
989    <xsl:template match="processing-instruction('linebreak')">
990            <br/>
991    </xsl:template>
992
993    <xsl:template match="processing-instruction('pearson')">
994            <xsl:copy/>
995    </xsl:template>
996
997    <xsl:template match="procedure">
998                    <xsl:apply-templates/>
999    </xsl:template>
1000
1001    <xsl:template match="step">
1002            <step><xsl:apply-templates/></step>
1003    </xsl:template>
1004
1005    <xsl:template match="toc">
1006            <xsl:element name="toc">
1007                    <xsl:attribute name="role">
1008                            <xsl:text>sect</xsl:text>
1009                    </xsl:attribute>
1010            </xsl:element>
1011    </xsl:template>
1012
1013    <xsl:template match="lot">
1014            <xsl:element name="toc">
1015                    <xsl:attribute name="role">
1016                            <xsl:text>table</xsl:text>
1017                    </xsl:attribute>
1018            </xsl:element>
1019    </xsl:template>
1020
1021    <xsl:template match="lof">
1022            <xsl:element name="toc">
1023                    <xsl:attribute name="role">
1024                            <xsl:text>figure</xsl:text>
1025                    </xsl:attribute>
1026            </xsl:element>
1027    </xsl:template>
1028
1029    <xsl:template match="blockquote">
1030            <motto><xsl:apply-templates/></motto>
1031    </xsl:template>
1032
1033         <xsl:template match="authorgroup">
1034                 <xsl:apply-templates/>
1035         </xsl:template>
1036
1037
1038         <xsl:template match="affiliation">
1039                 <!-- Ignoring affiliations for now -->
1040         </xsl:template>
1041
1042 </xsl:stylesheet>