| 1 |
<?xml version="1.0"?> |
| 2 |
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
| 3 |
xmlns:exsl="http://exslt.org/common" |
| 4 |
xmlns:cf="http://docbook.sourceforge.net/xmlns/chunkfast/1.0" |
| 5 |
xmlns:ng="http://docbook.org/docbook-ng" |
| 6 |
xmlns:db="http://docbook.org/ns/docbook" |
| 7 |
exclude-result-prefixes="exsl cf ng db" |
| 8 |
version="1.0"> |
| 9 |
|
| 10 |
<!-- ******************************************************************** |
| 11 |
$Id: chunk-code.xsl 6942 2007-07-04 04:42:17Z xmldoc $ |
| 12 |
******************************************************************** |
| 13 |
|
| 14 |
This file is part of the XSL DocBook Stylesheet distribution. |
| 15 |
See ../README or http://docbook.sf.net/release/xsl/current/ for |
| 16 |
copyright and other information. |
| 17 |
|
| 18 |
******************************************************************** --> |
| 19 |
|
| 20 |
<!-- ==================================================================== --> |
| 21 |
|
| 22 |
|
| 23 |
<xsl:template match="*" mode="chunk-filename"> |
| 24 |
<!-- returns the filename of a chunk --> |
| 25 |
<xsl:variable name="ischunk"> |
| 26 |
<xsl:call-template name="chunk"/> |
| 27 |
</xsl:variable> |
| 28 |
|
| 29 |
<xsl:variable name="fn"> |
| 30 |
<xsl:apply-templates select="." mode="recursive-chunk-filename"/> |
| 31 |
</xsl:variable> |
| 32 |
|
| 33 |
<!-- |
| 34 |
<xsl:message> |
| 35 |
<xsl:value-of select="$ischunk"/> |
| 36 |
<xsl:text> (</xsl:text> |
| 37 |
<xsl:value-of select="local-name(.)"/> |
| 38 |
<xsl:text>) </xsl:text> |
| 39 |
<xsl:value-of select="$fn"/> |
| 40 |
<xsl:text>, </xsl:text> |
| 41 |
<xsl:call-template name="dbhtml-dir"/> |
| 42 |
</xsl:message> |
| 43 |
--> |
| 44 |
|
| 45 |
<!-- 2003-11-25 by ndw: |
| 46 |
The following test used to read test="$ischunk != 0 and $fn != ''" |
| 47 |
I've removed the ischunk part of the test so that href.to.uri and |
| 48 |
href.from.uri will be fully qualified even if the source or target |
| 49 |
isn't a chunk. I *think* that if $fn != '' then it's appropriate |
| 50 |
to put the directory on the front, even if the element isn't a |
| 51 |
chunk. I could be wrong. --> |
| 52 |
|
| 53 |
<xsl:if test="$fn != ''"> |
| 54 |
<xsl:call-template name="dbhtml-dir"/> |
| 55 |
</xsl:if> |
| 56 |
|
| 57 |
<xsl:value-of select="$fn"/> |
| 58 |
<!-- You can't add the html.ext here because dbhtml filename= may already --> |
| 59 |
<!-- have added it. It really does have to be handled in the recursive template --> |
| 60 |
</xsl:template> |
| 61 |
|
| 62 |
<xsl:template match="*" mode="recursive-chunk-filename"> |
| 63 |
<xsl:param name="recursive" select="false()"/> |
| 64 |
|
| 65 |
<!-- returns the filename of a chunk --> |
| 66 |
<xsl:variable name="ischunk"> |
| 67 |
<xsl:call-template name="chunk"/> |
| 68 |
</xsl:variable> |
| 69 |
|
| 70 |
<xsl:variable name="dbhtml-filename"> |
| 71 |
<xsl:call-template name="pi.dbhtml_filename"/> |
| 72 |
</xsl:variable> |
| 73 |
|
| 74 |
<xsl:variable name="filename"> |
| 75 |
<xsl:choose> |
| 76 |
<xsl:when test="$dbhtml-filename != ''"> |
| 77 |
<xsl:value-of select="$dbhtml-filename"/> |
| 78 |
</xsl:when> |
| 79 |
<!-- if this is the root element, use the root.filename --> |
| 80 |
<xsl:when test="not(parent::*) and $root.filename != ''"> |
| 81 |
<xsl:value-of select="$root.filename"/> |
| 82 |
<xsl:value-of select="$html.ext"/> |
| 83 |
</xsl:when> |
| 84 |
<!-- Special case --> |
| 85 |
<xsl:when test="self::legalnotice and not($generate.legalnotice.link = 0)"> |
| 86 |
<xsl:choose> |
| 87 |
<xsl:when test="(@id or @xml:id) and not($use.id.as.filename = 0)"> |
| 88 |
<!-- * if this legalnotice has an ID, then go ahead and use --> |
| 89 |
<!-- * just the value of that ID as the basename for the file --> |
| 90 |
<!-- * (that is, without prepending an "ln-" too it) --> |
| 91 |
<xsl:value-of select="(@id|@xml:id)[1]"/> |
| 92 |
<xsl:value-of select="$html.ext"/> |
| 93 |
</xsl:when> |
| 94 |
<xsl:otherwise> |
| 95 |
<!-- * otherwise, if this legalnotice does not have an ID, --> |
| 96 |
<!-- * then we generate an ID... --> |
| 97 |
<xsl:variable name="id"> |
| 98 |
<xsl:call-template name="object.id"/> |
| 99 |
</xsl:variable> |
| 100 |
<!-- * ...and then we take that generated ID, prepend an --> |
| 101 |
<!-- * "ln-" to it, and use that as the basename for the file --> |
| 102 |
<xsl:value-of select="concat('ln-',$id,$html.ext)"/> |
| 103 |
</xsl:otherwise> |
| 104 |
</xsl:choose> |
| 105 |
</xsl:when> |
| 106 |
<!-- if there's no dbhtml filename, and if we're to use IDs as --> |
| 107 |
<!-- filenames, then use the ID to generate the filename. --> |
| 108 |
<xsl:when test="(@id or @xml:id) and $use.id.as.filename != 0"> |
| 109 |
<xsl:value-of select="(@id|@xml:id)[1]"/> |
| 110 |
<xsl:value-of select="$html.ext"/> |
| 111 |
</xsl:when> |
| 112 |
<xsl:otherwise></xsl:otherwise> |
| 113 |
</xsl:choose> |
| 114 |
</xsl:variable> |
| 115 |
|
| 116 |
<xsl:choose> |
| 117 |
<xsl:when test="$ischunk='0'"> |
| 118 |
<!-- if called on something that isn't a chunk, walk up... --> |
| 119 |
<xsl:choose> |
| 120 |
<xsl:when test="count(parent::*)>0"> |
| 121 |
<xsl:apply-templates mode="recursive-chunk-filename" select="parent::*"> |
| 122 |
<xsl:with-param name="recursive" select="$recursive"/> |
| 123 |
</xsl:apply-templates> |
| 124 |
</xsl:when> |
| 125 |
<!-- unless there is no up, in which case return "" --> |
| 126 |
<xsl:otherwise></xsl:otherwise> |
| 127 |
</xsl:choose> |
| 128 |
</xsl:when> |
| 129 |
|
| 130 |
<xsl:when test="not($recursive) and $filename != ''"> |
| 131 |
<!-- if this chunk has an explicit name, use it --> |
| 132 |
<xsl:value-of select="$filename"/> |
| 133 |
</xsl:when> |
| 134 |
|
| 135 |
<xsl:when test="self::set"> |
| 136 |
<xsl:value-of select="$root.filename"/> |
| 137 |
<xsl:if test="not($recursive)"> |
| 138 |
<xsl:value-of select="$html.ext"/> |
| 139 |
</xsl:if> |
| 140 |
</xsl:when> |
| 141 |
|
| 142 |
<xsl:when test="self::book"> |
| 143 |
<xsl:text>bk</xsl:text> |
| 144 |
<xsl:number level="any" format="01"/> |
| 145 |
<xsl:if test="not($recursive)"> |
| 146 |
<xsl:value-of select="$html.ext"/> |
| 147 |
</xsl:if> |
| 148 |
</xsl:when> |
| 149 |
|
| 150 |
<xsl:when test="self::article"> |
| 151 |
<xsl:if test="/set"> |
| 152 |
<!-- in a set, make sure we inherit the right book info... --> |
| 153 |
<xsl:apply-templates mode="recursive-chunk-filename" select="parent::*"> |
| 154 |
<xsl:with-param name="recursive" select="true()"/> |
| 155 |
</xsl:apply-templates> |
| 156 |
</xsl:if> |
| 157 |
|
| 158 |
<xsl:text>ar</xsl:text> |
| 159 |
<xsl:number level="any" format="01" from="book"/> |
| 160 |
<xsl:if test="not($recursive)"> |
| 161 |
<xsl:value-of select="$html.ext"/> |
| 162 |
</xsl:if> |
| 163 |
</xsl:when> |
| 164 |
|
| 165 |
<xsl:when test="self::preface"> |
| 166 |
<xsl:if test="/set"> |
| 167 |
<!-- in a set, make sure we inherit the right book info... --> |
| 168 |
<xsl:apply-templates mode="recursive-chunk-filename" select="parent::*"> |
| 169 |
<xsl:with-param name="recursive" select="true()"/> |
| 170 |
</xsl:apply-templates> |
| 171 |
</xsl:if> |
| 172 |
|
| 173 |
<xsl:text>pr</xsl:text> |
| 174 |
<xsl:number level="any" format="01" from="book"/> |
| 175 |
<xsl:if test="not($recursive)"> |
| 176 |
<xsl:value-of select="$html.ext"/> |
| 177 |
</xsl:if> |
| 178 |
</xsl:when> |
| 179 |
|
| 180 |
<xsl:when test="self::chapter"> |
| 181 |
<xsl:if test="/set"> |
| 182 |
<!-- in a set, make sure we inherit the right book info... --> |
| 183 |
<xsl:apply-templates mode="recursive-chunk-filename" select="parent::*"> |
| 184 |
<xsl:with-param name="recursive" select="true()"/> |
| 185 |
</xsl:apply-templates> |
| 186 |
</xsl:if> |
| 187 |
|
| 188 |
<xsl:text>ch</xsl:text> |
| 189 |
<xsl:number level="any" format="01" from="book"/> |
| 190 |
<xsl:if test="not($recursive)"> |
| 191 |
<xsl:value-of select="$html.ext"/> |
| 192 |
</xsl:if> |
| 193 |
</xsl:when> |
| 194 |
|
| 195 |
<xsl:when test="self::appendix"> |
| 196 |
<xsl:if test="/set"> |
| 197 |
<!-- in a set, make sure we inherit the right book info... --> |
| 198 |
<xsl:apply-templates mode="recursive-chunk-filename" select="parent::*"> |
| 199 |
<xsl:with-param name="recursive" select="true()"/> |
| 200 |
</xsl:apply-templates> |
| 201 |
</xsl:if> |
| 202 |
|
| 203 |
<xsl:text>ap</xsl:text> |
| 204 |
<xsl:number level="any" format="a" from="book"/> |
| 205 |
<xsl:if test="not($recursive)"> |
| 206 |
<xsl:value-of select="$html.ext"/> |
| 207 |
</xsl:if> |
| 208 |
</xsl:when> |
| 209 |
|
| 210 |
<xsl:when test="self::part"> |
| 211 |
<xsl:choose> |
| 212 |
<xsl:when test="/set"> |
| 213 |
<!-- in a set, make sure we inherit the right book info... --> |
| 214 |
<xsl:apply-templates mode="recursive-chunk-filename" select="parent::*"> |
| 215 |
<xsl:with-param name="recursive" select="true()"/> |
| 216 |
</xsl:apply-templates> |
| 217 |
</xsl:when> |
| 218 |
<xsl:otherwise> |
| 219 |
</xsl:otherwise> |
| 220 |
</xsl:choose> |
| 221 |
|
| 222 |
<xsl:text>pt</xsl:text> |
| 223 |
<xsl:number level="any" format="01" from="book"/> |
| 224 |
<xsl:if test="not($recursive)"> |
| 225 |
<xsl:value-of select="$html.ext"/> |
| 226 |
</xsl:if> |
| 227 |
</xsl:when> |
| 228 |
|
| 229 |
<xsl:when test="self::reference"> |
| 230 |
<xsl:choose> |
| 231 |
<xsl:when test="/set"> |
| 232 |
<!-- in a set, make sure we inherit the right book info... --> |
| 233 |
<xsl:apply-templates mode="recursive-chunk-filename" select="parent::*"> |
| 234 |
<xsl:with-param name="recursive" select="true()"/> |
| 235 |
</xsl:apply-templates> |
| 236 |
</xsl:when> |
| 237 |
<xsl:otherwise> |
| 238 |
</xsl:otherwise> |
| 239 |
</xsl:choose> |
| 240 |
|
| 241 |
<xsl:text>rn</xsl:text> |
| 242 |
<xsl:number level="any" format="01" from="book"/> |
| 243 |
<xsl:if test="not($recursive)"> |
| 244 |
<xsl:value-of select="$html.ext"/> |
| 245 |
</xsl:if> |
| 246 |
</xsl:when> |
| 247 |
|
| 248 |
<xsl:when test="self::refentry"> |
| 249 |
<xsl:choose> |
| 250 |
<xsl:when test="parent::reference"> |
| 251 |
<xsl:apply-templates mode="recursive-chunk-filename" select="parent::*"> |
| 252 |
<xsl:with-param name="recursive" select="true()"/> |
| 253 |
</xsl:apply-templates> |
| 254 |
</xsl:when> |
| 255 |
<xsl:otherwise> |
| 256 |
</xsl:otherwise> |
| 257 |
</xsl:choose> |
| 258 |
|
| 259 |
<xsl:text>re</xsl:text> |
| 260 |
<xsl:number level="any" format="01" from="book"/> |
| 261 |
<xsl:if test="not($recursive)"> |
| 262 |
<xsl:value-of select="$html.ext"/> |
| 263 |
</xsl:if> |
| 264 |
</xsl:when> |
| 265 |
|
| 266 |
<xsl:when test="self::colophon"> |
| 267 |
<xsl:choose> |
| 268 |
<xsl:when test="/set"> |
| 269 |
<!-- in a set, make sure we inherit the right book info... --> |
| 270 |
<xsl:apply-templates mode="recursive-chunk-filename" select="parent::*"> |
| 271 |
<xsl:with-param name="recursive" select="true()"/> |
| 272 |
</xsl:apply-templates> |
| 273 |
</xsl:when> |
| 274 |
<xsl:otherwise> |
| 275 |
</xsl:otherwise> |
| 276 |
</xsl:choose> |
| 277 |
|
| 278 |
<xsl:text>co</xsl:text> |
| 279 |
<xsl:number level="any" format="01" from="book"/> |
| 280 |
<xsl:if test="not($recursive)"> |
| 281 |
<xsl:value-of select="$html.ext"/> |
| 282 |
</xsl:if> |
| 283 |
</xsl:when> |
| 284 |
|
| 285 |
<xsl:when test="self::sect1 |
| 286 |
or self::sect2 |
| 287 |
or self::sect3 |
| 288 |
or self::sect4 |
| 289 |
or self::sect5 |
| 290 |
or self::section"> |
| 291 |
<xsl:apply-templates mode="recursive-chunk-filename" select="parent::*"> |
| 292 |
<xsl:with-param name="recursive" select="true()"/> |
| 293 |
</xsl:apply-templates> |
| 294 |
<xsl:text>s</xsl:text> |
| 295 |
<xsl:number format="01"/> |
| 296 |
<xsl:if test="not($recursive)"> |
| 297 |
<xsl:value-of select="$html.ext"/> |
| 298 |
</xsl:if> |
| 299 |
</xsl:when> |
| 300 |
|
| 301 |
<xsl:when test="self::bibliography"> |
| 302 |
<xsl:choose> |
| 303 |
<xsl:when test="/set"> |
| 304 |
<!-- in a set, make sure we inherit the right book info... --> |
| 305 |
<xsl:apply-templates mode="recursive-chunk-filename" select="parent::*"> |
| 306 |
<xsl:with-param name="recursive" select="true()"/> |
| 307 |
</xsl:apply-templates> |
| 308 |
</xsl:when> |
| 309 |
<xsl:otherwise> |
| 310 |
</xsl:otherwise> |
| 311 |
</xsl:choose> |
| 312 |
|
| 313 |
<xsl:text>bi</xsl:text> |
| 314 |
<xsl:number level="any" format="01" from="book"/> |
| 315 |
<xsl:if test="not($recursive)"> |
| 316 |
<xsl:value-of select="$html.ext"/> |
| 317 |
</xsl:if> |
| 318 |
</xsl:when> |
| 319 |
|
| 320 |
<xsl:when test="self::glossary"> |
| 321 |
<xsl:choose> |
| 322 |
<xsl:when test="/set"> |
| 323 |
<!-- in a set, make sure we inherit the right book info... --> |
| 324 |
<xsl:apply-templates mode="recursive-chunk-filename" select="parent::*"> |
| 325 |
<xsl:with-param name="recursive" select="true()"/> |
| 326 |
</xsl:apply-templates> |
| 327 |
</xsl:when> |
| 328 |
<xsl:otherwise> |
| 329 |
</xsl:otherwise> |
| 330 |
</xsl:choose> |
| 331 |
|
| 332 |
<xsl:text>go</xsl:text> |
| 333 |
<xsl:number level="any" format="01" from="book"/> |
| 334 |
<xsl:if test="not($recursive)"> |
| 335 |
<xsl:value-of select="$html.ext"/> |
| 336 |
</xsl:if> |
| 337 |
</xsl:when> |
| 338 |
|
| 339 |
<xsl:when test="self::index"> |
| 340 |
<xsl:choose> |
| 341 |
<xsl:when test="/set"> |
| 342 |
<!-- in a set, make sure we inherit the right book info... --> |
| 343 |
<xsl:apply-templates mode="recursive-chunk-filename" select="parent::*"> |
| 344 |
<xsl:with-param name="recursive" select="true()"/> |
| 345 |
</xsl:apply-templates> |
| 346 |
</xsl:when> |
| 347 |
<xsl:otherwise> |
| 348 |
</xsl:otherwise> |
| 349 |
</xsl:choose> |
| 350 |
|
| 351 |
<xsl:text>ix</xsl:text> |
| 352 |
<xsl:number level="any" format="01" from="book"/> |
| 353 |
<xsl:if test="not($recursive)"> |
| 354 |
<xsl:value-of select="$html.ext"/> |
| 355 |
</xsl:if> |
| 356 |
</xsl:when> |
| 357 |
|
| 358 |
<xsl:when test="self::setindex"> |
| 359 |
<xsl:text>si</xsl:text> |
| 360 |
<xsl:number level="any" format="01" from="set"/> |
| 361 |
<xsl:if test="not($recursive)"> |
| 362 |
<xsl:value-of select="$html.ext"/> |
| 363 |
</xsl:if> |
| 364 |
</xsl:when> |
| 365 |
|
| 366 |
<xsl:otherwise> |
| 367 |
<xsl:text>chunk-filename-error-</xsl:text> |
| 368 |
<xsl:value-of select="name(.)"/> |
| 369 |
<xsl:number level="any" format="01" from="set"/> |
| 370 |
<xsl:if test="not($recursive)"> |
| 371 |
<xsl:value-of select="$html.ext"/> |
| 372 |
</xsl:if> |
| 373 |
</xsl:otherwise> |
| 374 |
</xsl:choose> |
| 375 |
</xsl:template> |
| 376 |
|
| 377 |
<!-- ==================================================================== --> |
| 378 |
|
| 379 |
|
| 380 |
|
| 381 |
<xsl:template match="processing-instruction('dbhtml')"> |
| 382 |
<!-- nop --> |
| 383 |
</xsl:template> |
| 384 |
|
| 385 |
<!-- ==================================================================== --> |
| 386 |
|
| 387 |
|
| 388 |
<xsl:template match="*" mode="find.chunks"> |
| 389 |
<xsl:variable name="chunk"> |
| 390 |
<xsl:call-template name="chunk"/> |
| 391 |
</xsl:variable> |
| 392 |
|
| 393 |
<xsl:choose> |
| 394 |
<xsl:when test="$chunk != 0"> |
| 395 |
<cf:div id="{generate-id()}"> |
| 396 |
<xsl:apply-templates select="." mode="class.attribute"/> |
| 397 |
<xsl:apply-templates select="*" mode="find.chunks"/> |
| 398 |
</cf:div> |
| 399 |
</xsl:when> |
| 400 |
<xsl:otherwise> |
| 401 |
<xsl:apply-templates select="*" mode="find.chunks"/> |
| 402 |
</xsl:otherwise> |
| 403 |
</xsl:choose> |
| 404 |
</xsl:template> |
| 405 |
|
| 406 |
<xsl:template match="/"> |
| 407 |
<!-- * Get a title for current doc so that we let the user --> |
| 408 |
<!-- * know what document we are processing at this point. --> |
| 409 |
<xsl:variable name="doc.title"> |
| 410 |
<xsl:call-template name="get.doc.title"/> |
| 411 |
</xsl:variable> |
| 412 |
<xsl:choose> |
| 413 |
<!-- Hack! If someone hands us a DocBook V5.x or DocBook NG document, |
| 414 |
toss the namespace and continue. Use the docbook5 namespaced |
| 415 |
stylesheets for DocBook5 if you don't want to use this feature.--> |
| 416 |
<!-- include extra test for Xalan quirk --> |
| 417 |
<xsl:when test="(function-available('exsl:node-set') or |
| 418 |
contains(system-property('xsl:vendor'), |
| 419 |
'Apache Software Foundation')) |
| 420 |
and (*/self::ng:* or */self::db:*)"> |
| 421 |
<xsl:call-template name="log.message"> |
| 422 |
<xsl:with-param name="level">Note</xsl:with-param> |
| 423 |
<xsl:with-param name="source" select="$doc.title"/> |
| 424 |
<xsl:with-param name="context-desc"> |
| 425 |
<xsl:text>namesp. cut</xsl:text> |
| 426 |
</xsl:with-param> |
| 427 |
<xsl:with-param name="message"> |
| 428 |
<xsl:text>stripped namespace before processing</xsl:text> |
| 429 |
</xsl:with-param> |
| 430 |
</xsl:call-template> |
| 431 |
<xsl:variable name="nons"> |
| 432 |
<xsl:apply-templates mode="stripNS"/> |
| 433 |
</xsl:variable> |
| 434 |
<xsl:call-template name="log.message"> |
| 435 |
<xsl:with-param name="level">Note</xsl:with-param> |
| 436 |
<xsl:with-param name="source" select="$doc.title"/> |
| 437 |
<xsl:with-param name="context-desc"> |
| 438 |
<xsl:text>namesp. cut</xsl:text> |
| 439 |
</xsl:with-param> |
| 440 |
<xsl:with-param name="message"> |
| 441 |
<xsl:text>processing stripped document</xsl:text> |
| 442 |
</xsl:with-param> |
| 443 |
</xsl:call-template> |
| 444 |
<xsl:apply-templates select="exsl:node-set($nons)"/> |
| 445 |
</xsl:when> |
| 446 |
<!-- Can't process unless namespace removed --> |
| 447 |
<xsl:when test="*/self::ng:* or */self::db:*"> |
| 448 |
<xsl:message terminate="yes"> |
| 449 |
<xsl:text>Unable to strip the namespace from DB5 document,</xsl:text> |
| 450 |
<xsl:text> cannot proceed.</xsl:text> |
| 451 |
</xsl:message> |
| 452 |
</xsl:when> |
| 453 |
<xsl:otherwise> |
| 454 |
<xsl:choose> |
| 455 |
<xsl:when test="$rootid != ''"> |
| 456 |
<xsl:choose> |
| 457 |
<xsl:when test="count(key('id',$rootid)) = 0"> |
| 458 |
<xsl:message terminate="yes"> |
| 459 |
<xsl:text>ID '</xsl:text> |
| 460 |
<xsl:value-of select="$rootid"/> |
| 461 |
<xsl:text>' not found in document.</xsl:text> |
| 462 |
</xsl:message> |
| 463 |
</xsl:when> |
| 464 |
<xsl:otherwise> |
| 465 |
<xsl:if test="$collect.xref.targets = 'yes' or |
| 466 |
$collect.xref.targets = 'only'"> |
| 467 |
<xsl:apply-templates select="key('id', $rootid)" |
| 468 |
mode="collect.targets"/> |
| 469 |
</xsl:if> |
| 470 |
<xsl:if test="$collect.xref.targets != 'only'"> |
| 471 |
<xsl:apply-templates select="key('id',$rootid)" |
| 472 |
mode="process.root"/> |
| 473 |
<xsl:if test="$tex.math.in.alt != ''"> |
| 474 |
<xsl:apply-templates select="key('id',$rootid)" |
| 475 |
mode="collect.tex.math"/> |
| 476 |
</xsl:if> |
| 477 |
<xsl:if test="$generate.manifest != 0"> |
| 478 |
<xsl:call-template name="generate.manifest"> |
| 479 |
<xsl:with-param name="node" select="key('id',$rootid)"/> |
| 480 |
</xsl:call-template> |
| 481 |
</xsl:if> |
| 482 |
</xsl:if> |
| 483 |
</xsl:otherwise> |
| 484 |
</xsl:choose> |
| 485 |
</xsl:when> |
| 486 |
<xsl:otherwise> |
| 487 |
<xsl:if test="$collect.xref.targets = 'yes' or |
| 488 |
$collect.xref.targets = 'only'"> |
| 489 |
<xsl:apply-templates select="/" mode="collect.targets"/> |
| 490 |
</xsl:if> |
| 491 |
<xsl:if test="$collect.xref.targets != 'only'"> |
| 492 |
<xsl:apply-templates select="/" mode="process.root"/> |
| 493 |
<xsl:if test="$tex.math.in.alt != ''"> |
| 494 |
<xsl:apply-templates select="/" mode="collect.tex.math"/> |
| 495 |
</xsl:if> |
| 496 |
<xsl:if test="$generate.manifest != 0"> |
| 497 |
<xsl:call-template name="generate.manifest"> |
| 498 |
<xsl:with-param name="node" select="/"/> |
| 499 |
</xsl:call-template> |
| 500 |
</xsl:if> |
| 501 |
</xsl:if> |
| 502 |
</xsl:otherwise> |
| 503 |
</xsl:choose> |
| 504 |
</xsl:otherwise> |
| 505 |
</xsl:choose> |
| 506 |
</xsl:template> |
| 507 |
|
| 508 |
<xsl:template match="*" mode="process.root"> |
| 509 |
<xsl:apply-templates select="."/> |
| 510 |
</xsl:template> |
| 511 |
|
| 512 |
<!-- ====================================================================== --> |
| 513 |
|
| 514 |
<xsl:template match="set|book|part|preface|chapter|appendix |
| 515 |
|article |
| 516 |
|reference|refentry |
| 517 |
|book/glossary|article/glossary|part/glossary |
| 518 |
|book/bibliography|article/bibliography|part/bibliography |
| 519 |
|colophon"> |
| 520 |
<xsl:choose> |
| 521 |
<xsl:when test="$onechunk != 0 and parent::*"> |
| 522 |
<xsl:apply-imports/> |
| 523 |
</xsl:when> |
| 524 |
<xsl:otherwise> |
| 525 |
<xsl:call-template name="process-chunk-element"/> |
| 526 |
</xsl:otherwise> |
| 527 |
</xsl:choose> |
| 528 |
</xsl:template> |
| 529 |
|
| 530 |
<xsl:template match="sect1|sect2|sect3|sect4|sect5|section"> |
| 531 |
<xsl:variable name="ischunk"> |
| 532 |
<xsl:call-template name="chunk"/> |
| 533 |
</xsl:variable> |
| 534 |
|
| 535 |
<xsl:choose> |
| 536 |
<xsl:when test="not(parent::*)"> |
| 537 |
<xsl:call-template name="process-chunk-element"/> |
| 538 |
</xsl:when> |
| 539 |
<xsl:when test="$ischunk = 0"> |
| 540 |
<xsl:apply-imports/> |
| 541 |
</xsl:when> |
| 542 |
<xsl:otherwise> |
| 543 |
<xsl:call-template name="process-chunk-element"/> |
| 544 |
</xsl:otherwise> |
| 545 |
</xsl:choose> |
| 546 |
</xsl:template> |
| 547 |
|
| 548 |
<xsl:template match="setindex |
| 549 |
|book/index |
| 550 |
|article/index |
| 551 |
|part/index"> |
| 552 |
<!-- some implementations use completely empty index tags to indicate --> |
| 553 |
<!-- where an automatically generated index should be inserted. so --> |
| 554 |
<!-- if the index is completely empty, skip it. --> |
| 555 |
<xsl:if test="count(*)>0 or $generate.index != '0'"> |
| 556 |
<xsl:call-template name="process-chunk-element"/> |
| 557 |
</xsl:if> |
| 558 |
</xsl:template> |
| 559 |
|
| 560 |
<!-- Resolve xml:base attributes --> |
| 561 |
<xsl:template match="@fileref"> |
| 562 |
<!-- need a check for absolute urls --> |
| 563 |
<xsl:choose> |
| 564 |
<xsl:when test="contains(., ':')"> |
| 565 |
<!-- it has a uri scheme so it is an absolute uri --> |
| 566 |
<xsl:value-of select="."/> |
| 567 |
</xsl:when> |
| 568 |
<xsl:when test="$keep.relative.image.uris != 0"> |
| 569 |
<!-- leave it alone --> |
| 570 |
<xsl:value-of select="."/> |
| 571 |
</xsl:when> |
| 572 |
<xsl:otherwise> |
| 573 |
<!-- its a relative uri --> |
| 574 |
<xsl:call-template name="relative-uri"> |
| 575 |
<xsl:with-param name="destdir"> |
| 576 |
<xsl:call-template name="dbhtml-dir"> |
| 577 |
<xsl:with-param name="context" select=".."/> |
| 578 |
</xsl:call-template> |
| 579 |
</xsl:with-param> |
| 580 |
</xsl:call-template> |
| 581 |
</xsl:otherwise> |
| 582 |
</xsl:choose> |
| 583 |
</xsl:template> |
| 584 |
|
| 585 |
<!-- ==================================================================== --> |
| 586 |
<xsl:template match="set|book|part|preface|chapter|appendix |
| 587 |
|article |
| 588 |
|reference|refentry |
| 589 |
|sect1|sect2|sect3|sect4|sect5 |
| 590 |
|section |
| 591 |
|book/glossary|article/glossary|part/glossary |
| 592 |
|book/bibliography|article/bibliography|part/bibliography |
| 593 |
|colophon" |
| 594 |
mode="enumerate-files"> |
| 595 |
<xsl:variable name="ischunk"><xsl:call-template name="chunk"/></xsl:variable> |
| 596 |
<xsl:if test="$ischunk='1'"> |
| 597 |
<xsl:call-template name="make-relative-filename"> |
| 598 |
<xsl:with-param name="base.dir"> |
| 599 |
<xsl:if test="$manifest.in.base.dir = 0"> |
| 600 |
<xsl:value-of select="$base.dir"/> |
| 601 |
</xsl:if> |
| 602 |
</xsl:with-param> |
| 603 |
<xsl:with-param name="base.name"> |
| 604 |
<xsl:apply-templates mode="chunk-filename" select="."/> |
| 605 |
</xsl:with-param> |
| 606 |
</xsl:call-template> |
| 607 |
<xsl:text> </xsl:text> |
| 608 |
</xsl:if> |
| 609 |
<xsl:apply-templates select="*" mode="enumerate-files"/> |
| 610 |
</xsl:template> |
| 611 |
|
| 612 |
<xsl:template match="book/index|article/index|part/index" |
| 613 |
mode="enumerate-files"> |
| 614 |
<xsl:if test="$htmlhelp.output != 1"> |
| 615 |
<xsl:variable name="ischunk"><xsl:call-template name="chunk"/></xsl:variable> |
| 616 |
<xsl:if test="$ischunk='1'"> |
| 617 |
<xsl:call-template name="make-relative-filename"> |
| 618 |
<xsl:with-param name="base.dir"> |
| 619 |
<xsl:if test="$manifest.in.base.dir = 0"> |
| 620 |
<xsl:value-of select="$base.dir"/> |
| 621 |
</xsl:if> |
| 622 |
</xsl:with-param> |
| 623 |
<xsl:with-param name="base.name"> |
| 624 |
<xsl:apply-templates mode="chunk-filename" select="."/> |
| 625 |
</xsl:with-param> |
| 626 |
</xsl:call-template> |
| 627 |
<xsl:text> </xsl:text> |
| 628 |
</xsl:if> |
| 629 |
<xsl:apply-templates select="*" mode="enumerate-files"/> |
| 630 |
</xsl:if> |
| 631 |
</xsl:template> |
| 632 |
|
| 633 |
<xsl:template match="legalnotice" mode="enumerate-files"> |
| 634 |
<xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable> |
| 635 |
<xsl:if test="$generate.legalnotice.link != 0"> |
| 636 |
<xsl:call-template name="make-relative-filename"> |
| 637 |
<xsl:with-param name="base.dir"> |
| 638 |
<xsl:if test="$manifest.in.base.dir = 0"> |
| 639 |
<xsl:value-of select="$base.dir"/> |
| 640 |
</xsl:if> |
| 641 |
</xsl:with-param> |
| 642 |
<xsl:with-param name="base.name"> |
| 643 |
<xsl:apply-templates mode="chunk-filename" select="."/> |
| 644 |
</xsl:with-param> |
| 645 |
</xsl:call-template> |
| 646 |
<xsl:text> </xsl:text> |
| 647 |
</xsl:if> |
| 648 |
</xsl:template> |
| 649 |
|
| 650 |
<xsl:template match="mediaobject[imageobject] | inlinemediaobject[imageobject]" mode="enumerate-files"> |
| 651 |
<xsl:variable name="longdesc.uri"> |
| 652 |
<xsl:call-template name="longdesc.uri"> |
| 653 |
<xsl:with-param name="mediaobject" |
| 654 |
select="."/> |
| 655 |
</xsl:call-template> |
| 656 |
</xsl:variable> |
| 657 |
<xsl:variable name="mediaobject" select="."/> |
| 658 |
|
| 659 |
<xsl:if test="$html.longdesc != 0 and $mediaobject/textobject[not(phrase)]"> |
| 660 |
<xsl:call-template name="longdesc.uri"> |
| 661 |
<xsl:with-param name="mediaobject" select="$mediaobject"/> |
| 662 |
</xsl:call-template> |
| 663 |
<xsl:text> </xsl:text> |
| 664 |
</xsl:if> |
| 665 |
</xsl:template> |
| 666 |
|
| 667 |
<xsl:template match="text()" mode="enumerate-files"> |
| 668 |
</xsl:template> |
| 669 |
|
| 670 |
</xsl:stylesheet> |