1<?xml version="1.0"?> 2<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 3 version="1.0"> 4 5<!-- ******************************************************************** 6 $Id: chunk-common.xsl,v 1.45 2006/04/27 08:59:37 xmldoc Exp $ 7 ******************************************************************** 8 9 This file is part of the XSL DocBook Stylesheet distribution. 10 See /README or http://nwalsh.com/docbook/xsl/ for copyright 11 and other information. 12 13 ******************************************************************** --> 14 15<!-- ==================================================================== --> 16 17<xsl:template name="chunk"> 18 <xsl:param name="node" select="."/> 19 <!-- returns 1 if $node is a chunk --> 20 21 <!-- ==================================================================== --> 22 <!-- What's a chunk? 23 24 The root element 25 appendix 26 article 27 bibliography in article or part or book 28 book 29 chapter 30 colophon 31 glossary in article or part or book 32 index in article or part or book 33 part 34 preface 35 refentry 36 reference 37 sect{1,2,3,4,5} if position()>1 && depth < chunk.section.depth 38 section if position()>1 && depth < chunk.section.depth 39 set 40 setindex 41 --> 42 <!-- ==================================================================== --> 43 44<!-- 45 <xsl:message> 46 <xsl:text>chunk: </xsl:text> 47 <xsl:value-of select="name($node)"/> 48 <xsl:text>(</xsl:text> 49 <xsl:value-of select="$node/@id"/> 50 <xsl:text>)</xsl:text> 51 <xsl:text> csd: </xsl:text> 52 <xsl:value-of select="$chunk.section.depth"/> 53 <xsl:text> cfs: </xsl:text> 54 <xsl:value-of select="$chunk.first.sections"/> 55 <xsl:text> ps: </xsl:text> 56 <xsl:value-of select="count($node/parent::section)"/> 57 <xsl:text> prs: </xsl:text> 58 <xsl:value-of select="count($node/preceding-sibling::section)"/> 59 </xsl:message> 60--> 61 62 <xsl:choose> 63 <xsl:when test="not($node/parent::*)">1</xsl:when> 64 65 <xsl:when test="local-name($node) = 'sect1' 66 and $chunk.section.depth >= 1 67 and ($chunk.first.sections != 0 68 or count($node/preceding-sibling::sect1) > 0)"> 69 <xsl:text>1</xsl:text> 70 </xsl:when> 71 <xsl:when test="local-name($node) = 'sect2' 72 and $chunk.section.depth >= 2 73 and ($chunk.first.sections != 0 74 or count($node/preceding-sibling::sect2) > 0)"> 75 <xsl:call-template name="chunk"> 76 <xsl:with-param name="node" select="$node/parent::*"/> 77 </xsl:call-template> 78 </xsl:when> 79 <xsl:when test="local-name($node) = 'sect3' 80 and $chunk.section.depth >= 3 81 and ($chunk.first.sections != 0 82 or count($node/preceding-sibling::sect3) > 0)"> 83 <xsl:call-template name="chunk"> 84 <xsl:with-param name="node" select="$node/parent::*"/> 85 </xsl:call-template> 86 </xsl:when> 87 <xsl:when test="local-name($node) = 'sect4' 88 and $chunk.section.depth >= 4 89 and ($chunk.first.sections != 0 90 or count($node/preceding-sibling::sect4) > 0)"> 91 <xsl:call-template name="chunk"> 92 <xsl:with-param name="node" select="$node/parent::*"/> 93 </xsl:call-template> 94 </xsl:when> 95 <xsl:when test="local-name($node) = 'sect5' 96 and $chunk.section.depth >= 5 97 and ($chunk.first.sections != 0 98 or count($node/preceding-sibling::sect5) > 0)"> 99 <xsl:call-template name="chunk"> 100 <xsl:with-param name="node" select="$node/parent::*"/> 101 </xsl:call-template> 102 </xsl:when> 103 <xsl:when test="local-name($node) = 'section' 104 and $chunk.section.depth >= count($node/ancestor::section)+1 105 and ($chunk.first.sections != 0 106 or count($node/preceding-sibling::section) > 0)"> 107 <xsl:call-template name="chunk"> 108 <xsl:with-param name="node" select="$node/parent::*"/> 109 </xsl:call-template> 110 </xsl:when> 111 112 <xsl:when test="local-name($node)='preface'">1</xsl:when> 113 <xsl:when test="local-name($node)='chapter'">1</xsl:when> 114 <xsl:when test="local-name($node)='appendix'">1</xsl:when> 115 <xsl:when test="local-name($node)='article'">1</xsl:when> 116 <xsl:when test="local-name($node)='part'">1</xsl:when> 117 <xsl:when test="local-name($node)='reference'">1</xsl:when> 118 <xsl:when test="local-name($node)='refentry'">1</xsl:when> 119 <xsl:when test="local-name($node)='index' and ($generate.index != 0 or count($node/*) > 0) 120 and (local-name($node/parent::*) = 'article' 121 or local-name($node/parent::*) = 'book' 122 or local-name($node/parent::*) = 'part' 123 )">1</xsl:when> 124 <xsl:when test="local-name($node)='bibliography' 125 and (local-name($node/parent::*) = 'article' 126 or local-name($node/parent::*) = 'book' 127 or local-name($node/parent::*) = 'part' 128 )">1</xsl:when> 129 <xsl:when test="local-name($node)='glossary' 130 and (local-name($node/parent::*) = 'article' 131 or local-name($node/parent::*) = 'book' 132 or local-name($node/parent::*) = 'part' 133 )">1</xsl:when> 134 <xsl:when test="local-name($node)='colophon'">1</xsl:when> 135 <xsl:when test="local-name($node)='book'">1</xsl:when> 136 <xsl:when test="local-name($node)='set'">1</xsl:when> 137 <xsl:when test="local-name($node)='setindex'">1</xsl:when> 138 <xsl:when test="local-name($node)='legalnotice' 139 and $generate.legalnotice.link != 0">1</xsl:when> 140 <xsl:otherwise>0</xsl:otherwise> 141 </xsl:choose> 142</xsl:template> 143 144<!-- ==================================================================== --> 145 146<xsl:template match="*" mode="chunk-filename"> 147 <!-- returns the filename of a chunk --> 148 <xsl:variable name="ischunk"> 149 <xsl:call-template name="chunk"/> 150 </xsl:variable> 151 152 <xsl:variable name="fn"> 153 <xsl:apply-templates select="." mode="recursive-chunk-filename"/> 154 </xsl:variable> 155 156 <!-- 157 <xsl:message> 158 <xsl:value-of select="$ischunk"/> 159 <xsl:text> (</xsl:text> 160 <xsl:value-of select="local-name(.)"/> 161 <xsl:text>) </xsl:text> 162 <xsl:value-of select="$fn"/> 163 <xsl:text>, </xsl:text> 164 <xsl:call-template name="dbhtml-dir"/> 165 </xsl:message> 166 --> 167 168 <!-- 2003-11-25 by ndw: 169 The following test used to read test="$ischunk != 0 and $fn != ''" 170 I've removed the ischunk part of the test so that href.to.uri and 171 href.from.uri will be fully qualified even if the source or target 172 isn't a chunk. I *think* that if $fn != '' then it's appropriate 173 to put the directory on the front, even if the element isn't a 174 chunk. I could be wrong. --> 175 176 <xsl:if test="$fn != ''"> 177 <xsl:call-template name="dbhtml-dir"/> 178 </xsl:if> 179 180 <xsl:value-of select="$fn"/> 181 <!-- You can't add the html.ext here because dbhtml filename= may already --> 182 <!-- have added it. It really does have to be handled in the recursive template --> 183</xsl:template> 184 185<xsl:template match="*" mode="recursive-chunk-filename"> 186 <xsl:param name="recursive" select="false()"/> 187 188 <!-- returns the filename of a chunk --> 189 <xsl:variable name="ischunk"> 190 <xsl:call-template name="chunk"/> 191 </xsl:variable> 192 193 <xsl:variable name="dbhtml-filename"> 194 <xsl:call-template name="dbhtml-filename"/> 195 </xsl:variable> 196 197 <xsl:variable name="filename"> 198 <xsl:choose> 199 <xsl:when test="$dbhtml-filename != ''"> 200 <xsl:value-of select="$dbhtml-filename"/> 201 </xsl:when> 202 <!-- if this is the root element, use the root.filename --> 203 <xsl:when test="not(parent::*) and $root.filename != ''"> 204 <xsl:value-of select="$root.filename"/> 205 <xsl:value-of select="$html.ext"/> 206 </xsl:when> 207 <!-- Special case --> 208 <xsl:when test="self::legalnotice and $generate.legalnotice.link != 0"> 209 <xsl:variable name="id"> 210 <xsl:call-template name="object.id"/> 211 </xsl:variable> 212 <xsl:value-of select="concat('ln-',$id,$html.ext)"/> 213 </xsl:when> 214 <!-- if there's no dbhtml filename, and if we're to use IDs as --> 215 <!-- filenames, then use the ID to generate the filename. --> 216 <xsl:when test="@id and $use.id.as.filename != 0"> 217 <xsl:value-of select="@id"/> 218 <xsl:value-of select="$html.ext"/> 219 </xsl:when> 220 <xsl:otherwise></xsl:otherwise> 221 </xsl:choose> 222 </xsl:variable> 223 224 <xsl:choose> 225 <xsl:when test="$ischunk='0'"> 226 <!-- if called on something that isn't a chunk, walk up... --> 227 <xsl:choose> 228 <xsl:when test="count(parent::*)>0"> 229 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*"> 230 <xsl:with-param name="recursive" select="$recursive"/> 231 </xsl:apply-templates> 232 </xsl:when> 233 <!-- unless there is no up, in which case return "" --> 234 <xsl:otherwise></xsl:otherwise> 235 </xsl:choose> 236 </xsl:when> 237 238 <xsl:when test="not($recursive) and $filename != ''"> 239 <!-- if this chunk has an explicit name, use it --> 240 <xsl:value-of select="$filename"/> 241 </xsl:when> 242 243 <xsl:when test="self::set"> 244 <xsl:value-of select="$root.filename"/> 245 <xsl:if test="not($recursive)"> 246 <xsl:value-of select="$html.ext"/> 247 </xsl:if> 248 </xsl:when> 249 250 <xsl:when test="self::book"> 251 <xsl:text>bk</xsl:text> 252 <xsl:number level="any" format="01"/> 253 <xsl:if test="not($recursive)"> 254 <xsl:value-of select="$html.ext"/> 255 </xsl:if> 256 </xsl:when> 257 258 <xsl:when test="self::article"> 259 <xsl:if test="/set"> 260 <!-- in a set, make sure we inherit the right book info... --> 261 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*"> 262 <xsl:with-param name="recursive" select="true()"/> 263 </xsl:apply-templates> 264 </xsl:if> 265 266 <xsl:text>ar</xsl:text> 267 <xsl:number level="any" format="01" from="book"/> 268 <xsl:if test="not($recursive)"> 269 <xsl:value-of select="$html.ext"/> 270 </xsl:if> 271 </xsl:when> 272 273 <xsl:when test="self::preface"> 274 <xsl:if test="/set"> 275 <!-- in a set, make sure we inherit the right book info... --> 276 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*"> 277 <xsl:with-param name="recursive" select="true()"/> 278 </xsl:apply-templates> 279 </xsl:if> 280 281 <xsl:text>pr</xsl:text> 282 <xsl:number level="any" format="01" from="book"/> 283 <xsl:if test="not($recursive)"> 284 <xsl:value-of select="$html.ext"/> 285 </xsl:if> 286 </xsl:when> 287 288 <xsl:when test="self::chapter"> 289 <xsl:if test="/set"> 290 <!-- in a set, make sure we inherit the right book info... --> 291 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*"> 292 <xsl:with-param name="recursive" select="true()"/> 293 </xsl:apply-templates> 294 </xsl:if> 295 296 <xsl:text>ch</xsl:text> 297 <xsl:number level="any" format="01" from="book"/> 298 <xsl:if test="not($recursive)"> 299 <xsl:value-of select="$html.ext"/> 300 </xsl:if> 301 </xsl:when> 302 303 <xsl:when test="self::appendix"> 304 <xsl:if test="/set"> 305 <!-- in a set, make sure we inherit the right book info... --> 306 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*"> 307 <xsl:with-param name="recursive" select="true()"/> 308 </xsl:apply-templates> 309 </xsl:if> 310 311 <xsl:text>ap</xsl:text> 312 <xsl:number level="any" format="a" from="book"/> 313 <xsl:if test="not($recursive)"> 314 <xsl:value-of select="$html.ext"/> 315 </xsl:if> 316 </xsl:when> 317 318 <xsl:when test="self::part"> 319 <xsl:choose> 320 <xsl:when test="/set"> 321 <!-- in a set, make sure we inherit the right book info... --> 322 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*"> 323 <xsl:with-param name="recursive" select="true()"/> 324 </xsl:apply-templates> 325 </xsl:when> 326 <xsl:otherwise> 327 </xsl:otherwise> 328 </xsl:choose> 329 330 <xsl:text>pt</xsl:text> 331 <xsl:number level="any" format="01" from="book"/> 332 <xsl:if test="not($recursive)"> 333 <xsl:value-of select="$html.ext"/> 334 </xsl:if> 335 </xsl:when> 336 337 <xsl:when test="self::reference"> 338 <xsl:choose> 339 <xsl:when test="/set"> 340 <!-- in a set, make sure we inherit the right book info... --> 341 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*"> 342 <xsl:with-param name="recursive" select="true()"/> 343 </xsl:apply-templates> 344 </xsl:when> 345 <xsl:otherwise> 346 </xsl:otherwise> 347 </xsl:choose> 348 349 <xsl:text>rn</xsl:text> 350 <xsl:number level="any" format="01" from="book"/> 351 <xsl:if test="not($recursive)"> 352 <xsl:value-of select="$html.ext"/> 353 </xsl:if> 354 </xsl:when> 355 356 <xsl:when test="self::refentry"> 357 <xsl:choose> 358 <xsl:when test="parent::reference"> 359 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*"> 360 <xsl:with-param name="recursive" select="true()"/> 361 </xsl:apply-templates> 362 </xsl:when> 363 <xsl:otherwise> 364 </xsl:otherwise> 365 </xsl:choose> 366 367 <xsl:text>re</xsl:text> 368 <xsl:number level="any" format="01" from="book"/> 369 <xsl:if test="not($recursive)"> 370 <xsl:value-of select="$html.ext"/> 371 </xsl:if> 372 </xsl:when> 373 374 <xsl:when test="self::colophon"> 375 <xsl:choose> 376 <xsl:when test="/set"> 377 <!-- in a set, make sure we inherit the right book info... --> 378 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*"> 379 <xsl:with-param name="recursive" select="true()"/> 380 </xsl:apply-templates> 381 </xsl:when> 382 <xsl:otherwise> 383 </xsl:otherwise> 384 </xsl:choose> 385 386 <xsl:text>co</xsl:text> 387 <xsl:number level="any" format="01" from="book"/> 388 <xsl:if test="not($recursive)"> 389 <xsl:value-of select="$html.ext"/> 390 </xsl:if> 391 </xsl:when> 392 393 <xsl:when test="self::sect1 394 or self::sect2 395 or self::sect3 396 or self::sect4 397 or self::sect5 398 or self::section"> 399 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*"> 400 <xsl:with-param name="recursive" select="true()"/> 401 </xsl:apply-templates> 402 <xsl:text>s</xsl:text> 403 <xsl:number format="01"/> 404 <xsl:if test="not($recursive)"> 405 <xsl:value-of select="$html.ext"/> 406 </xsl:if> 407 </xsl:when> 408 409 <xsl:when test="self::bibliography"> 410 <xsl:choose> 411 <xsl:when test="/set"> 412 <!-- in a set, make sure we inherit the right book info... --> 413 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*"> 414 <xsl:with-param name="recursive" select="true()"/> 415 </xsl:apply-templates> 416 </xsl:when> 417 <xsl:otherwise> 418 </xsl:otherwise> 419 </xsl:choose> 420 421 <xsl:text>bi</xsl:text> 422 <xsl:number level="any" format="01" from="book"/> 423 <xsl:if test="not($recursive)"> 424 <xsl:value-of select="$html.ext"/> 425 </xsl:if> 426 </xsl:when> 427 428 <xsl:when test="self::glossary"> 429 <xsl:choose> 430 <xsl:when test="/set"> 431 <!-- in a set, make sure we inherit the right book info... --> 432 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*"> 433 <xsl:with-param name="recursive" select="true()"/> 434 </xsl:apply-templates> 435 </xsl:when> 436 <xsl:otherwise> 437 </xsl:otherwise> 438 </xsl:choose> 439 440 <xsl:text>go</xsl:text> 441 <xsl:number level="any" format="01" from="book"/> 442 <xsl:if test="not($recursive)"> 443 <xsl:value-of select="$html.ext"/> 444 </xsl:if> 445 </xsl:when> 446 447 <xsl:when test="self::index"> 448 <xsl:choose> 449 <xsl:when test="/set"> 450 <!-- in a set, make sure we inherit the right book info... --> 451 <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*"> 452 <xsl:with-param name="recursive" select="true()"/> 453 </xsl:apply-templates> 454 </xsl:when> 455 <xsl:otherwise> 456 </xsl:otherwise> 457 </xsl:choose> 458 459 <xsl:text>ix</xsl:text> 460 <xsl:number level="any" format="01" from="book"/> 461 <xsl:if test="not($recursive)"> 462 <xsl:value-of select="$html.ext"/> 463 </xsl:if> 464 </xsl:when> 465 466 <xsl:when test="self::setindex"> 467 <xsl:text>si</xsl:text> 468 <xsl:number level="any" format="01" from="set"/> 469 <xsl:if test="not($recursive)"> 470 <xsl:value-of select="$html.ext"/> 471 </xsl:if> 472 </xsl:when> 473 474 <xsl:otherwise> 475 <xsl:text>chunk-filename-error-</xsl:text> 476 <xsl:value-of select="name(.)"/> 477 <xsl:number level="any" format="01" from="set"/> 478 <xsl:if test="not($recursive)"> 479 <xsl:value-of select="$html.ext"/> 480 </xsl:if> 481 </xsl:otherwise> 482 </xsl:choose> 483</xsl:template> 484 485<!-- ==================================================================== --> 486 487<xsl:template name="href.target.uri"> 488 <xsl:param name="object" select="."/> 489 <xsl:variable name="ischunk"> 490 <xsl:call-template name="chunk"> 491 <xsl:with-param name="node" select="$object"/> 492 </xsl:call-template> 493 </xsl:variable> 494 495 <xsl:apply-templates mode="chunk-filename" select="$object"/> 496 497 <xsl:if test="$ischunk='0'"> 498 <xsl:text>#</xsl:text> 499 <xsl:call-template name="object.id"> 500 <xsl:with-param name="object" select="$object"/> 501 </xsl:call-template> 502 </xsl:if> 503</xsl:template> 504 505<xsl:template name="href.target"> 506 <xsl:param name="context" select="."/> 507 <xsl:param name="object" select="."/> 508 509 <xsl:variable name="href.to.uri"> 510 <xsl:call-template name="href.target.uri"> 511 <xsl:with-param name="object" select="$object"/> 512 </xsl:call-template> 513 </xsl:variable> 514 515 <xsl:variable name="href.from.uri"> 516 <xsl:call-template name="href.target.uri"> 517 <xsl:with-param name="object" select="$context"/> 518 </xsl:call-template> 519 </xsl:variable> 520 521 <!-- 522 <xsl:message>href.to.uri: <xsl:value-of select="$href.to.uri"/></xsl:message> 523 <xsl:message>href.from.uri: <xsl:value-of select="$href.from.uri"/></xsl:message> 524 --> 525 526 <xsl:variable name="href.to"> 527 <xsl:call-template name="trim.common.uri.paths"> 528 <xsl:with-param name="uriA" select="$href.to.uri"/> 529 <xsl:with-param name="uriB" select="$href.from.uri"/> 530 <xsl:with-param name="return" select="'A'"/> 531 </xsl:call-template> 532 </xsl:variable> 533 534 <xsl:variable name="href.from"> 535 <xsl:call-template name="trim.common.uri.paths"> 536 <xsl:with-param name="uriA" select="$href.to.uri"/> 537 <xsl:with-param name="uriB" select="$href.from.uri"/> 538 <xsl:with-param name="return" select="'B'"/> 539 </xsl:call-template> 540 </xsl:variable> 541 542 <xsl:variable name="depth"> 543 <xsl:call-template name="count.uri.path.depth"> 544 <xsl:with-param name="filename" select="$href.from"/> 545 </xsl:call-template> 546 </xsl:variable> 547 548 <xsl:variable name="href"> 549 <xsl:call-template name="copy-string"> 550 <xsl:with-param name="string" select="'../'"/> 551 <xsl:with-param name="count" select="$depth"/> 552 </xsl:call-template> 553 <xsl:value-of select="$href.to"/> 554 </xsl:variable> 555 556 <!-- 557 <xsl:message> 558 <xsl:text>In </xsl:text> 559 <xsl:value-of select="name(.)"/> 560 <xsl:text> (</xsl:text> 561 <xsl:value-of select="$href.from"/> 562 <xsl:text>,</xsl:text> 563 <xsl:value-of select="$depth"/> 564 <xsl:text>) </xsl:text> 565 <xsl:value-of select="name($object)"/> 566 <xsl:text> href=</xsl:text> 567 <xsl:value-of select="$href"/> 568 </xsl:message> 569 --> 570 571 <xsl:value-of select="$href"/> 572</xsl:template> 573 574<!-- ==================================================================== --> 575 576<xsl:template name="html.head"> 577 <xsl:param name="prev" select="/foo"/> 578 <xsl:param name="next" select="/foo"/> 579 <xsl:variable name="this" select="."/> 580 <xsl:variable name="home" select="/*[1]"/> 581 <xsl:variable name="up" select="parent::*"/> 582 583 <head> 584 <xsl:call-template name="system.head.content"/> 585 <xsl:call-template name="head.content"/> 586 587 <xsl:if test="$home"> 588 <link rel="start"> 589 <xsl:attribute name="href"> 590 <xsl:call-template name="href.target"> 591 <xsl:with-param name="object" select="$home"/> 592 </xsl:call-template> 593 </xsl:attribute> 594 <xsl:attribute name="title"> 595 <xsl:apply-templates select="$home" 596 mode="object.title.markup.textonly"/> 597 </xsl:attribute> 598 </link> 599 </xsl:if> 600 601 <xsl:if test="$up"> 602 <link rel="up"> 603 <xsl:attribute name="href"> 604 <xsl:call-template name="href.target"> 605 <xsl:with-param name="object" select="$up"/> 606 </xsl:call-template> 607 </xsl:attribute> 608 <xsl:attribute name="title"> 609 <xsl:apply-templates select="$up" mode="object.title.markup.textonly"/> 610 </xsl:attribute> 611 </link> 612 </xsl:if> 613 614 <xsl:if test="$prev"> 615 <link rel="prev"> 616 <xsl:attribute name="href"> 617 <xsl:call-template name="href.target"> 618 <xsl:with-param name="object" select="$prev"/> 619 </xsl:call-template> 620 </xsl:attribute> 621 <xsl:attribute name="title"> 622 <xsl:apply-templates select="$prev" mode="object.title.markup.textonly"/> 623 </xsl:attribute> 624 </link> 625 </xsl:if> 626 627 <xsl:if test="$next"> 628 <link rel="next"> 629 <xsl:attribute name="href"> 630 <xsl:call-template name="href.target"> 631 <xsl:with-param name="object" select="$next"/> 632 </xsl:call-template> 633 </xsl:attribute> 634 <xsl:attribute name="title"> 635 <xsl:apply-templates select="$next" mode="object.title.markup.textonly"/> 636 </xsl:attribute> 637 </link> 638 </xsl:if> 639 640 <xsl:if test="$html.extra.head.links != 0"> 641 <xsl:for-each select="//part 642 |//reference 643 |//preface 644 |//chapter 645 |//article 646 |//refentry 647 |//appendix[not(parent::article)]|appendix 648 |//glossary[not(parent::article)]|glossary 649 |//index[not(parent::article)]|index"> 650 <link rel="{local-name(.)}"> 651 <xsl:attribute name="href"> 652 <xsl:call-template name="href.target"> 653 <xsl:with-param name="context" select="$this"/> 654 <xsl:with-param name="object" select="."/> 655 </xsl:call-template> 656 </xsl:attribute> 657 <xsl:attribute name="title"> 658 <xsl:apply-templates select="." mode="object.title.markup.textonly"/> 659 </xsl:attribute> 660 </link> 661 </xsl:for-each> 662 663 <xsl:for-each select="section|sect1|refsection|refsect1"> 664 <link> 665 <xsl:attribute name="rel"> 666 <xsl:choose> 667 <xsl:when test="local-name($this) = 'section' 668 or local-name($this) = 'refsection'"> 669 <xsl:value-of select="'subsection'"/> 670 </xsl:when> 671 <xsl:otherwise> 672 <xsl:value-of select="'section'"/> 673 </xsl:otherwise> 674 </xsl:choose> 675 </xsl:attribute> 676 <xsl:attribute name="href"> 677 <xsl:call-template name="href.target"> 678 <xsl:with-param name="context" select="$this"/> 679 <xsl:with-param name="object" select="."/> 680 </xsl:call-template> 681 </xsl:attribute> 682 <xsl:attribute name="title"> 683 <xsl:apply-templates select="." mode="object.title.markup.textonly"/> 684 </xsl:attribute> 685 </link> 686 </xsl:for-each> 687 688 <xsl:for-each select="sect2|sect3|sect4|sect5|refsect2|refsect3"> 689 <link rel="subsection"> 690 <xsl:attribute name="href"> 691 <xsl:call-template name="href.target"> 692 <xsl:with-param name="context" select="$this"/> 693 <xsl:with-param name="object" select="."/> 694 </xsl:call-template> 695 </xsl:attribute> 696 <xsl:attribute name="title"> 697 <xsl:apply-templates select="." mode="object.title.markup.textonly"/> 698 </xsl:attribute> 699 </link> 700 </xsl:for-each> 701 </xsl:if> 702 703 <!-- * if we have a legalnotice and user wants it output as a --> 704 <!-- * separate page and $html.head.legalnotice.link.types is --> 705 <!-- * non-empty, we generate a link or links for each value in --> 706 <!-- * $html.head.legalnotice.link.types --> 707 <xsl:if test="//legalnotice 708 and not($generate.legalnotice.link = 0) 709 and not($html.head.legalnotice.link.types = '')"> 710 <xsl:call-template name="make.legalnotice.head.links"/> 711 </xsl:if> 712 713 <xsl:call-template name="user.head.content"/> 714 </head> 715</xsl:template> 716 717<!-- ==================================================================== --> 718 719<xsl:template name="header.navigation"> 720 <xsl:param name="prev" select="/foo"/> 721 <xsl:param name="next" select="/foo"/> 722 <xsl:param name="nav.context"/> 723 724 <xsl:variable name="home" select="/*[1]"/> 725 <xsl:variable name="up" select="parent::*"/> 726 727 <xsl:variable name="row1" select="$navig.showtitles != 0"/> 728 <xsl:variable name="row2" select="count($prev) > 0 729 or (count($up) > 0 730 and generate-id($up) != generate-id($home) 731 and $navig.showtitles != 0) 732 or count($next) > 0"/> 733 734 <xsl:if test="$suppress.navigation = '0' and $suppress.header.navigation = '0'"> 735 <div class="navheader"> 736 <xsl:if test="$row1 or $row2"> 737 <table width="100%" summary="Navigation header"> 738 <xsl:if test="$row1"> 739 <tr> 740 <th colspan="3" align="center"> 741 <xsl:apply-templates select="." mode="object.title.markup"/> 742 </th> 743 </tr> 744 </xsl:if> 745 746 <xsl:if test="$row2"> 747 <tr> 748 <td width="20%" align="left"> 749 <xsl:if test="count($prev)>0"> 750 <a accesskey="p"> 751 <xsl:attribute name="href"> 752 <xsl:call-template name="href.target"> 753 <xsl:with-param name="object" select="$prev"/> 754 </xsl:call-template> 755 </xsl:attribute> 756 <xsl:call-template name="navig.content"> 757 <xsl:with-param name="direction" select="'prev'"/> 758 </xsl:call-template> 759 </a> 760 </xsl:if> 761 <xsl:text> </xsl:text> 762 </td> 763 <th width="60%" align="center"> 764 <xsl:choose> 765 <xsl:when test="count($up) > 0 766 and generate-id($up) != generate-id($home) 767 and $navig.showtitles != 0"> 768 <xsl:apply-templates select="$up" mode="object.title.markup"/> 769 </xsl:when> 770 <xsl:otherwise> </xsl:otherwise> 771 </xsl:choose> 772 </th> 773 <td width="20%" align="right"> 774 <xsl:text> </xsl:text> 775 <xsl:if test="count($next)>0"> 776 <a accesskey="n"> 777 <xsl:attribute name="href"> 778 <xsl:call-template name="href.target"> 779 <xsl:with-param name="object" select="$next"/> 780 </xsl:call-template> 781 </xsl:attribute> 782 <xsl:call-template name="navig.content"> 783 <xsl:with-param name="direction" select="'next'"/> 784 </xsl:call-template> 785 </a> 786 </xsl:if> 787 </td> 788 </tr> 789 </xsl:if> 790 </table> 791 </xsl:if> 792 <xsl:if test="$header.rule != 0"> 793 <hr/> 794 </xsl:if> 795 </div> 796 </xsl:if> 797</xsl:template> 798 799<!-- ==================================================================== --> 800 801<xsl:template name="footer.navigation"> 802 <xsl:param name="prev" select="/foo"/> 803 <xsl:param name="next" select="/foo"/> 804 <xsl:param name="nav.context"/> 805 806 <xsl:variable name="home" select="/*[1]"/> 807 <xsl:variable name="up" select="parent::*"/> 808 809 <xsl:variable name="row1" select="count($prev) > 0 810 or count($up) > 0 811 or count($next) > 0"/> 812 813 <xsl:variable name="row2" select="($prev and $navig.showtitles != 0) 814 or (generate-id($home) != generate-id(.) 815 or $nav.context = 'toc') 816 or ($chunk.tocs.and.lots != 0 817 and $nav.context != 'toc') 818 or ($next and $navig.showtitles != 0)"/> 819 820 <xsl:if test="$suppress.navigation = '0' and $suppress.footer.navigation = '0'"> 821 <div class="navfooter"> 822 <xsl:if test="$footer.rule != 0"> 823 <hr/> 824 </xsl:if> 825 826 <xsl:if test="$row1 or $row2"> 827 <table width="100%" summary="Navigation footer"> 828 <xsl:if test="$row1"> 829 <tr> 830 <td width="40%" align="left"> 831 <xsl:if test="count($prev)>0"> 832 <a accesskey="p"> 833 <xsl:attribute name="href"> 834 <xsl:call-template name="href.target"> 835 <xsl:with-param name="object" select="$prev"/> 836 </xsl:call-template> 837 </xsl:attribute> 838 <xsl:call-template name="navig.content"> 839 <xsl:with-param name="direction" select="'prev'"/> 840 </xsl:call-template> 841 </a> 842 </xsl:if> 843 <xsl:text> </xsl:text> 844 </td> 845 <td width="20%" align="center"> 846 <xsl:choose> 847 <xsl:when test="count($up)>0 848 and generate-id($up) != generate-id($home)"> 849 <a accesskey="u"> 850 <xsl:attribute name="href"> 851 <xsl:call-template name="href.target"> 852 <xsl:with-param name="object" select="$up"/> 853 </xsl:call-template> 854 </xsl:attribute> 855 <xsl:call-template name="navig.content"> 856 <xsl:with-param name="direction" select="'up'"/> 857 </xsl:call-template> 858 </a> 859 </xsl:when> 860 <xsl:otherwise> </xsl:otherwise> 861 </xsl:choose> 862 </td> 863 <td width="40%" align="right"> 864 <xsl:text> </xsl:text> 865 <xsl:if test="count($next)>0"> 866 <a accesskey="n"> 867 <xsl:attribute name="href"> 868 <xsl:call-template name="href.target"> 869 <xsl:with-param name="object" select="$next"/> 870 </xsl:call-template> 871 </xsl:attribute> 872 <xsl:call-template name="navig.content"> 873 <xsl:with-param name="direction" select="'next'"/> 874 </xsl:call-template> 875 </a> 876 </xsl:if> 877 </td> 878 </tr> 879 </xsl:if> 880 881 <xsl:if test="$row2"> 882 <tr> 883 <td width="40%" align="left" valign="top"> 884 <xsl:if test="$navig.showtitles != 0"> 885 <xsl:apply-templates select="$prev" mode="object.title.markup"/> 886 </xsl:if> 887 <xsl:text> </xsl:text> 888 </td> 889 <td width="20%" align="center"> 890 <xsl:choose> 891 <xsl:when test="$home != . or $nav.context = 'toc'"> 892 <a accesskey="h"> 893 <xsl:attribute name="href"> 894 <xsl:call-template name="href.target"> 895 <xsl:with-param name="object" select="$home"/> 896 </xsl:call-template> 897 </xsl:attribute> 898 <xsl:call-template name="navig.content"> 899 <xsl:with-param name="direction" select="'home'"/> 900 </xsl:call-template> 901 </a> 902 <xsl:if test="$chunk.tocs.and.lots != 0 and $nav.context != 'toc'"> 903 <xsl:text> | </xsl:text> 904 </xsl:if> 905 </xsl:when> 906 <xsl:otherwise> </xsl:otherwise> 907 </xsl:choose> 908 909 <xsl:if test="$chunk.tocs.and.lots != 0 and $nav.context != 'toc'"> 910 <a accesskey="t"> 911 <xsl:attribute name="href"> 912 <xsl:apply-templates select="/*[1]" 913 mode="recursive-chunk-filename"> 914 <xsl:with-param name="recursive" select="true()"/> 915 </xsl:apply-templates> 916 <xsl:text>-toc</xsl:text> 917 <xsl:value-of select="$html.ext"/> 918 </xsl:attribute> 919 <xsl:call-template name="gentext"> 920 <xsl:with-param name="key" select="'nav-toc'"/> 921 </xsl:call-template> 922 </a> 923 </xsl:if> 924 </td> 925 <td width="40%" align="right" valign="top"> 926 <xsl:text> </xsl:text> 927 <xsl:if test="$navig.showtitles != 0"> 928 <xsl:apply-templates select="$next" mode="object.title.markup"/> 929 </xsl:if> 930 </td> 931 </tr> 932 </xsl:if> 933 </table> 934 </xsl:if> 935 </div> 936 </xsl:if> 937</xsl:template> 938 939<!-- ==================================================================== --> 940 941<xsl:template name="navig.content"> 942 <xsl:param name="direction" select="next"/> 943 <xsl:variable name="navtext"> 944 <xsl:choose> 945 <xsl:when test="$direction = 'prev'"> 946 <xsl:call-template name="gentext.nav.prev"/> 947 </xsl:when> 948 <xsl:when test="$direction = 'next'"> 949 <xsl:call-template name="gentext.nav.next"/> 950 </xsl:when> 951 <xsl:when test="$direction = 'up'"> 952 <xsl:call-template name="gentext.nav.up"/> 953 </xsl:when> 954 <xsl:when test="$direction = 'home'"> 955 <xsl:call-template name="gentext.nav.home"/> 956 </xsl:when> 957 <xsl:otherwise> 958 <xsl:text>xxx</xsl:text> 959 </xsl:otherwise> 960 </xsl:choose> 961 </xsl:variable> 962 963 <xsl:choose> 964 <xsl:when test="$navig.graphics != 0"> 965 <img> 966 <xsl:attribute name="src"> 967 <xsl:value-of select="$navig.graphics.path"/> 968 <xsl:value-of select="$direction"/> 969 <xsl:value-of select="$navig.graphics.extension"/> 970 </xsl:attribute> 971 <xsl:attribute name="alt"> 972 <xsl:value-of select="$navtext"/> 973 </xsl:attribute> 974 </img> 975 </xsl:when> 976 <xsl:otherwise> 977 <xsl:value-of select="$navtext"/> 978 </xsl:otherwise> 979 </xsl:choose> 980</xsl:template> 981 982<!-- ==================================================================== --> 983<!-- * The following does tail-recursion through a space-separated --> 984<!-- * list of link types specified in $html.head.legalnotice.link.types, --> 985<!-- * popping off link types and generating links for them until it --> 986<!-- * depletes the list. --> 987 988<xsl:template name="make.legalnotice.head.links"> 989 <!-- * the following ID is used as part of the legalnotice filename; --> 990 <!-- * we need it in order to construct the filename for use in the --> 991 <!-- * value of the href attribute on the link --> 992 <xsl:param name="id"> 993 <xsl:call-template name="object.id"> 994 <xsl:with-param name="object" select="//legalnotice[1]"/> 995 </xsl:call-template> 996 </xsl:param> 997 <xsl:param name="linktype"> 998 <xsl:choose> 999 <xsl:when test="contains($html.head.legalnotice.link.types, ' ')"> 1000 <xsl:value-of 1001 select="normalize-space( 1002 substring-before($html.head.legalnotice.link.types, ' '))"/> 1003 </xsl:when> 1004 <xsl:otherwise> 1005 <xsl:value-of select="$html.head.legalnotice.link.types"/> 1006 </xsl:otherwise> 1007 </xsl:choose> 1008 </xsl:param> 1009 <xsl:param 1010 name="remaining.linktypes" 1011 select="concat( 1012 normalize-space( 1013 substring-after($html.head.legalnotice.link.types, ' ')),' ')"/> 1014 <xsl:if test="not($linktype = '')"> 1015 <link rel="{$linktype}"> 1016 <xsl:attribute name="href"> 1017 <xsl:value-of select="concat('ln-',$id,$html.ext)"/> 1018 </xsl:attribute> 1019 <xsl:attribute name="title"> 1020 <xsl:apply-templates select="//legalnotice[1]" 1021 mode="object.title.markup.textonly"/> 1022 </xsl:attribute> 1023 </link> 1024 <xsl:call-template name="make.legalnotice.head.links"> 1025 <!-- * pop the next value off the list of link types --> 1026 <xsl:with-param 1027 name="linktype" 1028 select="substring-before($remaining.linktypes, ' ')"/> 1029 <!-- * remove the link type from the list of remaining link types --> 1030 <xsl:with-param 1031 name="remaining.linktypes" 1032 select="substring-after($remaining.linktypes, ' ')"/> 1033 </xsl:call-template> 1034 </xsl:if> 1035</xsl:template> 1036 1037<!-- ==================================================================== --> 1038 1039<xsl:template match="processing-instruction('dbhtml')"> 1040 <!-- nop --> 1041</xsl:template> 1042 1043<!-- ==================================================================== --> 1044 1045<xsl:template name="chunk-element-content"> 1046 <xsl:param name="prev"/> 1047 <xsl:param name="next"/> 1048 <xsl:param name="nav.context"/> 1049 <xsl:param name="content"> 1050 <xsl:apply-imports/> 1051 </xsl:param> 1052 1053 <xsl:call-template name="user.preroot"/> 1054 1055 <html> 1056 <xsl:call-template name="html.head"> 1057 <xsl:with-param name="prev" select="$prev"/> 1058 <xsl:with-param name="next" select="$next"/> 1059 </xsl:call-template> 1060 1061 <body> 1062 <xsl:call-template name="body.attributes"/> 1063 <xsl:call-template name="user.header.navigation"/> 1064 1065 <xsl:call-template name="header.navigation"> 1066 <xsl:with-param name="prev" select="$prev"/> 1067 <xsl:with-param name="next" select="$next"/> 1068 <xsl:with-param name="nav.context" select="$nav.context"/> 1069 </xsl:call-template> 1070 1071 <xsl:call-template name="user.header.content"/> 1072 1073 <xsl:copy-of select="$content"/> 1074 1075 <xsl:call-template name="user.footer.content"/> 1076 1077 <xsl:call-template name="footer.navigation"> 1078 <xsl:with-param name="prev" select="$prev"/> 1079 <xsl:with-param name="next" select="$next"/> 1080 <xsl:with-param name="nav.context" select="$nav.context"/> 1081 </xsl:call-template> 1082 1083 <xsl:call-template name="user.footer.navigation"/> 1084 </body> 1085 </html> 1086</xsl:template> 1087 1088</xsl:stylesheet> 1089