Moving docs tree to docs-xml to make room for generated docs in the release tarball.
[tprouty/samba.git] / docs-xml / xslt / db2latex-xsl / xsl / common / gentext.xsl
1 <?xml version='1.0'?>
2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3                 xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"
4                 exclude-result-prefixes="doc"
5                 version='1.0'>
6
7 <!-- ********************************************************************
8      $Id: gentext.xsl,v 1.4 2004/01/04 09:26:24 j-devenish Exp $
9      ********************************************************************
10
11      This file is part of the XSL DocBook Stylesheet distribution.
12
13      Copyright (C) 1999, 2000, 2001, 2002 Norman Walsh.
14      ******************************************************************** -->
15
16 <!-- ==================================================================== -->
17
18 <xsl:param name="appendix.autolabel" select="0"/>
19
20 <xsl:template match="*" mode="object.title.template">
21   <xsl:call-template name="gentext.template">
22     <xsl:with-param name="context" select="'title'"/>
23     <xsl:with-param name="name">
24       <xsl:call-template name="xpath.location"/>
25     </xsl:with-param>
26   </xsl:call-template>
27 </xsl:template>
28
29 <xsl:template match="chapter" mode="object.title.template">
30   <xsl:choose>
31     <xsl:when test="$chapter.autolabel != 0">
32       <xsl:call-template name="gentext.template">
33         <xsl:with-param name="context" select="'title-numbered'"/>
34         <xsl:with-param name="name">
35           <xsl:call-template name="xpath.location"/>
36         </xsl:with-param>
37       </xsl:call-template>
38     </xsl:when>
39     <xsl:otherwise>
40       <xsl:call-template name="gentext.template">
41         <xsl:with-param name="context" select="'title-unnumbered'"/>
42         <xsl:with-param name="name">
43           <xsl:call-template name="xpath.location"/>
44         </xsl:with-param>
45       </xsl:call-template>
46     </xsl:otherwise>
47   </xsl:choose>
48 </xsl:template>
49
50 <xsl:template match="appendix" mode="object.title.template">
51   <xsl:choose>
52     <xsl:when test="$appendix.autolabel != 0">
53       <xsl:call-template name="gentext.template">
54         <xsl:with-param name="context" select="'title-numbered'"/>
55         <xsl:with-param name="name">
56           <xsl:call-template name="xpath.location"/>
57         </xsl:with-param>
58       </xsl:call-template>
59     </xsl:when>
60     <xsl:otherwise>
61       <xsl:call-template name="gentext.template">
62         <xsl:with-param name="context" select="'title-unnumbered'"/>
63         <xsl:with-param name="name">
64           <xsl:call-template name="xpath.location"/>
65         </xsl:with-param>
66       </xsl:call-template>
67     </xsl:otherwise>
68   </xsl:choose>
69 </xsl:template>
70
71 <xsl:template match="section|sect1|sect2|sect3|sect4|sect5|simplesect
72                      |bridgehead"
73               mode="object.title.template">
74   <xsl:choose>
75     <xsl:when test="$section.autolabel != 0">
76       <xsl:call-template name="gentext.template">
77         <xsl:with-param name="context" select="'title-numbered'"/>
78         <xsl:with-param name="name">
79           <xsl:call-template name="xpath.location"/>
80         </xsl:with-param>
81       </xsl:call-template>
82     </xsl:when>
83     <xsl:otherwise>
84       <xsl:call-template name="gentext.template">
85         <xsl:with-param name="context" select="'title-unnumbered'"/>
86         <xsl:with-param name="name">
87           <xsl:call-template name="xpath.location"/>
88         </xsl:with-param>
89       </xsl:call-template>
90     </xsl:otherwise>
91   </xsl:choose>
92 </xsl:template>
93
94 <xsl:template match="procedure" mode="object.title.template">
95   <xsl:choose>
96     <xsl:when test="$formal.procedures != 0">
97       <xsl:call-template name="gentext.template">
98         <xsl:with-param name="context" select="'title'"/>
99         <xsl:with-param name="name">
100           <xsl:call-template name="xpath.location"/>
101           <xsl:text>.formal</xsl:text>
102         </xsl:with-param>
103       </xsl:call-template>
104     </xsl:when>
105     <xsl:otherwise>
106       <xsl:call-template name="gentext.template">
107         <xsl:with-param name="context" select="'title'"/>
108         <xsl:with-param name="name">
109           <xsl:call-template name="xpath.location"/>
110         </xsl:with-param>
111       </xsl:call-template>
112     </xsl:otherwise>
113   </xsl:choose>
114 </xsl:template>
115
116 <!-- ============================================================ -->
117
118 <xsl:template match="*" mode="object.subtitle.template">
119   <xsl:call-template name="gentext.template">
120     <xsl:with-param name="context" select="'subtitle'"/>
121     <xsl:with-param name="name">
122       <xsl:call-template name="xpath.location"/>
123     </xsl:with-param>
124   </xsl:call-template>
125 </xsl:template>
126
127 <!-- ============================================================ -->
128
129 <xsl:template match="*" mode="is.autonumber">
130   <xsl:value-of select="'0'"/>
131 </xsl:template>
132
133 <xsl:template match="section|sect1|sect2|sect3|sect4|sect5" 
134               mode="is.autonumber">
135   <xsl:value-of select="$section.autolabel"/>
136 </xsl:template>
137
138 <xsl:template match="figure|example|table|equation" mode="is.autonumber">
139   <xsl:value-of select="'1'"/>
140 </xsl:template>
141
142 <xsl:template match="appendix" mode="is.autonumber">
143   <xsl:value-of select="$appendix.autolabel"/>
144 </xsl:template>
145
146 <xsl:template match="chapter" mode="is.autonumber">
147   <xsl:value-of select="$chapter.autolabel"/>
148 </xsl:template>
149
150 <xsl:template match="part" mode="is.autonumber">
151   <xsl:value-of select="$part.autolabel"/>
152 </xsl:template>
153
154 <xsl:template match="preface" mode="is.autonumber">
155   <xsl:value-of select="$preface.autolabel"/>
156 </xsl:template>
157
158 <xsl:template match="question|answer" mode="is.autonumber">
159   <xsl:choose>
160     <xsl:when test="$qanda.defaultlabel = 'number'
161                     and not(label)">
162       <xsl:value-of select="'1'"/>
163     </xsl:when>
164     <xsl:otherwise>
165       <xsl:value-of select="'0'"/>
166     </xsl:otherwise>
167   </xsl:choose>
168 </xsl:template>
169
170 <xsl:template match="qandadiv" mode="is.autonumber">
171   <xsl:value-of select="$qandadiv.autolabel"/>
172 </xsl:template>
173
174 <xsl:template match="bridgehead" mode="is.autonumber">
175   <xsl:value-of select="$section.autolabel"/>
176 </xsl:template>
177
178 <xsl:template match="*" mode="object.xref.template">
179   <xsl:param name="purpose"/>
180   <xsl:param name="xrefstyle"/>
181   <xsl:param name="referrer"/>
182
183   <!-- Is autonumbering on? -->
184   <xsl:variable name="autonumber">
185     <xsl:apply-templates select="." mode="is.autonumber"/>
186   </xsl:variable>
187
188   <xsl:variable name="number-and-title-template">
189     <xsl:call-template name="gentext.template.exists">
190       <xsl:with-param name="context" select="'xref-number-and-title'"/>
191       <xsl:with-param name="name">
192         <xsl:call-template name="xpath.location"/>
193       </xsl:with-param>
194     </xsl:call-template>
195   </xsl:variable>
196
197   <xsl:variable name="number-template">
198     <xsl:call-template name="gentext.template.exists">
199       <xsl:with-param name="context" select="'xref-number'"/>
200       <xsl:with-param name="name">
201         <xsl:call-template name="xpath.location"/>
202       </xsl:with-param>
203     </xsl:call-template>
204   </xsl:variable>
205
206   <xsl:variable name="context">
207     <xsl:choose>
208       <xsl:when test="$autonumber != 0 
209                       and $number-and-title-template != 0
210                       and $xref.with.number.and.title != 0">
211          <xsl:value-of select="'xref-number-and-title'"/>
212       </xsl:when>
213       <xsl:when test="$autonumber != 0 
214                       and $number-template != 0">
215          <xsl:value-of select="'xref-number'"/>
216       </xsl:when>
217       <xsl:otherwise>
218          <xsl:value-of select="'xref'"/>
219       </xsl:otherwise>
220     </xsl:choose>
221   </xsl:variable>
222
223   <xsl:call-template name="gentext.template">
224     <xsl:with-param name="context" select="$context"/>
225     <xsl:with-param name="name">
226       <xsl:call-template name="xpath.location"/>
227     </xsl:with-param>
228     <xsl:with-param name="purpose" select="$purpose"/>
229     <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
230     <xsl:with-param name="referrer" select="$referrer"/>
231   </xsl:call-template>
232
233 </xsl:template>
234
235
236 <!-- ============================================================ -->
237
238 <xsl:template match="*" mode="object.title.markup">
239   <xsl:param name="allow-anchors" select="0"/>
240   <xsl:variable name="template">
241     <xsl:apply-templates select="." mode="object.title.template"/>
242   </xsl:variable>
243
244 <!--
245   <xsl:message>
246     <xsl:text>object.title.markup: </xsl:text>
247     <xsl:value-of select="local-name(.)"/>
248     <xsl:text>: </xsl:text>
249     <xsl:value-of select="$template"/>
250   </xsl:message>
251 -->
252
253   <xsl:call-template name="substitute-markup">
254     <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
255     <xsl:with-param name="template" select="$template"/>
256   </xsl:call-template>
257 </xsl:template>
258
259 <xsl:template match="*" mode="object.title.markup.textonly">
260   <xsl:variable name="title">
261     <xsl:apply-templates select="." mode="object.title.markup"/>
262   </xsl:variable>
263   <xsl:value-of select="$title"/>
264 </xsl:template>
265
266 <!-- ============================================================ -->
267
268 <xsl:template match="*" mode="object.titleabbrev.markup">
269   <xsl:param name="allow-anchors" select="0"/>
270
271   <!-- Just for consistency in template naming -->
272
273   <xsl:apply-templates select="." mode="titleabbrev.markup">
274     <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
275   </xsl:apply-templates>
276 </xsl:template>
277
278 <!-- ============================================================ -->
279
280 <xsl:template match="*" mode="object.subtitle.markup">
281   <xsl:variable name="template">
282     <xsl:apply-templates select="." mode="object.subtitle.template"/>
283   </xsl:variable>
284
285   <xsl:call-template name="substitute-markup">
286     <xsl:with-param name="template" select="$template"/>
287   </xsl:call-template>
288 </xsl:template>
289
290 <!-- ============================================================ -->
291
292 <xsl:template match="*" mode="object.xref.markup">
293   <xsl:param name="purpose"/>
294   <xsl:param name="xrefstyle"/>
295   <xsl:param name="referrer"/>
296
297   <xsl:variable name="template">
298     <xsl:choose>
299       <xsl:when test="starts-with(normalize-space($xrefstyle), 'select:')">
300         <xsl:call-template name="make.gentext.template">
301           <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
302           <xsl:with-param name="purpose" select="$purpose"/>
303           <xsl:with-param name="referrer" select="$referrer"/>
304         </xsl:call-template>
305       </xsl:when>
306       <xsl:when test="starts-with(normalize-space($xrefstyle), 'template:')">
307         <xsl:value-of select="substring-after(normalize-space($xrefstyle), 'template:')"/>
308       </xsl:when>
309       <xsl:otherwise>
310         <xsl:apply-templates select="." mode="object.xref.template">
311           <xsl:with-param name="purpose" select="$purpose"/>
312           <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
313           <xsl:with-param name="referrer" select="$referrer"/>
314         </xsl:apply-templates>
315       </xsl:otherwise>
316     </xsl:choose>
317   </xsl:variable>
318
319 <!-- 
320   <xsl:message>
321     <xsl:text>object.xref.markup: </xsl:text>
322     <xsl:value-of select="local-name(.)"/>
323     <xsl:text>(</xsl:text>
324     <xsl:value-of select="$xrefstyle"/>
325     <xsl:text>, </xsl:text>
326     <xsl:value-of select="$purpose"/>
327     <xsl:text>)</xsl:text>
328     <xsl:text>: [</xsl:text>
329     <xsl:value-of select="$template"/>
330     <xsl:text>]</xsl:text>
331   </xsl:message>
332 -->
333
334   <xsl:if test="$template = ''">
335     <xsl:message>
336       <xsl:text>object.xref.markup: empty xref template</xsl:text>
337       <xsl:text> for linkend="</xsl:text>
338       <xsl:value-of select="@id"/>
339       <xsl:text>" and @xrefstyle="</xsl:text>
340       <xsl:value-of select="$xrefstyle"/>
341       <xsl:text>"</xsl:text>
342     </xsl:message>
343   </xsl:if>
344
345   <xsl:call-template name="substitute-markup">
346     <xsl:with-param name="purpose" select="$purpose"/>
347     <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
348     <xsl:with-param name="referrer" select="$referrer"/>
349     <xsl:with-param name="template" select="$template"/>
350   </xsl:call-template>
351 </xsl:template>
352
353 <xsl:template match="listitem" mode="object.xref.markup">
354   <xsl:choose>
355     <xsl:when test="parent::orderedlist">
356       <xsl:variable name="template">
357         <xsl:apply-templates select="." mode="object.xref.template"/>
358       </xsl:variable>
359       <xsl:call-template name="substitute-markup">
360         <xsl:with-param name="template" select="$template"/>
361       </xsl:call-template>
362     </xsl:when>
363     <xsl:otherwise>
364       <xsl:message>
365         <xsl:text>Xref is only supported to listitems in an</xsl:text>
366         <xsl:text> orderedlist: </xsl:text>
367         <xsl:value-of select="@id"/>
368       </xsl:message>
369       <xsl:text>???</xsl:text>
370     </xsl:otherwise>
371   </xsl:choose>
372 </xsl:template>
373
374 <xsl:template match="question" mode="object.xref.markup">
375   <xsl:param name="purpose"/>
376   <xsl:param name="xrefstyle"/>
377   <xsl:param name="referrer"/>
378
379   <xsl:variable name="deflabel">
380     <xsl:choose>
381       <xsl:when test="ancestor-or-self::*[@defaultlabel]">
382         <xsl:value-of select="(ancestor-or-self::*[@defaultlabel])[last()]
383                               /@defaultlabel"/>
384       </xsl:when>
385       <xsl:otherwise>
386         <xsl:value-of select="$qanda.defaultlabel"/>
387       </xsl:otherwise>
388     </xsl:choose>
389   </xsl:variable>
390
391   <xsl:variable name="template">
392     <xsl:choose>
393       <!-- This avoids double Q: Q: in xref when defaultlabel=qanda -->
394       <xsl:when test="$deflabel = 'qanda' and not(label)">%n</xsl:when>
395       <xsl:otherwise>
396         <xsl:apply-templates select="." mode="object.xref.template">
397           <xsl:with-param name="purpose" select="$purpose"/>
398           <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
399           <xsl:with-param name="referrer" select="$referrer"/>
400         </xsl:apply-templates>
401       </xsl:otherwise>
402     </xsl:choose>
403   </xsl:variable>
404
405   <xsl:call-template name="substitute-markup">
406     <xsl:with-param name="purpose" select="$purpose"/>
407     <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
408     <xsl:with-param name="referrer" select="$referrer"/>
409     <xsl:with-param name="template" select="$template"/>
410   </xsl:call-template>
411 </xsl:template>
412
413 <!-- ============================================================ -->
414
415 <xsl:template name="substitute-markup">
416   <xsl:param name="template" select="''"/>
417   <xsl:param name="allow-anchors" select="'0'"/>
418   <xsl:param name="title" select="''"/>
419   <xsl:param name="subtitle" select="''"/>
420   <xsl:param name="label" select="''"/>
421   <xsl:param name="pagenumber" select="''"/>
422   <xsl:param name="purpose"/>
423   <xsl:param name="xrefstyle"/>
424   <xsl:param name="referrer"/>
425
426   <xsl:choose>
427     <xsl:when test="contains($template, '%')">
428       <xsl:value-of select="substring-before($template, '%')"/>
429       <xsl:variable name="candidate"
430              select="substring(substring-after($template, '%'), 1, 1)"/>
431       <xsl:choose>
432         <xsl:when test="$candidate = 't'">
433           <xsl:apply-templates select="." mode="insert.title.markup">
434             <xsl:with-param name="purpose" select="$purpose"/>
435             <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
436             <xsl:with-param name="title">
437               <xsl:choose>
438                 <xsl:when test="$title != ''">
439                   <xsl:copy-of select="$title"/>
440                 </xsl:when>
441                 <xsl:otherwise>
442                   <xsl:apply-templates select="." mode="title.markup">
443                     <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
444                   </xsl:apply-templates>
445                 </xsl:otherwise>
446               </xsl:choose>
447             </xsl:with-param>
448           </xsl:apply-templates>
449         </xsl:when>
450         <xsl:when test="$candidate = 's'">
451           <xsl:apply-templates select="." mode="insert.subtitle.markup">
452             <xsl:with-param name="purpose" select="$purpose"/>
453             <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
454             <xsl:with-param name="subtitle">
455               <xsl:choose>
456                 <xsl:when test="$subtitle != ''">
457                   <xsl:copy-of select="$subtitle"/>
458                 </xsl:when>
459                 <xsl:otherwise>
460                   <xsl:apply-templates select="." mode="subtitle.markup">
461                     <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
462                   </xsl:apply-templates>
463                 </xsl:otherwise>
464               </xsl:choose>
465             </xsl:with-param>
466           </xsl:apply-templates>
467         </xsl:when>
468         <xsl:when test="$candidate = 'n'">
469           <xsl:apply-templates select="." mode="insert.label.markup">
470             <xsl:with-param name="purpose" select="$purpose"/>
471             <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
472             <xsl:with-param name="label">
473               <xsl:choose>
474                 <xsl:when test="$label != ''">
475                   <xsl:copy-of select="$label"/>
476                 </xsl:when>
477                 <xsl:otherwise>
478                   <xsl:apply-templates select="." mode="label.markup"/>
479                 </xsl:otherwise>
480               </xsl:choose>
481             </xsl:with-param>
482           </xsl:apply-templates>
483         </xsl:when>
484         <xsl:when test="$candidate = 'p'">
485           <xsl:apply-templates select="." mode="insert.pagenumber.markup">
486             <xsl:with-param name="purpose" select="$purpose"/>
487             <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
488             <xsl:with-param name="pagenumber">
489               <xsl:choose>
490                 <xsl:when test="$pagenumber != ''">
491                   <xsl:copy-of select="$pagenumber"/>
492                 </xsl:when>
493                 <xsl:otherwise>
494                   <xsl:apply-templates select="." mode="pagenumber.markup"/>
495                 </xsl:otherwise>
496               </xsl:choose>
497             </xsl:with-param>
498           </xsl:apply-templates>
499         </xsl:when>
500         <xsl:when test="$candidate = 'd'">
501           <xsl:apply-templates select="." mode="insert.direction.markup">
502             <xsl:with-param name="purpose" select="$purpose"/>
503             <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
504             <xsl:with-param name="direction">
505               <xsl:choose>
506                 <xsl:when test="$referrer">
507                   <xsl:variable name="referent-is-below">
508                     <xsl:for-each select="preceding::xref">
509                       <xsl:if test="generate-id(.) = generate-id($referrer)">1</xsl:if>
510                     </xsl:for-each>
511                   </xsl:variable>
512                   <xsl:choose>
513                     <xsl:when test="$referent-is-below = ''">
514                       <xsl:call-template name="gentext">
515                         <xsl:with-param name="key" select="'above'"/>
516                       </xsl:call-template>
517                     </xsl:when>
518                     <xsl:otherwise>
519                       <xsl:call-template name="gentext">
520                         <xsl:with-param name="key" select="'below'"/>
521                       </xsl:call-template>
522                     </xsl:otherwise>
523                   </xsl:choose>
524                 </xsl:when>
525                 <xsl:otherwise>
526                   <xsl:message>Attempt to use %d in gentext with no referrer!</xsl:message>
527                 </xsl:otherwise>
528               </xsl:choose>
529             </xsl:with-param>
530           </xsl:apply-templates>
531         </xsl:when>
532         <xsl:when test="$candidate = '%' ">
533           <xsl:text>%</xsl:text>
534         </xsl:when>
535         <xsl:otherwise>
536           <xsl:text>%</xsl:text><xsl:value-of select="$candidate"/>
537         </xsl:otherwise>
538       </xsl:choose>
539       <!-- recurse with the rest of the template string -->
540       <xsl:variable name="rest"
541             select="substring($template,
542             string-length(substring-before($template, '%'))+3)"/>
543       <xsl:call-template name="substitute-markup">
544         <xsl:with-param name="template" select="$rest"/>
545         <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
546         <xsl:with-param name="title" select="$title"/>
547         <xsl:with-param name="subtitle" select="$subtitle"/>
548         <xsl:with-param name="label" select="$label"/>
549         <xsl:with-param name="pagenumber" select="$pagenumber"/>
550         <xsl:with-param name="purpose" select="$purpose"/>
551         <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
552         <xsl:with-param name="referrer" select="$referrer"/>
553       </xsl:call-template>
554     </xsl:when>
555     <xsl:otherwise>
556       <xsl:value-of select="$template"/>
557     </xsl:otherwise>
558   </xsl:choose>
559 </xsl:template>
560
561 <!-- ============================================================ -->
562
563 <xsl:template name="make.gentext.template">
564   <xsl:param name="xrefstyle" select="''"/>
565   <xsl:param name="purpose"/>
566   <xsl:param name="referrer"/>
567   <xsl:param name="lang">
568     <xsl:call-template name="l10n.language"/>
569   </xsl:param>
570
571   <!-- parse xrefstyle to get parts -->
572   <xsl:variable name="parts"
573       select="substring-after(normalize-space($xrefstyle), 'select:')"/>
574
575   <xsl:variable name="labeltype">
576     <xsl:choose>
577       <xsl:when test="contains($parts, 'labelnumber')">
578          <xsl:text>labelnumber</xsl:text>
579       </xsl:when>
580       <xsl:when test="contains($parts, 'labelname')">
581          <xsl:text>labelname</xsl:text>
582       </xsl:when>
583       <xsl:when test="contains($parts, 'label')">
584          <xsl:text>label</xsl:text>
585       </xsl:when>
586     </xsl:choose>
587   </xsl:variable>
588
589   <xsl:variable name="titletype">
590     <xsl:choose>
591       <xsl:when test="contains($parts, 'quotedtitle')">
592          <xsl:text>quotedtitle</xsl:text>
593       </xsl:when>
594       <xsl:when test="contains($parts, 'title')">
595          <xsl:text>title</xsl:text>
596       </xsl:when>
597     </xsl:choose>
598   </xsl:variable>
599
600   <xsl:variable name="pagetype">
601     <xsl:choose>
602       <xsl:when test="$insert.xref.page.number = 'no'">
603         <!-- suppress page numbers -->
604       </xsl:when>
605       <xsl:when test="contains($parts, 'nopage')">
606          <xsl:text>nopage</xsl:text>
607       </xsl:when>
608       <xsl:when test="contains($parts, 'pagenumber')">
609          <xsl:text>pagenumber</xsl:text>
610       </xsl:when>
611       <xsl:when test="contains($parts, 'pageabbrev')">
612          <xsl:text>pageabbrev</xsl:text>
613       </xsl:when>
614       <xsl:when test="contains($parts, 'Page')">
615          <xsl:text>Page</xsl:text>
616       </xsl:when>
617       <xsl:when test="contains($parts, 'page')">
618          <xsl:text>page</xsl:text>
619       </xsl:when>
620     </xsl:choose>
621   </xsl:variable>
622
623   <xsl:if test="$labeltype != ''">
624     <xsl:choose>
625       <xsl:when test="$labeltype = 'labelname'">
626         <xsl:call-template name="gentext"/>
627       </xsl:when>
628       <xsl:when test="$labeltype = 'labelnumber'">
629         <xsl:text>%n</xsl:text>
630       </xsl:when>
631       <xsl:when test="$labeltype = 'label'">
632         <xsl:call-template name="gentext.template">
633           <xsl:with-param name="context" select="'xref-number'"/>
634           <xsl:with-param name="name">
635             <xsl:call-template name="xpath.location"/>
636           </xsl:with-param>
637           <xsl:with-param name="purpose" select="$purpose"/>
638           <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
639           <xsl:with-param name="referrer" select="$referrer"/>
640         </xsl:call-template>
641       </xsl:when>
642     </xsl:choose>
643
644     <xsl:choose>
645       <xsl:when test="$titletype != ''">
646         <xsl:value-of select="$xref.label-title.separator"/>
647       </xsl:when>
648       <xsl:when test="$pagetype != ''">
649         <xsl:value-of select="$xref.label-page.separator"/>
650       </xsl:when>
651     </xsl:choose>
652   </xsl:if>
653
654   <xsl:if test="$titletype != ''">
655     <xsl:choose>
656       <xsl:when test="$titletype = 'title'">
657         <xsl:text>%t</xsl:text>
658       </xsl:when>
659       <xsl:when test="$titletype = 'quotedtitle'">
660         <xsl:call-template name="gentext.dingbat">
661           <xsl:with-param name="dingbat" select="'startquote'"/>
662         </xsl:call-template>
663         <xsl:text>%t</xsl:text>
664         <xsl:call-template name="gentext.dingbat">
665           <xsl:with-param name="dingbat" select="'endquote'"/>
666         </xsl:call-template>
667       </xsl:when>
668     </xsl:choose>
669
670     <xsl:choose>
671       <xsl:when test="$pagetype != '' and $pagetype != 'nopage'">
672         <xsl:value-of select="$xref.title-page.separator"/>
673       </xsl:when>
674     </xsl:choose>
675   </xsl:if>
676   
677   <xsl:if test="$pagetype != ''">
678     <xsl:choose>
679       <!-- special case: use regular xref template -->
680       <xsl:when test="$pagetype = 'nopage' 
681                       and $labeltype = '' 
682                       and $titletype = ''">
683         <xsl:apply-templates select="." mode="object.xref.template">
684           <xsl:with-param name="purpose" select="$purpose"/>
685           <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
686           <xsl:with-param name="referrer" select="$referrer"/>
687         </xsl:apply-templates>
688       </xsl:when>
689       <xsl:when test="$pagetype = 'page'">
690         <xsl:call-template name="gentext.template">
691           <xsl:with-param name="context" select="'xref'"/>
692           <xsl:with-param name="name" select="'page'"/>
693         </xsl:call-template>
694       </xsl:when>
695       <xsl:when test="$pagetype = 'Page'">
696         <xsl:call-template name="gentext.template">
697           <xsl:with-param name="context" select="'xref'"/>
698           <xsl:with-param name="name" select="'Page'"/>
699         </xsl:call-template>
700       </xsl:when>
701       <xsl:when test="$pagetype = 'pageabbrev'">
702         <xsl:call-template name="gentext.template">
703           <xsl:with-param name="context" select="'xref'"/>
704           <xsl:with-param name="name" select="'pageabbrev'"/>
705         </xsl:call-template>
706       </xsl:when>
707       <xsl:when test="$pagetype = 'pagenumber'">
708         <xsl:text>%p</xsl:text>
709       </xsl:when>
710     </xsl:choose>
711
712   </xsl:if>
713
714 </xsl:template>
715
716 </xsl:stylesheet>