Next update of VFS modules development guide
[Samba.git] / docs / xslt / db2latex-xsl / xsl / labelid.mod.xsl
blobe6f90c63eb90f49f8b835aefb7fb6316b2f107b0
1 <?xml version='1.0'?>
2 <!DOCTYPE xsl:stylesheet [ <!ENTITY % xsldoc.ent SYSTEM "./xsldoc.ent"> %xsldoc.ent; ]>
3 <!--#############################################################################
4 | $Id: labelid.mod.xsl,v 1.5 2004/01/01 12:26:41 j-devenish Exp $
5 |- #############################################################################
6 | $Author: j-devenish $
7 + ############################################################################## -->
9 <xsl:stylesheet
10 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
11 xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"
12 exclude-result-prefixes="doc" version='1.0'>
14 <doc:reference id="labelid" xmlns="">
15 <referenceinfo>
16 <releaseinfo role="meta">
17 $Id: labelid.mod.xsl,v 1.5 2004/01/01 12:26:41 j-devenish Exp $
18 </releaseinfo>
19 <authorgroup>
20 &ramon;
21 &james;
22 </authorgroup>
23 <copyright>
24 <year>2000</year><year>2001</year><year>2002</year><year>2003</year><year>2004</year>
25 <holder>Ramon Casellas</holder>
26 </copyright>
27 <revhistory>
28 <doc:revision rcasver="1.5">&rev_2003_05;</doc:revision>
29 </revhistory>
30 </referenceinfo>
31 <title>Labels and Anchors for Cross-referencing <filename>labelid.mod.xsl</filename></title>
32 <partintro>
33 <para>
37 </para>
38 </partintro>
39 </doc:reference>
41 <doc:template xmlns="">
42 <refpurpose> Generate &LaTeX; <function condition="latex">label</function>s </refpurpose>
43 <doc:description>
44 <para>
46 This template marks the current object with a <function
47 condition="latex">label</function>.
49 </para>
50 </doc:description>
51 <doc:variables>
52 &no_var;
53 </doc:variables>
54 <!--
55 <doc:params>
56 <variablelist>
57 <varlistentry><term>object</term>
58 <listitem><para>The node whose id is to be used.</para></listitem>
59 </varlistentry>
60 </variablelist>
61 </doc:params>
62 <doc:notes>
63 </doc:notes>
64 -->
65 <doc:seealso>
66 <itemizedlist>
67 <listitem><simpara><xref linkend="template.generate.label.id"/></simpara></listitem>
68 </itemizedlist>
69 </doc:seealso>
70 </doc:template>
71 <xsl:template name="label.id">
72 <xsl:text>\label{</xsl:text>
73 <xsl:call-template name="generate.label.id"/>
74 <xsl:text>}</xsl:text>
75 </xsl:template>
77 <doc:template xmlns="">
78 <refpurpose> Generate a reliable cross-reference id </refpurpose>
79 <doc:description>
80 <para>
82 The passed argument indicates the object whose <sgmltag
83 class="attribute">id</sgmltag> attribute is used to generate the
84 label. In this sense, in most cases its the current node itself. If
85 the used object has not an id attribute, a unique id is obtained by
86 means of the <literal>generate-id</literal> function. Moreover, if
87 we are using the hyperref package, a hypertarget is also defined
88 for this object.
90 </para>
91 </doc:description>
92 <doc:variables>
93 &no_var;
94 </doc:variables>
95 <doc:params>
96 <variablelist>
97 <varlistentry><term>object</term>
98 <listitem><para>The node whose id is to be used.</para></listitem>
99 </varlistentry>
100 </variablelist>
101 </doc:params>
102 </doc:template>
103 <xsl:template name="generate.label.id">
104 <xsl:param name="object" select="."/>
105 <xsl:variable name="id">
106 <xsl:choose>
107 <xsl:when test="$object/@id">
108 <xsl:value-of select="$object/@id"/>
109 </xsl:when>
110 <xsl:otherwise>
111 <xsl:value-of select="generate-id($object)"/>
112 </xsl:otherwise>
113 </xsl:choose>
114 </xsl:variable>
115 <xsl:value-of select="normalize-space($id)"/>
116 </xsl:template>
118 <!--
119 <xsl:template match="*" mode="label.content">
120 <xsl:message>
121 <xsl:text>Request for label of unexpected element: </xsl:text>
122 <xsl:value-of select="name(.)"/>
123 </xsl:message>
124 </xsl:template>
126 <xsl:template match="set|book" mode="label.content">
127 <xsl:param name="punct">.</xsl:param>
128 <xsl:if test="@label">
129 <xsl:value-of select="@label"/>
130 <xsl:value-of select="$punct"/>
131 </xsl:if>
132 </xsl:template>
134 <xsl:template match="part" mode="label.content">
135 <xsl:param name="punct">.</xsl:param>
136 <xsl:choose>
137 <xsl:when test="@label">
138 <xsl:value-of select="@label"/>
139 <xsl:value-of select="$punct"/>
140 </xsl:when>
141 <xsl:when test="$part.autolabel != 0">
142 <xsl:number from="book" count="part" format="I"/>
143 <xsl:value-of select="$punct"/>
144 </xsl:when>
145 </xsl:choose>
146 </xsl:template>
149 <xsl:template match="preface" mode="label.content">
150 <xsl:param name="punct">.</xsl:param>
151 <xsl:choose>
152 <xsl:when test="@label">
153 <xsl:value-of select="@label"/>
154 <xsl:value-of select="$punct"/>
155 </xsl:when>
156 <xsl:when test="$preface.autolabel != 0">
157 <xsl:number from="book" count="preface" format="1" level="any"/>
158 <xsl:value-of select="$punct"/>
159 </xsl:when>
160 </xsl:choose>
161 </xsl:template>
163 <xsl:template match="chapter" mode="label.content">
164 <xsl:param name="punct">.</xsl:param>
165 <xsl:choose>
166 <xsl:when test="@label">
167 <xsl:value-of select="@label"/>
168 <xsl:value-of select="$punct"/>
169 </xsl:when>
170 <xsl:when test="$chapter.autolabel != 0">
171 <xsl:number from="book" count="chapter" format="1" level="any"/>
172 <xsl:value-of select="$punct"/>
173 </xsl:when>
174 </xsl:choose>
175 </xsl:template>
177 <xsl:template match="appendix" mode="label.content">
178 <xsl:param name="punct">.</xsl:param>
179 <xsl:choose>
180 <xsl:when test="@label">
181 <xsl:value-of select="@label"/>
182 <xsl:value-of select="$punct"/>
183 </xsl:when>
184 <xsl:when test="$chapter.autolabel != 0">
185 <xsl:number from="book" count="appendix" format="A" level="any"/>
186 <xsl:value-of select="$punct"/>
187 </xsl:when>
188 </xsl:choose>
189 </xsl:template>
191 <xsl:template match="article" mode="label.content">
192 <xsl:param name="punct">.</xsl:param>
193 <xsl:if test="@label">
194 <xsl:value-of select="@label"/>
195 <xsl:value-of select="$punct"/>
196 </xsl:if>
197 </xsl:template>
200 <xsl:template match="dedication|colophon" mode="label.content">
201 <xsl:param name="punct">.</xsl:param>
202 <xsl:if test="@label">
203 <xsl:value-of select="@label"/>
204 <xsl:value-of select="$punct"/>
205 </xsl:if>
206 </xsl:template>
208 <xsl:template match="reference" mode="label.content">
209 <xsl:param name="punct">.</xsl:param>
210 <xsl:choose>
211 <xsl:when test="@label">
212 <xsl:value-of select="@label"/>
213 <xsl:value-of select="$punct"/>
214 </xsl:when>
215 <xsl:when test="$part.autolabel != 0">
216 <xsl:number from="book" count="reference" format="I" level="any"/>
217 <xsl:value-of select="$punct"/>
218 </xsl:when>
219 </xsl:choose>
220 </xsl:template>
222 <xsl:template match="refentry" mode="label.content">
223 <xsl:param name="punct">.</xsl:param>
224 <xsl:if test="@label">
225 <xsl:value-of select="@label"/>
226 <xsl:value-of select="$punct"/>
227 </xsl:if>
228 </xsl:template>
230 <xsl:template match="section" mode="label.content">
231 <xsl:param name="punct">.</xsl:param>
233 <xsl:if test="local-name(..) = 'section'">
234 <xsl:apply-templates select=".." mode="label.content">
235 <xsl:with-param name="punct">.</xsl:with-param>
236 </xsl:apply-templates>
237 </xsl:if>
239 <xsl:variable name="parent.is.component">
240 <xsl:call-template name="is.component">
241 <xsl:with-param name="node" select=".."/>
242 </xsl:call-template>
243 </xsl:variable>
245 <xsl:variable name="label">
246 <xsl:call-template name="label.this.section">
247 <xsl:with-param name="section" select="."/>
248 </xsl:call-template>
249 </xsl:variable>
251 <xsl:if test="$section.label.includes.component.label != 0
252 and $parent.is.component != 0">
253 <xsl:apply-templates select=".." mode="label.content">
254 <xsl:with-param name="punct">.</xsl:with-param>
255 </xsl:apply-templates>
256 </xsl:if>
258 <xsl:choose>
259 <xsl:when test="@label">
260 <xsl:value-of select="@label"/>
261 <xsl:value-of select="$punct"/>
262 </xsl:when>
263 <xsl:when test="$label != 0">
264 <xsl:number count="section"/>
265 <xsl:value-of select="$punct"/>
266 </xsl:when>
267 </xsl:choose>
268 </xsl:template>
270 <xsl:template match="sect1" mode="label.content">
271 <xsl:param name="punct">.</xsl:param>
273 <xsl:variable name="parent.is.component">
274 <xsl:call-template name="is.component">
275 <xsl:with-param name="node" select=".."/>
276 </xsl:call-template>
277 </xsl:variable>
278 <xsl:if test="$section.label.includes.component.label != 0
279 and $parent.is.component">
280 <xsl:apply-templates select=".." mode="label.content">
281 <xsl:with-param name="punct">.</xsl:with-param>
282 </xsl:apply-templates>
283 </xsl:if>
285 <xsl:choose>
286 <xsl:when test="@label">
287 <xsl:value-of select="@label"/>
288 <xsl:value-of select="$punct"/>
289 </xsl:when>
290 <xsl:when test="$section.autolabel != 0">
291 <xsl:number count="sect1"/>
292 <xsl:value-of select="$punct"/>
293 </xsl:when>
294 </xsl:choose>
295 </xsl:template>
297 <xsl:template match="sect2|sect3|sect4|sect5" mode="label.content">
298 <xsl:param name="punct">.</xsl:param>
300 <xsl:apply-templates select=".." mode="label.content">
301 <xsl:with-param name="punct">.</xsl:with-param>
302 </xsl:apply-templates>
304 <xsl:choose>
305 <xsl:when test="@label">
306 <xsl:value-of select="@label"/>
307 <xsl:value-of select="$punct"/>
308 </xsl:when>
309 <xsl:when test="$section.autolabel != 0">
310 <xsl:choose>
311 <xsl:when test="local-name(.) = 'sect2'">
312 <xsl:number count="sect2"/>
313 </xsl:when>
314 <xsl:when test="local-name(.) = 'sect3'">
315 <xsl:number count="sect3"/>
316 </xsl:when>
317 <xsl:when test="local-name(.) = 'sect4'">
318 <xsl:number count="sect4"/>
319 </xsl:when>
320 <xsl:when test="local-name(.) = 'sect5'">
321 <xsl:number count="sect5"/>
322 </xsl:when>
323 <xsl:otherwise>
324 <xsl:message>label.content: this can't happen!</xsl:message>
325 </xsl:otherwise>
326 </xsl:choose>
327 <xsl:value-of select="$punct"/>
328 </xsl:when>
329 </xsl:choose>
330 </xsl:template>
331 <xsl:template match="refsect1|refsect2|refsect3" mode="label.content">
332 <xsl:param name="punct">.</xsl:param>
333 <xsl:choose>
334 <xsl:when test="@label">
335 <xsl:value-of select="@label"/>
336 <xsl:value-of select="$punct"/>
337 </xsl:when>
338 <xsl:when test="$section.autolabel != 0">
339 <xsl:number level="multiple" count="refsect1|refsect2|refsect3"/>
340 <xsl:value-of select="$punct"/>
341 </xsl:when>
342 </xsl:choose>
343 </xsl:template>
345 <xsl:template match="simplesect" mode="label.content">
346 <xsl:param name="punct">.</xsl:param>
347 <xsl:choose>
348 <xsl:when test="@label">
349 <xsl:value-of select="@label"/>
350 <xsl:value-of select="$punct"/>
351 </xsl:when>
352 <xsl:when test="$section.autolabel != 0">
353 <xsl:number level="multiple" count="section
354 |sect1|sect2|sect3|sect4|sect5
355 |refsect1|refsect2|refsect3
356 |simplesect"/>
357 <xsl:value-of select="$punct"/>
358 </xsl:when>
359 </xsl:choose>
360 </xsl:template>
362 <xsl:template match="qandadiv" mode="label.content">
363 <xsl:param name="punct">.</xsl:param>
364 <xsl:variable name="prefix">
365 <xsl:if test="$qanda.inherit.numeration != 0">
366 <xsl:variable name="lparent" select="(ancestor::set
367 |ancestor::book
368 |ancestor::chapter
369 |ancestor::appendix
370 |ancestor::preface
371 |ancestor::section
372 |ancestor::simplesect
373 |ancestor::sect1
374 |ancestor::sect2
375 |ancestor::sect3
376 |ancestor::sect4
377 |ancestor::sect5
378 |ancestor::refsect1
379 |ancestor::refsect2
380 |ancestor::refsect3)[last()]"/>
381 <xsl:if test="count($lparent)>0">
382 <xsl:apply-templates select="$lparent" mode="label.content"/>
383 </xsl:if>
384 </xsl:if>
385 </xsl:variable>
386 <xsl:choose>
387 <xsl:when test="@label">
388 <xsl:value-of select="$prefix"/>
389 <xsl:value-of select="@label"/>
390 <xsl:value-of select="$punct"/>
391 </xsl:when>
392 <xsl:when test="$qandadiv.autolabel != 0">
393 <xsl:value-of select="$prefix"/>
394 <xsl:number level="multiple" count="qandadiv" format="1"/>
395 <xsl:value-of select="$punct"/>
396 </xsl:when>
397 </xsl:choose>
398 </xsl:template>
400 <xsl:template match="question|answer" mode="label.content">
401 <xsl:param name="punct">.</xsl:param>
402 <xsl:variable name="prefix">
403 <xsl:if test="$qanda.inherit.numeration != 0">
404 <xsl:variable name="lparent" select="(ancestor::set
405 |ancestor::book
406 |ancestor::chapter
407 |ancestor::appendix
408 |ancestor::preface
409 |ancestor::section
410 |ancestor::simplesect
411 |ancestor::sect1
412 |ancestor::sect2
413 |ancestor::sect3
414 |ancestor::sect4
415 |ancestor::sect5
416 |ancestor::refsect1
417 |ancestor::refsect2
418 |ancestor::refsect3
419 |ancestor::qandadiv)[last()]"/>
420 <xsl:if test="count($lparent)>0">
421 <xsl:apply-templates select="$lparent" mode="label.content"/>
422 </xsl:if>
423 </xsl:if>
424 </xsl:variable>
426 <xsl:variable name="inhlabel"
427 select="ancestor-or-self::qandaset/@defaultlabel[1]"/>
429 <xsl:variable name="deflabel">
430 <xsl:choose>
431 <xsl:when test="$inhlabel != ''">
432 <xsl:value-of select="$inhlabel"/>
433 </xsl:when>
434 <xsl:otherwise>
435 <xsl:value-of select="$qanda.defaultlabel"/>
436 </xsl:otherwise>
437 </xsl:choose>
438 </xsl:variable>
440 <xsl:variable name="label" select="label"/>
442 <xsl:choose>
443 <xsl:when test="count($label)>0">
444 <xsl:value-of select="$prefix"/>
445 <xsl:apply-templates select="$label"/>
446 <xsl:value-of select="$punct"/>
447 </xsl:when>
449 <xsl:when test="$deflabel = 'qanda'">
450 <xsl:call-template name="gentext.element.name"/>
451 </xsl:when>
453 <xsl:when test="$deflabel = 'number'">
454 <xsl:if test="name(.) = 'question'">
455 <xsl:value-of select="$prefix"/>
456 <xsl:number level="multiple" count="qandaentry" format="1"/>
457 <xsl:value-of select="$punct"/>
458 </xsl:if>
459 </xsl:when>
460 </xsl:choose>
461 </xsl:template>
463 <xsl:template match="bibliography|glossary|index" mode="label.content">
464 <xsl:param name="punct">.</xsl:param>
465 <xsl:if test="@label">
466 <xsl:value-of select="@label"/>
467 <xsl:value-of select="$punct"/>
468 </xsl:if>
469 </xsl:template>
471 <xsl:template match="figure|table|example|equation" mode="label.content">
472 <xsl:param name="punct">.</xsl:param>
473 <xsl:choose>
474 <xsl:when test="@label">
475 <xsl:value-of select="@label"/>
476 <xsl:value-of select="$punct"/>
477 </xsl:when>
478 <xsl:otherwise>
479 <xsl:variable name="pchap"
480 select="ancestor::chapter|ancestor::appendix"/>
481 <xsl:choose>
482 <xsl:when test="count($pchap)>0">
483 <xsl:apply-templates select="$pchap" mode="label.content">
484 <xsl:with-param name="punct">.</xsl:with-param>
485 </xsl:apply-templates>
486 <xsl:number format="1" from="chapter|appendix" level="any"/>
487 <xsl:value-of select="$punct"/>
488 </xsl:when>
489 <xsl:otherwise>
490 <xsl:number format="1" from="book|article" level="any"/>
491 <xsl:value-of select="$punct"/>
492 </xsl:otherwise>
493 </xsl:choose>
494 </xsl:otherwise>
495 </xsl:choose>
496 </xsl:template>
498 <xsl:template match="abstract" mode="label.content">
499 <xsl:param name="punct">.</xsl:param>
500 </xsl:template>
501 -->
503 </xsl:stylesheet>