Debian Codegraph @

xslt/docbook/common/db-title.xsl

raw
1 <?xml version='1.0' encoding='UTF-8'?><!-- -*- indent-tabs-mode: nil -*- -->
2 <!--
3 This program is free software; you can redistribute it and/or modify it under
4 the terms of the GNU Lesser General Public License as published by the Free
5 Software Foundation; either version 2 of the License, or (at your option) any
6 later version.
7
8 This program is distributed in the hope that it will be useful, but WITHOUT
9 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
11 details.
12
13 You should have received a copy of the GNU Lesser General Public License
14 along with this program; see the file COPYING.LGPL. If not, see <http://www.gnu.org/licenses/>.
15 -->
16 <!DOCTYPE xsl:stylesheet [
17 <!ENTITY % selectors SYSTEM "db-selectors.mod">
18 %selectors;
19 ]>
20
21 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
22 xmlns:db="http://docbook.org/ns/docbook"
23 xmlns:msg="http://projects.gnome.org/yelp/gettext/"
24 exclude-result-prefixes="db msg"
25 version="1.0">
26
27 <!--!!==========================================================================
28 DocBook Titles
29 Support for DocBook title, titleabbrev, and subtitle elements.
30 @revision[version=3.4 date=2011-11-10 status=final]
31
32 This stylesheet contains templates for outputting titles based on title,
33 titleabbrev, or subtitle elements. It supports automatic titles for certain
34 elements with optional titles.
35 -->
36
37
38 <!--**==========================================================================
39 db.title
40 Output a title for an element.
41 @revision[version=3.28 date=2017-03-18 status=final]
42
43 [xsl:params]
44 $node: The element to output the title of.
45 $info: The info child element of $node.
46
47 This template outputs the title of the element $node as it might be used for
48 a heading or for link text. For certain types of elements, this templates will
49 use a localized automatic title if no explicit title is provided.
50
51 When $node is an element for which this template cannot construct a title,
52 it calls itself recursively passing the parent element of $node.
53 -->
54 <xsl:template name="db.title">
55 <xsl:param name="node" select="."/>
56 <xsl:param name="info" select="$node/&db_infos;"/>
57 <xsl:choose>
58 <xsl:when test="$node/self::anchor or $node/self::db:anchor">
59 <xsl:variable name="target_chunk_id">
60 <xsl:call-template name="db.chunk.chunk-id">
61 <xsl:with-param name="node" select="."/>
62 </xsl:call-template>
63 </xsl:variable>
64 <xsl:variable name="target_chunk" select="key('db.id.key', $target_chunk_id)"/>
65 <xsl:call-template name="db.title">
66 <xsl:with-param name="node" select="$target_chunk"/>
67 </xsl:call-template>
68 </xsl:when>
69 <xsl:when test="$node/self::refentry/refmeta/refentrytitle or
70 $node/self::db:refentry/db:refmeta/db:refentrytitle">
71 <xsl:apply-templates select="($node/refmeta/refentrytitle | $node/db:refmeta/db:refentrytitle)[1]/node()"/>
72 <xsl:if test="$node/refmeta/manvolnum | $node/db:refmeta/db:manvolnum">
73 <xsl:text>(</xsl:text>
74 <xsl:apply-templates select="($node/refmeta/manvolnum | $node/db:refmeta/db:manvolnum)[1]/node()"/>
75 <xsl:text>)</xsl:text>
76 </xsl:if>
77 </xsl:when>
78 <xsl:when test="$node/title or $node/db:title">
79 <xsl:apply-templates select="$node/title/node() | $node/db:title/node()"/>
80 </xsl:when>
81 <xsl:when test="$info/title or $info/db:title">
82 <xsl:apply-templates select="$info/title/node() | $info/db:title/node()"/>
83 </xsl:when>
84 <xsl:when test="$node/self::bibliography or $node/self::db:bibliography">
85 <xsl:call-template name="l10n.gettext">
86 <xsl:with-param name="msgid" select="'Bibliography'"/>
87 </xsl:call-template>
88 </xsl:when>
89 <xsl:when test="$node/self::colophon or $node/self::db:colophon">
90 <xsl:call-template name="l10n.gettext">
91 <xsl:with-param name="msgid" select="'Colophon'"/>
92 </xsl:call-template>
93 </xsl:when>
94 <xsl:when test="$node/self::dedication or $node/self::db:dedication">
95 <xsl:call-template name="l10n.gettext">
96 <xsl:with-param name="msgid" select="'Dedication'"/>
97 </xsl:call-template>
98 </xsl:when>
99 <xsl:when test="$node/self::glossary or $node/self::db:glossary">
100 <xsl:call-template name="l10n.gettext">
101 <xsl:with-param name="msgid" select="'Glossary'"/>
102 </xsl:call-template>
103 </xsl:when>
104 <xsl:when test="$node/self::glossentry or $node/self::db:glossentry">
105 <xsl:apply-templates select="$node/glossterm/node() | $node/db:glossterm/node()"/>
106 </xsl:when>
107 <xsl:when test="$node/self::index or $node/self::db:index or
108 $node/self::setindex or $node/self::db:setindex">
109 <xsl:call-template name="l10n.gettext">
110 <xsl:with-param name="msgid" select="'Index'"/>
111 </xsl:call-template>
112 </xsl:when>
113 <xsl:when test="$node/self::qandaentry or $node/self::db:qandaentry">
114 <xsl:call-template name="db.title">
115 <xsl:with-param name="node" select="question | db:question"/>
116 </xsl:call-template>
117 </xsl:when>
118 <xsl:when test="$node/self::question or $node/self::db:question">
119 <xsl:apply-templates select="($node//para | $node//db:para)[1]/node()"/>
120 </xsl:when>
121 <xsl:when test="$node/self::refentry or $node/self::db:refentry">
122 <xsl:apply-templates select="($node/refnamediv/refname | $node/db:refnamediv/db:refname)[1]/node()"/>
123 </xsl:when>
124 <xsl:when test="$node/self::refsynopsisdiv or $node/self::db:refsynopsisdiv">
125 <xsl:call-template name="l10n.gettext">
126 <xsl:with-param name="msgid" select="'Synopsis'"/>
127 </xsl:call-template>
128 </xsl:when>
129 <xsl:when test="$node/..">
130 <xsl:call-template name="db.title">
131 <xsl:with-param name="node" select="$node/.."/>
132 </xsl:call-template>
133 </xsl:when>
134 </xsl:choose>
135 </xsl:template>
136
137
138 <!--**==========================================================================
139 db.titleabbrev
140 Output an abbreviated title for an element.
141 @revision[version=3.4 date=2011-11-10 status=final]
142
143 [xsl:params]
144 $node: The element to output the abbreviated title of.
145 $info: The info child element of $node.
146
147 This template outputs the abbreviated title of the element $node, which is
148 sometimes used for link text. If no explicit `titleabbrev` element is found,
149 this template just calls {db.title}.
150 -->
151 <xsl:template name="db.titleabbrev">
152 <xsl:param name="node" select="."/>
153 <xsl:param name="info" select="$node/&db_infos;"/>
154 <xsl:variable name="titleabbrev" select="
155 $node/titleabbrev | $node/db:titleabbrev | $info/titleabbrev | $info/db:titleabbrev"/>
156 <xsl:choose>
157 <xsl:when test="$titleabbrev">
158 <xsl:apply-templates select="$titleabbrev[1]/node()"/>
159 </xsl:when>
160 <xsl:otherwise>
161 <xsl:call-template name="db.title">
162 <xsl:with-param name="node" select="$node"/>
163 <xsl:with-param name="info" select="$info"/>
164 </xsl:call-template>
165 </xsl:otherwise>
166 </xsl:choose>
167 </xsl:template>
168
169
170 <!--**==========================================================================
171 db.subtitle
172 Output a subtitle for an element.
173 @revision[version=3.4 date=2011-11-10 status=final]
174
175 [xsl:params]
176 $node: The element to output the subtitle of.
177 $info: The info child element of $node.
178
179 This template outputs the subtitle of the element $node, which is sometimes
180 used for link text. If no explicit `titleabbrev` element is found, this template
181 just calls {db.title}. This template is not suitable for determining whehter a
182 subtitle should be placed in a heading, as it will always return the title if
183 a subtitle is not found.
184 -->
185 <xsl:template name="db.subtitle">
186 <xsl:param name="node" select="."/>
187 <xsl:param name="info" select="$node/&db_infos;"/>
188 <xsl:variable name="subtitle" select="
189 $node/subtitle | $node/db:subtitle | $info/subtitle | $info/db:subtitle"/>
190 <xsl:choose>
191 <xsl:when test="$subtitle">
192 <xsl:apply-templates select="$subtitle[1]/node()"/>
193 </xsl:when>
194 <xsl:otherwise>
195 <xsl:call-template name="db.title">
196 <xsl:with-param name="node" select="$node"/>
197 <xsl:with-param name="info" select="$info"/>
198 </xsl:call-template>
199 </xsl:otherwise>
200 </xsl:choose>
201 </xsl:template>
202
203 </xsl:stylesheet>