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"
7 <!-- ********************************************************************
8 $Id: common.xsl,v 1.1 2003/04/30 21:39:49 ab Exp $
9 ********************************************************************
11 Derived from the official DocBook XSL Stylesheets
12 See http://nwalsh.com/docbook/xsl/ for copyright and other information.
14 This file contains general templates common to both the HTML and FO
15 versions of the DocBook stylesheets.
16 ******************************************************************** -->
18 <doc:reference xmlns="">
20 <releaseinfo role="meta"> $Id: common.xsl,v 1.1 2003/04/30 21:39:49 ab Exp $ </releaseinfo>
22 <surname>Ramon</surname>
23 <firstname>Casellas</firstname>
26 <year>1999</year><year>2000</year>
27 <holder>Norman Walsh</holder>
30 <title>Common Template Reference</title>
33 <section><title>Introduction</title>
35 <para>This is technical reference documentation for the DocBook XSL
36 Stylesheets; it documents (some of) the parameters, templates, and
37 other elements of the stylesheets.</para>
39 <para>This is not intended to be <quote>user</quote> documentation.
40 It is provided for developers writing customization layers for the
41 stylesheets, and for anyone who's interested in <quote>how it
44 <para>Although I am trying to be thorough, this documentation is known
45 to be incomplete. Don't forget to read the source, too :-)</para>
51 <!-- ==================================================================== -->
52 <!-- Establish strip/preserve whitespace rules -->
54 <xsl:preserve-space elements="*"/>
56 <xsl:strip-space elements="
57 abstract affiliation anchor answer appendix area areaset areaspec
58 artheader article audiodata audioobject author authorblurb authorgroup
59 beginpage bibliodiv biblioentry bibliography biblioset blockquote book
60 bookbiblio bookinfo callout calloutlist caption caution chapter
61 citerefentry cmdsynopsis co collab colophon colspec confgroup
62 copyright dedication docinfo editor entry entrytbl epigraph equation
63 example figure footnote footnoteref formalpara funcprototype
64 funcsynopsis glossary glossdef glossdiv glossentry glosslist graphicco
65 group highlights imagedata imageobject imageobjectco important index
66 indexdiv indexentry indexterm informalequation informalexample
67 informalfigure informaltable inlineequation inlinemediaobject
68 itemizedlist itermset keycombo keywordset legalnotice listitem lot
69 mediaobject mediaobjectco menuchoice msg msgentry msgexplan msginfo
70 msgmain msgrel msgset msgsub msgtext note objectinfo
71 orderedlist othercredit part partintro preface printhistory procedure
72 programlistingco publisher qandadiv qandaentry qandaset question
73 refentry reference refmeta refnamediv refsect1 refsect1info refsect2
74 refsect2info refsect3 refsect3info refsynopsisdiv refsynopsisdivinfo
75 revhistory revision row sbr screenco screenshot sect1 sect1info sect2
76 sect2info sect3 sect3info sect4 sect4info sect5 sect5info section
77 sectioninfo seglistitem segmentedlist seriesinfo set setindex setinfo
78 shortcut sidebar simplelist simplesect spanspec step subject
79 subjectset substeps synopfragment table tbody textobject tfoot tgroup
80 thead tip toc tocchap toclevel1 toclevel2 toclevel3 toclevel4
81 toclevel5 tocpart varargs variablelist varlistentry videodata
82 videoobject void warning subjectset
96 <!-- ====================================================================== -->
98 <doc:template name="is.component" xmlns="">
99 <refpurpose>Tests if a given node is a component-level element</refpurpose>
102 <para>This template returns '1' if the specified node is a component
103 (Chapter, Appendix, etc.), and '0' otherwise.</para>
108 <varlistentry><term>node</term>
110 <para>The node which is to be tested.</para>
117 <para>This template returns '1' if the specified node is a component
118 (Chapter, Appendix, etc.), and '0' otherwise.</para>
122 <xsl:template name="is.component">
123 <xsl:param name="node" select="."/>
125 <xsl:when test="local-name($node) = 'appendix'
126 or local-name($node) = 'article'
127 or local-name($node) = 'chapter'
128 or local-name($node) = 'preface'
129 or local-name($node) = 'bibliography'
130 or local-name($node) = 'glossary'
131 or local-name($node) = 'index'">1</xsl:when>
132 <xsl:otherwise>0</xsl:otherwise>
136 <!-- ====================================================================== -->
138 <doc:template name="is.section" xmlns="">
139 <refpurpose>Tests if a given node is a section-level element</refpurpose>
142 <para>This template returns '1' if the specified node is a section
143 (Section, Sect1, Sect2, etc.), and '0' otherwise.</para>
148 <varlistentry><term>node</term>
150 <para>The node which is to be tested.</para>
157 <para>This template returns '1' if the specified node is a section
158 (Section, Sect1, Sect2, etc.), and '0' otherwise.</para>
162 <xsl:template name="is.section">
163 <xsl:param name="node" select="."/>
165 <xsl:when test="local-name($node) = 'section'
166 or local-name($node) = 'sect1'
167 or local-name($node) = 'sect2'
168 or local-name($node) = 'sect3'
169 or local-name($node) = 'sect4'
170 or local-name($node) = 'sect5'
171 or local-name($node) = 'refsect1'
172 or local-name($node) = 'refsect2'
173 or local-name($node) = 'refsect3'
174 or local-name($node) = 'simplesect'">1</xsl:when>
175 <xsl:otherwise>0</xsl:otherwise>
179 <!-- ====================================================================== -->
181 <doc:template name="section.level" xmlns="">
182 <refpurpose>Returns the hierarchical level of a section.</refpurpose>
185 <para>This template calculates the hierarchical level of a section.
186 Hierarchically, components are <quote>top level</quote>, so a
187 <sgmltag>sect1</sgmltag> is at level 2, <sgmltag>sect3</sgmltag> is
188 at level 3, etc.</para>
190 <para>Recursive sections are calculated down to the sixth level.</para>
195 <varlistentry><term>node</term>
197 <para>The section node for which the level should be calculated.
198 Defaults to the context node.</para>
205 <para>The section level, <quote>2</quote>, <quote>3</quote>, etc.
210 <xsl:template name="section.level">
211 <xsl:param name="node" select="."/>
213 <xsl:when test="name($node)='sect1'">2</xsl:when>
214 <xsl:when test="name($node)='sect2'">3</xsl:when>
215 <xsl:when test="name($node)='sect3'">4</xsl:when>
216 <xsl:when test="name($node)='sect4'">5</xsl:when>
217 <xsl:when test="name($node)='sect5'">6</xsl:when>
218 <xsl:when test="name($node)='section'">
220 <xsl:when test="$node/../../../../../section">6</xsl:when>
221 <xsl:when test="$node/../../../../section">5</xsl:when>
222 <xsl:when test="$node/../../../section">4</xsl:when>
223 <xsl:when test="$node/../../section">3</xsl:when>
224 <xsl:otherwise>2</xsl:otherwise>
227 <xsl:when test="name($node)='simplesect'">
229 <xsl:when test="$node/../../sect1">3</xsl:when>
230 <xsl:when test="$node/../../sect2">4</xsl:when>
231 <xsl:when test="$node/../../sect3">5</xsl:when>
232 <xsl:when test="$node/../../sect4">6</xsl:when>
233 <xsl:when test="$node/../../sect5">6</xsl:when>
234 <xsl:when test="$node/../../section">
236 <xsl:when test="$node/../../../../../section">6</xsl:when>
237 <xsl:when test="$node/../../../../section">5</xsl:when>
238 <xsl:when test="$node/../../../section">4</xsl:when>
239 <xsl:otherwise>3</xsl:otherwise>
242 <xsl:otherwise>2</xsl:otherwise>
245 <xsl:otherwise>2</xsl:otherwise>
247 </xsl:template><!-- section.level -->
249 <doc:template name="qanda.section.level" xmlns="">
250 <refpurpose>Returns the hierarchical level of a QandASet.</refpurpose>
253 <para>This template calculates the hierarchical level of a QandASet.
258 <para>The level, <quote>1</quote>, <quote>2</quote>, etc.
263 <xsl:template name="qanda.section.level">
264 <xsl:variable name="section"
265 select="(ancestor::section
266 |ancestor::simplesect
274 |ancestor::refsect1)[last()]"/>
276 <xsl:when test="count($section) = '0'">1</xsl:when>
278 <xsl:call-template name="section.level">
279 <xsl:with-param name="node" select="$section"/>
285 <xsl:template name="qandadiv.section.level">
286 <xsl:variable name="section.level">
287 <xsl:call-template name="qanda.section.level"/>
289 <xsl:variable name="anc.divs" select="ancestor::qandadiv"/>
291 <xsl:value-of select="count($anc.divs) + number($section.level)"/>
294 <!-- ====================================================================== -->
296 <xsl:template name="object.id">
297 <xsl:param name="object" select="."/>
299 <xsl:when test="$object/@id">
300 <xsl:value-of select="$object/@id"/>
303 <xsl:value-of select="generate-id($object)"/>
308 <xsl:template name="person.name">
309 <!-- Return a formatted string representation of the contents of
310 the specified node (by default, the current element).
311 Handles Honorific, FirstName, SurName, and Lineage.
312 If %author-othername-in-middle% is #t, also OtherName
313 Handles *only* the first of each.
314 Format is "Honorific. FirstName [OtherName] SurName, Lineage"
316 <xsl:param name="node" select="."/>
319 <!-- handle corpauthor as a special case...-->
320 <xsl:when test="name($node)='corpauthor'">
321 <xsl:apply-templates select="$node"/>
324 <xsl:variable name="h_nl" select="$node//honorific[1]"/>
325 <xsl:variable name="f_nl" select="$node//firstname[1]"/>
326 <xsl:variable name="o_nl" select="$node//othername[1]"/>
327 <xsl:variable name="s_nl" select="$node//surname[1]"/>
328 <xsl:variable name="l_nl" select="$node//lineage[1]"/>
330 <xsl:variable name="has_h" select="$h_nl"/>
331 <xsl:variable name="has_f" select="$f_nl"/>
332 <xsl:variable name="has_o"
333 select="$o_nl and ($author.othername.in.middle != 0)"/>
334 <xsl:variable name="has_s" select="$s_nl"/>
335 <xsl:variable name="has_l" select="$l_nl"/>
337 <xsl:if test="$has_h">
338 <xsl:value-of select="$h_nl"/>.
341 <xsl:if test="$has_f">
342 <xsl:if test="$has_h"><xsl:text> </xsl:text></xsl:if>
343 <xsl:value-of select="$f_nl"/>
346 <xsl:if test="$has_o">
347 <xsl:if test="$has_h or $has_f"><xsl:text> </xsl:text></xsl:if>
348 <xsl:value-of select="$o_nl"/>
351 <xsl:if test="$has_s">
352 <xsl:if test="$has_h or $has_f or $has_o">
353 <xsl:text> </xsl:text>
355 <xsl:value-of select="$s_nl"/>
358 <xsl:if test="$has_l">
359 <xsl:text>, </xsl:text>
360 <xsl:value-of select="$l_nl"/>
364 </xsl:template> <!-- person.name -->
366 <xsl:template name="person.name.list">
367 <!-- Return a formatted string representation of the contents of
368 the current element. The current element must contain one or
369 more AUTHORs, CORPAUTHORs, OTHERCREDITs, and/or EDITORs.
373 John Doe and Jane Doe
375 John Doe, Jane Doe, and A. Nonymous
377 <xsl:param name="person.list" select="./author|./corpauthor|./othercredit|./editor"/>
378 <xsl:param name="person.count" select="count($person.list)"/>
379 <xsl:param name="count" select="1"/>
382 <xsl:when test="$count>$person.count"></xsl:when>
384 <xsl:call-template name="person.name">
385 <xsl:with-param name="node" select="$person.list[position()=$count]"/>
387 <xsl:if test="$count<$person.count">
388 <xsl:if test="$person.count>2">,</xsl:if>
389 <xsl:text> </xsl:text>
391 <xsl:if test="$count+1=$person.count">and </xsl:if>
392 <xsl:call-template name="person.name.list">
393 <xsl:with-param name="person.list" select="$person.list"/>
394 <xsl:with-param name="person.count" select="$person.count"/>
395 <xsl:with-param name="count" select="$count+1"/>
399 </xsl:template><!-- person.name.list -->
401 <!-- === synopsis ======================================================= -->
402 <!-- The following definitions match those given in the reference
403 documentation for DocBook V3.0
406 <xsl:variable name="arg.choice.opt.open.str">[</xsl:variable>
407 <xsl:variable name="arg.choice.opt.close.str">]</xsl:variable>
408 <xsl:variable name="arg.choice.req.open.str">{</xsl:variable>
409 <xsl:variable name="arg.choice.req.close.str">}</xsl:variable>
410 <xsl:variable name="arg.choice.plain.open.str"><xsl:text> </xsl:text></xsl:variable>
411 <xsl:variable name="arg.choice.plain.close.str"><xsl:text> </xsl:text></xsl:variable>
412 <xsl:variable name="arg.choice.def.open.str">[</xsl:variable>
413 <xsl:variable name="arg.choice.def.close.str">]</xsl:variable>
414 <xsl:variable name="arg.rep.repeat.str">...</xsl:variable>
415 <xsl:variable name="arg.rep.norepeat.str"></xsl:variable>
416 <xsl:variable name="arg.rep.def.str"></xsl:variable>
417 <xsl:variable name="arg.or.sep"> | </xsl:variable>
418 <xsl:variable name="cmdsynopsis.hanging.indent">4pi</xsl:variable>
420 <!-- ====================================================================== -->
421 <!-- label content -->
423 <doc:mode mode="label.content" xmlns="">
424 <refpurpose>Provides access to element labels</refpurpose>
426 <para>Processing an element in the
427 <literal role="mode">label.content</literal> mode produces the
428 element label.</para>
429 <para>If the label is non-null, either because the
430 <sgmltag class="attribute">label</sgmltag> attribute was present on the
431 element or the stylesheet automatically generated a label, trailing
432 punctuation is automatically added.</para>
436 <xsl:template match="*" mode="label.content">
438 <xsl:text>Request for label of unexpected element: </xsl:text>
439 <xsl:value-of select="name(.)"/>
443 <xsl:template match="set|book" mode="label.content">
444 <xsl:param name="punct">.</xsl:param>
445 <xsl:if test="@label">
446 <xsl:value-of select="@label"/>
447 <xsl:value-of select="$punct"/>
451 <xsl:template match="part" mode="label.content">
452 <xsl:param name="punct">.</xsl:param>
454 <xsl:when test="@label">
455 <xsl:value-of select="@label"/>
456 <xsl:value-of select="$punct"/>
458 <xsl:when test="$part.autolabel != 0">
459 <xsl:number from="book" count="part" format="I"/>
460 <xsl:value-of select="$punct"/>
465 <xsl:template match="preface" mode="label.content">
466 <xsl:param name="punct">.</xsl:param>
468 <xsl:when test="@label">
469 <xsl:value-of select="@label"/>
470 <xsl:value-of select="$punct"/>
472 <xsl:when test="$preface.autolabel != 0">
473 <xsl:number from="book" count="preface" format="1" level="any"/>
474 <xsl:value-of select="$punct"/>
479 <xsl:template match="chapter" mode="label.content">
480 <xsl:param name="punct">.</xsl:param>
482 <xsl:when test="@label">
483 <xsl:value-of select="@label"/>
484 <xsl:value-of select="$punct"/>
486 <xsl:when test="$chapter.autolabel != 0">
487 <xsl:number from="book" count="chapter" format="1" level="any"/>
488 <xsl:value-of select="$punct"/>
493 <xsl:template match="appendix" mode="label.content">
494 <xsl:param name="punct">.</xsl:param>
496 <xsl:when test="@label">
497 <xsl:value-of select="@label"/>
498 <xsl:value-of select="$punct"/>
500 <xsl:when test="$chapter.autolabel != 0">
501 <xsl:number from="book" count="appendix" format="A" level="any"/>
502 <xsl:value-of select="$punct"/>
507 <xsl:template match="article" mode="label.content">
508 <xsl:param name="punct">.</xsl:param>
509 <xsl:if test="@label">
510 <xsl:value-of select="@label"/>
511 <xsl:value-of select="$punct"/>
515 <xsl:template match="dedication|colophon" mode="label.content">
516 <xsl:param name="punct">.</xsl:param>
517 <xsl:if test="@label">
518 <xsl:value-of select="@label"/>
519 <xsl:value-of select="$punct"/>
523 <xsl:template match="reference" mode="label.content">
524 <xsl:param name="punct">.</xsl:param>
526 <xsl:when test="@label">
527 <xsl:value-of select="@label"/>
528 <xsl:value-of select="$punct"/>
530 <xsl:when test="$part.autolabel != 0">
531 <xsl:number from="book" count="reference" format="I" level="any"/>
532 <xsl:value-of select="$punct"/>
537 <xsl:template match="refentry" mode="label.content">
538 <xsl:param name="punct">.</xsl:param>
539 <xsl:if test="@label">
540 <xsl:value-of select="@label"/>
541 <xsl:value-of select="$punct"/>
545 <xsl:template match="section" mode="label.content">
546 <xsl:param name="punct">.</xsl:param>
548 <!-- if this is a nested section, label the parent -->
549 <xsl:if test="local-name(..) = 'section'">
550 <xsl:apply-templates select=".." mode="label.content">
551 <xsl:with-param name="punct">.</xsl:with-param>
552 </xsl:apply-templates>
555 <!-- if the parent is a component, maybe label that too -->
556 <xsl:variable name="parent.is.component">
557 <xsl:call-template name="is.component">
558 <xsl:with-param name="node" select=".."/>
562 <!-- does this section get labelled? -->
563 <xsl:variable name="label">
564 <xsl:call-template name="label.this.section">
565 <xsl:with-param name="section" select="."/>
569 <xsl:if test="$section.label.includes.component.label != 0
570 and $parent.is.component != 0">
571 <xsl:apply-templates select=".." mode="label.content">
572 <xsl:with-param name="punct">.</xsl:with-param>
573 </xsl:apply-templates>
577 <xsl:when test="@label">
578 <xsl:value-of select="@label"/>
579 <xsl:value-of select="$punct"/>
581 <xsl:when test="$label != 0">
582 <xsl:number count="section"/>
583 <xsl:value-of select="$punct"/>
588 <xsl:template match="sect1" mode="label.content">
589 <xsl:param name="punct">.</xsl:param>
591 <!-- if the parent is a component, maybe label that too -->
592 <xsl:variable name="parent.is.component">
593 <xsl:call-template name="is.component">
594 <xsl:with-param name="node" select=".."/>
597 <xsl:if test="$section.label.includes.component.label != 0
598 and $parent.is.component">
599 <xsl:apply-templates select=".." mode="label.content">
600 <xsl:with-param name="punct">.</xsl:with-param>
601 </xsl:apply-templates>
605 <xsl:when test="@label">
606 <xsl:value-of select="@label"/>
607 <xsl:value-of select="$punct"/>
609 <xsl:when test="$section.autolabel != 0">
610 <xsl:number count="sect1"/>
611 <xsl:value-of select="$punct"/>
616 <xsl:template match="sect2|sect3|sect4|sect5" mode="label.content">
617 <xsl:param name="punct">.</xsl:param>
619 <!-- label the parent -->
620 <xsl:apply-templates select=".." mode="label.content">
621 <xsl:with-param name="punct">.</xsl:with-param>
622 </xsl:apply-templates>
625 <xsl:when test="@label">
626 <xsl:value-of select="@label"/>
627 <xsl:value-of select="$punct"/>
629 <xsl:when test="$section.autolabel != 0">
631 <xsl:when test="local-name(.) = 'sect2'">
632 <xsl:number count="sect2"/>
634 <xsl:when test="local-name(.) = 'sect3'">
635 <xsl:number count="sect3"/>
637 <xsl:when test="local-name(.) = 'sect4'">
638 <xsl:number count="sect4"/>
640 <xsl:when test="local-name(.) = 'sect5'">
641 <xsl:number count="sect5"/>
644 <xsl:message>label.content: this can't happen!</xsl:message>
647 <xsl:value-of select="$punct"/>
652 <xsl:template match="refsect1|refsect2|refsect3" mode="label.content">
653 <xsl:param name="punct">.</xsl:param>
655 <xsl:when test="@label">
656 <xsl:value-of select="@label"/>
657 <xsl:value-of select="$punct"/>
659 <xsl:when test="$section.autolabel != 0">
660 <xsl:number level="multiple" count="refsect1|refsect2|refsect3"/>
661 <xsl:value-of select="$punct"/>
666 <xsl:template match="simplesect" mode="label.content">
667 <xsl:param name="punct">.</xsl:param>
669 <xsl:when test="@label">
670 <xsl:value-of select="@label"/>
671 <xsl:value-of select="$punct"/>
673 <xsl:when test="$section.autolabel != 0">
674 <xsl:number level="multiple" count="section
675 |sect1|sect2|sect3|sect4|sect5
676 |refsect1|refsect2|refsect3
678 <xsl:value-of select="$punct"/>
683 <xsl:template match="qandadiv" mode="label.content">
684 <xsl:param name="punct">.</xsl:param>
685 <xsl:variable name="prefix">
686 <xsl:if test="$qanda.inherit.numeration != 0">
687 <xsl:variable name="lparent" select="(ancestor::set
693 |ancestor::simplesect
701 |ancestor::refsect3)[last()]"/>
702 <xsl:if test="count($lparent)>0">
703 <xsl:apply-templates select="$lparent" mode="label.content"/>
708 <xsl:when test="@label">
709 <xsl:value-of select="$prefix"/>
710 <xsl:value-of select="@label"/>
711 <xsl:value-of select="$punct"/>
713 <xsl:when test="$qandadiv.autolabel != 0">
714 <xsl:value-of select="$prefix"/>
715 <xsl:number level="multiple" count="qandadiv" format="1"/>
716 <xsl:value-of select="$punct"/>
721 <xsl:template match="question|answer" mode="label.content">
722 <xsl:param name="punct">.</xsl:param>
723 <xsl:variable name="prefix">
724 <xsl:if test="$qanda.inherit.numeration != 0">
725 <xsl:variable name="lparent" select="(ancestor::set
731 |ancestor::simplesect
740 |ancestor::qandadiv)[last()]"/>
741 <xsl:if test="count($lparent)>0">
742 <xsl:apply-templates select="$lparent" mode="label.content"/>
747 <xsl:variable name="inhlabel"
748 select="ancestor-or-self::qandaset/@defaultlabel[1]"/>
750 <xsl:variable name="deflabel">
752 <xsl:when test="$inhlabel != ''">
753 <xsl:value-of select="$inhlabel"/>
756 <xsl:value-of select="$qanda.defaultlabel"/>
761 <xsl:variable name="label" select="label"/>
764 <xsl:when test="count($label)>0">
765 <xsl:value-of select="$prefix"/>
766 <xsl:apply-templates select="$label"/>
767 <xsl:value-of select="$punct"/>
770 <xsl:when test="$deflabel = 'qanda'">
771 <xsl:call-template name="gentext.element.name"/>
774 <xsl:when test="$deflabel = 'number'">
775 <xsl:if test="name(.) = 'question'">
776 <xsl:value-of select="$prefix"/>
777 <xsl:number level="multiple" count="qandaentry" format="1"/>
778 <xsl:value-of select="$punct"/>
784 <xsl:template match="bibliography|glossary|index" mode="label.content">
785 <xsl:param name="punct">.</xsl:param>
786 <xsl:if test="@label">
787 <xsl:value-of select="@label"/>
788 <xsl:value-of select="$punct"/>
792 <xsl:template match="figure|table|example|equation" mode="label.content">
793 <xsl:param name="punct">.</xsl:param>
795 <xsl:when test="@label">
796 <xsl:value-of select="@label"/>
797 <xsl:value-of select="$punct"/>
800 <xsl:variable name="pchap"
801 select="ancestor::chapter|ancestor::appendix"/>
803 <xsl:when test="count($pchap)>0">
804 <xsl:apply-templates select="$pchap" mode="label.content">
805 <xsl:with-param name="punct">.</xsl:with-param>
806 </xsl:apply-templates>
807 <xsl:number format="1" from="chapter|appendix" level="any"/>
808 <xsl:value-of select="$punct"/>
811 <xsl:number format="1" from="book|article" level="any"/>
812 <xsl:value-of select="$punct"/>
819 <xsl:template match="abstract" mode="label.content">
820 <xsl:param name="punct">.</xsl:param>
823 <!-- ====================================================================== -->
825 <xsl:template name="label.this.section">
826 <xsl:param name="section" select="."/>
827 <xsl:value-of select="$section.autolabel"/>
830 <doc:template name="label.this.section" xmlns="">
831 <refpurpose>Returns true if $section should be labelled</refpurpose>
833 <para>Returns true if the specified section should be labelled.
834 By default, this template simply returns $section.autolabel, but
835 custom stylesheets may override it to get more selective behavior.</para>
839 <!-- ====================================================================== -->
840 <!-- title content -->
842 <doc:mode mode="title.content" xmlns="">
843 <refpurpose>Provides access to element titles</refpurpose>
845 <para>Processing an element in the
846 <literal role="mode">title.content</literal> mode produces the
847 title of the element. This does not include the label. If
848 <parameter>text-only</parameter> is true, the text of the title
849 is returned, without inline markup, otherwise inline markup is processed
850 (in the default mode). By default, <parameter>text-only</parameter>
856 <xsl:template match="*" mode="title.content">
857 <xsl:param name="text-only" select="'0'"/>
858 <xsl:param name="allow-anchors" select="'0'"/>
860 <xsl:when test="title">
861 <xsl:apply-templates select="title[1]" mode="title.content">
862 <xsl:with-param name="text-only" select="$text-only"/>
863 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
864 </xsl:apply-templates>
868 <xsl:text>Request for title of unexpected element: </xsl:text>
869 <xsl:value-of select="name(.)"/>
871 <xsl:text>???TITLE???</xsl:text>
876 <xsl:template match="*" mode="no.anchor.mode">
877 <xsl:apply-templates select="."/>
880 <xsl:template match="anchor" mode="no.anchor.mode">
881 <!-- nop, suppressed -->
884 <xsl:template match="title" mode="title.content">
885 <xsl:param name="text-only" select="'0'"/>
886 <xsl:param name="allow-anchors" select="'0'"/>
888 <xsl:when test="$text-only != 0">
889 <xsl:value-of select="."/>
893 <xsl:when test="$allow-anchors != 0">
894 <xsl:apply-templates/>
897 <xsl:apply-templates mode="no.anchor.mode"/>
904 <xsl:template match="set" mode="title.content">
905 <xsl:param name="text-only" select="'0'"/>
906 <xsl:param name="allow-anchors" select="'0'"/>
907 <xsl:apply-templates select="(setinfo/title|title)[1]"
908 mode="title.content">
909 <xsl:with-param name="text-only" select="$text-only"/>
910 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
911 </xsl:apply-templates>
914 <xsl:template match="book" mode="title.content">
915 <xsl:param name="text-only" select="'0'"/>
916 <xsl:param name="allow-anchors" select="'0'"/>
917 <xsl:apply-templates select="(bookinfo/title|title)[1]"
918 mode="title.content">
919 <xsl:with-param name="text-only" select="$text-only"/>
920 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
921 </xsl:apply-templates>
924 <xsl:template match="part" mode="title.content">
925 <xsl:param name="text-only" select="'0'"/>
926 <xsl:param name="allow-anchors" select="'0'"/>
927 <xsl:apply-templates select="(partinfo/title|docinfo/title|title)[1]"
928 mode="title.content">
929 <xsl:with-param name="text-only" select="$text-only"/>
930 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
931 </xsl:apply-templates>
934 <xsl:template match="preface|chapter|appendix" mode="title.content">
935 <xsl:param name="text-only" select="'0'"/>
936 <xsl:param name="allow-anchors" select="'0'"/>
937 <xsl:variable name="title" select="(docinfo/title
943 <xsl:when test="$title">
944 <xsl:apply-templates select="$title" mode="title.content">
945 <xsl:with-param name="text-only" select="$text-only"/>
946 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
947 </xsl:apply-templates>
950 <xsl:call-template name="gentext.element.name">
951 <xsl:with-param name="element.name" select="name(.)"/>
957 <xsl:template match="dedication|colophon" mode="title.content">
958 <xsl:param name="text-only" select="'0'"/>
959 <xsl:param name="allow-anchors" select="'0'"/>
961 <xsl:when test="title">
962 <xsl:apply-templates select="title" mode="title.content">
963 <xsl:with-param name="text-only" select="$text-only"/>
964 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
965 </xsl:apply-templates>
968 <xsl:call-template name="gentext.element.name">
969 <xsl:with-param name="element.name" select="name(.)"/>
975 <xsl:template match="article" mode="title.content">
976 <xsl:param name="text-only" select="'0'"/>
977 <xsl:param name="allow-anchors" select="'0'"/>
978 <xsl:variable name="title" select="(artheader/title
982 <xsl:apply-templates select="$title" mode="title.content">
983 <xsl:with-param name="text-only" select="$text-only"/>
984 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
985 </xsl:apply-templates>
988 <xsl:template match="reference" mode="title.content">
989 <xsl:param name="text-only" select="'0'"/>
990 <xsl:param name="allow-anchors" select="'0'"/>
991 <xsl:apply-templates select="(referenceinfo/title|docinfo/title|title)[1]"
992 mode="title.content">
993 <xsl:with-param name="text-only" select="$text-only"/>
994 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
995 </xsl:apply-templates>
998 <xsl:template match="refentry" mode="title.content">
999 <xsl:param name="text-only" select="'0'"/>
1000 <xsl:param name="allow-anchors" select="'0'"/>
1001 <xsl:variable name="refmeta" select=".//refmeta"/>
1002 <xsl:variable name="refentrytitle" select="$refmeta//refentrytitle"/>
1003 <xsl:variable name="refnamediv" select=".//refnamediv"/>
1004 <xsl:variable name="refname" select="$refnamediv//refname"/>
1006 <xsl:variable name="title">
1008 <xsl:when test="$refentrytitle">
1009 <xsl:apply-templates select="$refentrytitle[1]" mode="title.content"/>
1011 <xsl:when test="$refname">
1012 <xsl:apply-templates select="$refname[1]" mode="title.content"/>
1014 <xsl:otherwise>REFENTRY WITHOUT TITLE???</xsl:otherwise>
1019 <xsl:when test="$text-only != 0">
1020 <xsl:value-of select="$title"/>
1022 <xsl:otherwise><xsl:copy-of select="$title"/></xsl:otherwise>
1026 <xsl:template match="refentrytitle|refname" mode="title.content">
1027 <xsl:apply-templates/>
1030 <xsl:template match="section
1031 |sect1|sect2|sect3|sect4|sect5
1032 |refsect1|refsect2|refsect3
1034 mode="title.content">
1035 <xsl:param name="text-only" select="'0'"/>
1036 <xsl:param name="allow-anchors" select="'0'"/>
1037 <xsl:variable name="title" select="(sectioninfo/title
1048 <xsl:apply-templates select="$title" mode="title.content">
1049 <xsl:with-param name="text-only" select="$text-only"/>
1050 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
1051 </xsl:apply-templates>
1054 <xsl:template match="bibliography|glossary|index" mode="title.content">
1055 <xsl:param name="text-only" select="'0'"/>
1056 <xsl:param name="allow-anchors" select="'0'"/>
1058 <xsl:when test="title">
1059 <xsl:apply-templates select="title" mode="title.content">
1060 <xsl:with-param name="text-only" select="$text-only"/>
1061 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
1062 </xsl:apply-templates>
1065 <xsl:call-template name="gentext.element.name">
1066 <xsl:with-param name="element.name" select="name(.)"/>
1067 </xsl:call-template>
1072 <xsl:template match="figure|table|example|equation" mode="title.content">
1073 <xsl:param name="text-only" select="'0'"/>
1074 <xsl:param name="allow-anchors" select="'0'"/>
1075 <xsl:apply-templates select="title" mode="title.content">
1076 <xsl:with-param name="text-only" select="$text-only"/>
1077 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
1078 </xsl:apply-templates>
1081 <xsl:template match="abstract" mode="title.content">
1082 <xsl:param name="text-only" select="'0'"/>
1083 <xsl:param name="allow-anchors" select="'0'"/>
1085 <xsl:when test="title">
1086 <xsl:apply-templates select="title" mode="title.content">
1087 <xsl:with-param name="text-only" select="$text-only"/>
1088 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
1089 </xsl:apply-templates>
1092 <xsl:call-template name="gentext.element.name">
1093 <xsl:with-param name="element.name" select="name(.)"/>
1094 </xsl:call-template>
1099 <!-- ====================================================================== -->
1100 <!-- subtitle content -->
1102 <doc:mode mode="subtitle.content" xmlns="">
1103 <refpurpose>Provides access to element subtitles</refpurpose>
1105 <para>Processing an element in the
1106 <literal role="mode">subtitle.content</literal> mode produces the
1107 subtitle of the element. If
1108 <parameter>text-only</parameter> is true, the text of the title
1109 is returned, without inline markup, otherwise inline markup is processed
1110 (in the default mode). By default, <parameter>text-only</parameter>
1116 <xsl:template match="*" mode="subtitle.content">
1118 <xsl:text>Request for subtitle of unexpected element: </xsl:text>
1119 <xsl:value-of select="name(.)"/>
1121 <xsl:text>???SUBTITLE???</xsl:text>
1124 <xsl:template match="subtitle" mode="subtitle.content">
1125 <xsl:param name="text-only" select="'0'"/>
1126 <xsl:param name="allow-anchors" select="'0'"/>
1128 <xsl:when test="$text-only != 0">
1129 <xsl:value-of select="."/>
1132 <xsl:apply-templates/>
1137 <xsl:template match="set" mode="subtitle.content">
1138 <xsl:param name="text-only" select="'0'"/>
1139 <xsl:param name="allow-anchors" select="'0'"/>
1140 <xsl:apply-templates select="(setinfo/subtitle|subtitle)[1]"
1141 mode="subtitle.content">
1142 <xsl:with-param name="text-only" select="$text-only"/>
1143 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
1144 </xsl:apply-templates>
1147 <xsl:template match="book" mode="subtitle.content">
1148 <xsl:param name="text-only" select="'0'"/>
1149 <xsl:param name="allow-anchors" select="'0'"/>
1150 <xsl:apply-templates select="(bookinfo/subtitle|subtitle)[1]"
1151 mode="subtitle.content">
1152 <xsl:with-param name="text-only" select="$text-only"/>
1153 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
1154 </xsl:apply-templates>
1157 <xsl:template match="part" mode="subtitle.content">
1158 <xsl:param name="text-only" select="'0'"/>
1159 <xsl:param name="allow-anchors" select="'0'"/>
1160 <xsl:apply-templates select="(partinfo/subtitle
1163 mode="subtitle.content">
1164 <xsl:with-param name="text-only" select="$text-only"/>
1165 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
1166 </xsl:apply-templates>
1169 <xsl:template match="preface|chapter|appendix" mode="subtitle.content">
1170 <xsl:param name="text-only" select="'0'"/>
1171 <xsl:param name="allow-anchors" select="'0'"/>
1172 <xsl:apply-templates select="(docinfo/subtitle
1173 |prefaceinfo/subtitle
1174 |chapterinfo/subtitle
1175 |appendixinfo/subtitle
1177 mode="subtitle.content">
1178 <xsl:with-param name="text-only" select="$text-only"/>
1179 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
1180 </xsl:apply-templates>
1183 <xsl:template match="dedication|colophon" mode="subtitle.content">
1184 <xsl:param name="text-only" select="'0'"/>
1185 <xsl:param name="allow-anchors" select="'0'"/>
1186 <xsl:apply-templates select="subtitle"
1187 mode="subtitle.content">
1188 <xsl:with-param name="text-only" select="$text-only"/>
1189 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
1190 </xsl:apply-templates>
1193 <xsl:template match="reference" mode="subtitle.content">
1194 <xsl:param name="text-only" select="'0'"/>
1195 <xsl:param name="allow-anchors" select="'0'"/>
1196 <xsl:apply-templates select="(referenceinfo/subtitle
1199 mode="subtitle.content">
1200 <xsl:with-param name="text-only" select="$text-only"/>
1201 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
1202 </xsl:apply-templates>
1205 <xsl:template match="refentry" mode="subtitle.content">
1206 <xsl:param name="text-only" select="'0'"/>
1207 <xsl:param name="allow-anchors" select="'0'"/>
1208 <xsl:apply-templates select="(refentryinfo/subtitle
1209 |docinfo/subtitle)[1]"
1210 mode="subtitle.content">
1211 <xsl:with-param name="text-only" select="$text-only"/>
1212 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
1213 </xsl:apply-templates>
1216 <xsl:template match="section
1217 |sect1|sect2|sect3|sect4|sect5
1218 |refsect1|refsect2|refsect3
1220 mode="subtitle.content">
1221 <xsl:param name="text-only" select="'0'"/>
1222 <xsl:param name="allow-anchors" select="'0'"/>
1223 <xsl:apply-templates select="(sectioninfo/subtitle
1229 |refsect1info/subtitle
1230 |refsect2info/subtitle
1231 |refsect3info/subtitle
1233 mode="subtitle.content">
1234 <xsl:with-param name="text-only" select="$text-only"/>
1235 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
1236 </xsl:apply-templates>
1239 <!-- ====================================================================== -->
1240 <!-- title reference (label + title) -->
1242 <doc:mode mode="title.ref" xmlns="">
1243 <refpurpose>Provides reference text for an element</refpurpose>
1245 <para>Processing an element in the
1246 <literal role="mode">title.ref</literal> mode produces the
1247 label and title of the element.
1252 <varlistentry><term>text-only</term>
1255 <parameter>text-only</parameter> is true, the text of the title
1256 is returned, without inline markup, otherwise inline markup is processed
1257 (in the default mode). By default, <parameter>text-only</parameter>
1261 <varlistentry><term>label-wrapper</term>
1263 <para>If <parameter>label-wrapper</parameter> is not the emtpy string,
1264 it must be the name of an element. The element so named will be wrapped
1265 around labels on output.</para>
1268 <varlistentry><term>title-wrapper</term>
1270 <para>If <parameter>title.wrapper</parameter> is not the emtpy string,
1271 it must be the name of an element. The element so named will be wrapped
1272 around titles on output.</para>
1275 <varlistentry><term>label-wrapper-class</term>
1277 <para>If a <parameter>label-wrapper</parameter> is provided and
1278 <parameter>label-wrapper-class</parameter> is not the emtpy string,
1279 it be used as the value for a <sgmltag class="attribute">class</sgmltag>
1280 attribute on the <parameter>label-wrapper</parameter> element.</para>
1281 <para>This is a dirty hack because it only makes sense for the HTML
1282 stylesheet (there's no <sgmltag class="attribute">class</sgmltag> attribute
1283 on the FO elements). What I'd really like to do is pass an attribute
1284 set as a parameter, but I can't.</para>
1287 <varlistentry><term>title-wrapper-class</term>
1289 <para>If a <parameter>title-wrapper</parameter> is provided and
1290 <parameter>title-wrapper-class</parameter> is not the emtpy string,
1291 it be used as the value for a <sgmltag class="attribute">class</sgmltag>
1292 attribute on the <parameter>title-wrapper</parameter> element.</para>
1293 <para>This is a dirty hack because it only makes sense for the HTML
1294 stylesheet (there's no <sgmltag class="attribute">class</sgmltag> attribute
1295 on the FO elements). What I'd really like to do is pass an attribute
1296 set as a parameter, but I can't.</para>
1303 <xsl:template match="*" mode="title.ref">
1304 <xsl:param name="text-only" select="'0'"/>
1305 <xsl:param name="allow-anchors" select="'0'"/>
1306 <xsl:param name="label-wrapper" select="''"/>
1307 <xsl:param name="title-wrapper" select="''"/>
1309 <xsl:param name="label-wrapper-class" select="''"/>
1310 <xsl:param name="title-wrapper-class" select="''"/>
1312 <xsl:variable name="label">
1313 <xsl:apply-templates select="." mode="label.content"/>
1316 <xsl:if test="$label != ''">
1318 <xsl:when test="$text-only = 0">
1320 <xsl:when test="$label-wrapper != ''">
1321 <xsl:element name="{$label-wrapper}">
1322 <xsl:if test="$label-wrapper-class != ''">
1323 <xsl:attribute name="class">
1324 <xsl:value-of select="$label-wrapper-class"/>
1327 <xsl:copy-of select="$label"/>
1331 <xsl:copy-of select="$label"/>
1334 <xsl:text> </xsl:text>
1337 <xsl:value-of select="$label"/>
1338 <xsl:text> </xsl:text>
1344 <xsl:when test="$text-only = 0">
1346 <xsl:when test="$title-wrapper != ''">
1347 <xsl:element name="{$title-wrapper}">
1348 <xsl:if test="$title-wrapper-class != ''">
1349 <xsl:attribute name="class">
1350 <xsl:value-of select="$title-wrapper-class"/>
1353 <xsl:apply-templates select="." mode="title.content">
1354 <xsl:with-param name="text-only" select="$text-only"/>
1355 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
1356 </xsl:apply-templates>
1360 <xsl:apply-templates select="." mode="title.content">
1361 <xsl:with-param name="text-only" select="$text-only"/>
1362 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
1363 </xsl:apply-templates>
1368 <xsl:apply-templates select="." mode="title.content">
1369 <xsl:with-param name="text-only" select="$text-only"/>
1370 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
1371 </xsl:apply-templates>
1376 <xsl:template match="figure|table|example|equation
1377 |chapter|appendix" mode="title.ref">
1378 <xsl:param name="text-only" select="'0'"/>
1379 <xsl:param name="allow-anchors" select="'0'"/>
1380 <xsl:param name="label-wrapper" select="''"/>
1381 <xsl:param name="title-wrapper" select="''"/>
1383 <xsl:param name="label-wrapper-class" select="''"/>
1384 <xsl:param name="title-wrapper-class" select="''"/>
1386 <xsl:variable name="label">
1387 <xsl:call-template name="gentext.element.name">
1388 <xsl:with-param name="element.name">
1389 <xsl:value-of select="name(.)"/>
1391 </xsl:call-template>
1392 <xsl:call-template name="gentext.space"/>
1393 <xsl:apply-templates select="." mode="label.content"/>
1396 <xsl:if test="$label != ''">
1398 <xsl:when test="$text-only = 0">
1400 <xsl:when test="$label-wrapper != ''">
1401 <xsl:element name="{$label-wrapper}">
1402 <xsl:if test="$label-wrapper-class != ''">
1403 <xsl:attribute name="class">
1404 <xsl:value-of select="$label-wrapper-class"/>
1407 <xsl:copy-of select="$label"/>
1411 <xsl:copy-of select="$label"/>
1414 <xsl:text> </xsl:text>
1417 <xsl:value-of select="$label"/>
1418 <xsl:text> </xsl:text>
1424 <xsl:when test="$text-only = 0">
1426 <xsl:when test="$title-wrapper != ''">
1427 <xsl:element name="{$title-wrapper}">
1428 <xsl:if test="$title-wrapper-class != ''">
1429 <xsl:attribute name="class">
1430 <xsl:value-of select="$title-wrapper-class"/>
1433 <xsl:apply-templates select="." mode="title.content">
1434 <xsl:with-param name="text-only" select="$text-only"/>
1435 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
1436 </xsl:apply-templates>
1440 <xsl:apply-templates select="." mode="title.content">
1441 <xsl:with-param name="text-only" select="$text-only"/>
1442 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
1443 </xsl:apply-templates>
1448 <xsl:apply-templates select="." mode="title.content">
1449 <xsl:with-param name="text-only" select="$text-only"/>
1450 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
1451 </xsl:apply-templates>
1456 <!-- ====================================================================== -->
1458 <xsl:template name="xref.g.subst">
1459 <xsl:param name="string"></xsl:param>
1460 <xsl:param name="target" select="."/>
1461 <xsl:variable name="subst">%g</xsl:variable>
1464 <xsl:when test="contains($string, $subst)">
1465 <xsl:value-of select="substring-before($string, $subst)"/>
1466 <xsl:call-template name="gentext.element.name">
1467 <xsl:with-param name="element.name" select="name($target)"/>
1468 </xsl:call-template>
1469 <xsl:call-template name="xref.g.subst">
1470 <xsl:with-param name="string"
1471 select="substring-after($string, $subst)"/>
1472 <xsl:with-param name="target" select="$target"/>
1473 </xsl:call-template>
1476 <xsl:value-of select="$string"/>
1481 <xsl:template name="xref.t.subst">
1482 <xsl:param name="string"></xsl:param>
1483 <xsl:param name="target" select="."/>
1484 <xsl:variable name="subst">%t</xsl:variable>
1487 <xsl:when test="contains($string, $subst)">
1488 <xsl:call-template name="xref.g.subst">
1489 <xsl:with-param name="string"
1490 select="substring-before($string, $subst)"/>
1491 <xsl:with-param name="target" select="$target"/>
1492 </xsl:call-template>
1493 <xsl:call-template name="title.xref">
1494 <xsl:with-param name="target" select="$target"/>
1495 </xsl:call-template>
1496 <xsl:call-template name="xref.t.subst">
1497 <xsl:with-param name="string"
1498 select="substring-after($string, $subst)"/>
1499 <xsl:with-param name="target" select="$target"/>
1500 </xsl:call-template>
1503 <xsl:call-template name="xref.g.subst">
1504 <xsl:with-param name="string" select="$string"/>
1505 <xsl:with-param name="target" select="$target"/>
1506 </xsl:call-template>
1511 <xsl:template name="xref.n.subst">
1512 <xsl:param name="string"></xsl:param>
1513 <xsl:param name="target" select="."/>
1514 <xsl:variable name="subst">%n</xsl:variable>
1517 <xsl:when test="contains($string, $subst)">
1518 <xsl:call-template name="xref.t.subst">
1519 <xsl:with-param name="string"
1520 select="substring-before($string, $subst)"/>
1521 <xsl:with-param name="target" select="$target"/>
1522 </xsl:call-template>
1523 <xsl:call-template name="number.xref">
1524 <xsl:with-param name="target" select="$target"/>
1525 </xsl:call-template>
1526 <xsl:call-template name="xref.t.subst">
1527 <xsl:with-param name="string"
1528 select="substring-after($string, $subst)"/>
1529 <xsl:with-param name="target" select="$target"/>
1530 </xsl:call-template>
1533 <xsl:call-template name="xref.t.subst">
1534 <xsl:with-param name="string" select="$string"/>
1535 <xsl:with-param name="target" select="$target"/>
1536 </xsl:call-template>
1541 <xsl:template name="subst.xref.text">
1542 <xsl:param name="xref.text"></xsl:param>
1543 <xsl:param name="target" select="."/>
1545 <xsl:call-template name="xref.n.subst">
1546 <xsl:with-param name="string" select="$xref.text"/>
1547 <xsl:with-param name="target" select="$target"/>
1548 </xsl:call-template>
1551 <!-- ====================================================================== -->
1553 <xsl:template name="filename-basename">
1554 <!-- We assume all filenames are really URIs and use "/" -->
1555 <xsl:param name="filename"></xsl:param>
1556 <xsl:param name="recurse" select="false()"/>
1559 <xsl:when test="substring-after($filename, '/') != ''">
1560 <xsl:call-template name="filename-basename">
1561 <xsl:with-param name="filename"
1562 select="substring-after($filename, '/')"/>
1563 <xsl:with-param name="recurse" select="true()"/>
1564 </xsl:call-template>
1567 <xsl:value-of select="$filename"/>
1572 <xsl:template name="filename-extension">
1573 <xsl:param name="filename"></xsl:param>
1574 <xsl:param name="recurse" select="false()"/>
1576 <!-- Make sure we only look at the base name... -->
1577 <xsl:variable name="basefn">
1579 <xsl:when test="$recurse">
1580 <xsl:value-of select="$filename"/>
1583 <xsl:call-template name="filename-basename">
1584 <xsl:with-param name="filename" select="$filename"/>
1585 </xsl:call-template>
1591 <xsl:when test="substring-after($basefn, '.') != ''">
1592 <xsl:call-template name="filename-extension">
1593 <xsl:with-param name="filename"
1594 select="substring-after($basefn, '.')"/>
1595 <xsl:with-param name="recurse" select="true()"/>
1596 </xsl:call-template>
1598 <xsl:when test="$recurse">
1599 <xsl:value-of select="$basefn"/>
1601 <xsl:otherwise></xsl:otherwise>
1605 <!-- ====================================================================== -->
1607 <doc:template name="select.mediaobject" xmlns="">
1608 <refpurpose>Selects an appropriate media object from a list</refpurpose>
1611 <para>This template examines a list of media objects (usually the
1612 children of a mediaobject or inlinemediaobject) and processes
1613 the "right" object.</para>
1615 <para>This template relies on a template named "is.acceptable.mediaobject"
1616 to determine if a given object is an acceptable graphic. The semantics
1617 of media objects is that the first acceptable graphic should be used.
1620 <para>If no acceptable object is located, nothing happens.</para>
1625 <varlistentry><term>olist</term>
1627 <para>The node list of potential objects to examine.</para>
1634 <para>Calls <xsl:apply-templates> on the selected object.</para>
1638 <xsl:template name="select.mediaobject">
1639 <xsl:param name="olist"
1640 select="imageobject|imageobjectco
1641 |videoobject|audioobject|textobject"/>
1642 <xsl:param name="count">1</xsl:param>
1644 <xsl:if test="$count <= count($olist)">
1645 <xsl:variable name="object" select="$olist[position()=$count]"/>
1647 <xsl:variable name="useobject">
1649 <!-- The phrase is never used -->
1650 <xsl:when test="name($object)='textobject' and $object/phrase">
1651 <xsl:text>0</xsl:text>
1653 <!-- The first textobject is a reasonable fallback -->
1654 <xsl:when test="name($object)='textobject'">
1655 <xsl:text>1</xsl:text>
1657 <!-- If there's only one object, use it -->
1658 <xsl:when test="$count = 1 and count($olist) = 1">
1659 <xsl:text>1</xsl:text>
1661 <!-- Otherwise, see if this one is a useable graphic -->
1664 <!-- peek inside imageobjectco to simplify the test -->
1665 <xsl:when test="local-name($object) = 'imageobjectco'">
1666 <xsl:call-template name="is.acceptable.mediaobject">
1667 <xsl:with-param name="object" select="$object/imageobject"/>
1668 </xsl:call-template>
1671 <xsl:call-template name="is.acceptable.mediaobject">
1672 <xsl:with-param name="object" select="$object"/>
1673 </xsl:call-template>
1681 <xsl:when test="$useobject='1'">
1682 <xsl:apply-templates select="$object"/>
1685 <xsl:call-template name="select.mediaobject">
1686 <xsl:with-param name="olist" select="$olist"/>
1687 <xsl:with-param name="count" select="$count + 1"/>
1688 </xsl:call-template>
1694 <doc:template name="is.acceptable.mediaobject" xmlns="">
1695 <refpurpose>Returns '1' if the specified media object is recognized.</refpurpose>
1698 <para>This template examines a media object and returns '1' if the
1699 object is recognized as a graphic.</para>
1704 <varlistentry><term>object</term>
1706 <para>The media object to consider.</para>
1717 <xsl:template name="is.acceptable.mediaobject">
1718 <xsl:param name="object"></xsl:param>
1720 <xsl:variable name="filename">
1721 <xsl:call-template name="mediaobject.filename">
1722 <xsl:with-param name="object" select="$object"/>
1723 </xsl:call-template>
1726 <xsl:variable name="ext">
1727 <xsl:call-template name="filename-extension">
1728 <xsl:with-param name="filename" select="$filename"/>
1729 </xsl:call-template>
1732 <!-- there will only be one -->
1733 <xsl:variable name="data" select="$object/videodata
1735 |$object/audiodata"/>
1737 <xsl:variable name="format" select="$data/@format"/>
1739 <xsl:variable name="graphic.format">
1740 <xsl:if test="$format">
1741 <xsl:call-template name="is.graphic.format">
1742 <xsl:with-param name="format" select="$format"/>
1743 </xsl:call-template>
1747 <xsl:variable name="graphic.ext">
1748 <xsl:if test="$ext">
1749 <xsl:call-template name="is.graphic.extension">
1750 <xsl:with-param name="ext" select="$ext"/>
1751 </xsl:call-template>
1756 <xsl:when test="$graphic.format = '1'">1</xsl:when>
1757 <xsl:when test="$graphic.ext = '1'">1</xsl:when>
1758 <xsl:otherwise>0</xsl:otherwise>
1762 <xsl:template name="is.graphic.format">
1763 <xsl:param name="format"></xsl:param>
1764 <xsl:if test="$format = 'PNG'
1767 or $format = 'linespecific'
1769 or $format = 'GIF87a'
1770 or $format = 'GIF89a'
1771 or $format = 'BMP'">1</xsl:if>
1774 <xsl:template name="is.graphic.extension">
1775 <xsl:param name="ext"></xsl:param>
1776 <xsl:if test="$ext = 'png'
1784 or $ext = 'bmp'">1</xsl:if>
1787 <xsl:template name="mediaobject.filename">
1788 <xsl:param name="object"></xsl:param>
1790 <xsl:variable name="data" select="$object/videodata
1792 |$object/audiodata"/>
1794 <xsl:variable name="filename">
1796 <xsl:when test="$data[@fileref]">
1797 <xsl:value-of select="$data/@fileref"/>
1799 <xsl:when test="$data[@entityref]">
1800 <xsl:value-of select="unparsed-entity-uri($data/@entityref)"/>
1802 <xsl:otherwise></xsl:otherwise>
1806 <xsl:variable name="has.ext" select="contains($filename, '.') != ''"/>
1808 <xsl:variable name="ext">
1810 <xsl:when test="contains($filename, '.')">
1811 <xsl:call-template name="filename-extension">
1812 <xsl:with-param name="filename" select="$filename"/>
1813 </xsl:call-template>
1816 <xsl:value-of select="$graphic.default.extension"/>
1821 <xsl:variable name="graphic.ext">
1822 <xsl:call-template name="is.graphic.extension">
1823 <xsl:with-param name="ext" select="$ext"/>
1824 </xsl:call-template>
1828 <xsl:when test="not($has.ext)">
1830 <xsl:when test="$ext != ''">
1831 <xsl:value-of select="$filename"/>
1832 <xsl:text>.</xsl:text>
1833 <xsl:value-of select="$ext"/>
1836 <xsl:value-of select="$filename"/>
1840 <xsl:when test="not($graphic.ext)">
1842 <xsl:when test="$graphic.default.extension != ''">
1843 <xsl:value-of select="$filename"/>
1844 <xsl:text>.</xsl:text>
1845 <xsl:value-of select="$graphic.default.extension"/>
1848 <xsl:value-of select="$filename"/>
1853 <xsl:value-of select="$filename"/>
1858 <!-- ====================================================================== -->
1860 <doc:template name="check.id.unique" xmlns="">
1861 <refpurpose>Warn users about references to non-unique IDs</refpurpose>
1863 <para>If passed an ID in <varname>linkend</varname>,
1864 <function>check.id.unique</function> prints
1865 a warning message to the user if either the ID does not exist or
1866 the ID is not unique.</para>
1870 <xsl:template name="check.id.unique">
1871 <xsl:param name="linkend"></xsl:param>
1872 <xsl:if test="$linkend != ''">
1873 <xsl:variable name="targets" select="id($linkend)"/>
1874 <xsl:variable name="target" select="$targets[1]"/>
1876 <xsl:if test="count($targets)=0">
1878 <xsl:text>Error: no ID for constraint linkend: </xsl:text>
1879 <xsl:value-of select="$linkend"/>
1880 <xsl:text>.</xsl:text>
1884 <xsl:if test="count($targets)>1">
1886 <xsl:text>Warning: multiple "IDs" for constraint linkend: </xsl:text>
1887 <xsl:value-of select="$linkend"/>
1888 <xsl:text>.</xsl:text>
1894 <doc:template name="check.idref.targets" xmlns="">
1895 <refpurpose>Warn users about incorrectly typed references</refpurpose>
1897 <para>If passed an ID in <varname>linkend</varname>,
1898 <function>check.idref.targets</function> makes sure that the element
1899 pointed to by the link is one of the elements listed in
1900 <varname>element-list</varname> and warns the user otherwise.</para>
1904 <xsl:template name="check.idref.targets">
1905 <xsl:param name="linkend"></xsl:param>
1906 <xsl:param name="element-list"></xsl:param>
1907 <xsl:if test="$linkend != ''">
1908 <xsl:variable name="targets" select="id($linkend)"/>
1909 <xsl:variable name="target" select="$targets[1]"/>
1911 <xsl:if test="count($target) > 0">
1912 <xsl:if test="not(contains(concat(' ', $element-list, ' '), name($target)))">
1914 <xsl:text>Error: linkend (</xsl:text>
1915 <xsl:value-of select="$linkend"/>
1916 <xsl:text>) points to "</xsl:text>
1917 <xsl:value-of select="name($target)"/>
1918 <xsl:text>" not (one of): </xsl:text>
1919 <xsl:value-of select="$element-list"/>
1926 <!-- ====================================================================== -->