1<?xml version='1.0'?> 2<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 3 xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" 4 exclude-result-prefixes="doc" 5 version='1.0'> 6 7<!-- ******************************************************************** 8 $Id: gentext.xsl,v 1.34 2005/07/10 08:54:39 bobstayton Exp $ 9 ******************************************************************** 10 11 This file is part of the XSL DocBook Stylesheet distribution. 12 See /README or http://nwalsh.com/docbook/xsl/ for copyright 13 and other information. 14 15 ******************************************************************** --> 16 17<!-- ==================================================================== --> 18 19 20<xsl:template match="*" mode="object.title.template"> 21 <xsl:call-template name="gentext.template"> 22 <xsl:with-param name="context" select="'title'"/> 23 <xsl:with-param name="name"> 24 <xsl:call-template name="xpath.location"/> 25 </xsl:with-param> 26 </xsl:call-template> 27</xsl:template> 28 29<xsl:template match="chapter" mode="object.title.template"> 30 <xsl:choose> 31 <xsl:when test="string($chapter.autolabel) != 0"> 32 <xsl:call-template name="gentext.template"> 33 <xsl:with-param name="context" select="'title-numbered'"/> 34 <xsl:with-param name="name"> 35 <xsl:call-template name="xpath.location"/> 36 </xsl:with-param> 37 </xsl:call-template> 38 </xsl:when> 39 <xsl:otherwise> 40 <xsl:call-template name="gentext.template"> 41 <xsl:with-param name="context" select="'title-unnumbered'"/> 42 <xsl:with-param name="name"> 43 <xsl:call-template name="xpath.location"/> 44 </xsl:with-param> 45 </xsl:call-template> 46 </xsl:otherwise> 47 </xsl:choose> 48</xsl:template> 49 50<xsl:template match="appendix" mode="object.title.template"> 51 <xsl:choose> 52 <xsl:when test="string($appendix.autolabel) != 0"> 53 <xsl:call-template name="gentext.template"> 54 <xsl:with-param name="context" select="'title-numbered'"/> 55 <xsl:with-param name="name"> 56 <xsl:call-template name="xpath.location"/> 57 </xsl:with-param> 58 </xsl:call-template> 59 </xsl:when> 60 <xsl:otherwise> 61 <xsl:call-template name="gentext.template"> 62 <xsl:with-param name="context" select="'title-unnumbered'"/> 63 <xsl:with-param name="name"> 64 <xsl:call-template name="xpath.location"/> 65 </xsl:with-param> 66 </xsl:call-template> 67 </xsl:otherwise> 68 </xsl:choose> 69</xsl:template> 70 71<xsl:template match="part" mode="object.title.template"> 72 <xsl:choose> 73 <xsl:when test="string($part.autolabel) != 0"> 74 <xsl:call-template name="gentext.template"> 75 <xsl:with-param name="context" select="'title-numbered'"/> 76 <xsl:with-param name="name"> 77 <xsl:call-template name="xpath.location"/> 78 </xsl:with-param> 79 </xsl:call-template> 80 </xsl:when> 81 <xsl:otherwise> 82 <xsl:call-template name="gentext.template"> 83 <xsl:with-param name="context" select="'title-unnumbered'"/> 84 <xsl:with-param name="name"> 85 <xsl:call-template name="xpath.location"/> 86 </xsl:with-param> 87 </xsl:call-template> 88 </xsl:otherwise> 89 </xsl:choose> 90</xsl:template> 91 92<xsl:template match="section|sect1|sect2|sect3|sect4|sect5|simplesect 93 |bridgehead" 94 mode="object.title.template"> 95 <xsl:variable name="is.numbered"> 96 <xsl:call-template name="label.this.section"/> 97 </xsl:variable> 98 <xsl:choose> 99 <xsl:when test="$is.numbered != 0"> 100 <xsl:call-template name="gentext.template"> 101 <xsl:with-param name="context" select="'title-numbered'"/> 102 <xsl:with-param name="name"> 103 <xsl:call-template name="xpath.location"/> 104 </xsl:with-param> 105 </xsl:call-template> 106 </xsl:when> 107 <xsl:otherwise> 108 <xsl:call-template name="gentext.template"> 109 <xsl:with-param name="context" select="'title-unnumbered'"/> 110 <xsl:with-param name="name"> 111 <xsl:call-template name="xpath.location"/> 112 </xsl:with-param> 113 </xsl:call-template> 114 </xsl:otherwise> 115 </xsl:choose> 116</xsl:template> 117 118<xsl:template match="procedure" mode="object.title.template"> 119 <xsl:choose> 120 <xsl:when test="$formal.procedures != 0 and title"> 121 <xsl:call-template name="gentext.template"> 122 <xsl:with-param name="context" select="'title'"/> 123 <xsl:with-param name="name"> 124 <xsl:call-template name="xpath.location"/> 125 <xsl:text>.formal</xsl:text> 126 </xsl:with-param> 127 </xsl:call-template> 128 </xsl:when> 129 <xsl:otherwise> 130 <xsl:call-template name="gentext.template"> 131 <xsl:with-param name="context" select="'title'"/> 132 <xsl:with-param name="name"> 133 <xsl:call-template name="xpath.location"/> 134 </xsl:with-param> 135 </xsl:call-template> 136 </xsl:otherwise> 137 </xsl:choose> 138</xsl:template> 139 140<!-- ============================================================ --> 141 142<xsl:template match="*" mode="object.subtitle.template"> 143 <xsl:call-template name="gentext.template"> 144 <xsl:with-param name="context" select="'subtitle'"/> 145 <xsl:with-param name="name"> 146 <xsl:call-template name="xpath.location"/> 147 </xsl:with-param> 148 </xsl:call-template> 149</xsl:template> 150 151<!-- ============================================================ --> 152 153<xsl:template match="*" mode="is.autonumber"> 154 <xsl:value-of select="'0'"/> 155</xsl:template> 156 157<xsl:template match="section|sect1|sect2|sect3|sect4|sect5" 158 mode="is.autonumber"> 159 <xsl:call-template name="label.this.section"/> 160</xsl:template> 161 162<xsl:template match="figure|example|table|equation" mode="is.autonumber"> 163 <xsl:value-of select="'1'"/> 164</xsl:template> 165 166<xsl:template match="appendix" mode="is.autonumber"> 167 <xsl:value-of select="$appendix.autolabel"/> 168</xsl:template> 169 170<xsl:template match="chapter" mode="is.autonumber"> 171 <xsl:value-of select="$chapter.autolabel"/> 172</xsl:template> 173 174<xsl:template match="part" mode="is.autonumber"> 175 <xsl:value-of select="$part.autolabel"/> 176</xsl:template> 177 178<xsl:template match="preface" mode="is.autonumber"> 179 <xsl:value-of select="$preface.autolabel"/> 180</xsl:template> 181 182<xsl:template match="question|answer" mode="is.autonumber"> 183 <xsl:choose> 184 <xsl:when test="$qanda.defaultlabel = 'number' 185 and not(label)"> 186 <xsl:value-of select="'1'"/> 187 </xsl:when> 188 <xsl:otherwise> 189 <xsl:value-of select="'0'"/> 190 </xsl:otherwise> 191 </xsl:choose> 192</xsl:template> 193 194<xsl:template match="qandadiv" mode="is.autonumber"> 195 <xsl:value-of select="$qandadiv.autolabel"/> 196</xsl:template> 197 198<xsl:template match="bridgehead" mode="is.autonumber"> 199 <xsl:value-of select="$section.autolabel"/> 200</xsl:template> 201 202<xsl:template match="*" mode="object.xref.template"> 203 <xsl:param name="purpose"/> 204 <xsl:param name="xrefstyle"/> 205 <xsl:param name="referrer"/> 206 207 <!-- Is autonumbering on? --> 208 <xsl:variable name="autonumber"> 209 <xsl:apply-templates select="." mode="is.autonumber"/> 210 </xsl:variable> 211 212 <xsl:variable name="number-and-title-template"> 213 <xsl:call-template name="gentext.template.exists"> 214 <xsl:with-param name="context" select="'xref-number-and-title'"/> 215 <xsl:with-param name="name"> 216 <xsl:call-template name="xpath.location"/> 217 </xsl:with-param> 218 </xsl:call-template> 219 </xsl:variable> 220 221 <xsl:variable name="number-template"> 222 <xsl:call-template name="gentext.template.exists"> 223 <xsl:with-param name="context" select="'xref-number'"/> 224 <xsl:with-param name="name"> 225 <xsl:call-template name="xpath.location"/> 226 </xsl:with-param> 227 </xsl:call-template> 228 </xsl:variable> 229 230 <xsl:variable name="context"> 231 <xsl:choose> 232 <xsl:when test="string($autonumber) != 0 233 and $number-and-title-template != 0 234 and $xref.with.number.and.title != 0"> 235 <xsl:value-of select="'xref-number-and-title'"/> 236 </xsl:when> 237 <xsl:when test="string($autonumber) != 0 238 and $number-template != 0"> 239 <xsl:value-of select="'xref-number'"/> 240 </xsl:when> 241 <xsl:otherwise> 242 <xsl:value-of select="'xref'"/> 243 </xsl:otherwise> 244 </xsl:choose> 245 </xsl:variable> 246 247 <xsl:call-template name="gentext.template"> 248 <xsl:with-param name="context" select="$context"/> 249 <xsl:with-param name="name"> 250 <xsl:call-template name="xpath.location"/> 251 </xsl:with-param> 252 <xsl:with-param name="purpose" select="$purpose"/> 253 <xsl:with-param name="xrefstyle" select="$xrefstyle"/> 254 <xsl:with-param name="referrer" select="$referrer"/> 255 </xsl:call-template> 256 257</xsl:template> 258 259 260<!-- ============================================================ --> 261 262<xsl:template match="*" mode="object.title.markup"> 263 <xsl:param name="allow-anchors" select="0"/> 264 <xsl:variable name="template"> 265 <xsl:apply-templates select="." mode="object.title.template"/> 266 </xsl:variable> 267 268<!-- 269 <xsl:message> 270 <xsl:text>object.title.markup: </xsl:text> 271 <xsl:value-of select="local-name(.)"/> 272 <xsl:text>: </xsl:text> 273 <xsl:value-of select="$template"/> 274 </xsl:message> 275--> 276 277 <xsl:call-template name="substitute-markup"> 278 <xsl:with-param name="allow-anchors" select="$allow-anchors"/> 279 <xsl:with-param name="template" select="$template"/> 280 </xsl:call-template> 281</xsl:template> 282 283<xsl:template match="*" mode="object.title.markup.textonly"> 284 <xsl:variable name="title"> 285 <xsl:apply-templates select="." mode="object.title.markup"/> 286 </xsl:variable> 287 <xsl:value-of select="$title"/> 288</xsl:template> 289 290<!-- ============================================================ --> 291 292<xsl:template match="*" mode="object.titleabbrev.markup"> 293 <xsl:param name="allow-anchors" select="0"/> 294 295 <!-- Just for consistency in template naming --> 296 297 <xsl:apply-templates select="." mode="titleabbrev.markup"> 298 <xsl:with-param name="allow-anchors" select="$allow-anchors"/> 299 </xsl:apply-templates> 300</xsl:template> 301 302<!-- ============================================================ --> 303 304<xsl:template match="*" mode="object.subtitle.markup"> 305 <xsl:variable name="template"> 306 <xsl:apply-templates select="." mode="object.subtitle.template"/> 307 </xsl:variable> 308 309 <xsl:call-template name="substitute-markup"> 310 <xsl:with-param name="template" select="$template"/> 311 </xsl:call-template> 312</xsl:template> 313 314<!-- ============================================================ --> 315 316<xsl:template match="*" mode="object.xref.markup"> 317 <xsl:param name="purpose"/> 318 <xsl:param name="xrefstyle"/> 319 <xsl:param name="referrer"/> 320 <xsl:param name="verbose" select="1"/> 321 322 <xsl:variable name="template"> 323 <xsl:choose> 324 <xsl:when test="starts-with(normalize-space($xrefstyle), 'select:')"> 325 <xsl:call-template name="make.gentext.template"> 326 <xsl:with-param name="xrefstyle" select="$xrefstyle"/> 327 <xsl:with-param name="purpose" select="$purpose"/> 328 <xsl:with-param name="referrer" select="$referrer"/> 329 </xsl:call-template> 330 </xsl:when> 331 <xsl:when test="starts-with(normalize-space($xrefstyle), 'template:')"> 332 <xsl:value-of select="substring-after(normalize-space($xrefstyle), 'template:')"/> 333 </xsl:when> 334 <xsl:otherwise> 335 <xsl:apply-templates select="." mode="object.xref.template"> 336 <xsl:with-param name="purpose" select="$purpose"/> 337 <xsl:with-param name="xrefstyle" select="$xrefstyle"/> 338 <xsl:with-param name="referrer" select="$referrer"/> 339 </xsl:apply-templates> 340 </xsl:otherwise> 341 </xsl:choose> 342 </xsl:variable> 343 344<!-- 345 <xsl:message> 346 <xsl:text>object.xref.markup: </xsl:text> 347 <xsl:value-of select="local-name(.)"/> 348 <xsl:text>(</xsl:text> 349 <xsl:value-of select="$xrefstyle"/> 350 <xsl:text>, </xsl:text> 351 <xsl:value-of select="$purpose"/> 352 <xsl:text>)</xsl:text> 353 <xsl:text>: [</xsl:text> 354 <xsl:value-of select="$template"/> 355 <xsl:text>]</xsl:text> 356 </xsl:message> 357--> 358 359 <xsl:if test="$template = '' and $verbose != 0"> 360 <xsl:message> 361 <xsl:text>object.xref.markup: empty xref template</xsl:text> 362 <xsl:text> for linkend="</xsl:text> 363 <xsl:value-of select="@id"/> 364 <xsl:text>" and @xrefstyle="</xsl:text> 365 <xsl:value-of select="$xrefstyle"/> 366 <xsl:text>"</xsl:text> 367 </xsl:message> 368 </xsl:if> 369 370 <xsl:call-template name="substitute-markup"> 371 <xsl:with-param name="purpose" select="$purpose"/> 372 <xsl:with-param name="xrefstyle" select="$xrefstyle"/> 373 <xsl:with-param name="referrer" select="$referrer"/> 374 <xsl:with-param name="template" select="$template"/> 375 <xsl:with-param name="verbose" select="$verbose"/> 376 </xsl:call-template> 377</xsl:template> 378 379<xsl:template match="listitem" mode="object.xref.markup"> 380 <xsl:param name="verbose" select="1"/> 381 382 <xsl:choose> 383 <xsl:when test="parent::orderedlist"> 384 <xsl:variable name="template"> 385 <xsl:apply-templates select="." mode="object.xref.template"/> 386 </xsl:variable> 387 <xsl:call-template name="substitute-markup"> 388 <xsl:with-param name="template" select="$template"/> 389 </xsl:call-template> 390 </xsl:when> 391 <xsl:when test="$verbose != 0"> 392 <xsl:message> 393 <xsl:text>Xref is only supported to listitems in an</xsl:text> 394 <xsl:text> orderedlist: </xsl:text> 395 <xsl:value-of select="@id"/> 396 </xsl:message> 397 <xsl:text>???</xsl:text> 398 </xsl:when> 399 </xsl:choose> 400</xsl:template> 401 402<xsl:template match="question" mode="object.xref.markup"> 403 <xsl:param name="purpose"/> 404 <xsl:param name="xrefstyle"/> 405 <xsl:param name="referrer"/> 406 407 <xsl:variable name="deflabel"> 408 <xsl:choose> 409 <xsl:when test="ancestor-or-self::*[@defaultlabel]"> 410 <xsl:value-of select="(ancestor-or-self::*[@defaultlabel])[last()] 411 /@defaultlabel"/> 412 </xsl:when> 413 <xsl:otherwise> 414 <xsl:value-of select="$qanda.defaultlabel"/> 415 </xsl:otherwise> 416 </xsl:choose> 417 </xsl:variable> 418 419 <xsl:variable name="template"> 420 <xsl:choose> 421 <!-- This avoids double Q: Q: in xref when defaultlabel=qanda --> 422 <xsl:when test="$deflabel = 'qanda' and not(label)">%n</xsl:when> 423 <xsl:otherwise> 424 <xsl:apply-templates select="." mode="object.xref.template"> 425 <xsl:with-param name="purpose" select="$purpose"/> 426 <xsl:with-param name="xrefstyle" select="$xrefstyle"/> 427 <xsl:with-param name="referrer" select="$referrer"/> 428 </xsl:apply-templates> 429 </xsl:otherwise> 430 </xsl:choose> 431 </xsl:variable> 432 433 <xsl:call-template name="substitute-markup"> 434 <xsl:with-param name="purpose" select="$purpose"/> 435 <xsl:with-param name="xrefstyle" select="$xrefstyle"/> 436 <xsl:with-param name="referrer" select="$referrer"/> 437 <xsl:with-param name="template" select="$template"/> 438 </xsl:call-template> 439</xsl:template> 440 441<!-- ============================================================ --> 442 443<xsl:template name="substitute-markup"> 444 <xsl:param name="template" select="''"/> 445 <xsl:param name="allow-anchors" select="'0'"/> 446 <xsl:param name="title" select="''"/> 447 <xsl:param name="subtitle" select="''"/> 448 <xsl:param name="docname" select="''"/> 449 <xsl:param name="label" select="''"/> 450 <xsl:param name="pagenumber" select="''"/> 451 <xsl:param name="purpose"/> 452 <xsl:param name="xrefstyle"/> 453 <xsl:param name="referrer"/> 454 <xsl:param name="verbose"/> 455 456 <xsl:choose> 457 <xsl:when test="contains($template, '%')"> 458 <xsl:value-of select="substring-before($template, '%')"/> 459 <xsl:variable name="candidate" 460 select="substring(substring-after($template, '%'), 1, 1)"/> 461 <xsl:choose> 462 <xsl:when test="$candidate = 't'"> 463 <xsl:apply-templates select="." mode="insert.title.markup"> 464 <xsl:with-param name="purpose" select="$purpose"/> 465 <xsl:with-param name="xrefstyle" select="$xrefstyle"/> 466 <xsl:with-param name="title"> 467 <xsl:choose> 468 <xsl:when test="$title != ''"> 469 <xsl:copy-of select="$title"/> 470 </xsl:when> 471 <xsl:otherwise> 472 <xsl:apply-templates select="." mode="title.markup"> 473 <xsl:with-param name="allow-anchors" select="$allow-anchors"/> 474 <xsl:with-param name="verbose" select="$verbose"/> 475 </xsl:apply-templates> 476 </xsl:otherwise> 477 </xsl:choose> 478 </xsl:with-param> 479 </xsl:apply-templates> 480 </xsl:when> 481 <xsl:when test="$candidate = 's'"> 482 <xsl:apply-templates select="." mode="insert.subtitle.markup"> 483 <xsl:with-param name="purpose" select="$purpose"/> 484 <xsl:with-param name="xrefstyle" select="$xrefstyle"/> 485 <xsl:with-param name="subtitle"> 486 <xsl:choose> 487 <xsl:when test="$subtitle != ''"> 488 <xsl:copy-of select="$subtitle"/> 489 </xsl:when> 490 <xsl:otherwise> 491 <xsl:apply-templates select="." mode="subtitle.markup"> 492 <xsl:with-param name="allow-anchors" select="$allow-anchors"/> 493 </xsl:apply-templates> 494 </xsl:otherwise> 495 </xsl:choose> 496 </xsl:with-param> 497 </xsl:apply-templates> 498 </xsl:when> 499 <xsl:when test="$candidate = 'n'"> 500 <xsl:apply-templates select="." mode="insert.label.markup"> 501 <xsl:with-param name="purpose" select="$purpose"/> 502 <xsl:with-param name="xrefstyle" select="$xrefstyle"/> 503 <xsl:with-param name="label"> 504 <xsl:choose> 505 <xsl:when test="$label != ''"> 506 <xsl:copy-of select="$label"/> 507 </xsl:when> 508 <xsl:otherwise> 509 <xsl:apply-templates select="." mode="label.markup"/> 510 </xsl:otherwise> 511 </xsl:choose> 512 </xsl:with-param> 513 </xsl:apply-templates> 514 </xsl:when> 515 <xsl:when test="$candidate = 'p'"> 516 <xsl:apply-templates select="." mode="insert.pagenumber.markup"> 517 <xsl:with-param name="purpose" select="$purpose"/> 518 <xsl:with-param name="xrefstyle" select="$xrefstyle"/> 519 <xsl:with-param name="pagenumber"> 520 <xsl:choose> 521 <xsl:when test="$pagenumber != ''"> 522 <xsl:copy-of select="$pagenumber"/> 523 </xsl:when> 524 <xsl:otherwise> 525 <xsl:apply-templates select="." mode="pagenumber.markup"/> 526 </xsl:otherwise> 527 </xsl:choose> 528 </xsl:with-param> 529 </xsl:apply-templates> 530 </xsl:when> 531 <xsl:when test="$candidate = 'o'"> 532 <!-- olink target document title --> 533 <xsl:apply-templates select="." mode="insert.olink.docname.markup"> 534 <xsl:with-param name="purpose" select="$purpose"/> 535 <xsl:with-param name="xrefstyle" select="$xrefstyle"/> 536 <xsl:with-param name="docname"> 537 <xsl:choose> 538 <xsl:when test="$docname != ''"> 539 <xsl:copy-of select="$docname"/> 540 </xsl:when> 541 <xsl:otherwise> 542 <xsl:apply-templates select="." mode="olink.docname.markup"/> 543 </xsl:otherwise> 544 </xsl:choose> 545 </xsl:with-param> 546 </xsl:apply-templates> 547 </xsl:when> 548 <xsl:when test="$candidate = 'd'"> 549 <xsl:apply-templates select="." mode="insert.direction.markup"> 550 <xsl:with-param name="purpose" select="$purpose"/> 551 <xsl:with-param name="xrefstyle" select="$xrefstyle"/> 552 <xsl:with-param name="direction"> 553 <xsl:choose> 554 <xsl:when test="$referrer"> 555 <xsl:variable name="referent-is-below"> 556 <xsl:for-each select="preceding::xref"> 557 <xsl:if test="generate-id(.) = generate-id($referrer)">1</xsl:if> 558 </xsl:for-each> 559 </xsl:variable> 560 <xsl:choose> 561 <xsl:when test="$referent-is-below = ''"> 562 <xsl:call-template name="gentext"> 563 <xsl:with-param name="key" select="'above'"/> 564 </xsl:call-template> 565 </xsl:when> 566 <xsl:otherwise> 567 <xsl:call-template name="gentext"> 568 <xsl:with-param name="key" select="'below'"/> 569 </xsl:call-template> 570 </xsl:otherwise> 571 </xsl:choose> 572 </xsl:when> 573 <xsl:otherwise> 574 <xsl:message>Attempt to use %d in gentext with no referrer!</xsl:message> 575 </xsl:otherwise> 576 </xsl:choose> 577 </xsl:with-param> 578 </xsl:apply-templates> 579 </xsl:when> 580 <xsl:when test="$candidate = '%' "> 581 <xsl:text>%</xsl:text> 582 </xsl:when> 583 <xsl:otherwise> 584 <xsl:text>%</xsl:text><xsl:value-of select="$candidate"/> 585 </xsl:otherwise> 586 </xsl:choose> 587 <!-- recurse with the rest of the template string --> 588 <xsl:variable name="rest" 589 select="substring($template, 590 string-length(substring-before($template, '%'))+3)"/> 591 <xsl:call-template name="substitute-markup"> 592 <xsl:with-param name="template" select="$rest"/> 593 <xsl:with-param name="allow-anchors" select="$allow-anchors"/> 594 <xsl:with-param name="title" select="$title"/> 595 <xsl:with-param name="subtitle" select="$subtitle"/> 596 <xsl:with-param name="docname" select="$docname"/> 597 <xsl:with-param name="label" select="$label"/> 598 <xsl:with-param name="pagenumber" select="$pagenumber"/> 599 <xsl:with-param name="purpose" select="$purpose"/> 600 <xsl:with-param name="xrefstyle" select="$xrefstyle"/> 601 <xsl:with-param name="referrer" select="$referrer"/> 602 <xsl:with-param name="verbose" select="$verbose"/> 603 </xsl:call-template> 604 </xsl:when> 605 <xsl:otherwise> 606 <xsl:value-of select="$template"/> 607 </xsl:otherwise> 608 </xsl:choose> 609</xsl:template> 610 611<!-- ============================================================ --> 612 613<xsl:template name="make.gentext.template"> 614 <xsl:param name="xrefstyle" select="''"/> 615 <xsl:param name="purpose"/> 616 <xsl:param name="referrer"/> 617 <xsl:param name="lang"> 618 <xsl:call-template name="l10n.language"/> 619 </xsl:param> 620 <xsl:param name="target.elem" select="local-name(.)"/> 621 622 <!-- parse xrefstyle to get parts --> 623 <xsl:variable name="parts" 624 select="substring-after(normalize-space($xrefstyle), 'select:')"/> 625 626 <xsl:variable name="labeltype"> 627 <xsl:choose> 628 <xsl:when test="contains($parts, 'labelnumber')"> 629 <xsl:text>labelnumber</xsl:text> 630 </xsl:when> 631 <xsl:when test="contains($parts, 'labelname')"> 632 <xsl:text>labelname</xsl:text> 633 </xsl:when> 634 <xsl:when test="contains($parts, 'label')"> 635 <xsl:text>label</xsl:text> 636 </xsl:when> 637 </xsl:choose> 638 </xsl:variable> 639 640 <xsl:variable name="titletype"> 641 <xsl:choose> 642 <xsl:when test="contains($parts, 'quotedtitle')"> 643 <xsl:text>quotedtitle</xsl:text> 644 </xsl:when> 645 <xsl:when test="contains($parts, 'title')"> 646 <xsl:text>title</xsl:text> 647 </xsl:when> 648 </xsl:choose> 649 </xsl:variable> 650 651 <xsl:variable name="pagetype"> 652 <xsl:choose> 653 <xsl:when test="$insert.olink.page.number = 'no' and 654 local-name($referrer) = 'olink'"> 655 <!-- suppress page numbers --> 656 </xsl:when> 657 <xsl:when test="$insert.xref.page.number = 'no' and 658 local-name($referrer) != 'olink'"> 659 <!-- suppress page numbers --> 660 </xsl:when> 661 <xsl:when test="contains($parts, 'nopage')"> 662 <xsl:text>nopage</xsl:text> 663 </xsl:when> 664 <xsl:when test="contains($parts, 'pagenumber')"> 665 <xsl:text>pagenumber</xsl:text> 666 </xsl:when> 667 <xsl:when test="contains($parts, 'pageabbrev')"> 668 <xsl:text>pageabbrev</xsl:text> 669 </xsl:when> 670 <xsl:when test="contains($parts, 'Page')"> 671 <xsl:text>Page</xsl:text> 672 </xsl:when> 673 <xsl:when test="contains($parts, 'page')"> 674 <xsl:text>page</xsl:text> 675 </xsl:when> 676 </xsl:choose> 677 </xsl:variable> 678 679 <xsl:variable name="docnametype"> 680 <xsl:choose> 681 <xsl:when test="($olink.doctitle = 0 or 682 $olink.doctitle = 'no') and 683 local-name($referrer) = 'olink'"> 684 <!-- suppress docname --> 685 </xsl:when> 686 <xsl:when test="contains($parts, 'nodocname')"> 687 <xsl:text>nodocname</xsl:text> 688 </xsl:when> 689 <xsl:when test="contains($parts, 'docnamelong')"> 690 <xsl:text>docnamelong</xsl:text> 691 </xsl:when> 692 <xsl:when test="contains($parts, 'docname')"> 693 <xsl:text>docname</xsl:text> 694 </xsl:when> 695 </xsl:choose> 696 </xsl:variable> 697 698 <xsl:if test="$labeltype != ''"> 699 <xsl:choose> 700 <xsl:when test="$labeltype = 'labelname'"> 701 <xsl:call-template name="gentext"> 702 <xsl:with-param name="key"> 703 <xsl:choose> 704 <xsl:when test="local-name($referrer) = 'olink'"> 705 <xsl:value-of select="$target.elem"/> 706 </xsl:when> 707 <xsl:otherwise> 708 <xsl:value-of select="local-name(.)"/> 709 </xsl:otherwise> 710 </xsl:choose> 711 </xsl:with-param> 712 </xsl:call-template> 713 </xsl:when> 714 <xsl:when test="$labeltype = 'labelnumber'"> 715 <xsl:text>%n</xsl:text> 716 </xsl:when> 717 <xsl:when test="$labeltype = 'label'"> 718 <xsl:call-template name="gentext.template"> 719 <xsl:with-param name="context" select="'xref-number'"/> 720 <xsl:with-param name="name"> 721 <xsl:choose> 722 <xsl:when test="local-name($referrer) = 'olink'"> 723 <xsl:value-of select="$target.elem"/> 724 </xsl:when> 725 <xsl:otherwise> 726 <xsl:call-template name="xpath.location"/> 727 </xsl:otherwise> 728 </xsl:choose> 729 </xsl:with-param> 730 <xsl:with-param name="purpose" select="$purpose"/> 731 <xsl:with-param name="xrefstyle" select="$xrefstyle"/> 732 <xsl:with-param name="referrer" select="$referrer"/> 733 </xsl:call-template> 734 </xsl:when> 735 </xsl:choose> 736 737 <xsl:choose> 738 <xsl:when test="$titletype != ''"> 739 <xsl:value-of select="$xref.label-title.separator"/> 740 </xsl:when> 741 <xsl:when test="$pagetype != ''"> 742 <xsl:value-of select="$xref.label-page.separator"/> 743 </xsl:when> 744 </xsl:choose> 745 </xsl:if> 746 747 <xsl:if test="$titletype != ''"> 748 <xsl:choose> 749 <xsl:when test="$titletype = 'title'"> 750 <xsl:text>%t</xsl:text> 751 </xsl:when> 752 <xsl:when test="$titletype = 'quotedtitle'"> 753 <xsl:call-template name="gentext.dingbat"> 754 <xsl:with-param name="dingbat" select="'startquote'"/> 755 </xsl:call-template> 756 <xsl:text>%t</xsl:text> 757 <xsl:call-template name="gentext.dingbat"> 758 <xsl:with-param name="dingbat" select="'endquote'"/> 759 </xsl:call-template> 760 </xsl:when> 761 </xsl:choose> 762 763 <xsl:choose> 764 <xsl:when test="$pagetype != '' and $pagetype != 'nopage'"> 765 <xsl:value-of select="$xref.title-page.separator"/> 766 </xsl:when> 767 </xsl:choose> 768 </xsl:if> 769 770 <!-- special case: use regular xref template if just turning off page --> 771 <xsl:if test="($pagetype = 'nopage' or $docnametype = 'nodocname') 772 and local-name($referrer) != 'olink' 773 and $labeltype = '' 774 and $titletype = ''"> 775 <xsl:apply-templates select="." mode="object.xref.template"> 776 <xsl:with-param name="purpose" select="$purpose"/> 777 <xsl:with-param name="xrefstyle" select="$xrefstyle"/> 778 <xsl:with-param name="referrer" select="$referrer"/> 779 </xsl:apply-templates> 780 </xsl:if> 781 782 <xsl:if test="$pagetype != ''"> 783 <xsl:choose> 784 <xsl:when test="$pagetype = 'page'"> 785 <xsl:call-template name="gentext.template"> 786 <xsl:with-param name="context" select="'xref'"/> 787 <xsl:with-param name="name" select="'page'"/> 788 </xsl:call-template> 789 </xsl:when> 790 <xsl:when test="$pagetype = 'Page'"> 791 <xsl:call-template name="gentext.template"> 792 <xsl:with-param name="context" select="'xref'"/> 793 <xsl:with-param name="name" select="'Page'"/> 794 </xsl:call-template> 795 </xsl:when> 796 <xsl:when test="$pagetype = 'pageabbrev'"> 797 <xsl:call-template name="gentext.template"> 798 <xsl:with-param name="context" select="'xref'"/> 799 <xsl:with-param name="name" select="'pageabbrev'"/> 800 </xsl:call-template> 801 </xsl:when> 802 <xsl:when test="$pagetype = 'pagenumber'"> 803 <xsl:text>%p</xsl:text> 804 </xsl:when> 805 </xsl:choose> 806 807 </xsl:if> 808 809 <!-- Add reference to other document title --> 810 <xsl:if test="$docnametype != '' and local-name($referrer) = 'olink'"> 811 <!-- Any separator should be in the gentext template --> 812 <xsl:choose> 813 <xsl:when test="$docnametype = 'docnamelong'"> 814 <xsl:call-template name="gentext.template"> 815 <xsl:with-param name="context" select="'xref'"/> 816 <xsl:with-param name="name" select="'docnamelong'"/> 817 </xsl:call-template> 818 </xsl:when> 819 <xsl:when test="$docnametype = 'docname'"> 820 <xsl:call-template name="gentext.template"> 821 <xsl:with-param name="context" select="'xref'"/> 822 <xsl:with-param name="name" select="'docname'"/> 823 </xsl:call-template> 824 </xsl:when> 825 </xsl:choose> 826 827 </xsl:if> 828 829</xsl:template> 830 831</xsl:stylesheet> 832