| 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 "../common/db-selectors.mod"> |
| 18 |
%selectors; |
| 19 |
<!ENTITY primarykey "normalize-space(concat( |
| 20 |
primary/@sortas | db:primary/@sortas, ' ', |
| 21 |
primary | db:primary))"> |
| 22 |
<!ENTITY secondarykey "normalize-space(concat( |
| 23 |
primary/@sortas | db:primary/@sortas, ' ', |
| 24 |
primary | db:primary, ' ', |
| 25 |
secondary/@sortas | db:secondary/@sortas, ' ', |
| 26 |
secondary | db:secondary))"> |
| 27 |
<!ENTITY tertiarykey "normalize-space(concat( |
| 28 |
primary/@sortas | db:primary/@sortas, ' ', |
| 29 |
primary | db:primary, ' ', |
| 30 |
secondary/@sortas | db:secondary/@sortas, ' ', |
| 31 |
secondary | db:secondary, ' ', |
| 32 |
tertiary/@sortas | db:tertiary/@sortas, ' ', |
| 33 |
tertiary | db:tertiary))"> |
| 34 |
<!ENTITY uppercase "'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"> |
| 35 |
<!ENTITY lowercase "'abcdefghijklmnopqrstuvwxyz'"> |
| 36 |
]> |
| 37 |
<!-- FIXME: upper/lower for langs? --> |
| 38 |
|
| 39 |
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
| 40 |
xmlns:db="http://docbook.org/ns/docbook" |
| 41 |
xmlns:msg="http://projects.gnome.org/yelp/gettext/" |
| 42 |
xmlns:set="http://exslt.org/sets" |
| 43 |
xmlns="http://www.w3.org/1999/xhtml" |
| 44 |
exclude-result-prefixes="db msg set" |
| 45 |
version="1.0"> |
| 46 |
|
| 47 |
<!--!!========================================================================== |
| 48 |
DocBook to HTML - Indexes |
| 49 |
|
| 50 |
This module provides templates to process DocBook indexes. |
| 51 |
--> |
| 52 |
|
| 53 |
<!-- FIXME: |
| 54 |
indexdiv |
| 55 |
seeie |
| 56 |
seealsoie |
| 57 |
indexterm (autoidx) |
| 58 |
--> |
| 59 |
|
| 60 |
<xsl:key name="db.index.all.key" |
| 61 |
match="indexterm | db:indexterm" |
| 62 |
use="''"/> |
| 63 |
|
| 64 |
<xsl:key name="db.index.primary.key" |
| 65 |
match="indexterm | db:indexterm" |
| 66 |
use="&primarykey;"/> |
| 67 |
|
| 68 |
<xsl:key name="db.index.secondary.key" |
| 69 |
match="indexterm[secondary] | db:indexterm[db:secondary]" |
| 70 |
use="&secondarykey;"/> |
| 71 |
|
| 72 |
<xsl:key name="db.index.tertiary.key" |
| 73 |
match="indexterm[tertiary] | db:indexterm[db:tertiary]" |
| 74 |
use="&tertiarykey;"/> |
| 75 |
|
| 76 |
<!-- == Matched Templates == --> |
| 77 |
|
| 78 |
<!-- = suppress = --> |
| 79 |
<xsl:template match="primaryie | db:primaryie"/> |
| 80 |
<xsl:template match="secondaryie | db:secondaryie"/> |
| 81 |
<xsl:template match="tertiaryie | db:tertiaryie"/> |
| 82 |
|
| 83 |
<!-- = indexentry = --> |
| 84 |
<xsl:template match="indexentry | db:indexentry"> |
| 85 |
<xsl:variable name="if"><xsl:call-template name="db.profile.test"/></xsl:variable> |
| 86 |
<xsl:if test="$if != ''"> |
| 87 |
<dt class="ixprimary"> |
| 88 |
<xsl:apply-templates select="primaryie/node() | db:primaryie/node()"/> |
| 89 |
</dt> |
| 90 |
<xsl:variable name="pri_see" |
| 91 |
select="seeie[not(preceding-sibling::secondaryie)] | |
| 92 |
db:seeie[not(preceding-sibling::db:secondaryie)]"/> |
| 93 |
<xsl:variable name="pri_seealso" |
| 94 |
select="seealsoie[not(preceding-sibling::secondaryie)] | |
| 95 |
db:seealsoie[not(preceding-sibling::db:secondaryie)]"/> |
| 96 |
<xsl:if test="$pri_see"> |
| 97 |
<dd class="ixsee"> |
| 98 |
<xsl:call-template name="l10n.gettext"> |
| 99 |
<xsl:with-param name="msgid" select="'seeie.format'"/> |
| 100 |
<xsl:with-param name="node" select="$pri_see"/> |
| 101 |
<xsl:with-param name="format" select="true()"/> |
| 102 |
</xsl:call-template> |
| 103 |
</dd> |
| 104 |
</xsl:if> |
| 105 |
<xsl:if test="$pri_seealso"> |
| 106 |
<dd class="ixseealso"> |
| 107 |
<xsl:call-template name="l10n.gettext"> |
| 108 |
<xsl:with-param name="msgid" select="'seealsoie.format'"/> |
| 109 |
<xsl:with-param name="node" select="$pri_seealso"/> |
| 110 |
<xsl:with-param name="format" select="true()"/> |
| 111 |
</xsl:call-template> |
| 112 |
</dd> |
| 113 |
</xsl:if> |
| 114 |
<xsl:for-each select="secondaryie | db:secondaryie"> |
| 115 |
<dd class="ixsecondary"> |
| 116 |
<dl class="ixsecondary"> |
| 117 |
<dt class="ixsecondary"> |
| 118 |
<xsl:apply-templates/> |
| 119 |
</dt> |
| 120 |
<xsl:variable name="sec_see" |
| 121 |
select="following-sibling::seeie |
| 122 |
[set:has-same-node(preceding-sibling::secondaryie[1], current())] | |
| 123 |
following-sibling::db:seeie |
| 124 |
[set:has-same-node(preceding-sibling::db:secondaryie[1], current())]"/> |
| 125 |
<xsl:variable name="sec_seealso" |
| 126 |
select="following-sibling::seealsoie |
| 127 |
[set:has-same-node(preceding-sibling::secondaryie[1], current())] | |
| 128 |
following-sibling::db:seealsoie |
| 129 |
[set:has-same-node(preceding-sibling::db:secondaryie[1], current())]"/> |
| 130 |
<xsl:variable name="tertiary" |
| 131 |
select="following-sibling::tertiaryie |
| 132 |
[set:has-same-node(preceding-sibling::secondaryie[1], current())] | |
| 133 |
following-sibling::db:tertiaryie |
| 134 |
[set:has-same-node(preceding-sibling::db:secondaryie[1], current())]"/> |
| 135 |
<xsl:if test="$sec_see"> |
| 136 |
<dd class="ixsee"> |
| 137 |
<xsl:call-template name="l10n.gettext"> |
| 138 |
<xsl:with-param name="msgid" select="'seeie.format'"/> |
| 139 |
<xsl:with-param name="node" select="$sec_see"/> |
| 140 |
<xsl:with-param name="format" select="true()"/> |
| 141 |
</xsl:call-template> |
| 142 |
</dd> |
| 143 |
</xsl:if> |
| 144 |
<xsl:if test="$sec_seealso"> |
| 145 |
<dd class="ixseealso"> |
| 146 |
<xsl:call-template name="l10n.gettext"> |
| 147 |
<xsl:with-param name="msgid" select="'seealsoie.format'"/> |
| 148 |
<xsl:with-param name="node" select="$sec_seealso"/> |
| 149 |
<xsl:with-param name="format" select="true()"/> |
| 150 |
</xsl:call-template> |
| 151 |
</dd> |
| 152 |
</xsl:if> |
| 153 |
<xsl:if test="$tertiary"> |
| 154 |
<!-- FIXME --> |
| 155 |
</xsl:if> |
| 156 |
</dl> |
| 157 |
</dd> |
| 158 |
</xsl:for-each> |
| 159 |
</xsl:if> |
| 160 |
</xsl:template> |
| 161 |
|
| 162 |
<!-- = index = --> |
| 163 |
<xsl:template match="index | db:index"> |
| 164 |
<xsl:param name="depth_in_chunk"> |
| 165 |
<xsl:call-template name="db.chunk.depth-in-chunk"/> |
| 166 |
</xsl:param> |
| 167 |
<xsl:param name="depth_of_chunk"> |
| 168 |
<xsl:call-template name="db.chunk.depth-of-chunk"/> |
| 169 |
</xsl:param> |
| 170 |
<xsl:call-template name="db2html.division.div"> |
| 171 |
<xsl:with-param name="info" select="indexinfo | db:info"/> |
| 172 |
<xsl:with-param name="divisions" select="indexdiv | db:indexdiv"/> |
| 173 |
<xsl:with-param name="entries" select="indexentry | db:indexentry"/> |
| 174 |
<xsl:with-param name="depth_in_chunk" select="$depth_in_chunk"/> |
| 175 |
<xsl:with-param name="depth_of_chunk" select="$depth_of_chunk"/> |
| 176 |
</xsl:call-template> |
| 177 |
</xsl:template> |
| 178 |
|
| 179 |
<!-- = indexdiv = --> |
| 180 |
<xsl:template match="indexdiv | db:indexdiv"> |
| 181 |
<xsl:param name="depth_in_chunk"> |
| 182 |
<xsl:call-template name="db.chunk.depth-in-chunk"/> |
| 183 |
</xsl:param> |
| 184 |
<xsl:param name="depth_of_chunk"> |
| 185 |
<xsl:call-template name="db.chunk.depth-of-chunk"/> |
| 186 |
</xsl:param> |
| 187 |
<xsl:call-template name="db2html.division.div"> |
| 188 |
<xsl:with-param name="entries" select="indexentry | db:indexentry"/> |
| 189 |
<xsl:with-param name="depth_in_chunk" select="$depth_in_chunk"/> |
| 190 |
<xsl:with-param name="depth_of_chunk" select="$depth_of_chunk"/> |
| 191 |
</xsl:call-template> |
| 192 |
</xsl:template> |
| 193 |
|
| 194 |
<!-- = setindex = --> |
| 195 |
<xsl:template match="setindex | db:setindex"> |
| 196 |
<xsl:param name="depth_in_chunk"> |
| 197 |
<xsl:call-template name="db.chunk.depth-in-chunk"/> |
| 198 |
</xsl:param> |
| 199 |
<xsl:param name="depth_of_chunk"> |
| 200 |
<xsl:call-template name="db.chunk.depth-of-chunk"/> |
| 201 |
</xsl:param> |
| 202 |
<xsl:call-template name="db2html.division.div"> |
| 203 |
<xsl:with-param name="info" select="setindexinfo | db:info"/> |
| 204 |
<xsl:with-param name="divisions" select="indexdiv | db:indexdiv"/> |
| 205 |
<xsl:with-param name="entries" select="indexentry | db:indexentry"/> |
| 206 |
<xsl:with-param name="depth_in_chunk" select="$depth_in_chunk"/> |
| 207 |
<xsl:with-param name="depth_of_chunk" select="$depth_of_chunk"/> |
| 208 |
</xsl:call-template> |
| 209 |
</xsl:template> |
| 210 |
|
| 211 |
<!--#% l10n.format.mode --> |
| 212 |
<xsl:template mode="l10n.format.mode" match="msg:seeie"> |
| 213 |
<xsl:param name="node"/> |
| 214 |
<xsl:for-each select="$node"> |
| 215 |
<xsl:if test="position() != 1"> |
| 216 |
<xsl:call-template name="l10n.gettext"> |
| 217 |
<xsl:with-param name="msgid" select="', '"/> |
| 218 |
</xsl:call-template> |
| 219 |
</xsl:if> |
| 220 |
<xsl:apply-templates/> |
| 221 |
<!-- |
| 222 |
<xsl:choose> |
| 223 |
<xsl:when test="@otherterm"> |
| 224 |
<a> |
| 225 |
<xsl:attribute name="href"> |
| 226 |
<xsl:call-template name="db.xref.target"> |
| 227 |
<xsl:with-param name="linkend" select="@otherterm"/> |
| 228 |
</xsl:call-template> |
| 229 |
</xsl:attribute> |
| 230 |
<xsl:attribute name="title"> |
| 231 |
<xsl:call-template name="db.xref.tooltip"> |
| 232 |
<xsl:with-param name="linkend" select="@otherterm"/> |
| 233 |
</xsl:call-template> |
| 234 |
</xsl:attribute> |
| 235 |
<xsl:choose> |
| 236 |
<xsl:when test="normalize-space(.) != ''"> |
| 237 |
<xsl:apply-templates/> |
| 238 |
</xsl:when> |
| 239 |
<xsl:otherwise> |
| 240 |
<xsl:call-template name="db.xref.content"> |
| 241 |
<xsl:with-param name="linkend" select="@otherterm"/> |
| 242 |
<xsl:with-param name="role" select="'glosssee'"/> |
| 243 |
</xsl:call-template> |
| 244 |
</xsl:otherwise> |
| 245 |
</xsl:choose> |
| 246 |
</a> |
| 247 |
</xsl:when> |
| 248 |
<xsl:otherwise> |
| 249 |
<xsl:apply-templates/> |
| 250 |
</xsl:otherwise> |
| 251 |
</xsl:choose> |
| 252 |
--> |
| 253 |
</xsl:for-each> |
| 254 |
</xsl:template> |
| 255 |
|
| 256 |
<!-- = index % db2html.division.div.content.mode = --> |
| 257 |
<!-- Auto-generated indexes --> |
| 258 |
<xsl:template mode="db2html.division.div.content.mode" |
| 259 |
match="index[count(indexentry | indexdiv) = 0] | |
| 260 |
db:index[count(db:indexentry | db:indexdiv) = 0]"> |
| 261 |
<xsl:param name="node" select="."/> |
| 262 |
<xsl:param name="info" select="indexinfo | db:info"/> |
| 263 |
<xsl:param name="depth_in_chunk"> |
| 264 |
<xsl:call-template name="db.chunk.depth-in-chunk"> |
| 265 |
<xsl:with-param name="node" select="$node"/> |
| 266 |
</xsl:call-template> |
| 267 |
</xsl:param> |
| 268 |
<xsl:param name="depth_of_chunk"> |
| 269 |
<xsl:call-template name="db.chunk.depth-of-chunk"> |
| 270 |
<xsl:with-param name="node" select="$node"/> |
| 271 |
</xsl:call-template> |
| 272 |
</xsl:param> |
| 273 |
<xsl:variable name="nots" select="title | db:title | titleabbrev | db:titleabbrev | subtitle | db:subtitle"/> |
| 274 |
<xsl:apply-templates select="set:difference(*, $nots)"> |
| 275 |
<xsl:with-param name="depth_in_chunk" select="$depth_in_chunk + 1"/> |
| 276 |
<xsl:with-param name="depth_of_chunk" select="$depth_of_chunk"/> |
| 277 |
</xsl:apply-templates> |
| 278 |
|
| 279 |
<xsl:variable name="allterms" select="key('db.index.all.key', '')"/> |
| 280 |
<xsl:variable name="prifirstterms" |
| 281 |
select="$allterms[count(. | key('db.index.primary.key', &primarykey;)[1]) = 1]"/> |
| 282 |
<dl> |
| 283 |
<xsl:for-each select="$prifirstterms"> |
| 284 |
<xsl:sort select="translate(&primarykey;, &uppercase;, &lowercase;)"/> |
| 285 |
<xsl:variable name="term" select="."/> |
| 286 |
<xsl:if test="true()"> |
| 287 |
<dt class="ixprimary"> |
| 288 |
<xsl:apply-templates select="primary/node() | db:primary/node()"/> |
| 289 |
</dt> |
| 290 |
<xsl:variable name="prikey" select="&primarykey;"/> |
| 291 |
<xsl:variable name="priterms" select="key('db.index.primary.key', $prikey)"/> |
| 292 |
<xsl:variable name="prilinks" |
| 293 |
select="$priterms[not(secondary | db:secondary | see | db:see)]"/> |
| 294 |
<xsl:for-each select="$prilinks"> |
| 295 |
<dd class="ixlink"> |
| 296 |
<xsl:call-template name="db2html.xref"> |
| 297 |
<xsl:with-param name="target" select="."/> |
| 298 |
</xsl:call-template> |
| 299 |
</dd> |
| 300 |
</xsl:for-each> |
| 301 |
<xsl:variable name="prisee" |
| 302 |
select="$priterms[not(secondary)]/see | $priterms[not(db:secondary)]/db:see"/> |
| 303 |
<xsl:for-each select="$prisee"> |
| 304 |
<dd class="ixsee"> |
| 305 |
<xsl:call-template name="l10n.gettext"> |
| 306 |
<xsl:with-param name="msgid" select="'seeie.format'"/> |
| 307 |
<xsl:with-param name="node" select="."/> |
| 308 |
<xsl:with-param name="format" select="true()"/> |
| 309 |
</xsl:call-template> |
| 310 |
</dd> |
| 311 |
</xsl:for-each> |
| 312 |
<xsl:variable name="priseealso" |
| 313 |
select="$priterms[not(secondary)]/seealso | $priterms[not(db:secondary)]/db:seealso"/> |
| 314 |
<xsl:for-each select="$priseealso"> |
| 315 |
<dd class="ixseealso"> |
| 316 |
<xsl:call-template name="l10n.gettext"> |
| 317 |
<xsl:with-param name="msgid" select="'seealsoie.format'"/> |
| 318 |
<xsl:with-param name="node" select="."/> |
| 319 |
<xsl:with-param name="format" select="true()"/> |
| 320 |
</xsl:call-template> |
| 321 |
</dd> |
| 322 |
</xsl:for-each> |
| 323 |
<xsl:if test="$priterms/secondary or $priterms/db:secondary"> |
| 324 |
<dd class="ixsecondary"> |
| 325 |
<dl class="ixsecondary"> |
| 326 |
<xsl:variable name="secfirstterms" |
| 327 |
select="$priterms[count(. | key('db.index.secondary.key', |
| 328 |
&secondarykey;)[1]) = 1]"/> |
| 329 |
<xsl:for-each select="$secfirstterms"> |
| 330 |
<xsl:sort select="translate(&secondarykey;, &uppercase;, &lowercase;)"/> |
| 331 |
<xsl:if test="secondary | db:secondary"> |
| 332 |
<dt class="ixsecondary"> |
| 333 |
<xsl:value-of select="secondary | db:secondary"/> |
| 334 |
</dt> |
| 335 |
<xsl:variable name="seckey" select="&secondarykey;"/> |
| 336 |
<xsl:variable name="secterms" select="key('db.index.secondary.key', $seckey)"/> |
| 337 |
<xsl:variable name="seclinks" |
| 338 |
select="$secterms[not(tertiary | db:tertiary | see | db:see)]"/> |
| 339 |
<xsl:for-each select="$seclinks"> |
| 340 |
<dd class="ixlink"> |
| 341 |
<xsl:call-template name="db2html.xref"> |
| 342 |
<xsl:with-param name="target" select="."/> |
| 343 |
</xsl:call-template> |
| 344 |
</dd> |
| 345 |
</xsl:for-each> |
| 346 |
<xsl:variable name="secsee" |
| 347 |
select="$secterms[not(tertiary)]/see | $secterms[not(db:tertiary)]/db:see"/> |
| 348 |
<xsl:for-each select="$secsee"> |
| 349 |
<dd class="ixsee"> |
| 350 |
<xsl:call-template name="l10n.gettext"> |
| 351 |
<xsl:with-param name="msgid" select="'seeie.format'"/> |
| 352 |
<xsl:with-param name="node" select="."/> |
| 353 |
<xsl:with-param name="format" select="true()"/> |
| 354 |
</xsl:call-template> |
| 355 |
</dd> |
| 356 |
</xsl:for-each> |
| 357 |
<xsl:variable name="secseealso" |
| 358 |
select="$secterms[not(tertiary)]/seealso | $secterms[not(db:tertiary)]/db:seealso"/> |
| 359 |
<xsl:for-each select="$secseealso"> |
| 360 |
<dd class="ixseealso"> |
| 361 |
<xsl:call-template name="l10n.gettext"> |
| 362 |
<xsl:with-param name="msgid" select="'seealsoie.format'"/> |
| 363 |
<xsl:with-param name="node" select="."/> |
| 364 |
<xsl:with-param name="format" select="true()"/> |
| 365 |
</xsl:call-template> |
| 366 |
</dd> |
| 367 |
</xsl:for-each> |
| 368 |
<xsl:if test="$secterms/tertiary or $secterms/db:tertiary"> |
| 369 |
<dd class="ixtertiary"> |
| 370 |
<dl class="ixtertiary"> |
| 371 |
<xsl:variable name="terfirstterms" |
| 372 |
select="$secterms[count(. | key('db.index.tertiary.key', |
| 373 |
&tertiarykey;)[1]) = 1]"/> |
| 374 |
<xsl:for-each select="$terfirstterms"> |
| 375 |
<xsl:sort select="translate(&tertiarykey;, &uppercase;, &lowercase;)"/> |
| 376 |
<xsl:if test="tertiary | db:tertiary"> |
| 377 |
<dt class="ixtertiary"> |
| 378 |
<xsl:value-of select="tertiary | db:tertiary"/> |
| 379 |
</dt> |
| 380 |
<xsl:variable name="terkey" select="&tertiarykey;"/> |
| 381 |
<xsl:variable name="terterms" select="key('db.index.tertiary.key', $terkey)"/> |
| 382 |
<xsl:variable name="terlinks" select="$terterms[not(see | db:see)]"/> |
| 383 |
<xsl:for-each select="$terlinks"> |
| 384 |
<dd class="ixlink"> |
| 385 |
<xsl:call-template name="db2html.xref"> |
| 386 |
<xsl:with-param name="target" select="."/> |
| 387 |
</xsl:call-template> |
| 388 |
</dd> |
| 389 |
</xsl:for-each> |
| 390 |
<xsl:variable name="tersee" |
| 391 |
select="$terterms/see | $terterms/db:see"/> |
| 392 |
<xsl:for-each select="$tersee"> |
| 393 |
<dd class="ixsee"> |
| 394 |
<xsl:call-template name="l10n.gettext"> |
| 395 |
<xsl:with-param name="msgid" select="'seeie.format'"/> |
| 396 |
<xsl:with-param name="node" select="."/> |
| 397 |
<xsl:with-param name="format" select="true()"/> |
| 398 |
</xsl:call-template> |
| 399 |
</dd> |
| 400 |
</xsl:for-each> |
| 401 |
<xsl:variable name="terseealso" |
| 402 |
select="$terterms/seealso | $terterms/db:seealso"/> |
| 403 |
<xsl:for-each select="$terseealso"> |
| 404 |
<dd class="ixseealso"> |
| 405 |
<xsl:call-template name="l10n.gettext"> |
| 406 |
<xsl:with-param name="msgid" select="'seealsoie.format'"/> |
| 407 |
<xsl:with-param name="node" select="."/> |
| 408 |
<xsl:with-param name="format" select="true()"/> |
| 409 |
</xsl:call-template> |
| 410 |
</dd> |
| 411 |
</xsl:for-each> |
| 412 |
</xsl:if> |
| 413 |
</xsl:for-each> |
| 414 |
</dl> |
| 415 |
</dd> |
| 416 |
</xsl:if> |
| 417 |
</xsl:if> |
| 418 |
</xsl:for-each> |
| 419 |
</dl> |
| 420 |
</dd> |
| 421 |
</xsl:if> |
| 422 |
</xsl:if> |
| 423 |
</xsl:for-each> |
| 424 |
</dl> |
| 425 |
</xsl:template> |
| 426 |
|
| 427 |
</xsl:stylesheet> |