[15c7d39] | 1 | <?xml version='1.0'?>
|
---|
| 2 | <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
---|
| 3 | xmlns:exsl="http://exslt.org/common"
|
---|
| 4 | xmlns:ng="http://docbook.org/docbook-ng"
|
---|
| 5 | xmlns:db="http://docbook.org/ns/docbook"
|
---|
| 6 | xmlns:xlink="http://www.w3.org/1999/xlink"
|
---|
| 7 | exclude-result-prefixes="db ng exsl xlink"
|
---|
| 8 | version='1.0'>
|
---|
| 9 |
|
---|
| 10 | <!-- ********************************************************************
|
---|
| 11 | $Id: endnotes.xsl 8703 2010-07-06 20:57:06Z nwalsh $
|
---|
| 12 | ********************************************************************
|
---|
| 13 |
|
---|
| 14 | This file is part of the XSL DocBook Stylesheet distribution.
|
---|
| 15 | See ../README or http://docbook.sf.net/release/xsl/current/ for
|
---|
| 16 | copyright and other information.
|
---|
| 17 |
|
---|
| 18 | ******************************************************************** -->
|
---|
| 19 |
|
---|
| 20 | <!-- ==================================================================== -->
|
---|
| 21 | <!-- * -->
|
---|
| 22 | <!-- * The templates in this file handle elements whose contents can't -->
|
---|
| 23 | <!-- * be displayed completely within the main text flow in output, but -->
|
---|
| 24 | <!-- * instead need to be displayed "out of line". Those elements are: -->
|
---|
| 25 | <!-- * -->
|
---|
| 26 | <!-- * - elements providing annotative text (annotation|alt|footnote) -->
|
---|
| 27 | <!-- * - elements pointing at external resources (ulink, link, and -->
|
---|
| 28 | <!-- * any elements with xlink:href attributes; and imagedata, -->
|
---|
| 29 | <!-- * audiodata, and videodata - which (using their fileref -->
|
---|
| 30 | <!-- * attribute) reference external files -->
|
---|
| 31 | <!-- * -->
|
---|
| 32 | <!-- * Within this stylesheet, the above are collectively referred to as -->
|
---|
| 33 | <!-- * a "notesources". This stylesheet handles those notesources in -->
|
---|
| 34 | <!-- * this way: -->
|
---|
| 35 | <!-- * -->
|
---|
| 36 | <!-- * 1. Constructs a numbered in-memory index of all unique "earmarks“ -->
|
---|
| 37 | <!-- * of all notesources in the document. For each link, the -->
|
---|
| 38 | <!-- * earmark is the value of its url or xlink:href attribute; for -->
|
---|
| 39 | <!-- * each imagedata|audiodata|videodata: the value of its fileref -->
|
---|
| 40 | <!-- * attribute; for each annotative element: its content. -->
|
---|
| 41 | <!-- * -->
|
---|
| 42 | <!-- * Notesources with the same earmark are assigned the same -->
|
---|
| 43 | <!-- * number. -->
|
---|
| 44 | <!-- * -->
|
---|
| 45 | <!-- * By design, that index excludes any element whose string value -->
|
---|
| 46 | <!-- * is identical to the value of its url xlink:href attribute). -->
|
---|
| 47 | <!-- * -->
|
---|
| 48 | <!-- * 2. Puts a numbered marker inline to mark the place where the -->
|
---|
| 49 | <!-- * notesource occurs in the main text flow. -->
|
---|
| 50 | <!-- * -->
|
---|
| 51 | <!-- * 3. Generates a numbered endnotes list (titled NOTES in English) -->
|
---|
| 52 | <!-- * at the end of the man page, with the contents of each -->
|
---|
| 53 | <!-- * notesource. -->
|
---|
| 54 | <!-- * -->
|
---|
| 55 | <!-- * Note that table footnotes are not listed in the endnotes list, -->
|
---|
| 56 | <!-- * and are not handled by this stylesheet (they are instead handled -->
|
---|
| 57 | <!-- * by the table.xsl stylesheet). -->
|
---|
| 58 | <!-- * -->
|
---|
| 59 | <!-- * Also, we don't get notesources in *info sections or Refmeta or -->
|
---|
| 60 | <!-- * Refnamediv or Indexterm, because, in manpages output, contents of -->
|
---|
| 61 | <!-- * those are either suppressed or are displayed out of document -->
|
---|
| 62 | <!-- * order - for example, the Info/Author content gets moved to the -->
|
---|
| 63 | <!-- * end of the page. So, if we were to number notesources in the -->
|
---|
| 64 | <!-- * Author content, it would "throw off" the numbering at the -->
|
---|
| 65 | <!-- * beginning of the main text flow. -->
|
---|
| 66 | <!-- * -->
|
---|
| 67 | <!-- * And for the record, one reason we don't use xsl:key to index the -->
|
---|
| 68 | <!-- * earmarks is that we need to get and check the sets of -->
|
---|
| 69 | <!-- * earmarks for uniqueness per-Refentry (not per-document). -->
|
---|
| 70 | <!-- * -->
|
---|
| 71 | <!-- * FIXME: -->
|
---|
| 72 | <!-- * as with "repeat" URLS, alt instances that have the same string value -->
|
---|
| 73 | <!-- * as preceding ones (likely to occur for repeat acroynyms and -->
|
---|
| 74 | <!-- * abbreviations) should be listed only once in the endnotes list, -->
|
---|
| 75 | <!-- * and numbered accordingly inline; split man.indent.width into -->
|
---|
| 76 | <!-- * man.indent.width.value (default 4) and man.indent.width.units -->
|
---|
| 77 | <!-- * (default n); also, if the first child of notesource is some block -->
|
---|
| 78 | <!-- * content other than a (non-formal) paragraph, the current code -->
|
---|
| 79 | <!-- * will probably end up generating a blank line after the -->
|
---|
| 80 | <!-- * corresponding number in the endnotes list... we should probably -->
|
---|
| 81 | <!-- * try to instead display the title of that block content there (if -->
|
---|
| 82 | <!-- * there is one: e.g., the list title, admonition title, etc.) -->
|
---|
| 83 |
|
---|
| 84 | <!-- ==================================================================== -->
|
---|
| 85 |
|
---|
| 86 | <xsl:template name="get.all.earmark.indexes.in.current.document">
|
---|
| 87 | <!-- * Here we create a tree to hold indexes of all earmarks in -->
|
---|
| 88 | <!-- * the current document. If the current document contains -->
|
---|
| 89 | <!-- * multiple refentry instances, then this tree will contain -->
|
---|
| 90 | <!-- * multiple indexes. -->
|
---|
| 91 | <xsl:if test="$man.endnotes.are.numbered != 0">
|
---|
| 92 | <!-- * Only create earmark indexes if user wants numbered endnotes -->
|
---|
| 93 | <xsl:for-each select="//refentry">
|
---|
| 94 | <earmark.index>
|
---|
| 95 | <xsl:attribute name="idref">
|
---|
| 96 | <xsl:value-of select="generate-id()"/>
|
---|
| 97 | </xsl:attribute>
|
---|
| 98 | <xsl:for-each
|
---|
| 99 | select=".//*[self::*[@xlink:href]
|
---|
| 100 | or self::ulink
|
---|
| 101 | or self::imagedata
|
---|
| 102 | or self::audiodata
|
---|
| 103 | or self::videodata
|
---|
| 104 | or self::footnote[not(ancestor::table)]
|
---|
| 105 | or self::annotation
|
---|
| 106 | or self::alt]
|
---|
| 107 | [(node()
|
---|
| 108 | or self::imagedata
|
---|
| 109 | or self::audiodata
|
---|
| 110 | or self::videodata
|
---|
| 111 | )
|
---|
| 112 | and not(ancestor::refentryinfo)
|
---|
| 113 | and not(ancestor::info)
|
---|
| 114 | and not(ancestor::docinfo)
|
---|
| 115 | and not(ancestor::refmeta)
|
---|
| 116 | and not(ancestor::refnamediv)
|
---|
| 117 | and not(ancestor::indexterm)
|
---|
| 118 | and not(. = @url)
|
---|
| 119 | and not(. = @xlink:href)
|
---|
| 120 | and not(@url =
|
---|
| 121 | preceding::ulink[node()
|
---|
| 122 | and not(ancestor::refentryinfo)
|
---|
| 123 | and not(ancestor::info)
|
---|
| 124 | and not(ancestor::docinfo)
|
---|
| 125 | and not(ancestor::refmeta)
|
---|
| 126 | and not(ancestor::refnamediv)
|
---|
| 127 | and not(ancestor::indexterm)
|
---|
| 128 | and (generate-id(ancestor::refentry)
|
---|
| 129 | = generate-id(current()))]/@url)
|
---|
| 130 | and not(@xlink:href =
|
---|
| 131 | preceding::*[@xlink:href][node()
|
---|
| 132 | and not(ancestor::refentryinfo)
|
---|
| 133 | and not(ancestor::info)
|
---|
| 134 | and not(ancestor::docinfo)
|
---|
| 135 | and not(ancestor::refmeta)
|
---|
| 136 | and not(ancestor::refnamediv)
|
---|
| 137 | and not(ancestor::indexterm)
|
---|
| 138 | and (generate-id(ancestor::refentry)
|
---|
| 139 | = generate-id(current()))]/@xlink:href)
|
---|
| 140 | and not(@fileref =
|
---|
| 141 | preceding::*[@fileref][
|
---|
| 142 | not(ancestor::refentryinfo)
|
---|
| 143 | and not(ancestor::info)
|
---|
| 144 | and not(ancestor::docinfo)
|
---|
| 145 | and not(ancestor::refmeta)
|
---|
| 146 | and not(ancestor::refnamediv)
|
---|
| 147 | and not(ancestor::indexterm)
|
---|
| 148 | and (generate-id(ancestor::refentry)
|
---|
| 149 | = generate-id(current()))]/@fileref)]">
|
---|
| 150 | <earmark>
|
---|
| 151 | <xsl:attribute name="id">
|
---|
| 152 | <xsl:value-of select="generate-id()"/>
|
---|
| 153 | </xsl:attribute>
|
---|
| 154 | <xsl:attribute name="number">
|
---|
| 155 | <xsl:value-of select="position()"/>
|
---|
| 156 | </xsl:attribute>
|
---|
| 157 | <xsl:if test="@url|@xlink:href|@fileref">
|
---|
| 158 | <!-- * Only add a uri attribute if the notesource is -->
|
---|
| 159 | <!-- * a link or an element that references an external -->
|
---|
| 160 | <!-- * (an imagedata, audiodata, or videodata element) -->
|
---|
| 161 | <xsl:attribute name="uri">
|
---|
| 162 | <xsl:value-of select="@url|@xlink:href|@fileref"/>
|
---|
| 163 | </xsl:attribute>
|
---|
| 164 | </xsl:if>
|
---|
| 165 | <xsl:copy>
|
---|
| 166 | <xsl:copy-of select="node()"/>
|
---|
| 167 | </xsl:copy>
|
---|
| 168 | </earmark>
|
---|
| 169 | </xsl:for-each>
|
---|
| 170 | </earmark.index>
|
---|
| 171 | </xsl:for-each>
|
---|
| 172 | </xsl:if>
|
---|
| 173 | </xsl:template>
|
---|
| 174 |
|
---|
| 175 | <!-- ==================================================================== -->
|
---|
| 176 |
|
---|
| 177 | <xsl:template match="*[@xlink:href]|ulink
|
---|
| 178 | |imagedata|audiodata|videodata
|
---|
| 179 | |footnote[not(ancestor::table)]
|
---|
| 180 | |annotation|alt">
|
---|
| 181 | <xsl:variable name="refname" select="ancestor::refentry/refnamediv[1]/refname[1]"/>
|
---|
| 182 | <xsl:variable name="all.earmark.indexes.in.current.document.rtf">
|
---|
| 183 | <xsl:call-template name="get.all.earmark.indexes.in.current.document"/>
|
---|
| 184 | </xsl:variable>
|
---|
| 185 | <xsl:variable name="all.earmark.indexes.in.current.document"
|
---|
| 186 | select="exsl:node-set($all.earmark.indexes.in.current.document.rtf)"/>
|
---|
| 187 | <xsl:variable name="all.earmarks.in.current.refentry.rtf">
|
---|
| 188 | <!-- * get the set of all earmarks for the ancestor Refentry of -->
|
---|
| 189 | <!-- * this notesource -->
|
---|
| 190 | <xsl:copy-of
|
---|
| 191 | select="$all.earmark.indexes.in.current.document/earmark.index
|
---|
| 192 | [@idref =
|
---|
| 193 | generate-id(current()/ancestor::refentry)]/earmark"/>
|
---|
| 194 | </xsl:variable>
|
---|
| 195 | <xsl:variable name="all.earmarks.in.current.refentry"
|
---|
| 196 | select="exsl:node-set($all.earmarks.in.current.refentry.rtf)"/>
|
---|
| 197 |
|
---|
| 198 | <!-- * identify the earmark for the current element -->
|
---|
| 199 | <xsl:variable name="earmark">
|
---|
| 200 | <xsl:choose>
|
---|
| 201 | <xsl:when test="@url|@xlink:href">
|
---|
| 202 | <xsl:value-of select="@url|@xlink:href"/>
|
---|
| 203 | </xsl:when>
|
---|
| 204 | <xsl:when test="@fileref">
|
---|
| 205 | <xsl:value-of select="@fileref"/>
|
---|
| 206 | </xsl:when>
|
---|
| 207 | <xsl:otherwise>
|
---|
| 208 | <xsl:value-of select="generate-id()"/>
|
---|
| 209 | </xsl:otherwise>
|
---|
| 210 | </xsl:choose>
|
---|
| 211 | </xsl:variable>
|
---|
| 212 |
|
---|
| 213 | <xsl:variable name="notesource.number">
|
---|
| 214 | <!-- * Get the number for this notesource -->
|
---|
| 215 | <!-- * -->
|
---|
| 216 | <!-- * If this is an imagedata, audiodata, or videodata element -->
|
---|
| 217 | <!-- * OR if it's a non-empty element AND its string value is not -->
|
---|
| 218 | <!-- * equal to the value of its url or xlink:href attribute (if -->
|
---|
| 219 | <!-- * it has one) AND user wants endnotes numbered, only then -->
|
---|
| 220 | <!-- * do we output a number for it -->
|
---|
| 221 | <xsl:if test="(self::imagedata or
|
---|
| 222 | self::audiodata or
|
---|
| 223 | self::videodata or
|
---|
| 224 | (node()
|
---|
| 225 | and not(. = @url)
|
---|
| 226 | and not(. = @xlink:href))
|
---|
| 227 | )
|
---|
| 228 | and $man.endnotes.are.numbered != 0">
|
---|
| 229 | <!-- * To select the number for this notesource, we -->
|
---|
| 230 | <!-- * check the index of all earmarks for the current refentry -->
|
---|
| 231 | <!-- * and find the number of the indexed earmark which matches -->
|
---|
| 232 | <!-- * this notesource's earmark. -->
|
---|
| 233 | <!-- * Note that multiple notesources may share the same -->
|
---|
| 234 | <!-- * numbered earmark; in that case, they get the same number. -->
|
---|
| 235 | <!-- * -->
|
---|
| 236 | <xsl:choose>
|
---|
| 237 | <xsl:when test="self::ulink or
|
---|
| 238 | self::*[@xlink:href] or
|
---|
| 239 | self::imagedata or
|
---|
| 240 | self::audiodata or
|
---|
| 241 | self::videodata">
|
---|
| 242 | <xsl:value-of select="$all.earmarks.in.current.refentry/earmark[@uri = $earmark]/@number"/>
|
---|
| 243 | </xsl:when>
|
---|
| 244 | <xsl:otherwise>
|
---|
| 245 | <xsl:value-of select="$all.earmarks.in.current.refentry/earmark[@id = $earmark]/@number"/>
|
---|
| 246 | </xsl:otherwise>
|
---|
| 247 | </xsl:choose>
|
---|
| 248 | </xsl:if>
|
---|
| 249 | </xsl:variable>
|
---|
| 250 |
|
---|
| 251 | <xsl:variable name="notesource.contents">
|
---|
| 252 | <xsl:choose>
|
---|
| 253 | <!-- * check to see if the element is empty or not -->
|
---|
| 254 | <xsl:when test="node()">
|
---|
| 255 | <!-- * this is a non-empty node, so process its contents -->
|
---|
| 256 | <xsl:apply-templates/>
|
---|
| 257 | <xsl:if test="../footnote or ../annotation">
|
---|
| 258 | <!-- * if this element is a footnote or annotation, we need to -->
|
---|
| 259 | <!-- * do some further checking on it, so we can emit warnings -->
|
---|
| 260 | <!-- * about potential problems -->
|
---|
| 261 | <xsl:for-each select="node()">
|
---|
| 262 | <xsl:if test="local-name() != 'para' and
|
---|
| 263 | local-name() != 'simpara' and
|
---|
| 264 | local-name() !=''">
|
---|
| 265 | <!-- * for each node we find as a child of a footnote or -->
|
---|
| 266 | <!-- * annotation, if it's not a para or a text node, emit a -->
|
---|
| 267 | <!-- * warning... because in manpages output, we can't render -->
|
---|
| 268 | <!-- * block-level child content of an endnote properly unless -->
|
---|
| 269 | <!-- * it's wrapped in a para that has some "prefatory" text -->
|
---|
| 270 | <xsl:variable name="parent-name" select="local-name(..)"/>
|
---|
| 271 | <xsl:variable name="endnote-number">
|
---|
| 272 | <xsl:call-template name="pad-string">
|
---|
| 273 | <!-- * endnote number may be 2 digits, so pad it with a space -->
|
---|
| 274 | <!-- * if we have only 1 digit -->
|
---|
| 275 | <xsl:with-param name="padVar" select="concat('#',$notesource.number)"/>
|
---|
| 276 | <xsl:with-param name="length" select="3"/>
|
---|
| 277 | </xsl:call-template>
|
---|
| 278 | </xsl:variable>
|
---|
| 279 | <xsl:call-template name="log.message">
|
---|
| 280 | <xsl:with-param name="level">Warn</xsl:with-param>
|
---|
| 281 | <xsl:with-param name="source" select="$refname"/>
|
---|
| 282 | <xsl:with-param name="context-desc">
|
---|
| 283 | <xsl:text>endnote </xsl:text>
|
---|
| 284 | <xsl:value-of select="$endnote-number"/>
|
---|
| 285 | </xsl:with-param>
|
---|
| 286 | <xsl:with-param name="message">
|
---|
| 287 | <xsl:text>Bad: </xsl:text>
|
---|
| 288 | <xsl:value-of select="$parent-name"/>
|
---|
| 289 | <!-- * figure out which occurance of this element type this -->
|
---|
| 290 | <!-- * instance is and output a number in square brackets so -->
|
---|
| 291 | <!-- * that end-user can know which element to fix -->
|
---|
| 292 | <xsl:text>[</xsl:text>
|
---|
| 293 | <xsl:value-of select="count(preceding::*[local-name() = $parent-name]) + 1"/>
|
---|
| 294 | <xsl:text>]</xsl:text>
|
---|
| 295 | <xsl:text> in source</xsl:text>
|
---|
| 296 | </xsl:with-param>
|
---|
| 297 | </xsl:call-template>
|
---|
| 298 | <xsl:call-template name="log.message">
|
---|
| 299 | <xsl:with-param name="level">Note</xsl:with-param>
|
---|
| 300 | <xsl:with-param name="source" select="$refname"/>
|
---|
| 301 | <xsl:with-param name="context-desc">
|
---|
| 302 | <xsl:text>endnote </xsl:text>
|
---|
| 303 | <xsl:value-of select="$endnote-number"/>
|
---|
| 304 | </xsl:with-param>
|
---|
| 305 | <xsl:with-param name="message">
|
---|
| 306 | <xsl:text>Has: </xsl:text>
|
---|
| 307 | <xsl:value-of select="$parent-name"/>
|
---|
| 308 | <xsl:text>/</xsl:text>
|
---|
| 309 | <xsl:value-of select="local-name(.)"/>
|
---|
| 310 | </xsl:with-param>
|
---|
| 311 | </xsl:call-template>
|
---|
| 312 | <xsl:call-template name="log.message">
|
---|
| 313 | <xsl:with-param name="level">Note</xsl:with-param>
|
---|
| 314 | <xsl:with-param name="source" select="$refname"/>
|
---|
| 315 | <xsl:with-param name="context-desc">
|
---|
| 316 | <xsl:text>endnote </xsl:text>
|
---|
| 317 | <xsl:value-of select="$endnote-number"/>
|
---|
| 318 | </xsl:with-param>
|
---|
| 319 | <xsl:with-param name="message">
|
---|
| 320 | <xsl:text>Fix: </xsl:text>
|
---|
| 321 | <xsl:value-of select="$parent-name"/>
|
---|
| 322 | <xsl:text>/</xsl:text>
|
---|
| 323 | <xsl:text>para/</xsl:text>
|
---|
| 324 | <xsl:value-of select="local-name(.)"/>
|
---|
| 325 | </xsl:with-param>
|
---|
| 326 | </xsl:call-template>
|
---|
| 327 | </xsl:if>
|
---|
| 328 | </xsl:for-each>
|
---|
| 329 | </xsl:if>
|
---|
| 330 | </xsl:when>
|
---|
| 331 | <xsl:otherwise>
|
---|
| 332 | <!-- * Otherwise this is an empty link or an empty imagedata, -->
|
---|
| 333 | <!-- * audiodata, or videodata element, so we just get the -->
|
---|
| 334 | <!-- * value of its url, xlink:href, or fileref attribute. -->
|
---|
| 335 | <xsl:if test="$man.hyphenate.urls = 0
|
---|
| 336 | and $man.break.after.slash = 0">
|
---|
| 337 | <!-- * Add hyphenation suppression in URL output only if -->
|
---|
| 338 | <!-- * break.after.slash is also non-zero -->
|
---|
| 339 | <xsl:call-template name="suppress.hyphenation"/>
|
---|
| 340 | <xsl:text>\%</xsl:text>
|
---|
| 341 | </xsl:if>
|
---|
| 342 | <xsl:value-of select="$earmark"/>
|
---|
| 343 | </xsl:otherwise>
|
---|
| 344 | </xsl:choose>
|
---|
| 345 | </xsl:variable>
|
---|
| 346 |
|
---|
| 347 | <xsl:if test="self::ulink or self::*[@xlink:href]">
|
---|
| 348 | <xsl:variable name="link.wrapper">
|
---|
| 349 | <xsl:value-of select="normalize-space($notesource.contents)"/>
|
---|
| 350 | </xsl:variable>
|
---|
| 351 | <xsl:text>\m[blue]</xsl:text>
|
---|
| 352 | <!-- * This is a hyperlink, so we need to determine if the user wants -->
|
---|
| 353 | <!-- * font formatting applied to it, and if so, what font -->
|
---|
| 354 | <xsl:choose>
|
---|
| 355 | <xsl:when test="$man.font.links = 'B'">
|
---|
| 356 | <xsl:call-template name="bold">
|
---|
| 357 | <xsl:with-param name="node" select="exsl:node-set($link.wrapper)"/>
|
---|
| 358 | <xsl:with-param name="context" select="."/>
|
---|
| 359 | </xsl:call-template>
|
---|
| 360 | </xsl:when>
|
---|
| 361 | <xsl:when test="$man.font.links = 'I'">
|
---|
| 362 | <xsl:call-template name="italic">
|
---|
| 363 | <xsl:with-param name="node" select="exsl:node-set($link.wrapper)"/>
|
---|
| 364 | <xsl:with-param name="context" select="."/>
|
---|
| 365 | </xsl:call-template>
|
---|
| 366 | </xsl:when>
|
---|
| 367 | <xsl:when test="$man.font.links = ''">
|
---|
| 368 | <!-- * if man.font.links is empty, user doesn't want links -->
|
---|
| 369 | <!-- * underlined, so just display content -->
|
---|
| 370 | <xsl:value-of select="$notesource.contents"/>
|
---|
| 371 | </xsl:when>
|
---|
| 372 | <xsl:otherwise>
|
---|
| 373 | <!-- * otherwise the user has specified an unsupported value for -->
|
---|
| 374 | <!-- * man.font.links, so emit a warning and don't apply any font -->
|
---|
| 375 | <!-- * formatting -->
|
---|
| 376 | <xsl:message>
|
---|
| 377 | <xsl:call-template name="log.message">
|
---|
| 378 | <xsl:with-param name="level">Warn</xsl:with-param>
|
---|
| 379 | <xsl:with-param name="source" select="$refname"/>
|
---|
| 380 | <xsl:with-param name="context-desc">
|
---|
| 381 | <xsl:text>link font</xsl:text>
|
---|
| 382 | </xsl:with-param>
|
---|
| 383 | <xsl:with-param name="message">
|
---|
| 384 | <xsl:text>invalid $man.font.links value: </xsl:text>
|
---|
| 385 | <xsl:text>'</xsl:text>
|
---|
| 386 | <xsl:value-of select="$man.font.links"/>
|
---|
| 387 | <xsl:text>'</xsl:text>
|
---|
| 388 | </xsl:with-param>
|
---|
| 389 | </xsl:call-template>
|
---|
| 390 | </xsl:message>
|
---|
| 391 | <xsl:value-of select="$notesource.contents"/>
|
---|
| 392 | </xsl:otherwise>
|
---|
| 393 | </xsl:choose>
|
---|
| 394 | <xsl:text>\m[]</xsl:text>
|
---|
| 395 | </xsl:if>
|
---|
| 396 |
|
---|
| 397 | <xsl:if test="$notesource.number != ''">
|
---|
| 398 | <!-- * Format the number by placing it in square brackets. -->
|
---|
| 399 | <!-- * Also, set the number in font-size -2, and superscripted (\u -->
|
---|
| 400 | <!-- * means to move up half a line vertically) -->
|
---|
| 401 | <xsl:text>\&\s-2\u[</xsl:text>
|
---|
| 402 | <xsl:value-of select="$notesource.number"/>
|
---|
| 403 | <xsl:text>]\d\s+2</xsl:text>
|
---|
| 404 | <!-- * Revert superscripting (\d means to move down half a line), and -->
|
---|
| 405 | <!-- * move the font-size back to what it was before. -->
|
---|
| 406 | <!-- * Note that the reason for the \& before the opening bracket -->
|
---|
| 407 | <!-- * is to prevent any possible linebreak from being introduced -->
|
---|
| 408 | <!-- * between the opening bracket and the following text. -->
|
---|
| 409 | </xsl:if>
|
---|
| 410 | </xsl:template>
|
---|
| 411 |
|
---|
| 412 | <!-- ==================================================================== -->
|
---|
| 413 |
|
---|
| 414 | <xsl:template name="endnotes.list">
|
---|
| 415 | <!-- We have stored earmark indexes for all refentry instances in the -->
|
---|
| 416 | <!-- current document, with the ID for each index being the same ID as -->
|
---|
| 417 | <!-- its corresponding refentry; so we now need to get the ID for the -->
|
---|
| 418 | <!-- current refentry so we can grab its corresponding earmark index -->
|
---|
| 419 | <xsl:variable name="current.refentry.id">
|
---|
| 420 | <xsl:value-of select="generate-id(.)"/>
|
---|
| 421 | </xsl:variable>
|
---|
| 422 |
|
---|
| 423 | <xsl:variable name="endnotes.rtf">
|
---|
| 424 | <xsl:variable name="all.earmark.indexes.in.current.document.rtf">
|
---|
| 425 | <xsl:call-template name="get.all.earmark.indexes.in.current.document"/>
|
---|
| 426 | </xsl:variable>
|
---|
| 427 | <xsl:variable name="all.earmark.indexes.in.current.document"
|
---|
| 428 | select="exsl:node-set($all.earmark.indexes.in.current.document.rtf)"/>
|
---|
| 429 | <xsl:copy-of
|
---|
| 430 | select="$all.earmark.indexes.in.current.document/earmark.index
|
---|
| 431 | [@idref = $current.refentry.id]/earmark"/>
|
---|
| 432 | </xsl:variable>
|
---|
| 433 |
|
---|
| 434 | <xsl:variable name="endnotes" select="exsl:node-set($endnotes.rtf)"/>
|
---|
| 435 |
|
---|
| 436 | <!-- * check to see if we have actually found any content to use as -->
|
---|
| 437 | <!-- * endnotes; if we have, we generate the endnotes list, if not, -->
|
---|
| 438 | <!-- * we do nothing -->
|
---|
| 439 | <xsl:if test="$endnotes/node()">
|
---|
| 440 | <xsl:call-template name="format.endnotes.list">
|
---|
| 441 | <xsl:with-param name="endnotes" select="$endnotes"/>
|
---|
| 442 | </xsl:call-template>
|
---|
| 443 | </xsl:if>
|
---|
| 444 |
|
---|
| 445 | </xsl:template>
|
---|
| 446 |
|
---|
| 447 | <!-- ==================================================================== -->
|
---|
| 448 |
|
---|
| 449 | <xsl:template name="format.endnotes.list">
|
---|
| 450 | <xsl:param name="endnotes"/>
|
---|
| 451 |
|
---|
| 452 | <!-- * ======= make the endnotes-list section heading ============= -->
|
---|
| 453 | <xsl:call-template name="make.subheading">
|
---|
| 454 | <xsl:with-param name="title">
|
---|
| 455 | <xsl:choose>
|
---|
| 456 | <!-- * if user has specified a heading, use that -->
|
---|
| 457 | <xsl:when test="$man.endnotes.list.heading != ''">
|
---|
| 458 | <xsl:value-of select="$man.endnotes.list.heading"/>
|
---|
| 459 | </xsl:when>
|
---|
| 460 | <xsl:otherwise>
|
---|
| 461 | <!-- * otherwise, get localized heading from gentext -->
|
---|
| 462 | <!-- * (in English, NOTES) -->
|
---|
| 463 | <xsl:call-template name="gentext">
|
---|
| 464 | <xsl:with-param name="key" select="'Notes'"/>
|
---|
| 465 | </xsl:call-template>
|
---|
| 466 | </xsl:otherwise>
|
---|
| 467 | </xsl:choose>
|
---|
| 468 | </xsl:with-param>
|
---|
| 469 | </xsl:call-template>
|
---|
| 470 |
|
---|
| 471 | <!-- * ================ process each earmark ====================== -->
|
---|
| 472 | <xsl:for-each select="$endnotes/earmark">
|
---|
| 473 | <!-- * make paragraph with hanging indent, and starting with a -->
|
---|
| 474 | <!-- * number in the form " 1." (padded to $man.indent.width - 1) -->
|
---|
| 475 | <xsl:text>.IP</xsl:text>
|
---|
| 476 | <xsl:text> "</xsl:text>
|
---|
| 477 | <xsl:variable name="endnote.number">
|
---|
| 478 | <xsl:value-of select="@number"/>
|
---|
| 479 | <xsl:text>.</xsl:text>
|
---|
| 480 | </xsl:variable>
|
---|
| 481 | <xsl:call-template name="pad-string">
|
---|
| 482 | <xsl:with-param name="padVar" select="$endnote.number"/>
|
---|
| 483 | <!-- FIXME: the following assumes that $man.indent.width is in -->
|
---|
| 484 | <!-- en's; also, this should probably use $list.indent instead -->
|
---|
| 485 | <xsl:with-param name="length" select="$man.indent.width - 1"/>
|
---|
| 486 | </xsl:call-template>
|
---|
| 487 | <xsl:text>"</xsl:text>
|
---|
| 488 | <xsl:if test="not($list-indent = '')">
|
---|
| 489 | <xsl:text> </xsl:text>
|
---|
| 490 | <xsl:value-of select="$list-indent"/>
|
---|
| 491 | </xsl:if>
|
---|
| 492 | <xsl:text> </xsl:text>
|
---|
| 493 |
|
---|
| 494 | <!-- * ========================================================= -->
|
---|
| 495 | <!-- * print the notesource/endnote contents -->
|
---|
| 496 | <!-- * ========================================================= -->
|
---|
| 497 | <xsl:choose>
|
---|
| 498 | <xsl:when test="*/node()">
|
---|
| 499 | <!-- * if the earmark has non-empty child content, then -->
|
---|
| 500 | <!-- * its corresponding notesource is either a link or -->
|
---|
| 501 | <!-- * an instance of annotative text, so we want to -->
|
---|
| 502 | <!-- * display that content -->
|
---|
| 503 | <xsl:choose>
|
---|
| 504 | <xsl:when test="*/node()[name(.)!='']">
|
---|
| 505 | <!-- * if node is not text only, then process it as-is -->
|
---|
| 506 | <xsl:apply-templates select="*/node()"/>
|
---|
| 507 | </xsl:when>
|
---|
| 508 | <xsl:otherwise>
|
---|
| 509 | <!-- * otherwise node is text-only, so normalize it -->
|
---|
| 510 | <xsl:value-of select="normalize-space(*/node())"/>
|
---|
| 511 | </xsl:otherwise>
|
---|
| 512 | </xsl:choose>
|
---|
| 513 | </xsl:when>
|
---|
| 514 | <xsl:otherwise>
|
---|
| 515 | <!-- * otherwise, this earmark has empty content, -->
|
---|
| 516 | <!-- * which means its corresponding notesource is an -->
|
---|
| 517 | <!-- * imagedata, audiodata, or videodata instance; in -->
|
---|
| 518 | <!-- * that case, we use the value of the notesource's -->
|
---|
| 519 | <!-- * @fileref attribute (which is stored in the -->
|
---|
| 520 | <!-- * earmark uri attribute) as the "contents" for -->
|
---|
| 521 | <!-- * this endnote/notesource -->
|
---|
| 522 | <xsl:call-template name="display.uri">
|
---|
| 523 | <xsl:with-param name="uri" select="@uri"/>
|
---|
| 524 | </xsl:call-template>
|
---|
| 525 | </xsl:otherwise>
|
---|
| 526 | </xsl:choose>
|
---|
| 527 | <xsl:text> </xsl:text>
|
---|
| 528 |
|
---|
| 529 | <!-- * ========================================================= -->
|
---|
| 530 | <!-- * print the URL for links -->
|
---|
| 531 | <!-- * ========================================================= -->
|
---|
| 532 | <!-- * In addition to the notesource contents, if the -->
|
---|
| 533 | <!-- * notesource is a link, we display the URL for the link. -->
|
---|
| 534 | <!-- * But for notesources that are imagedata, audiodata, or -->
|
---|
| 535 | <!-- * videodata instances, we don't want to (re)display the -->
|
---|
| 536 | <!-- * URL for those here, because for those elements, the -->
|
---|
| 537 | <!-- * notesource contents are the URL (the value of the -->
|
---|
| 538 | <!-- * @fileref attribute), and we have already rendered them. -->
|
---|
| 539 | <!-- * -->
|
---|
| 540 | <!-- * We know an earmark is a link if it has non-empty child -->
|
---|
| 541 | <!-- * content and a uri attribute; so we check for that -->
|
---|
| 542 | <!-- * condition here. -->
|
---|
| 543 | <xsl:if test="*/node() and @uri">
|
---|
| 544 | <xsl:text>.RS</xsl:text>
|
---|
| 545 | <xsl:if test="not($list-indent = '')">
|
---|
| 546 | <xsl:text> </xsl:text>
|
---|
| 547 | <xsl:value-of select="$list-indent"/>
|
---|
| 548 | </xsl:if>
|
---|
| 549 | <xsl:text> </xsl:text>
|
---|
| 550 | <!-- * Add hyphenation suppression in URL output only if -->
|
---|
| 551 | <!-- * $break.after.slash is also non-zero -->
|
---|
| 552 | <xsl:if test="$man.hyphenate.urls = 0
|
---|
| 553 | and $man.break.after.slash = 0">
|
---|
| 554 | <xsl:call-template name="suppress.hyphenation"/>
|
---|
| 555 | <xsl:text>\%</xsl:text>
|
---|
| 556 | </xsl:if>
|
---|
| 557 | <xsl:call-template name="display.uri">
|
---|
| 558 | <xsl:with-param name="uri" select="@uri"/>
|
---|
| 559 | </xsl:call-template>
|
---|
| 560 | <xsl:text> </xsl:text>
|
---|
| 561 | <xsl:text>.RE</xsl:text>
|
---|
| 562 | <xsl:text> </xsl:text>
|
---|
| 563 | </xsl:if>
|
---|
| 564 |
|
---|
| 565 | </xsl:for-each>
|
---|
| 566 | </xsl:template>
|
---|
| 567 |
|
---|
| 568 | <xsl:template name="display.uri">
|
---|
| 569 | <xsl:param name="uri"/>
|
---|
| 570 | <xsl:choose>
|
---|
| 571 | <xsl:when test="contains($uri, ':')">
|
---|
| 572 | <!-- * if this URI contains a colon character, it’s probably -->
|
---|
| 573 | <!-- * an absolute URI with a scheme, so we output it as-is -->
|
---|
| 574 | <xsl:value-of select="$uri"/>
|
---|
| 575 | </xsl:when>
|
---|
| 576 | <xsl:otherwise>
|
---|
| 577 | <!-- * otherwise this is probably not an absolute URI, so we -->
|
---|
| 578 | <!-- * need to prepend $man.base.url.for.relative.links to -->
|
---|
| 579 | <!-- * give the URI some "context" in man-page output -->
|
---|
| 580 | <xsl:value-of
|
---|
| 581 | select="concat($man.base.url.for.relative.links, $uri)"/>
|
---|
| 582 | </xsl:otherwise>
|
---|
| 583 | </xsl:choose>
|
---|
| 584 | </xsl:template>
|
---|
| 585 |
|
---|
| 586 | </xsl:stylesheet>
|
---|