Debian Codegraph @

xslt/docbook/common/db-xref.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
17 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
18 xmlns:db="http://docbook.org/ns/docbook"
19 xmlns:xl="http://www.w3.org/1999/xlink"
20 xmlns:msg="http://projects.gnome.org/yelp/gettext/"
21 xmlns:set="http://exslt.org/sets"
22 exclude-result-prefixes="db xl msg set"
23 version="1.0">
24
25 <!--!!==========================================================================
26 DocBook Links
27 -->
28
29
30 <!--**==========================================================================
31 db.ulink.tooltip
32 Generates the tooltip for an external link
33
34 [xsl:params]
35 $node: The element to generate a tooltip for
36 $url: The URL of the link, usually from the `url` attribute
37 -->
38 <xsl:template name="db.ulink.tooltip">
39 <xsl:param name="node" select="."/>
40 <xsl:param name="url" select="$node/@url | $node/@xl:href"/>
41 <xsl:choose>
42 <xsl:when test="starts-with($url, 'mailto:')">
43 <xsl:call-template name="l10n.gettext">
44 <xsl:with-param name="msgid" select="'email.tooltip'"/>
45 <xsl:with-param name="string">
46 <xsl:call-template name="utils.email_address">
47 <xsl:with-param name="url" select="$url"/>
48 </xsl:call-template>
49 </xsl:with-param>
50 <xsl:with-param name="format" select="true()"/>
51 </xsl:call-template>
52 </xsl:when>
53 <xsl:otherwise>
54 <xsl:value-of select="normalize-space($url)"/>
55 </xsl:otherwise>
56 </xsl:choose>
57 </xsl:template>
58
59
60 <!--**==========================================================================
61 db.xref.content
62 Generates the content of a cross reference
63
64 [xsl:params]
65 $linkend: The id of the linked-to element, usually from the `linkend` attribute
66 $target: The linked-to element
67 $xrefstyle: The cross reference style, usually from the `xrefstyle` attribute
68
69 REMARK: The xrefstyle/role stuff needs to be documented
70 -->
71 <xsl:template name="db.xref.content">
72 <xsl:param name="linkend" select="@linkend"/>
73 <xsl:param name="target" select="key('db.id.key', $linkend)"/>
74 <xsl:param name="xrefstyle" select="@xrefstyle"/>
75 <xsl:choose>
76 <xsl:when test="$xrefstyle = 'role:title'">
77 <xsl:call-template name="db.title">
78 <xsl:with-param name="node" select="$target"/>
79 </xsl:call-template>
80 </xsl:when>
81 <xsl:when test="$xrefstyle = 'role:titleabbrev'">
82 <xsl:call-template name="db.titleabbrev">
83 <xsl:with-param name="node" select="$target"/>
84 </xsl:call-template>
85 </xsl:when>
86 <xsl:when test="$xrefstyle = 'role:subtitle'">
87 <xsl:call-template name="db.subtitle">
88 <xsl:with-param name="node" select="$target"/>
89 </xsl:call-template>
90 </xsl:when>
91 <xsl:when test="$target/@xreflabel">
92 <xsl:value-of select="$target/@xreflabel"/>
93 </xsl:when>
94 <xsl:otherwise>
95 <xsl:call-template name="db.title">
96 <xsl:with-param name="node" select="$target"/>
97 </xsl:call-template>
98 </xsl:otherwise>
99 </xsl:choose>
100 </xsl:template>
101
102
103
104 <!--**==========================================================================
105 db.xref.target
106 Generates the target identifier of a cross reference
107
108 [xsl:params]
109 $linkend: The id of the linked-to element, usually from the `linkend` attribute
110 $target: The linked-to element
111 $is_chunk: Whether $target is known to be a chunked element
112
113 REMARK: Talk about how this works with chunking
114 -->
115 <xsl:template name="db.xref.target">
116 <xsl:param name="linkend" select="@linkend"/>
117 <xsl:param name="target" select="key('db.id.key', $linkend)"/>
118 <xsl:param name="is_chunk" select="false()"/>
119 <xsl:choose>
120 <xsl:when test="set:has-same-node($target, /*)">
121 <xsl:value-of select="concat($db.chunk.basename, $db.chunk.extension)"/>
122 </xsl:when>
123 <xsl:when test="$is_chunk">
124 <xsl:value-of select="concat($linkend, $db.chunk.extension)"/>
125 </xsl:when>
126 <xsl:otherwise>
127 <xsl:variable name="target_chunk_id">
128 <xsl:call-template name="db.chunk.chunk-id">
129 <xsl:with-param name="node" select="$target"/>
130 </xsl:call-template>
131 </xsl:variable>
132 <xsl:value-of select="concat($target_chunk_id, $db.chunk.extension)"/>
133 <xsl:if test="string($linkend) != '' and string($target_chunk_id) != string($linkend)">
134 <xsl:value-of select="concat('#', $linkend)"/>
135 </xsl:if>
136 </xsl:otherwise>
137 </xsl:choose>
138 </xsl:template>
139
140
141 <!--**==========================================================================
142 db.xref.tooltip
143 Generates the tooltip for a cross reference
144
145 [xsl:params]
146 $linkend: The id of the linked-to element, usually from the `linkend` attribute
147 $target: The linked-to element
148
149 REMARK: Document this
150 -->
151 <xsl:template name="db.xref.tooltip">
152 <xsl:param name="linkend" select="@linkend"/>
153 <xsl:param name="target" select="key('db.id.key', $linkend)"/>
154 <xsl:apply-templates mode="db.xref.tooltip.mode" select="$target"/>
155 </xsl:template>
156
157
158 <!--%%==========================================================================
159 db.xref.tooltip.mode
160 FIXME
161
162 REMARK: Document this
163 -->
164 <xsl:template mode="db.xref.tooltip.mode" match="*">
165 <xsl:call-template name="db.title">
166 <xsl:with-param name="node" select="."/>
167 </xsl:call-template>
168 </xsl:template>
169
170 <!-- = db.xref.tooltip.mode % biblioentry | bibliomixed = -->
171 <xsl:template mode="db.xref.tooltip.mode" match="biblioentry | bibliomixed |
172 db:biblioentry | db:bibliomixed ">
173 <xsl:call-template name="l10n.gettext">
174 <xsl:with-param name="msgid" select="'biblioentry.tooltip'"/>
175 <xsl:with-param name="node" select="."/>
176 <xsl:with-param name="format" select="true()"/>
177 </xsl:call-template>
178 </xsl:template>
179
180 <!-- = db.xref.tooltip.mode % glossentry = -->
181 <xsl:template mode="db.xref.tooltip.mode" match="glossentry | db:glossentry">
182 <xsl:call-template name="l10n.gettext">
183 <xsl:with-param name="msgid" select="'glossentry.tooltip'"/>
184 <xsl:with-param name="node" select="."/>
185 <xsl:with-param name="format" select="true()"/>
186 </xsl:call-template>
187 </xsl:template>
188
189 <!--#% l10n.format.mode -->
190 <xsl:template mode="l10n.format.mode" match="msg:glossterm">
191 <xsl:param name="node"/>
192 <xsl:apply-templates select="$node/glossterm/node() | $node/db:glossterm/node()"/>
193 </xsl:template>
194
195 </xsl:stylesheet>