| 1 |
<?xml version='1.0' encoding="iso-8859-1"?> |
| 2 |
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version='1.0'> |
| 3 |
|
| 4 |
<!--############################################################################ |
| 5 |
XSLT Stylesheet DocBook -> LaTeX |
| 6 |
############################################################################ --> |
| 7 |
<xsl:param name="xref.hypermarkup" select="0"/> |
| 8 |
<xsl:param name="ulink.block.symbol">\textbullet</xsl:param> |
| 9 |
|
| 10 |
|
| 11 |
<xsl:template match="anchor"> |
| 12 |
<xsl:call-template name="label.id"> |
| 13 |
<xsl:with-param name="inline" select="1"/> |
| 14 |
</xsl:call-template> |
| 15 |
</xsl:template> |
| 16 |
|
| 17 |
<!-- ==================================================================== --> |
| 18 |
|
| 19 |
<xsl:template name="hyperlink.markup"> |
| 20 |
<xsl:param name="referrer" select="." /> |
| 21 |
<xsl:param name="linkend"/> |
| 22 |
<xsl:param name="text"/> |
| 23 |
|
| 24 |
<xsl:variable name="targetbook" |
| 25 |
select="key('id',$linkend)/ancestor-or-self::book"/> |
| 26 |
|
| 27 |
<xsl:variable name="referbook" |
| 28 |
select="$referrer/ancestor-or-self::book"/> |
| 29 |
|
| 30 |
<xsl:variable name="referrer_i"> |
| 31 |
<xsl:apply-templates select="$referbook" mode="booknumber"/> |
| 32 |
</xsl:variable> |
| 33 |
|
| 34 |
<xsl:variable name="target_i"> |
| 35 |
<xsl:apply-templates select="$targetbook" mode="booknumber"/> |
| 36 |
</xsl:variable> |
| 37 |
|
| 38 |
<xsl:variable name="label"> |
| 39 |
<xsl:call-template name="id-encode"> |
| 40 |
<xsl:with-param name="string" select="$linkend"/> |
| 41 |
</xsl:call-template> |
| 42 |
</xsl:variable> |
| 43 |
|
| 44 |
<!-- The URL is local only if the target is in the referrer book --> |
| 45 |
<xsl:choose> |
| 46 |
<xsl:when test="$referrer_i != $target_i"> |
| 47 |
<xsl:text>\href{</xsl:text> |
| 48 |
<xsl:apply-templates select="$targetbook" mode="bookname"/> |
| 49 |
<xsl:value-of select="concat('\#',$label)" /> |
| 50 |
</xsl:when> |
| 51 |
<xsl:otherwise> |
| 52 |
<xsl:text>\hyperlink{</xsl:text> |
| 53 |
<xsl:value-of select="$label"/> |
| 54 |
</xsl:otherwise> |
| 55 |
</xsl:choose> |
| 56 |
<!-- The hot text --> |
| 57 |
<xsl:text>}{</xsl:text> |
| 58 |
<xsl:value-of select="$text"/> |
| 59 |
<xsl:text>}</xsl:text> |
| 60 |
</xsl:template> |
| 61 |
|
| 62 |
<!-- ==================================================================== --> |
| 63 |
|
| 64 |
<xsl:template match="*" mode="object.xref.markup2"> |
| 65 |
<xsl:param name="purpose" select="'xref'"/> |
| 66 |
<xsl:param name="xrefstyle"/> |
| 67 |
<xsl:param name="referrer"/> |
| 68 |
<xsl:param name="verbose" select="1"/> |
| 69 |
|
| 70 |
<xsl:variable name="markup"> |
| 71 |
<xsl:apply-templates select="." mode="object.xref.markup"> |
| 72 |
<xsl:with-param name="purpose" select="$purpose"/> |
| 73 |
<xsl:with-param name="xrefstyle" select="$xrefstyle"/> |
| 74 |
<xsl:with-param name="referrer" select="$referrer"/> |
| 75 |
<xsl:with-param name="verbose" select="$verbose"/> |
| 76 |
</xsl:apply-templates> |
| 77 |
</xsl:variable> |
| 78 |
|
| 79 |
<xsl:choose> |
| 80 |
<!-- Wrap with an hyperlink if asked and if it is not already a link --> |
| 81 |
<xsl:when test="$xref.hypermarkup=1 and |
| 82 |
not(contains($markup, '\hyperlink{') or |
| 83 |
contains($markup, '\href{'))"> |
| 84 |
<!-- Get the normal markup but replace hot links by counters --> |
| 85 |
<xsl:variable name="text"> |
| 86 |
<xsl:call-template name="string-replace"> |
| 87 |
<xsl:with-param name="string" select="$markup"/> |
| 88 |
<xsl:with-param name="from" select="'ref{'"/> |
| 89 |
<xsl:with-param name="to" select="'ref*{'"/> |
| 90 |
</xsl:call-template> |
| 91 |
</xsl:variable> |
| 92 |
<!-- Wrap the markup with an hyperlink --> |
| 93 |
<xsl:call-template name="hyperlink.markup"> |
| 94 |
<xsl:with-param name="referrer" select="$referrer"/> |
| 95 |
<xsl:with-param name="linkend" select="(@id|@xml:id)[1]"/> |
| 96 |
<xsl:with-param name="text" select="$text"/> |
| 97 |
</xsl:call-template> |
| 98 |
</xsl:when> |
| 99 |
<xsl:otherwise> |
| 100 |
<xsl:value-of select="$markup"/> |
| 101 |
</xsl:otherwise> |
| 102 |
</xsl:choose> |
| 103 |
</xsl:template> |
| 104 |
|
| 105 |
<!-- ==================================================================== --> |
| 106 |
|
| 107 |
<xsl:template match="xref|biblioref" mode="xref.text"> |
| 108 |
<xsl:variable name="target" select="key('id',@linkend)[1]"/> |
| 109 |
<xsl:choose> |
| 110 |
<!-- If there is an endterm --> |
| 111 |
<xsl:when test="@endterm"> |
| 112 |
<xsl:variable name="etarget" select="key('id',@endterm)[1]"/> |
| 113 |
<xsl:choose> |
| 114 |
<xsl:when test="count($etarget) = 0"> |
| 115 |
<xsl:message> |
| 116 |
<xsl:text>Endterm points to nonexistent ID: </xsl:text> |
| 117 |
<xsl:value-of select="@endterm"/> |
| 118 |
</xsl:message> |
| 119 |
<xsl:text>[??]</xsl:text> |
| 120 |
</xsl:when> |
| 121 |
<xsl:otherwise> |
| 122 |
<xsl:apply-templates select="$etarget" mode="xref.text"/> |
| 123 |
</xsl:otherwise> |
| 124 |
</xsl:choose> |
| 125 |
</xsl:when> |
| 126 |
<!-- If an xreflabel has been specified for the target --> |
| 127 |
<xsl:when test="$target/@xreflabel"> |
| 128 |
<xsl:call-template name="scape"> |
| 129 |
<xsl:with-param name="string" select="$target/@xreflabel"/> |
| 130 |
</xsl:call-template> |
| 131 |
</xsl:when> |
| 132 |
<!-- nothing specified --> |
| 133 |
<xsl:otherwise/> |
| 134 |
</xsl:choose> |
| 135 |
</xsl:template> |
| 136 |
|
| 137 |
<xsl:template match="xref" name="xref"> |
| 138 |
<xsl:variable name="target" select="key('id',@linkend)[1]"/> |
| 139 |
|
| 140 |
<xsl:call-template name="check.id.unique"> |
| 141 |
<xsl:with-param name="linkend" select="@linkend"/> |
| 142 |
</xsl:call-template> |
| 143 |
|
| 144 |
<xsl:variable name="xrefstyle"> |
| 145 |
<xsl:choose> |
| 146 |
<xsl:when test="@role and not(@xrefstyle) |
| 147 |
and $use.role.as.xrefstyle != 0"> |
| 148 |
<xsl:value-of select="@role"/> |
| 149 |
</xsl:when> |
| 150 |
<xsl:otherwise> |
| 151 |
<xsl:value-of select="@xrefstyle"/> |
| 152 |
</xsl:otherwise> |
| 153 |
</xsl:choose> |
| 154 |
</xsl:variable> |
| 155 |
|
| 156 |
<xsl:choose> |
| 157 |
<xsl:when test="count($target)=0"> |
| 158 |
<xsl:message> |
| 159 |
<xsl:text>XRef to nonexistent id: </xsl:text> |
| 160 |
<xsl:value-of select="@linkend"/> |
| 161 |
</xsl:message> |
| 162 |
<xsl:text>[?]</xsl:text> |
| 163 |
</xsl:when> |
| 164 |
<xsl:otherwise> |
| 165 |
<xsl:variable name="text"> |
| 166 |
<xsl:apply-templates select="." mode="xref.text"/> |
| 167 |
</xsl:variable> |
| 168 |
|
| 169 |
<!-- how to print it --> |
| 170 |
<xsl:choose> |
| 171 |
<xsl:when test="$text!=''"> |
| 172 |
<xsl:call-template name="hyperlink.markup"> |
| 173 |
<xsl:with-param name="linkend" select="@linkend"/> |
| 174 |
<xsl:with-param name="text" select="$text"/> |
| 175 |
</xsl:call-template> |
| 176 |
</xsl:when> |
| 177 |
<xsl:otherwise> |
| 178 |
<xsl:apply-templates select="$target" mode="xref-to"> |
| 179 |
<xsl:with-param name="referrer" select="."/> |
| 180 |
<xsl:with-param name="xrefstyle" select="$xrefstyle"/> |
| 181 |
</xsl:apply-templates> |
| 182 |
</xsl:otherwise> |
| 183 |
</xsl:choose> |
| 184 |
</xsl:otherwise> |
| 185 |
</xsl:choose> |
| 186 |
|
| 187 |
<!-- Add standard page reference? --> |
| 188 |
<xsl:choose> |
| 189 |
<xsl:when test="self::biblioref"> |
| 190 |
<!-- no page number for a biblio reference --> |
| 191 |
</xsl:when> |
| 192 |
<xsl:when test="starts-with(normalize-space($xrefstyle), 'select:') |
| 193 |
and contains($xrefstyle, 'nopage')"> |
| 194 |
<!-- negative xrefstyle in instance turns it off --> |
| 195 |
</xsl:when> |
| 196 |
<xsl:when test="not(starts-with(normalize-space($xrefstyle), 'select:') |
| 197 |
and (contains($xrefstyle, 'page') |
| 198 |
or contains($xrefstyle, 'Page'))) |
| 199 |
and ( $insert.xref.page.number = 'yes' |
| 200 |
or $insert.xref.page.number = '1') |
| 201 |
or (local-name($target) = 'para' |
| 202 |
and $xrefstyle = '' |
| 203 |
and $insert.xref.page.number.para = 'yes')"> |
| 204 |
<xsl:apply-templates select="$target" mode="page.citation"> |
| 205 |
<xsl:with-param name="id" select="@linkend"/> |
| 206 |
</xsl:apply-templates> |
| 207 |
</xsl:when> |
| 208 |
</xsl:choose> |
| 209 |
</xsl:template> |
| 210 |
|
| 211 |
<!-- ==================================================================== --> |
| 212 |
|
| 213 |
<!-- Currently no begin, end, units supports, so handle like xref --> |
| 214 |
<xsl:template match="biblioref"> |
| 215 |
<xsl:call-template name="xref"/> |
| 216 |
</xsl:template> |
| 217 |
|
| 218 |
<!-- ==================================================================== --> |
| 219 |
|
| 220 |
<xsl:template name="ulink-encode"> |
| 221 |
<xsl:param name="escape" select="0"/> |
| 222 |
|
| 223 |
<!-- messy sharp (#) in newtbl table cells, so escape it --> |
| 224 |
<xsl:call-template name="scape-encode"> |
| 225 |
<xsl:with-param name="string"> |
| 226 |
<xsl:choose> |
| 227 |
<xsl:when test="$escape != 0 or ancestor::entry or ancestor::revision or |
| 228 |
ancestor::footnote or ancestor::term"> |
| 229 |
<xsl:call-template name="string-replace"> |
| 230 |
<xsl:with-param name="string"> |
| 231 |
<xsl:call-template name="string-replace"> |
| 232 |
<xsl:with-param name="string"> |
| 233 |
<xsl:call-template name="string-replace"> |
| 234 |
<xsl:with-param name="string" select="@url"/> |
| 235 |
<xsl:with-param name="from" select="'%'"/> |
| 236 |
<xsl:with-param name="to" select="'\%'"/> |
| 237 |
</xsl:call-template> |
| 238 |
</xsl:with-param> |
| 239 |
<xsl:with-param name="from" select="'#'"/> |
| 240 |
<xsl:with-param name="to" select="'\#'"/> |
| 241 |
</xsl:call-template> |
| 242 |
</xsl:with-param> |
| 243 |
<xsl:with-param name="from" select="'&'"/> |
| 244 |
<xsl:with-param name="to" select="'\&'"/> |
| 245 |
</xsl:call-template> |
| 246 |
</xsl:when> |
| 247 |
<xsl:otherwise> |
| 248 |
<xsl:value-of select="@url"/> |
| 249 |
</xsl:otherwise> |
| 250 |
</xsl:choose> |
| 251 |
</xsl:with-param> |
| 252 |
</xsl:call-template> |
| 253 |
</xsl:template> |
| 254 |
|
| 255 |
<!-- Should the URI be shown? @xrefstyle overrides the parameter --> |
| 256 |
<xsl:template name="ulink-show"> |
| 257 |
<xsl:choose> |
| 258 |
<xsl:when test="starts-with(@xrefstyle, 'url.show')"> |
| 259 |
<xsl:value-of select="1"/> |
| 260 |
</xsl:when> |
| 261 |
<xsl:when test="starts-with(@xrefstyle, 'url.hide')"> |
| 262 |
<xsl:value-of select="0"/> |
| 263 |
</xsl:when> |
| 264 |
<xsl:otherwise> |
| 265 |
<xsl:value-of select="$ulink.show"/> |
| 266 |
</xsl:otherwise> |
| 267 |
</xsl:choose> |
| 268 |
</xsl:template> |
| 269 |
|
| 270 |
<!-- Should the URI be in a footnote? @xrefstyle overrides the parameter --> |
| 271 |
<xsl:template name="ulink-foot"> |
| 272 |
<!-- assume xrefstyle is in the form: "url[.show][{.infoot|.after}]" |
| 273 |
$style extract the optional '.infoot' or '.after' part --> |
| 274 |
<xsl:variable name="style"> |
| 275 |
<xsl:call-template name="string-replace"> |
| 276 |
<xsl:with-param name="string" |
| 277 |
select="substring-after(@xrefstyle, 'url')"/> |
| 278 |
<xsl:with-param name="from" select="'.show'"/> |
| 279 |
<xsl:with-param name="to" select="''"/> |
| 280 |
</xsl:call-template> |
| 281 |
</xsl:variable> |
| 282 |
|
| 283 |
<xsl:choose> |
| 284 |
<xsl:when test="$style = '.infoot'"> |
| 285 |
<xsl:value-of select="1"/> |
| 286 |
</xsl:when> |
| 287 |
<xsl:when test="$style = '.after'"> |
| 288 |
<xsl:value-of select="0"/> |
| 289 |
</xsl:when> |
| 290 |
<xsl:otherwise> |
| 291 |
<xsl:value-of select="$ulink.footnotes"/> |
| 292 |
</xsl:otherwise> |
| 293 |
</xsl:choose> |
| 294 |
</xsl:template> |
| 295 |
|
| 296 |
<xsl:template name="ulink.format"> |
| 297 |
<xsl:variable name="url"> |
| 298 |
<xsl:call-template name="ulink-encode"/> |
| 299 |
</xsl:variable> |
| 300 |
|
| 301 |
<xsl:choose> |
| 302 |
<xsl:when test=".=''"> |
| 303 |
<xsl:text>\url{</xsl:text> |
| 304 |
<xsl:value-of select="$url"/> |
| 305 |
<xsl:text>}</xsl:text> |
| 306 |
</xsl:when> |
| 307 |
<xsl:otherwise> |
| 308 |
<xsl:text>\href{</xsl:text> |
| 309 |
<xsl:value-of select="$url"/> |
| 310 |
<xsl:text>}{</xsl:text> |
| 311 |
<!-- text() within ulink is handled somewhere else --> |
| 312 |
<xsl:apply-templates/> |
| 313 |
<xsl:text>}</xsl:text> |
| 314 |
|
| 315 |
<xsl:variable name="url.show"> |
| 316 |
<xsl:call-template name="ulink-show"/> |
| 317 |
</xsl:variable> |
| 318 |
|
| 319 |
<xsl:variable name="url.foot"> |
| 320 |
<xsl:if test="$url.show != 0"> |
| 321 |
<xsl:call-template name="ulink-foot"/> |
| 322 |
</xsl:if> |
| 323 |
</xsl:variable> |
| 324 |
|
| 325 |
<xsl:if test="count(child::node()) != 0 |
| 326 |
and string(.) != @url |
| 327 |
and $url.show != 0"> |
| 328 |
<!-- yes, show the URI --> |
| 329 |
<xsl:choose> |
| 330 |
<xsl:when test="$url.foot != 0 and not(ancestor::footnote)"> |
| 331 |
<xsl:text>\footnote{</xsl:text> |
| 332 |
<xsl:text>\url{</xsl:text> |
| 333 |
<!-- Beware URL in a footnote --> |
| 334 |
<xsl:call-template name="ulink-encode"> |
| 335 |
<xsl:with-param name="escape" select="1"/> |
| 336 |
</xsl:call-template> |
| 337 |
<xsl:text>}</xsl:text> |
| 338 |
<xsl:text>}</xsl:text> |
| 339 |
</xsl:when> |
| 340 |
<xsl:otherwise> |
| 341 |
<!-- Append the URL after the hyperlink --> |
| 342 |
<xsl:text> [</xsl:text> |
| 343 |
<xsl:text>\url{</xsl:text> |
| 344 |
<xsl:value-of select="$url"/> |
| 345 |
<xsl:text>}</xsl:text> |
| 346 |
<xsl:text>]</xsl:text> |
| 347 |
</xsl:otherwise> |
| 348 |
</xsl:choose> |
| 349 |
</xsl:if> |
| 350 |
|
| 351 |
</xsl:otherwise> |
| 352 |
</xsl:choose> |
| 353 |
</xsl:template> |
| 354 |
|
| 355 |
|
| 356 |
<!-- Template that can be overwritten by user to customize the URL displayed as |
| 357 |
a block. The default is the solution sponsored by Freexian --> |
| 358 |
|
| 359 |
<xsl:template name="ulink.block.markup"> |
| 360 |
<xsl:text> </xsl:text> |
| 361 |
<!-- Put a symbol as a starter --> |
| 362 |
<xsl:value-of select="$ulink.block.symbol"/> |
| 363 |
<xsl:choose> |
| 364 |
<!-- In sidebar force left-alignment with a fixed space --> |
| 365 |
<xsl:when test="ancestor::sidebar"> |
| 366 |
<xsl:text>\enspace</xsl:text> |
| 367 |
</xsl:when> |
| 368 |
<xsl:otherwise> |
| 369 |
<xsl:text>\space</xsl:text> |
| 370 |
</xsl:otherwise> |
| 371 |
</xsl:choose> |
| 372 |
<xsl:call-template name="ulink.format"/> |
| 373 |
<xsl:text> </xsl:text> |
| 374 |
</xsl:template> |
| 375 |
|
| 376 |
<xsl:template match="ulink"> |
| 377 |
<xsl:variable name="urlstring"> |
| 378 |
</xsl:variable> |
| 379 |
|
| 380 |
<xsl:choose> |
| 381 |
<xsl:when test="@type='block'"> |
| 382 |
<xsl:call-template name="ulink.block.markup"/> |
| 383 |
</xsl:when> |
| 384 |
<xsl:otherwise> |
| 385 |
<xsl:call-template name="ulink.format"/> |
| 386 |
</xsl:otherwise> |
| 387 |
</xsl:choose> |
| 388 |
</xsl:template> |
| 389 |
|
| 390 |
<!-- ==================================================================== --> |
| 391 |
|
| 392 |
<!-- it now works thanks to "hyperlabel" --> |
| 393 |
|
| 394 |
<xsl:template match="link" mode="xref.text"> |
| 395 |
<xsl:choose> |
| 396 |
<xsl:when test=".!=''"> |
| 397 |
<xsl:call-template name="normalize-scape"> |
| 398 |
<xsl:with-param name="string"> |
| 399 |
<xsl:copy-of select="."/> |
| 400 |
</xsl:with-param> |
| 401 |
</xsl:call-template> |
| 402 |
</xsl:when> |
| 403 |
<xsl:when test="@endterm"> |
| 404 |
<xsl:variable name="etarget" select="key('id',@endterm)[1]"/> |
| 405 |
<xsl:choose> |
| 406 |
<xsl:when test="count($etarget) = 0"> |
| 407 |
<xsl:message> |
| 408 |
<xsl:text>Endterm points to nonexistent ID: </xsl:text> |
| 409 |
<xsl:value-of select="@endterm"/> |
| 410 |
</xsl:message> |
| 411 |
<xsl:text>???</xsl:text> |
| 412 |
</xsl:when> |
| 413 |
<xsl:otherwise> |
| 414 |
<xsl:apply-templates select="$etarget" mode="xref.text"/> |
| 415 |
</xsl:otherwise> |
| 416 |
</xsl:choose> |
| 417 |
</xsl:when> |
| 418 |
<xsl:otherwise/> |
| 419 |
</xsl:choose> |
| 420 |
</xsl:template> |
| 421 |
|
| 422 |
<xsl:template match="link"> |
| 423 |
<xsl:call-template name="hyperlink.markup"> |
| 424 |
<xsl:with-param name="linkend" select="@linkend"/> |
| 425 |
<xsl:with-param name="text"> |
| 426 |
<xsl:apply-templates select="." mode="xref.text"/> |
| 427 |
</xsl:with-param> |
| 428 |
</xsl:call-template> |
| 429 |
</xsl:template> |
| 430 |
|
| 431 |
<!-- Text of endterm xref must be managed with the text() function to support |
| 432 |
the special latex characters, but things like anchors must be skipped --> |
| 433 |
|
| 434 |
<xsl:template match="*" mode="xref.text"> |
| 435 |
<xsl:apply-templates select="text()|*[not(self::anchor)]"/> |
| 436 |
</xsl:template> |
| 437 |
|
| 438 |
<xsl:template match="term" mode="xref.text"> |
| 439 |
<xsl:variable name="text"> |
| 440 |
<xsl:apply-templates mode="xref.text"/> |
| 441 |
</xsl:variable> |
| 442 |
<xsl:value-of select="normalize-space($text)"/> |
| 443 |
</xsl:template> |
| 444 |
|
| 445 |
<!-- No reference must be made, but the label should be printed, if any --> |
| 446 |
<xsl:template match="link" mode="toc.skip"> |
| 447 |
<xsl:apply-templates select="." mode="xref.text"/> |
| 448 |
</xsl:template> |
| 449 |
|
| 450 |
<!-- ==================================================================== --> |
| 451 |
|
| 452 |
<xsl:template name="xref.nolink"> |
| 453 |
<xsl:param name="string"> |
| 454 |
<xsl:apply-templates select="."/> |
| 455 |
</xsl:param> |
| 456 |
|
| 457 |
<!-- Get the normal markup but replace hot links by counters --> |
| 458 |
<xsl:variable name="xref.text"> |
| 459 |
<xsl:call-template name="string-replace"> |
| 460 |
<xsl:with-param name="string" select="$string"/> |
| 461 |
<xsl:with-param name="from" select="'\ref{'"/> |
| 462 |
<xsl:with-param name="to" select="'\ref*{'"/> |
| 463 |
</xsl:call-template> |
| 464 |
</xsl:variable> |
| 465 |
|
| 466 |
<!-- Remove an internal hyperlink wrapper (external links seem ok) --> |
| 467 |
<xsl:choose> |
| 468 |
<xsl:when test="contains($xref.text, '\hyperlink{')"> |
| 469 |
<xsl:value-of select="substring-before($xref.text,'\hyperlink{')"/> |
| 470 |
<xsl:value-of select="substring-after(substring-after($xref.text, |
| 471 |
'\hyperlink{'), '}')"/> |
| 472 |
</xsl:when> |
| 473 |
<xsl:otherwise> |
| 474 |
<xsl:value-of select="$xref.text"/> |
| 475 |
</xsl:otherwise> |
| 476 |
</xsl:choose> |
| 477 |
</xsl:template> |
| 478 |
|
| 479 |
<!-- Try to have the label from text mode, else get the reference counter --> |
| 480 |
<xsl:template match="xref" mode="toc.skip"> |
| 481 |
<xsl:variable name="xref.text"> |
| 482 |
<xsl:apply-templates select="." mode="xref.text"/> |
| 483 |
</xsl:variable> |
| 484 |
|
| 485 |
<xsl:choose> |
| 486 |
<xsl:when test="$xref.text != ''"> |
| 487 |
<xsl:value-of select="$xref.text"/> |
| 488 |
</xsl:when> |
| 489 |
<xsl:otherwise> |
| 490 |
<xsl:call-template name="xref.nolink"/> |
| 491 |
</xsl:otherwise> |
| 492 |
</xsl:choose> |
| 493 |
</xsl:template> |
| 494 |
|
| 495 |
<xsl:template match="ulink" mode="toc.skip"> |
| 496 |
<xsl:choose> |
| 497 |
<xsl:when test=".=''"> |
| 498 |
<xsl:value-of select="@url"/> |
| 499 |
</xsl:when> |
| 500 |
<xsl:otherwise> |
| 501 |
<!-- LaTeX chars are scaped. Each / except the :// is mapped to a /\- --> |
| 502 |
<xsl:apply-templates mode="slash.hyphen"/> |
| 503 |
</xsl:otherwise> |
| 504 |
</xsl:choose> |
| 505 |
</xsl:template> |
| 506 |
|
| 507 |
<xsl:template match="ulink" mode="xref.text"> |
| 508 |
<xsl:apply-templates select="." mode="toc.skip"/> |
| 509 |
</xsl:template> |
| 510 |
|
| 511 |
|
| 512 |
<!--- ==================================================================== --> |
| 513 |
|
| 514 |
<xsl:template match="*" mode="xref-to"> |
| 515 |
<xsl:param name="referrer"/> |
| 516 |
<xsl:param name="xrefstyle"/> |
| 517 |
<xsl:param name="verbose" select="1"/> |
| 518 |
|
| 519 |
<xsl:param name="refelem" select="local-name(.)"/> |
| 520 |
<xsl:message> |
| 521 |
<xsl:text>Don't know what gentext to create for xref to: "</xsl:text> |
| 522 |
<xsl:value-of select="$refelem"/> |
| 523 |
<xsl:text>" (linkend=</xsl:text> |
| 524 |
<xsl:value-of select="(@id|@xml:id)[1]"/> |
| 525 |
<xsl:text>)</xsl:text> |
| 526 |
</xsl:message> |
| 527 |
<xsl:text>[?</xsl:text><xsl:value-of select="$refelem"/><xsl:text>]</xsl:text> |
| 528 |
</xsl:template> |
| 529 |
|
| 530 |
<xsl:template match="step" mode="xref-to"> |
| 531 |
<xsl:param name="referrer"/> |
| 532 |
<xsl:param name="xrefstyle"/> |
| 533 |
<xsl:param name="verbose" select="1"/> |
| 534 |
|
| 535 |
<xsl:call-template name="gentext"> |
| 536 |
<xsl:with-param name="key" select="'Step'"/> |
| 537 |
</xsl:call-template> |
| 538 |
<xsl:text> </xsl:text> |
| 539 |
<xsl:apply-templates select="." mode="label.markup"/> |
| 540 |
</xsl:template> |
| 541 |
|
| 542 |
<xsl:template match="title" mode="xref"> |
| 543 |
<xsl:apply-templates/> |
| 544 |
</xsl:template> |
| 545 |
|
| 546 |
<xsl:template match="book" mode="xref-to"> |
| 547 |
<xsl:param name="referrer"/> |
| 548 |
|
| 549 |
<xsl:variable name="text"> |
| 550 |
<xsl:text>\emph{</xsl:text> |
| 551 |
<xsl:choose> |
| 552 |
<xsl:when test="title"> |
| 553 |
<xsl:apply-templates select="title" mode="xref"/> |
| 554 |
</xsl:when> |
| 555 |
<xsl:otherwise> |
| 556 |
<xsl:apply-templates select="bookinfo/title" mode="xref"/> |
| 557 |
</xsl:otherwise> |
| 558 |
</xsl:choose> |
| 559 |
<xsl:text>}</xsl:text> |
| 560 |
</xsl:variable> |
| 561 |
|
| 562 |
<xsl:call-template name="hyperlink.markup"> |
| 563 |
<xsl:with-param name="referrer" select="$referrer"/> |
| 564 |
<xsl:with-param name="linkend" select="(@id|@xml:id)[1]"/> |
| 565 |
<xsl:with-param name="text" select="$text"/> |
| 566 |
</xsl:call-template> |
| 567 |
</xsl:template> |
| 568 |
|
| 569 |
<!-- These are elements for which no link text exists, so an xref to one |
| 570 |
uses the xrefstyle attribute if specified, or if not it falls back |
| 571 |
to the container element's link text --> |
| 572 |
<xsl:template match="para|phrase|simpara|anchor|quote" mode="xref-to"> |
| 573 |
<xsl:param name="referrer"/> |
| 574 |
<xsl:param name="xrefstyle"/> |
| 575 |
<xsl:param name="verbose"/> |
| 576 |
|
| 577 |
<xsl:variable name="context" select="(ancestor::simplesect |
| 578 |
|ancestor::section |
| 579 |
|ancestor::sect1 |
| 580 |
|ancestor::sect2 |
| 581 |
|ancestor::sect3 |
| 582 |
|ancestor::sect4 |
| 583 |
|ancestor::sect5 |
| 584 |
|ancestor::topic |
| 585 |
|ancestor::refsection |
| 586 |
|ancestor::refsect1 |
| 587 |
|ancestor::refsect2 |
| 588 |
|ancestor::refsect3 |
| 589 |
|ancestor::chapter |
| 590 |
|ancestor::appendix |
| 591 |
|ancestor::preface |
| 592 |
|ancestor::partintro |
| 593 |
|ancestor::dedication |
| 594 |
|ancestor::acknowledgements |
| 595 |
|ancestor::colophon |
| 596 |
|ancestor::bibliography |
| 597 |
|ancestor::index |
| 598 |
|ancestor::glossary |
| 599 |
|ancestor::glossentry |
| 600 |
|ancestor::listitem |
| 601 |
|ancestor::varlistentry)[last()]"/> |
| 602 |
|
| 603 |
<xsl:choose> |
| 604 |
<xsl:when test="$xrefstyle != ''"> |
| 605 |
<xsl:apply-templates select="." mode="object.xref.markup2"> |
| 606 |
<xsl:with-param name="xrefstyle" select="$xrefstyle"/> |
| 607 |
<xsl:with-param name="referrer" select="$referrer"/> |
| 608 |
<xsl:with-param name="verbose" select="$verbose"/> |
| 609 |
</xsl:apply-templates> |
| 610 |
</xsl:when> |
| 611 |
<xsl:otherwise> |
| 612 |
<xsl:if test="$verbose != 0"> |
| 613 |
<xsl:message> |
| 614 |
<xsl:text>WARNING: xref to <</xsl:text> |
| 615 |
<xsl:value-of select="local-name()"/> |
| 616 |
<xsl:text> id="</xsl:text> |
| 617 |
<xsl:value-of select="@id|@xml:id"/> |
| 618 |
<xsl:text>"> has no generated text. Trying its ancestor elements.</xsl:text> |
| 619 |
</xsl:message> |
| 620 |
</xsl:if> |
| 621 |
<xsl:apply-templates select="$context" mode="xref-to"> |
| 622 |
<xsl:with-param name="xrefstyle" select="$xrefstyle"/> |
| 623 |
<xsl:with-param name="referrer" select="$referrer"/> |
| 624 |
<xsl:with-param name="verbose" select="$verbose"/> |
| 625 |
</xsl:apply-templates> |
| 626 |
</xsl:otherwise> |
| 627 |
</xsl:choose> |
| 628 |
</xsl:template> |
| 629 |
|
| 630 |
<xsl:template match="variablelist|orderedlist|orderedlist|itemizedlist" |
| 631 |
mode="xref-to"> |
| 632 |
<xsl:param name="referrer"/> |
| 633 |
<xsl:param name="xrefstyle"/> |
| 634 |
<xsl:param name="verbose" select="1"/> |
| 635 |
|
| 636 |
<xsl:apply-templates select="." mode="object.xref.markup2"> |
| 637 |
<xsl:with-param name="purpose" select="'xref'"/> |
| 638 |
<xsl:with-param name="xrefstyle" select="$xrefstyle"/> |
| 639 |
<xsl:with-param name="referrer" select="$referrer"/> |
| 640 |
<xsl:with-param name="verbose" select="$verbose"/> |
| 641 |
</xsl:apply-templates> |
| 642 |
</xsl:template> |
| 643 |
|
| 644 |
<xsl:template match="dedication|preface|part|chapter|appendix" mode="xref-to"> |
| 645 |
<xsl:param name="referrer"/> |
| 646 |
<xsl:param name="xrefstyle"/> |
| 647 |
<xsl:param name="verbose" select="1"/> |
| 648 |
|
| 649 |
<xsl:apply-templates select="." mode="object.xref.markup2"> |
| 650 |
<xsl:with-param name="purpose" select="'xref'"/> |
| 651 |
<xsl:with-param name="xrefstyle" select="$xrefstyle"/> |
| 652 |
<xsl:with-param name="referrer" select="$referrer"/> |
| 653 |
<xsl:with-param name="verbose" select="$verbose"/> |
| 654 |
</xsl:apply-templates> |
| 655 |
</xsl:template> |
| 656 |
|
| 657 |
<xsl:template match="section|simplesect |
| 658 |
|sect1|sect2|sect3|sect4|sect5 |
| 659 |
|refsect1|refsect2|refsect3|refsection" mode="xref-to"> |
| 660 |
<xsl:param name="referrer"/> |
| 661 |
<xsl:param name="xrefstyle"/> |
| 662 |
<xsl:param name="verbose" select="1"/> |
| 663 |
|
| 664 |
<xsl:apply-templates select="." mode="object.xref.markup2"> |
| 665 |
<xsl:with-param name="purpose" select="'xref'"/> |
| 666 |
<xsl:with-param name="xrefstyle" select="$xrefstyle"/> |
| 667 |
<xsl:with-param name="referrer" select="$referrer"/> |
| 668 |
<xsl:with-param name="verbose" select="$verbose"/> |
| 669 |
</xsl:apply-templates> |
| 670 |
</xsl:template> |
| 671 |
|
| 672 |
<xsl:template match="figure|example|table" mode="xref-to"> |
| 673 |
<xsl:param name="referrer"/> |
| 674 |
<xsl:param name="xrefstyle"/> |
| 675 |
<xsl:param name="verbose" select="1"/> |
| 676 |
|
| 677 |
<xsl:apply-templates select="." mode="object.xref.markup2"> |
| 678 |
<xsl:with-param name="purpose" select="'xref'"/> |
| 679 |
<xsl:with-param name="xrefstyle" select="$xrefstyle"/> |
| 680 |
<xsl:with-param name="referrer" select="$referrer"/> |
| 681 |
<xsl:with-param name="verbose" select="$verbose"/> |
| 682 |
</xsl:apply-templates> |
| 683 |
</xsl:template> |
| 684 |
|
| 685 |
<!-- Equations have two reference counters, one for titled and one |
| 686 |
for untitled equations. So, the cross reference label must be |
| 687 |
different if a title is given or not. |
| 688 |
--> |
| 689 |
<xsl:template match="equation" mode="xref-to"> |
| 690 |
<xsl:param name="referrer"/> |
| 691 |
<xsl:param name="xrefstyle"/> |
| 692 |
<xsl:param name="verbose" select="1"/> |
| 693 |
|
| 694 |
<xsl:apply-templates select="." mode="object.xref.markup2"> |
| 695 |
<xsl:with-param name="purpose" select="'xref'"/> |
| 696 |
<xsl:with-param name="xrefstyle" select="$xrefstyle"/> |
| 697 |
<xsl:with-param name="referrer" select="$referrer"/> |
| 698 |
<xsl:with-param name="verbose" select="$verbose"/> |
| 699 |
</xsl:apply-templates> |
| 700 |
</xsl:template> |
| 701 |
|
| 702 |
<!-- Make the untitled equation markups different from the titled one. |
| 703 |
Change the context to make the difference. |
| 704 |
--> |
| 705 |
<xsl:template match="equation[not(child::title)]" mode="object.xref.template"> |
| 706 |
<xsl:param name="purpose"/> |
| 707 |
<xsl:param name="xrefstyle"/> |
| 708 |
<xsl:param name="referrer"/> |
| 709 |
|
| 710 |
<xsl:call-template name="gentext.template"> |
| 711 |
<xsl:with-param name="context" select="'xref-without-title'"/> |
| 712 |
<xsl:with-param name="name"> |
| 713 |
<xsl:call-template name="xpath.location"/> |
| 714 |
</xsl:with-param> |
| 715 |
<xsl:with-param name="purpose" select="$purpose"/> |
| 716 |
<xsl:with-param name="xrefstyle" select="$xrefstyle"/> |
| 717 |
<xsl:with-param name="referrer" select="$referrer"/> |
| 718 |
</xsl:call-template> |
| 719 |
</xsl:template> |
| 720 |
|
| 721 |
<xsl:template match="refentry" mode="xref-to"> |
| 722 |
<xsl:param name="referrer"/> |
| 723 |
|
| 724 |
<xsl:call-template name="hyperlink.markup"> |
| 725 |
<xsl:with-param name="referrer" select="$referrer"/> |
| 726 |
<xsl:with-param name="linkend" select="(@id|@xml:id)[1]"/> |
| 727 |
<xsl:with-param name="text"> |
| 728 |
<xsl:apply-templates |
| 729 |
select="(refmeta/refentrytitle|refnamediv/refname[1])[1]" |
| 730 |
mode="xref.text"/> |
| 731 |
<xsl:apply-templates select="refmeta/manvolnum"/> |
| 732 |
</xsl:with-param> |
| 733 |
</xsl:call-template> |
| 734 |
</xsl:template> |
| 735 |
|
| 736 |
<xsl:template match="refnamediv" mode="xref-to"> |
| 737 |
<xsl:param name="referrer"/> |
| 738 |
|
| 739 |
<xsl:call-template name="hyperlink.markup"> |
| 740 |
<xsl:with-param name="referrer" select="$referrer"/> |
| 741 |
<xsl:with-param name="linkend" select="(@id|@xml:id)[1]"/> |
| 742 |
<xsl:with-param name="text"> |
| 743 |
<xsl:apply-templates select="refname[1]" mode="xref.text"/> |
| 744 |
</xsl:with-param> |
| 745 |
</xsl:call-template> |
| 746 |
</xsl:template> |
| 747 |
|
| 748 |
<xsl:template match="varlistentry|term" mode="xref-to"> |
| 749 |
<xsl:param name="referrer"/> |
| 750 |
|
| 751 |
<xsl:call-template name="hyperlink.markup"> |
| 752 |
<xsl:with-param name="referrer" select="$referrer"/> |
| 753 |
<xsl:with-param name="linkend" select="(@id|@xml:id)[1]"/> |
| 754 |
<xsl:with-param name="text"> |
| 755 |
<xsl:choose> |
| 756 |
<xsl:when test="local-name(.)='term'"> |
| 757 |
<xsl:apply-templates select="." mode="xref.text"/> |
| 758 |
</xsl:when> |
| 759 |
<xsl:otherwise> |
| 760 |
<xsl:apply-templates select="term" mode="xref.text"/> |
| 761 |
</xsl:otherwise> |
| 762 |
</xsl:choose> |
| 763 |
</xsl:with-param> |
| 764 |
</xsl:call-template> |
| 765 |
</xsl:template> |
| 766 |
|
| 767 |
<xsl:template match="biblioentry|bibliomixed" mode="xref-to"> |
| 768 |
<xsl:text>\cite{</xsl:text> |
| 769 |
<xsl:call-template name="bibitem.id"/> |
| 770 |
<xsl:text>}</xsl:text> |
| 771 |
</xsl:template> |
| 772 |
|
| 773 |
<xsl:template match="glossentry" mode="xref-to"> |
| 774 |
<xsl:param name="referrer"/> |
| 775 |
|
| 776 |
<xsl:call-template name="hyperlink.markup"> |
| 777 |
<xsl:with-param name="referrer" select="$referrer"/> |
| 778 |
<xsl:with-param name="linkend" select="(@id|@xml:id)[1]"/> |
| 779 |
<xsl:with-param name="text"> |
| 780 |
<xsl:call-template name="inline.italicseq"> |
| 781 |
<xsl:with-param name="content"> |
| 782 |
<xsl:apply-templates select="glossterm" mode="xref.text"/> |
| 783 |
</xsl:with-param> |
| 784 |
</xsl:call-template> |
| 785 |
</xsl:with-param> |
| 786 |
</xsl:call-template> |
| 787 |
</xsl:template> |
| 788 |
|
| 789 |
<xsl:template match="cmdsynopsis" mode="xref-to"> |
| 790 |
<xsl:variable name="command" select="(.//command)[1]"/> |
| 791 |
<xsl:apply-templates select="$command" mode="xref"/> |
| 792 |
</xsl:template> |
| 793 |
|
| 794 |
<xsl:template match="funcsynopsis" mode="xref-to"> |
| 795 |
<xsl:variable name="func" select="(.//function)[1]"/> |
| 796 |
<xsl:apply-templates select="$func" mode="xref"/> |
| 797 |
</xsl:template> |
| 798 |
|
| 799 |
<xsl:template match="bibliography|glossary|index" mode="xref-to"> |
| 800 |
<xsl:param name="referrer"/> |
| 801 |
<xsl:param name="xrefstyle"/> |
| 802 |
<xsl:param name="verbose" select="1"/> |
| 803 |
|
| 804 |
<xsl:apply-templates select="." mode="object.xref.markup2"> |
| 805 |
<xsl:with-param name="purpose" select="'xref'"/> |
| 806 |
<xsl:with-param name="xrefstyle" select="$xrefstyle"/> |
| 807 |
<xsl:with-param name="referrer" select="$referrer"/> |
| 808 |
<xsl:with-param name="verbose" select="$verbose"/> |
| 809 |
</xsl:apply-templates> |
| 810 |
</xsl:template> |
| 811 |
|
| 812 |
<xsl:template match="reference" mode="xref-to"> |
| 813 |
<xsl:param name="referrer"/> |
| 814 |
<xsl:param name="xrefstyle"/> |
| 815 |
<xsl:param name="verbose" select="1"/> |
| 816 |
|
| 817 |
<xsl:apply-templates select="." mode="object.xref.markup2"> |
| 818 |
<xsl:with-param name="purpose" select="'xref'"/> |
| 819 |
<xsl:with-param name="xrefstyle" select="$xrefstyle"/> |
| 820 |
<xsl:with-param name="referrer" select="$referrer"/> |
| 821 |
<xsl:with-param name="verbose" select="$verbose"/> |
| 822 |
</xsl:apply-templates> |
| 823 |
</xsl:template> |
| 824 |
|
| 825 |
<!-- Xref to sidebar/qandaset --> |
| 826 |
<xsl:template match="sidebar" mode="xref-to"> |
| 827 |
<xsl:param name="referrer"/> |
| 828 |
<xsl:param name="xrefstyle"/> |
| 829 |
<xsl:param name="verbose" select="1"/> |
| 830 |
|
| 831 |
<xsl:apply-templates select="." mode="object.xref.markup2"> |
| 832 |
<xsl:with-param name="purpose" select="'xref'"/> |
| 833 |
<xsl:with-param name="xrefstyle" select="$xrefstyle"/> |
| 834 |
<xsl:with-param name="referrer" select="$referrer"/> |
| 835 |
<xsl:with-param name="verbose" select="$verbose"/> |
| 836 |
</xsl:apply-templates> |
| 837 |
</xsl:template> |
| 838 |
|
| 839 |
<xsl:template match="qandaset" mode="xref-to"> |
| 840 |
<xsl:param name="referrer"/> |
| 841 |
<xsl:param name="xrefstyle"/> |
| 842 |
<xsl:param name="verbose" select="1"/> |
| 843 |
|
| 844 |
<xsl:apply-templates select="." mode="object.xref.markup2"> |
| 845 |
<xsl:with-param name="purpose" select="'xref'"/> |
| 846 |
<xsl:with-param name="xrefstyle" select="$xrefstyle"/> |
| 847 |
<xsl:with-param name="referrer" select="$referrer"/> |
| 848 |
<xsl:with-param name="verbose" select="$verbose"/> |
| 849 |
</xsl:apply-templates> |
| 850 |
</xsl:template> |
| 851 |
|
| 852 |
<xsl:template match="question|answer" mode="xref-to"> |
| 853 |
<xsl:param name="referrer"/> |
| 854 |
<xsl:param name="xrefstyle"/> |
| 855 |
<xsl:param name="verbose" select="1"/> |
| 856 |
|
| 857 |
<xsl:apply-templates select="." mode="object.xref.markup2"> |
| 858 |
<xsl:with-param name="purpose" select="'xref'"/> |
| 859 |
<xsl:with-param name="xrefstyle" select="$xrefstyle"/> |
| 860 |
<xsl:with-param name="referrer" select="$referrer"/> |
| 861 |
<xsl:with-param name="verbose" select="$verbose"/> |
| 862 |
</xsl:apply-templates> |
| 863 |
</xsl:template> |
| 864 |
|
| 865 |
<xsl:template match="formalpara" mode="xref-to"> |
| 866 |
<xsl:param name="referrer"/> |
| 867 |
<xsl:param name="xrefstyle"/> |
| 868 |
<xsl:param name="verbose" select="1"/> |
| 869 |
|
| 870 |
<xsl:apply-templates select="." mode="object.xref.markup2"> |
| 871 |
<xsl:with-param name="purpose" select="'xref'"/> |
| 872 |
<xsl:with-param name="xrefstyle" select="$xrefstyle"/> |
| 873 |
<xsl:with-param name="referrer" select="$referrer"/> |
| 874 |
<xsl:with-param name="verbose" select="$verbose"/> |
| 875 |
</xsl:apply-templates> |
| 876 |
</xsl:template> |
| 877 |
|
| 878 |
<!-- hook to avoid numbered xref for preface sections --> |
| 879 |
<xsl:template match="preface/sect1| preface//sect2| |
| 880 |
preface//sect3| preface//sect4| |
| 881 |
preface//sect5| preface//section" |
| 882 |
mode="is.autonumber"> |
| 883 |
<xsl:value-of select="0"/> |
| 884 |
</xsl:template> |
| 885 |
|
| 886 |
<xsl:template match="co" mode="xref-to"> |
| 887 |
<xsl:call-template name="coref.link.create"> |
| 888 |
<xsl:with-param name="ref" select="(@id|@xml:id)[1]"/> |
| 889 |
<xsl:with-param name="circled" select="1"/> |
| 890 |
</xsl:call-template> |
| 891 |
</xsl:template> |
| 892 |
|
| 893 |
<!-- ==================================================================== --> |
| 894 |
|
| 895 |
<xsl:template match="olink"> |
| 896 |
<xsl:variable name="localinfo" select="@localinfo"/> |
| 897 |
|
| 898 |
<xsl:choose> |
| 899 |
<!-- olinks resolved by stylesheet and target database --> |
| 900 |
<xsl:when test="@targetdoc or @targetptr" > |
| 901 |
<xsl:variable name="targetdoc.att" select="@targetdoc"/> |
| 902 |
<xsl:variable name="targetptr.att" select="@targetptr"/> |
| 903 |
|
| 904 |
<xsl:variable name="olink.lang"> |
| 905 |
<xsl:call-template name="l10n.language"> |
| 906 |
<xsl:with-param name="xref-context" select="true()"/> |
| 907 |
</xsl:call-template> |
| 908 |
</xsl:variable> |
| 909 |
|
| 910 |
<xsl:variable name="target.database.filename"> |
| 911 |
<xsl:call-template name="select.target.database"> |
| 912 |
<xsl:with-param name="targetdoc.att" select="$targetdoc.att"/> |
| 913 |
<xsl:with-param name="targetptr.att" select="$targetptr.att"/> |
| 914 |
<xsl:with-param name="olink.lang" select="$olink.lang"/> |
| 915 |
</xsl:call-template> |
| 916 |
</xsl:variable> |
| 917 |
|
| 918 |
<xsl:variable name="target.database" |
| 919 |
select="document($target.database.filename, /)"/> |
| 920 |
|
| 921 |
<xsl:if test="$olink.debug != 0"> |
| 922 |
<xsl:message> |
| 923 |
<xsl:text>Olink debug: root element of target.database is '</xsl:text> |
| 924 |
<xsl:value-of select="local-name($target.database/*[1])"/> |
| 925 |
<xsl:text>'.</xsl:text> |
| 926 |
</xsl:message> |
| 927 |
</xsl:if> |
| 928 |
|
| 929 |
<xsl:variable name="olink.key"> |
| 930 |
<xsl:call-template name="select.olink.key"> |
| 931 |
<xsl:with-param name="targetdoc.att" select="$targetdoc.att"/> |
| 932 |
<xsl:with-param name="targetptr.att" select="$targetptr.att"/> |
| 933 |
<xsl:with-param name="olink.lang" select="$olink.lang"/> |
| 934 |
<xsl:with-param name="target.database" select="$target.database"/> |
| 935 |
</xsl:call-template> |
| 936 |
</xsl:variable> |
| 937 |
|
| 938 |
<xsl:if test="string-length($olink.key) = 0"> |
| 939 |
<xsl:message> |
| 940 |
<xsl:text>Error: unresolved olink: </xsl:text> |
| 941 |
<xsl:text>targetdoc/targetptr = '</xsl:text> |
| 942 |
<xsl:value-of select="$targetdoc.att"/> |
| 943 |
<xsl:text>/</xsl:text> |
| 944 |
<xsl:value-of select="$targetptr.att"/> |
| 945 |
<xsl:text>'.</xsl:text> |
| 946 |
</xsl:message> |
| 947 |
</xsl:if> |
| 948 |
|
| 949 |
<xsl:variable name="href"> |
| 950 |
<xsl:call-template name="make.olink.href"> |
| 951 |
<xsl:with-param name="olink.key" select="$olink.key"/> |
| 952 |
<xsl:with-param name="target.database" select="$target.database"/> |
| 953 |
</xsl:call-template> |
| 954 |
</xsl:variable> |
| 955 |
|
| 956 |
<!-- Olink that points to internal id can be a link --> |
| 957 |
<xsl:variable name="linkend"> |
| 958 |
<xsl:call-template name="olink.as.linkend"> |
| 959 |
<xsl:with-param name="olink.key" select="$olink.key"/> |
| 960 |
<xsl:with-param name="olink.lang" select="$olink.lang"/> |
| 961 |
<xsl:with-param name="target.database" select="$target.database"/> |
| 962 |
</xsl:call-template> |
| 963 |
</xsl:variable> |
| 964 |
|
| 965 |
<xsl:variable name="hottext"> |
| 966 |
<xsl:call-template name="olink.hottext"> |
| 967 |
<xsl:with-param name="olink.key" select="$olink.key"/> |
| 968 |
<xsl:with-param name="olink.lang" select="$olink.lang"/> |
| 969 |
<xsl:with-param name="target.database" select="$target.database"/> |
| 970 |
</xsl:call-template> |
| 971 |
</xsl:variable> |
| 972 |
|
| 973 |
<xsl:variable name="olink.docname.citation"> |
| 974 |
<xsl:call-template name="olink.document.citation"> |
| 975 |
<xsl:with-param name="olink.key" select="$olink.key"/> |
| 976 |
<xsl:with-param name="target.database" select="$target.database"/> |
| 977 |
<xsl:with-param name="olink.lang" select="$olink.lang"/> |
| 978 |
</xsl:call-template> |
| 979 |
</xsl:variable> |
| 980 |
|
| 981 |
<xsl:variable name="olink.page.citation"> |
| 982 |
<xsl:call-template name="olink.page.citation"> |
| 983 |
<xsl:with-param name="olink.key" select="$olink.key"/> |
| 984 |
<xsl:with-param name="target.database" select="$target.database"/> |
| 985 |
<xsl:with-param name="olink.lang" select="$olink.lang"/> |
| 986 |
<xsl:with-param name="linkend" select="$linkend"/> |
| 987 |
</xsl:call-template> |
| 988 |
</xsl:variable> |
| 989 |
|
| 990 |
<xsl:choose> |
| 991 |
<xsl:when test="$linkend != ''"> |
| 992 |
<!-- internal link --> |
| 993 |
<xsl:call-template name="hyperlink.markup"> |
| 994 |
<xsl:with-param name="linkend" select="$linkend"/> |
| 995 |
<xsl:with-param name="text" select="$hottext"/> |
| 996 |
</xsl:call-template> |
| 997 |
</xsl:when> |
| 998 |
<xsl:when test="$href != ''"> |
| 999 |
<!-- link to an external document --> |
| 1000 |
<xsl:call-template name="hyperref.format"> |
| 1001 |
<xsl:with-param name="href" select="$href"/> |
| 1002 |
<xsl:with-param name="hottext" select="$hottext"/> |
| 1003 |
</xsl:call-template> |
| 1004 |
<xsl:copy-of select="$olink.page.citation"/> |
| 1005 |
<xsl:copy-of select="$olink.docname.citation"/> |
| 1006 |
</xsl:when> |
| 1007 |
<xsl:otherwise> |
| 1008 |
<xsl:copy-of select="$hottext"/> |
| 1009 |
<xsl:copy-of select="$olink.page.citation"/> |
| 1010 |
<xsl:copy-of select="$olink.docname.citation"/> |
| 1011 |
</xsl:otherwise> |
| 1012 |
</xsl:choose> |
| 1013 |
</xsl:when> |
| 1014 |
|
| 1015 |
<!-- only XSL olink syntax supported --> |
| 1016 |
<xsl:otherwise> |
| 1017 |
<xsl:apply-templates/> |
| 1018 |
</xsl:otherwise> |
| 1019 |
</xsl:choose> |
| 1020 |
</xsl:template> |
| 1021 |
|
| 1022 |
<xsl:template name="olink.as.linkend"> |
| 1023 |
<xsl:param name="olink.key" select="''"/> |
| 1024 |
<xsl:param name="olink.lang" select="''"/> |
| 1025 |
<xsl:param name="target.database" select="NotANode"/> |
| 1026 |
|
| 1027 |
<xsl:variable name="targetdoc"> |
| 1028 |
<xsl:value-of select="substring-before($olink.key, '/')"/> |
| 1029 |
</xsl:variable> |
| 1030 |
|
| 1031 |
<xsl:variable name="targetptr"> |
| 1032 |
<xsl:value-of |
| 1033 |
select="substring-before(substring-after($olink.key, '/'), '/')"/> |
| 1034 |
</xsl:variable> |
| 1035 |
|
| 1036 |
<xsl:variable name="target.lang"> |
| 1037 |
<xsl:variable name="candidate"> |
| 1038 |
<xsl:for-each select="$target.database" > |
| 1039 |
<xsl:value-of |
| 1040 |
select="key('targetptr-key', $olink.key)/@lang" /> |
| 1041 |
</xsl:for-each> |
| 1042 |
</xsl:variable> |
| 1043 |
<xsl:choose> |
| 1044 |
<xsl:when test="$candidate != ''"> |
| 1045 |
<xsl:value-of select="$candidate"/> |
| 1046 |
</xsl:when> |
| 1047 |
<xsl:otherwise> |
| 1048 |
<xsl:value-of select="$olink.lang"/> |
| 1049 |
</xsl:otherwise> |
| 1050 |
</xsl:choose> |
| 1051 |
</xsl:variable> |
| 1052 |
|
| 1053 |
<xsl:if test="$current.docid = $targetdoc and |
| 1054 |
$olink.lang = $target.lang"> |
| 1055 |
<!-- |
| 1056 |
<xsl:message>targetdoc=<xsl:value-of select="$targetdoc"/></xsl:message> |
| 1057 |
<xsl:message>docid=<xsl:value-of select="$current.docid"/></xsl:message> |
| 1058 |
<xsl:message>lang=<xsl:value-of select="$target.lang"/></xsl:message> |
| 1059 |
<xsl:message>lang=<xsl:value-of select="$olink.lang"/></xsl:message> |
| 1060 |
<xsl:message>ptr=<xsl:value-of select="$targetptr"/></xsl:message> |
| 1061 |
--> |
| 1062 |
<xsl:variable name="targets" select="key('id',$targetptr)"/> |
| 1063 |
<xsl:variable name="target" select="$targets[1]"/> |
| 1064 |
<xsl:if test="$target"> |
| 1065 |
<xsl:value-of select="$targetptr"/> |
| 1066 |
</xsl:if> |
| 1067 |
</xsl:if> |
| 1068 |
|
| 1069 |
</xsl:template> |
| 1070 |
|
| 1071 |
<!-- ==================================================================== --> |
| 1072 |
|
| 1073 |
<xsl:template name="hyperref.format"> |
| 1074 |
<xsl:param name="href"/> |
| 1075 |
<xsl:param name="hottext"/> |
| 1076 |
<xsl:variable name="url" select="substring-before($href, '#')"/> |
| 1077 |
<xsl:variable name="name" select="substring-after($href, '#')"/> |
| 1078 |
<xsl:text>\hyperref{</xsl:text> |
| 1079 |
<xsl:value-of select="$url"/> |
| 1080 |
<!-- no specific 'category' --> |
| 1081 |
<xsl:text>}{}{</xsl:text> |
| 1082 |
<xsl:value-of select="$name"/> |
| 1083 |
<xsl:text>}{</xsl:text> |
| 1084 |
<xsl:value-of select="$hottext"/> |
| 1085 |
<xsl:text>}</xsl:text> |
| 1086 |
</xsl:template> |
| 1087 |
|
| 1088 |
<!-- ==================================================================== --> |
| 1089 |
|
| 1090 |
<xsl:template match="command" mode="xref"> |
| 1091 |
<xsl:call-template name="inline.boldseq"/> |
| 1092 |
</xsl:template> |
| 1093 |
|
| 1094 |
<xsl:template match="function" mode="xref"> |
| 1095 |
<xsl:call-template name="inline.monoseq"/> |
| 1096 |
</xsl:template> |
| 1097 |
|
| 1098 |
<!-- ==================================================================== --> |
| 1099 |
|
| 1100 |
<xsl:template match="*" mode="page.citation"> |
| 1101 |
<xsl:param name="id" select="'???'"/> |
| 1102 |
|
| 1103 |
<xsl:call-template name="substitute-markup"> |
| 1104 |
<xsl:with-param name="template"> |
| 1105 |
<xsl:call-template name="gentext.template"> |
| 1106 |
<xsl:with-param name="name" select="'page.citation'"/> |
| 1107 |
<xsl:with-param name="context" select="'xref'"/> |
| 1108 |
</xsl:call-template> |
| 1109 |
</xsl:with-param> |
| 1110 |
</xsl:call-template> |
| 1111 |
</xsl:template> |
| 1112 |
|
| 1113 |
<!-- ==================================================================== --> |
| 1114 |
|
| 1115 |
<xsl:template match="link" mode="no.anchor.mode" priority="1"> |
| 1116 |
<xsl:apply-templates select="." mode="xref.text"/> |
| 1117 |
</xsl:template> |
| 1118 |
|
| 1119 |
<!-- Escape tex characters in title markups --> |
| 1120 |
<xsl:template match="text()" mode="no.anchor.mode"> |
| 1121 |
<xsl:apply-templates select="."/> |
| 1122 |
</xsl:template> |
| 1123 |
|
| 1124 |
<!-- ==================================================================== --> |
| 1125 |
|
| 1126 |
<xsl:template match="part|chapter|appendix| |
| 1127 |
sect1|sect2|sect3|sect4|sect5|section" mode="label.markup" |
| 1128 |
priority="1"> |
| 1129 |
<xsl:text>\ref{</xsl:text> |
| 1130 |
<xsl:call-template name="id-encode"/> |
| 1131 |
<xsl:text>}</xsl:text> |
| 1132 |
</xsl:template> |
| 1133 |
|
| 1134 |
<xsl:template match="figure|example|table|equation" mode="label.markup" |
| 1135 |
priority="1"> |
| 1136 |
<xsl:text>\ref{</xsl:text> |
| 1137 |
<xsl:call-template name="id-encode"/> |
| 1138 |
<xsl:text>}</xsl:text> |
| 1139 |
</xsl:template> |
| 1140 |
|
| 1141 |
<xsl:template match="step" mode="label.markup" priority="1"> |
| 1142 |
<xsl:text>\ref{</xsl:text> |
| 1143 |
<xsl:call-template name="id-encode"/> |
| 1144 |
<xsl:text>}</xsl:text> |
| 1145 |
</xsl:template> |
| 1146 |
|
| 1147 |
<xsl:template match="*" mode="pagenumber.markup"> |
| 1148 |
<xsl:text>\pageref{</xsl:text> |
| 1149 |
<xsl:call-template name="id-encode"/> |
| 1150 |
<xsl:text>}</xsl:text> |
| 1151 |
</xsl:template> |
| 1152 |
|
| 1153 |
<!-- ==================================================================== --> |
| 1154 |
|
| 1155 |
<xsl:template match="*" mode="insert.title.markup"> |
| 1156 |
<xsl:param name="purpose"/> |
| 1157 |
<xsl:param name="xrefstyle"/> |
| 1158 |
<xsl:param name="title"/> |
| 1159 |
<xsl:param name="referrer"/> |
| 1160 |
|
| 1161 |
<xsl:call-template name="hyperlink.markup"> |
| 1162 |
<xsl:with-param name="referrer" select="$referrer"/> |
| 1163 |
<xsl:with-param name="linkend" select="(@id|@xml:id)[1]"/> |
| 1164 |
<xsl:with-param name="text" select="$title"/> |
| 1165 |
</xsl:call-template> |
| 1166 |
</xsl:template> |
| 1167 |
|
| 1168 |
<xsl:template match="*" mode="insert.subtitle.markup"> |
| 1169 |
<xsl:param name="purpose"/> |
| 1170 |
<xsl:param name="xrefstyle"/> |
| 1171 |
<xsl:param name="subtitle"/> |
| 1172 |
|
| 1173 |
<xsl:copy-of select="$subtitle"/> |
| 1174 |
</xsl:template> |
| 1175 |
|
| 1176 |
<xsl:template match="*" mode="insert.label.markup"> |
| 1177 |
<xsl:param name="purpose"/> |
| 1178 |
<xsl:param name="xrefstyle"/> |
| 1179 |
<xsl:param name="label"/> |
| 1180 |
|
| 1181 |
<xsl:copy-of select="$label"/> |
| 1182 |
</xsl:template> |
| 1183 |
|
| 1184 |
<xsl:template match="*" mode="insert.pagenumber.markup"> |
| 1185 |
<xsl:param name="purpose"/> |
| 1186 |
<xsl:param name="xrefstyle"/> |
| 1187 |
<xsl:param name="pagenumber"/> |
| 1188 |
|
| 1189 |
<xsl:copy-of select="$pagenumber"/> |
| 1190 |
</xsl:template> |
| 1191 |
|
| 1192 |
<xsl:template match="*" mode="insert.direction.markup"> |
| 1193 |
<xsl:param name="purpose"/> |
| 1194 |
<xsl:param name="xrefstyle"/> |
| 1195 |
<xsl:param name="direction"/> |
| 1196 |
|
| 1197 |
<xsl:copy-of select="$direction"/> |
| 1198 |
</xsl:template> |
| 1199 |
|
| 1200 |
<xsl:template match="*" mode="insert.olink.docname.markup"> |
| 1201 |
<xsl:param name="docname" select="''"/> |
| 1202 |
|
| 1203 |
<xsl:text>\emph{</xsl:text> |
| 1204 |
<xsl:copy-of select="$docname"/> |
| 1205 |
<xsl:text>}</xsl:text> |
| 1206 |
</xsl:template> |
| 1207 |
|
| 1208 |
</xsl:stylesheet> |