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:db = "http://docbook.org/ns/docbook" 5 xmlns:xlink="http://www.w3.org/1999/xlink" 6 exclude-result-prefixes="exsl db" 7 version="1.0"> 8 9<!-- 10# ====================================================================== 11# This file is part of DocBook V5.0CR5 12# 13# Copyright 2005 Norman Walsh, Sun Microsystems, Inc., and the 14# Organization for the Advancement of Structured Information 15# Standards (OASIS). 16# 17# Release: $Id: db4-upgrade.xsl 9828 2013-11-03 21:45:22Z tom_schr $ 18# 19# Permission to use, copy, modify and distribute this stylesheet 20# and its accompanying documentation for any purpose and without fee 21# is hereby granted in perpetuity, provided that the above copyright 22# notice and this paragraph appear in all copies. The copyright 23# holders make no representation about the suitability of the schema 24# for any purpose. It is provided "as is" without expressed or implied 25# warranty. 26# 27# Please direct all questions, bug reports, or suggestions for changes 28# to the docbook@lists.oasis-open.org mailing list. For more 29# information, see http://www.oasis-open.org/docbook/. 30# 31# ====================================================================== 32--> 33 34<xsl:param name="db5.version" select="'5.0'"/> <!-- DocBook version for the output 5.0 and 5.1 only current values --> 35<xsl:param name="db5.version.string" select="$db5.version"/> <!-- Set this if you want a local version number --> 36<xsl:param name="keep.numbered.sections" select="'0'"/> <!-- Set to 1 to keep numbered sections, default changes to recursive --> 37 38<xsl:variable name="version" select="'1.1'"/> <!-- version of this transform --> 39 40<xsl:output method="xml" encoding="utf-8" indent="no" omit-xml-declaration="yes"/> 41 42<xsl:preserve-space elements="*"/> 43<xsl:param name="rootid"> 44 <xsl:choose> 45 <xsl:when test="/*/@id"> 46 <xsl:value-of select="/*/@id"/> 47 </xsl:when> 48 <xsl:otherwise> 49 <xsl:text>UNKNOWN</xsl:text> 50 </xsl:otherwise> 51 </xsl:choose> 52</xsl:param> 53 54<xsl:param name="defaultDate" select="''"/> 55 56<xsl:template match="/"> 57 <xsl:variable name="converted"> 58 <xsl:apply-templates/> 59 </xsl:variable> 60 <xsl:comment> 61 <xsl:text> Converted by db4-upgrade version </xsl:text> 62 <xsl:value-of select="$version"/> 63 <xsl:text> </xsl:text> 64 </xsl:comment> 65 <xsl:text> </xsl:text> 66 <xsl:apply-templates select="exsl:node-set($converted)/*" mode="addNS"/> 67</xsl:template> 68 69<!-- Convert numbered sections into recursive sections, unless 70 $keep.numbered.sections is set to '1' --> 71<xsl:template match="sect1|sect2|sect3|sect4|sect5|section" 72 priority="200"> 73 <xsl:choose> 74 <xsl:when test="$keep.numbered.sections = '1'"> 75 <xsl:element name="{local-name(.)}"> 76 <xsl:call-template name="copy.attributes"/> 77 <xsl:apply-templates/> 78 </xsl:element> 79 </xsl:when> 80 <xsl:otherwise> 81 <section> 82 <xsl:call-template name="copy.attributes"/> 83 <xsl:apply-templates/> 84 </section> 85 </xsl:otherwise> 86 </xsl:choose> 87</xsl:template> 88<!-- This is the template for the elements (book, article, set) that allow 89 title, subtitle, and titleabbrev before (or in) info, but not after. 90 If title, subtitle, or titleabbrev exist both inside and outside the 91 info block, everything is moved inside. Otherwise things are left as is. --> 92<xsl:template match="bookinfo|articleinfo|artheader|setinfo" priority="200"> 93 <xsl:variable name="title.inside.info"> 94 <xsl:choose> 95 <xsl:when test="./title or ./subtitle or ./titleabbrev"> 96 <xsl:text>1</xsl:text> 97 </xsl:when> 98 <xsl:otherwise> 99 <xsl:text>0</xsl:text> 100 </xsl:otherwise> 101 </xsl:choose> 102 </xsl:variable> 103 <xsl:variable name="title.outside.info"> 104 <xsl:choose> 105 <xsl:when test="preceding-sibling::title or preceding-sibling::subtitle or preceding-sibling::titleabbrev"> 106 <xsl:text>1</xsl:text> 107 </xsl:when> 108 <xsl:otherwise> 109 <xsl:text>0</xsl:text> 110 </xsl:otherwise> 111 </xsl:choose> 112 </xsl:variable> 113 <info> 114 <xsl:if test="$title.inside.info = '1' and $title.outside.info = '1'"> 115 <xsl:call-template name="emit-message"> 116 <xsl:with-param name="message"> 117 <xsl:text>Found title|subtitle|titleabbrev both inside and outside </xsl:text><xsl:value-of select="local-name(.)"/> 118 <xsl:text>. Moving all inside info element.</xsl:text> 119 </xsl:with-param> 120 </xsl:call-template> 121 <xsl:if test="preceding-sibling::title and not(./title)"> 122 <xsl:apply-templates select="preceding-sibling::title" mode="copy"/> 123 </xsl:if> 124 <xsl:if test="preceding-sibling::subtitle and not(./subtitle)"> 125 <xsl:apply-templates select="preceding-sibling::subtitle" mode="copy"/> 126 </xsl:if> 127 <xsl:if test="preceding-sibling::titleabbrev and not(./titleabbrev)"> 128 <xsl:apply-templates select="preceding-sibling::titleabbrev" mode="copy"/> 129 </xsl:if> 130 </xsl:if> 131 <xsl:apply-templates/> 132 </info> 133</xsl:template> 134<!-- This is the template for the elements (all except book, article, set) that 135 allow title, subtitle, and titleabbrev after (or in) info, but not before. 136 If an info element exists, and there is a title, subtitle, or titleabbrev 137 after the info element, then the element is moved inside the info block. 138 However, if a duplicate element exists inside the info element, that element 139 is kept, and the one outside is dropped.--> 140<xsl:template match="appendixinfo|blockinfo|bibliographyinfo|glossaryinfo 141 |indexinfo|setindexinfo|chapterinfo 142 |sect1info|sect2info|sect3info|sect4info|sect5info|sectioninfo 143 |refsect1info|refsect2info|refsect3info|refsectioninfo 144 |referenceinfo|partinfo 145 |objectinfo|prefaceinfo|refsynopsisdivinfo 146 |screeninfo|sidebarinfo" 147 priority="200"> 148 <xsl:variable name="title.inside.info"> 149 <xsl:choose> 150 <xsl:when test="./title or ./subtitle or ./titleabbrev"> 151 <xsl:text>1</xsl:text> 152 </xsl:when> 153 <xsl:otherwise> 154 <xsl:text>0</xsl:text> 155 </xsl:otherwise> 156 </xsl:choose> 157 </xsl:variable> 158 159 <!-- place title/subtitle/titleabbrev inside if any of them are already inside. 160 otherwise place them before. --> 161 <xsl:choose> 162 <xsl:when test="$title.inside.info = '0'"> 163 <xsl:call-template name="emit-message"> 164 <xsl:with-param name="message"> 165 <xsl:text>Keeping one or more title elements before </xsl:text><xsl:value-of select="local-name(.)"/> 166 </xsl:with-param> 167 </xsl:call-template> 168 169 <xsl:if test="following-sibling::title and not(./title)"> 170 <xsl:apply-templates select="following-sibling::title" mode="copy"/> 171 </xsl:if> 172 <xsl:if test="following-sibling::subtitle and not(./subtitle)"> 173 <xsl:apply-templates select="following-sibling::subtitle" mode="copy"/> 174 </xsl:if> 175 <xsl:if test="following-sibling::titleabbrev and not(./titleabbrev)"> 176 <xsl:apply-templates select="following-sibling::titleabbrev" mode="copy"/> 177 </xsl:if> 178 <info> 179 <xsl:call-template name="copy.attributes"/> 180 <xsl:apply-templates/> 181 </info> 182 </xsl:when> 183 <xsl:otherwise> 184 <xsl:call-template name="emit-message"> 185 <xsl:with-param name="message"> 186 <xsl:text>Moving one or more title elements into </xsl:text><xsl:value-of select="local-name(.)"/> 187 </xsl:with-param> 188 </xsl:call-template> 189 <info> 190 <xsl:call-template name="copy.attributes"/> 191 <xsl:if test="following-sibling::title and not(./title)"> 192 <xsl:apply-templates select="following-sibling::title" mode="copy"/> 193 </xsl:if> 194 <xsl:if test="following-sibling::subtitle and not(./subtitle)"> 195 <xsl:apply-templates select="following-sibling::subtitle" mode="copy"/> 196 </xsl:if> 197 <xsl:if test="following-sibling::titleabbrev and not(./titleabbrev)"> 198 <xsl:apply-templates select="following-sibling::titleabbrev" mode="copy"/> 199 </xsl:if> 200 <xsl:apply-templates/> 201 </info> 202 </xsl:otherwise> 203 </xsl:choose> 204</xsl:template> 205 206<xsl:template match="refentryinfo" 207 priority="200"> 208 <info> 209 <xsl:call-template name="copy.attributes"/> 210 211 <xsl:if test="title"> 212 <xsl:call-template name="emit-message"> 213 <xsl:with-param name="message"> 214 <xsl:text>Discarding title from refentryinfo!</xsl:text> 215 </xsl:with-param> 216 </xsl:call-template> 217 </xsl:if> 218 219 <xsl:if test="titleabbrev"> 220 <xsl:call-template name="emit-message"> 221 <xsl:with-param name="message"> 222 <xsl:text>Discarding titleabbrev from refentryinfo!</xsl:text> 223 </xsl:with-param> 224 </xsl:call-template> 225 </xsl:if> 226 227 <xsl:if test="subtitle"> 228 <xsl:call-template name="emit-message"> 229 <xsl:with-param name="message"> 230 <xsl:text>Discarding subtitle from refentryinfo!</xsl:text> 231 </xsl:with-param> 232 </xsl:call-template> 233 </xsl:if> 234 235 <xsl:apply-templates/> 236 </info> 237</xsl:template> 238 239<xsl:template match="refmiscinfo" 240 priority="200"> 241 <refmiscinfo> 242 <xsl:call-template name="copy.attributes"> 243 <xsl:with-param name="suppress" select="'class'"/> 244 </xsl:call-template> 245 <xsl:if test="@class"> 246 <xsl:choose> 247 <xsl:when test="@class = 'source' 248 or @class = 'version' 249 or @class = 'manual' 250 or @class = 'sectdesc' 251 or @class = 'software'"> 252 <xsl:attribute name="class"> 253 <xsl:value-of select="@class"/> 254 </xsl:attribute> 255 </xsl:when> 256 <xsl:otherwise> 257 <xsl:attribute name="class"> 258 <xsl:value-of select="'other'"/> 259 </xsl:attribute> 260 <xsl:attribute name="otherclass"> 261 <xsl:value-of select="@class"/> 262 </xsl:attribute> 263 </xsl:otherwise> 264 </xsl:choose> 265 </xsl:if> 266 <xsl:apply-templates/> 267 </refmiscinfo> 268</xsl:template> 269 270<xsl:template match="corpauthor" priority="200"> 271 <author> 272 <xsl:call-template name="copy.attributes"/> 273 <orgname> 274 <xsl:apply-templates/> 275 </orgname> 276 </author> 277</xsl:template> 278 279<xsl:template match="corpname" priority="200"> 280 <orgname> 281 <xsl:call-template name="copy.attributes"/> 282 <xsl:apply-templates/> 283 </orgname> 284</xsl:template> 285 286<xsl:template match="author[not(personname)]|editor[not(personname)]|othercredit[not(personname)]" priority="200"> 287 <xsl:copy> 288 <xsl:call-template name="copy.attributes"/> 289 <personname> 290 <xsl:apply-templates select="honorific|firstname|surname|othername|lineage"/> 291 </personname> 292 <xsl:apply-templates select="*[not(self::honorific|self::firstname|self::surname 293 |self::othername|self::lineage)]"/> 294 </xsl:copy> 295</xsl:template> 296 297<xsl:template match="address|programlisting|screen|funcsynopsisinfo 298 |classsynopsisinfo" priority="200"> 299 <xsl:copy> 300 <xsl:call-template name="copy.attributes"> 301 <xsl:with-param name="suppress" select="'format'"/> 302 </xsl:call-template> 303 <xsl:apply-templates/> 304 </xsl:copy> 305</xsl:template> 306 307<!-- Suppress attributes with default values (i.e., added implicitly by DTD) --> 308<xsl:template match="productname" priority="200"> 309 <xsl:copy> 310 <xsl:call-template name="copy.attributes"> 311 <xsl:with-param name="suppress.default" select="'class=trade'"/> 312 </xsl:call-template> 313 <xsl:apply-templates/> 314 </xsl:copy> 315</xsl:template> 316 317<xsl:template match="orderedlist" priority="200"> 318 <xsl:copy> 319 <xsl:call-template name="copy.attributes"> 320 <xsl:with-param name="suppress.default" select="'inheritnum=ignore continuation=restarts'"/> 321 </xsl:call-template> 322 <xsl:apply-templates/> 323 </xsl:copy> 324</xsl:template> 325 326<xsl:template match="literallayout" priority="200"> 327 <xsl:copy> 328 <xsl:call-template name="copy.attributes"> 329 <xsl:with-param name="suppress" select="'format'"/><!-- Dropped entirely in DB5 --> 330 <xsl:with-param name="suppress.default" select="'class=normal'"/> 331 </xsl:call-template> 332 <xsl:apply-templates/> 333 </xsl:copy> 334</xsl:template> 335 336<xsl:template match="equation" priority="200"> 337 <xsl:choose> 338 <xsl:when test="not(title)"> 339 <xsl:call-template name="emit-message"> 340 <xsl:with-param 341 name="message" 342 >Convert equation without title to informal equation.</xsl:with-param> 343 </xsl:call-template> 344 <informalequation> 345 <xsl:call-template name="copy.attributes"/> 346 <xsl:apply-templates/> 347 </informalequation> 348 </xsl:when> 349 <xsl:otherwise> 350 <xsl:copy> 351 <xsl:call-template name="copy.attributes"/> 352 <xsl:apply-templates/> 353 </xsl:copy> 354 </xsl:otherwise> 355 </xsl:choose> 356</xsl:template> 357 358<xsl:template match="imagedata|videodata|audiodata|textdata" priority="200"> 359 <xsl:copy> 360 <xsl:call-template name="copy.attributes"> 361 <xsl:with-param name="suppress" select="'srccredit'"/> 362 </xsl:call-template> 363 <xsl:if test="@srccredit"> 364 <xsl:call-template name="emit-message"> 365 <xsl:with-param name="message"> 366 <xsl:text>Check conversion of srccredit </xsl:text> 367 <xsl:text>(othercredit="srccredit").</xsl:text> 368 </xsl:with-param> 369 </xsl:call-template> 370 <info> 371 <othercredit class="other" otherclass="srccredit"> 372 <orgname>???</orgname> 373 <contrib> 374 <xsl:value-of select="@srccredit"/> 375 </contrib> 376 </othercredit> 377 </info> 378 </xsl:if> 379 </xsl:copy> 380</xsl:template> 381 382<xsl:template match="sgmltag" priority="200"> 383 <tag> 384 <xsl:call-template name="copy.attributes"/> 385 <xsl:if test="@class = 'sgmlcomment'"> 386 <xsl:attribute name="class">comment</xsl:attribute> 387 </xsl:if> 388 <xsl:apply-templates/> 389 </tag> 390</xsl:template> 391 392<xsl:template match="inlinegraphic[@format='linespecific']" priority="210"> 393 <textobject> 394 <textdata> 395 <xsl:call-template name="copy.attributes"/> 396 </textdata> 397 </textobject> 398</xsl:template> 399 400<xsl:template match="inlinegraphic" priority="200"> 401 <inlinemediaobject> 402 <imageobject> 403 <imagedata> 404 <xsl:call-template name="copy.attributes"/> 405 </imagedata> 406 </imageobject> 407 </inlinemediaobject> 408</xsl:template> 409 410<xsl:template match="graphic[@format='linespecific']" priority="210"> 411 <mediaobject> 412 <textobject> 413 <textdata> 414 <xsl:call-template name="copy.attributes"/> 415 </textdata> 416 </textobject> 417 </mediaobject> 418</xsl:template> 419 420<xsl:template match="graphic" priority="200"> 421 <mediaobject> 422 <imageobject> 423 <imagedata> 424 <xsl:call-template name="copy.attributes"/> 425 </imagedata> 426 </imageobject> 427 </mediaobject> 428</xsl:template> 429 430<xsl:template match="pubsnumber" priority="200"> 431 <biblioid class="pubsnumber"> 432 <xsl:call-template name="copy.attributes"/> 433 <xsl:apply-templates/> 434 </biblioid> 435</xsl:template> 436 437<xsl:template match="invpartnumber" priority="200"> 438 <xsl:call-template name="emit-message"> 439 <xsl:with-param name="message"> 440 <xsl:text>Converting invpartnumber to biblioid otherclass="invpartnumber".</xsl:text> 441 </xsl:with-param> 442 </xsl:call-template> 443 <biblioid class="other" otherclass="invpartnumber"> 444 <xsl:call-template name="copy.attributes"/> 445 <xsl:apply-templates/> 446 </biblioid> 447</xsl:template> 448 449<xsl:template match="contractsponsor" priority="200"> 450 <xsl:variable name="contractnum" 451 select="preceding-sibling::contractnum|following-sibling::contractnum"/> 452 453 <xsl:call-template name="emit-message"> 454 <xsl:with-param name="message"> 455 <xsl:text>Converting contractsponsor to othercredit="contractsponsor".</xsl:text> 456 </xsl:with-param> 457 </xsl:call-template> 458 459 <othercredit class="other" otherclass="contractsponsor"> 460 <orgname> 461 <xsl:call-template name="copy.attributes"/> 462 <xsl:apply-templates/> 463 </orgname> 464 <xsl:for-each select="$contractnum"> 465 <contrib role="contractnum"> 466 <xsl:apply-templates select="node()"/> 467 </contrib> 468 </xsl:for-each> 469 </othercredit> 470</xsl:template> 471 472<xsl:template match="contractnum" priority="200"> 473 <xsl:if test="not(preceding-sibling::contractsponsor 474 |following-sibling::contractsponsor) 475 and not(preceding-sibling::contractnum)"> 476 <xsl:call-template name="emit-message"> 477 <xsl:with-param name="message"> 478 <xsl:text>Converting contractnum to othercredit="contractnum".</xsl:text> 479 </xsl:with-param> 480 </xsl:call-template> 481 482 <othercredit class="other" otherclass="contractnum"> 483 <orgname>???</orgname> 484 <xsl:for-each select="self::contractnum 485 |preceding-sibling::contractnum 486 |following-sibling::contractnum"> 487 <contrib> 488 <xsl:apply-templates select="node()"/> 489 </contrib> 490 </xsl:for-each> 491 </othercredit> 492 </xsl:if> 493</xsl:template> 494 495<xsl:template match="isbn|issn" priority="200"> 496 <biblioid class="{local-name(.)}"> 497 <xsl:call-template name="copy.attributes"/> 498 <xsl:apply-templates/> 499 </biblioid> 500</xsl:template> 501 502<xsl:template match="biblioid[count(*) = 1 503 and ulink 504 and normalize-space(text()) = '']" priority="200"> 505 <biblioid xlink:href="{ulink/@url}"> 506 <xsl:call-template name="copy.attributes"/> 507 <xsl:apply-templates select="ulink/node()"/> 508 </biblioid> 509</xsl:template> 510 511<xsl:template match="authorblurb" priority="200"> 512 <personblurb> 513 <xsl:call-template name="copy.attributes"/> 514 <xsl:apply-templates/> 515 </personblurb> 516</xsl:template> 517 518<xsl:template match="collabname" priority="200"> 519 <xsl:call-template name="emit-message"> 520 <xsl:with-param name="message"> 521 <xsl:text>Check conversion of collabname </xsl:text> 522 <xsl:text>(orgname role="collabname").</xsl:text> 523 </xsl:with-param> 524 </xsl:call-template> 525 <orgname role="collabname"> 526 <xsl:call-template name="copy.attributes"/> 527 <xsl:apply-templates/> 528 </orgname> 529</xsl:template> 530 531<xsl:template match="modespec" priority="200"> 532 <xsl:call-template name="emit-message"> 533 <xsl:with-param name="message"> 534 <xsl:text>Discarding modespec (</xsl:text> 535 <xsl:value-of select="."/> 536 <xsl:text>).</xsl:text> 537 </xsl:with-param> 538 </xsl:call-template> 539</xsl:template> 540 541<xsl:template match="mediaobjectco" priority="200"> 542 <mediaobject> 543 <xsl:copy-of select="@*"/> 544 <xsl:apply-templates/> 545 </mediaobject> 546</xsl:template> 547 548<xsl:template match="remark"> 549 <!-- get rid of any embedded markup if the version is 5.0. If it's > 5.0, leave markup in. --> 550 <remark> 551 <xsl:copy-of select="@*"/> 552 <xsl:choose> 553 <xsl:when test="$db5.version>5.0"> 554 <xsl:apply-templates/> 555 </xsl:when> 556 <xsl:otherwise> 557 <xsl:value-of select="."/> 558 </xsl:otherwise> 559 </xsl:choose> 560 </remark> 561</xsl:template> 562 563<xsl:template match="biblioentry/title 564 |bibliomset/title 565 |biblioset/title 566 |bibliomixed/title" priority="400"> 567 <citetitle> 568 <xsl:copy-of select="@*"/> 569 <xsl:apply-templates/> 570 </citetitle> 571</xsl:template> 572 573<xsl:template match="biblioentry/titleabbrev|biblioentry/subtitle 574 |bibliomset/titleabbrev|bibliomset/subtitle 575 |biblioset/titleabbrev|biblioset/subtitle 576 |bibliomixed/titleabbrev|bibliomixed/subtitle" 577 priority="400"> 578 <xsl:copy> 579 <xsl:copy-of select="@*"/> 580 <xsl:apply-templates/> 581 </xsl:copy> 582</xsl:template> 583 584<xsl:template match="biblioentry/contrib 585 |bibliomset/contrib 586 |bibliomixed/contrib" priority="200"> 587 <xsl:call-template name="emit-message"> 588 <xsl:with-param name="message"> 589 <xsl:text>Check conversion of contrib </xsl:text> 590 <xsl:text>(othercontrib="contrib").</xsl:text> 591 </xsl:with-param> 592 </xsl:call-template> 593 <othercredit class="other" otherclass="contrib"> 594 <orgname>???</orgname> 595 <contrib> 596 <xsl:call-template name="copy.attributes"/> 597 <xsl:apply-templates/> 598 </contrib> 599 </othercredit> 600</xsl:template> 601 602<xsl:template match="link" priority="200"> 603 <xsl:copy> 604 <xsl:call-template name="copy.attributes"/> 605 <xsl:apply-templates/> 606 </xsl:copy> 607</xsl:template> 608 609<xsl:template match="ulink" priority="200"> 610 <xsl:choose> 611 <xsl:when test="node()"> 612 <xsl:call-template name="emit-message"> 613 <xsl:with-param name="message"> 614 <xsl:text>Converting ulink to link.</xsl:text> 615 </xsl:with-param> 616 </xsl:call-template> 617 618 <link xlink:href="{@url}"> 619 <xsl:call-template name="copy.attributes"> 620 <xsl:with-param name="suppress" select="'url'"/> 621 </xsl:call-template> 622 <xsl:apply-templates/> 623 </link> 624 </xsl:when> 625 <xsl:otherwise> 626 <xsl:call-template name="emit-message"> 627 <xsl:with-param name="message"> 628 <xsl:text>Converting ulink to uri.</xsl:text> 629 </xsl:with-param> 630 </xsl:call-template> 631 632 <uri xlink:href="{@url}"> 633 <xsl:call-template name="copy.attributes"> 634 <xsl:with-param name="suppress" select="'url'"/> 635 </xsl:call-template> 636 <xsl:value-of select="@url"/> 637 </uri> 638 </xsl:otherwise> 639 </xsl:choose> 640</xsl:template> 641 642<xsl:template match="olink" priority="200"> 643 <xsl:if test="@linkmode"> 644 <xsl:call-template name="emit-message"> 645 <xsl:with-param name="message"> 646 <xsl:text>Discarding linkmode on olink.</xsl:text> 647 </xsl:with-param> 648 </xsl:call-template> 649 </xsl:if> 650 651 <xsl:choose> 652 <xsl:when test="@targetdocent"> 653 <xsl:call-template name="emit-message"> 654 <xsl:with-param name="message"> 655 <xsl:text>Converting olink targetdocent to targetdoc.</xsl:text> 656 </xsl:with-param> 657 </xsl:call-template> 658 659 <olink targetdoc="{unparsed-entity-uri(@targetdocent)}"> 660 <xsl:for-each select="@*"> 661 <xsl:if test="name(.) != 'targetdocent' 662 and name(.) != 'linkmode'"> 663 <xsl:copy/> 664 </xsl:if> 665 </xsl:for-each> 666 <xsl:apply-templates/> 667 </olink> 668 </xsl:when> 669 <xsl:otherwise> 670 <olink> 671 <xsl:for-each select="@*"> 672 <xsl:if test="name(.) != 'linkmode'"> 673 <xsl:copy/> 674 </xsl:if> 675 </xsl:for-each> 676 <xsl:apply-templates/> 677 </olink> 678 </xsl:otherwise> 679 </xsl:choose> 680</xsl:template> 681 682<xsl:template match="biblioentry/firstname 683 |biblioentry/surname 684 |biblioentry/othername 685 |biblioentry/lineage 686 |biblioentry/honorific 687 |bibliomset/firstname 688 |bibliomset/surname 689 |bibliomset/othername 690 |bibliomset/lineage 691 |bibliomset/honorific" priority="200"> 692 <xsl:choose> 693 <xsl:when test="preceding-sibling::firstname 694 |preceding-sibling::surname 695 |preceding-sibling::othername 696 |preceding-sibling::lineage 697 |preceding-sibling::honorific"> 698 <!-- nop --> 699 </xsl:when> 700 <xsl:otherwise> 701 <personname> 702 <xsl:apply-templates select="../firstname 703 |../surname 704 |../othername 705 |../lineage 706 |../honorific" mode="copy"/> 707 </personname> 708 </xsl:otherwise> 709 </xsl:choose> 710</xsl:template> 711 712<xsl:template match="areaset" priority="200"> 713 <xsl:copy> 714 <xsl:call-template name="copy.attributes"> 715 <xsl:with-param name="suppress" select="'coords'"/> 716 </xsl:call-template> 717 <xsl:apply-templates/> 718 </xsl:copy> 719</xsl:template> 720 721<xsl:template match="date|pubdate" priority="200"> 722 <xsl:variable name="rp1" select="substring-before(normalize-space(.), ' ')"/> 723 <xsl:variable name="rp2" 724 select="substring-before(substring-after(normalize-space(.), ' '), 725 ' ')"/> 726 <xsl:variable name="rp3" 727 select="substring-after(substring-after(normalize-space(.), ' '), ' ')"/> 728 729 <xsl:variable name="p1"> 730 <xsl:choose> 731 <xsl:when test="contains($rp1, ',')"> 732 <xsl:value-of select="substring-before($rp1, ',')"/> 733 </xsl:when> 734 <xsl:otherwise> 735 <xsl:value-of select="$rp1"/> 736 </xsl:otherwise> 737 </xsl:choose> 738 </xsl:variable> 739 740 <xsl:variable name="p2"> 741 <xsl:choose> 742 <xsl:when test="contains($rp2, ',')"> 743 <xsl:value-of select="substring-before($rp2, ',')"/> 744 </xsl:when> 745 <xsl:otherwise> 746 <xsl:value-of select="$rp2"/> 747 </xsl:otherwise> 748 </xsl:choose> 749 </xsl:variable> 750 751 <xsl:variable name="p3"> 752 <xsl:choose> 753 <xsl:when test="contains($rp3, ',')"> 754 <xsl:value-of select="substring-before($rp3, ',')"/> 755 </xsl:when> 756 <xsl:otherwise> 757 <xsl:value-of select="$rp3"/> 758 </xsl:otherwise> 759 </xsl:choose> 760 </xsl:variable> 761 762 <xsl:variable name="date"> 763 <xsl:choose> 764 <xsl:when test="string($p1+1) != 'NaN' and string($p3+1) != 'NaN'"> 765 <xsl:choose> 766 <xsl:when test="$p2 = 'Jan' or $p2 = 'January'"> 767 <xsl:number value="$p3" format="0001"/> 768 <xsl:text>-01-</xsl:text> 769 <xsl:number value="$p1" format="01"/> 770 </xsl:when> 771 <xsl:when test="$p2 = 'Feb' or $p2 = 'February'"> 772 <xsl:number value="$p3" format="0001"/> 773 <xsl:text>-02-</xsl:text> 774 <xsl:number value="$p1" format="01"/> 775 </xsl:when> 776 <xsl:when test="$p2 = 'Mar' or $p2 = 'March'"> 777 <xsl:number value="$p3" format="0001"/> 778 <xsl:text>-03-</xsl:text> 779 <xsl:number value="$p1" format="01"/> 780 </xsl:when> 781 <xsl:when test="$p2 = 'Apr' or $p2 = 'April'"> 782 <xsl:number value="$p3" format="0001"/> 783 <xsl:text>-04-</xsl:text> 784 <xsl:number value="$p1" format="01"/> 785 </xsl:when> 786 <xsl:when test="$p2 = 'May'"> 787 <xsl:number value="$p3" format="0001"/> 788 <xsl:text>-05-</xsl:text> 789 <xsl:number value="$p1" format="01"/> 790 </xsl:when> 791 <xsl:when test="$p2 = 'Jun' or $p2 = 'June'"> 792 <xsl:number value="$p3" format="0001"/> 793 <xsl:text>-06-</xsl:text> 794 <xsl:number value="$p1" format="01"/> 795 </xsl:when> 796 <xsl:when test="$p2 = 'Jul' or $p2 = 'July'"> 797 <xsl:number value="$p3" format="0001"/> 798 <xsl:text>-07-</xsl:text> 799 <xsl:number value="$p1" format="01"/> 800 </xsl:when> 801 <xsl:when test="$p2 = 'Aug' or $p2 = 'August'"> 802 <xsl:number value="$p3" format="0001"/> 803 <xsl:text>-08-</xsl:text> 804 <xsl:number value="$p1" format="01"/> 805 </xsl:when> 806 <xsl:when test="$p2 = 'Sep' or $p2 = 'September'"> 807 <xsl:number value="$p3" format="0001"/> 808 <xsl:text>-09-</xsl:text> 809 <xsl:number value="$p1" format="01"/> 810 </xsl:when> 811 <xsl:when test="$p2 = 'Oct' or $p2 = 'October'"> 812 <xsl:number value="$p3" format="0001"/> 813 <xsl:text>-10-</xsl:text> 814 <xsl:number value="$p1" format="01"/> 815 </xsl:when> 816 <xsl:when test="$p2 = 'Nov' or $p2 = 'November'"> 817 <xsl:number value="$p3" format="0001"/> 818 <xsl:text>-11-</xsl:text> 819 <xsl:number value="$p1" format="01"/> 820 </xsl:when> 821 <xsl:when test="$p2 = 'Dec' or $p2 = 'December'"> 822 <xsl:number value="$p3" format="0001"/> 823 <xsl:text>-12-</xsl:text> 824 <xsl:number value="$p1" format="01"/> 825 </xsl:when> 826 <xsl:otherwise> 827 <xsl:apply-templates/> 828 </xsl:otherwise> 829 </xsl:choose> 830 </xsl:when> 831 <xsl:when test="string($p2+1) != 'NaN' and string($p3+1) != 'NaN'"> 832 <xsl:choose> 833 <xsl:when test="$p1 = 'Jan' or $p1 = 'January'"> 834 <xsl:number value="$p3" format="0001"/> 835 <xsl:text>-01-</xsl:text> 836 <xsl:number value="$p2" format="01"/> 837 </xsl:when> 838 <xsl:when test="$p1 = 'Feb' or $p1 = 'February'"> 839 <xsl:number value="$p3" format="0001"/> 840 <xsl:text>-02-</xsl:text> 841 <xsl:number value="$p2" format="01"/> 842 </xsl:when> 843 <xsl:when test="$p1 = 'Mar' or $p1 = 'March'"> 844 <xsl:number value="$p3" format="0001"/> 845 <xsl:text>-03-</xsl:text> 846 <xsl:number value="$p2" format="01"/> 847 </xsl:when> 848 <xsl:when test="$p1 = 'Apr' or $p1 = 'April'"> 849 <xsl:number value="$p3" format="0001"/> 850 <xsl:text>-04-</xsl:text> 851 <xsl:number value="$p2" format="01"/> 852 </xsl:when> 853 <xsl:when test="$p1 = 'May'"> 854 <xsl:number value="$p3" format="0001"/> 855 <xsl:text>-05-</xsl:text> 856 <xsl:number value="$p2" format="01"/> 857 </xsl:when> 858 <xsl:when test="$p1 = 'Jun' or $p1 = 'June'"> 859 <xsl:number value="$p3" format="0001"/> 860 <xsl:text>-06-</xsl:text> 861 <xsl:number value="$p2" format="01"/> 862 </xsl:when> 863 <xsl:when test="$p1 = 'Jul' or $p1 = 'July'"> 864 <xsl:number value="$p3" format="0001"/> 865 <xsl:text>-07-</xsl:text> 866 <xsl:number value="$p2" format="01"/> 867 </xsl:when> 868 <xsl:when test="$p1 = 'Aug' or $p1 = 'August'"> 869 <xsl:number value="$p3" format="0001"/> 870 <xsl:text>-08-</xsl:text> 871 <xsl:number value="$p2" format="01"/> 872 </xsl:when> 873 <xsl:when test="$p1 = 'Sep' or $p1 = 'September'"> 874 <xsl:number value="$p3" format="0001"/> 875 <xsl:text>-09-</xsl:text> 876 <xsl:number value="$p2" format="01"/> 877 </xsl:when> 878 <xsl:when test="$p1 = 'Oct' or $p1 = 'October'"> 879 <xsl:number value="$p3" format="0001"/> 880 <xsl:text>-10-</xsl:text> 881 <xsl:number value="$p2" format="01"/> 882 </xsl:when> 883 <xsl:when test="$p1 = 'Nov' or $p1 = 'November'"> 884 <xsl:number value="$p3" format="0001"/> 885 <xsl:text>-11-</xsl:text> 886 <xsl:number value="$p2" format="01"/> 887 </xsl:when> 888 <xsl:when test="$p1 = 'Dec' or $p1 = 'December'"> 889 <xsl:number value="$p3" format="0001"/> 890 <xsl:text>-12-</xsl:text> 891 <xsl:number value="$p2" format="01"/> 892 </xsl:when> 893 <xsl:otherwise> 894 <xsl:apply-templates/> 895 </xsl:otherwise> 896 </xsl:choose> 897 </xsl:when> 898 <xsl:otherwise> 899 <xsl:apply-templates/> 900 </xsl:otherwise> 901 </xsl:choose> 902 </xsl:variable> 903 904 <xsl:choose> 905 <xsl:when test="normalize-space($date) != normalize-space(.)"> 906 <xsl:call-template name="emit-message"> 907 <xsl:with-param name="message"> 908 <xsl:text>Converted </xsl:text> 909 <xsl:value-of select="normalize-space(.)"/> 910 <xsl:text> into </xsl:text> 911 <xsl:value-of select="$date"/> 912 <xsl:text> for </xsl:text> 913 <xsl:value-of select="name(.)"/> 914 </xsl:with-param> 915 </xsl:call-template> 916 917 <xsl:copy> 918 <xsl:copy-of select="@*"/> 919 <xsl:value-of select="$date"/> 920 </xsl:copy> 921 </xsl:when> 922 923 <xsl:when test="$defaultDate != ''"> 924 <xsl:call-template name="emit-message"> 925 <xsl:with-param name="message"> 926 <xsl:text>Unparseable date: </xsl:text> 927 <xsl:value-of select="normalize-space(.)"/> 928 <xsl:text> in </xsl:text> 929 <xsl:value-of select="name(.)"/> 930 <xsl:text> (Using default: </xsl:text> 931 <xsl:value-of select="$defaultDate"/> 932 <xsl:text>)</xsl:text> 933 </xsl:with-param> 934 </xsl:call-template> 935 936 <xsl:copy> 937 <xsl:copy-of select="@*"/> 938 <xsl:copy-of select="$defaultDate"/> 939 <xsl:comment> 940 <xsl:value-of select="."/> 941 </xsl:comment> 942 </xsl:copy> 943 </xsl:when> 944 945 <xsl:otherwise> 946 <!-- these don't really matter anymore 947 <xsl:call-template name="emit-message"> 948 <xsl:with-param name="message"> 949 <xsl:text>Unparseable date: </xsl:text> 950 <xsl:value-of select="normalize-space(.)"/> 951 <xsl:text> in </xsl:text> 952 <xsl:value-of select="name(.)"/> 953 </xsl:with-param> 954 </xsl:call-template> 955 --> 956 <xsl:copy> 957 <xsl:copy-of select="@*"/> 958 <xsl:apply-templates/> 959 </xsl:copy> 960 </xsl:otherwise> 961 </xsl:choose> 962</xsl:template> 963 964<xsl:template match="title|subtitle|titleabbrev" priority="300"> 965 <xsl:variable name="local.name" select="local-name(.)"/> 966 <xsl:variable name="parent.name" select="local-name(..)"/> 967 968 <!-- First three tests drop element if parent ZZZ already has 969 ZZZinfo/title (or subtitle, or titleabbrev). --> 970 <xsl:choose> 971 <xsl:when test="../*[local-name(.) = concat($parent.name, 'info')]/*[local-name(.) = $local.name]"> 972 <xsl:call-template name="emit-message"> 973 <xsl:with-param name="message"> 974 <xsl:text>Check </xsl:text> 975 <xsl:value-of select="$parent.name"/> 976 <xsl:text> title.</xsl:text> 977 </xsl:with-param> 978 </xsl:call-template> 979 </xsl:when> 980 <!-- Before 4.0, <articleinfo> was known as <artheader> --> 981 <xsl:when test="$parent.name = 'article' and ../artheader/*[local-name(.) = $local.name]"> 982 <xsl:call-template name="emit-message"> 983 <xsl:with-param name="message"> 984 <xsl:text>Check </xsl:text> 985 <xsl:value-of select="$parent.name"/> 986 <xsl:text> title.</xsl:text> 987 </xsl:with-param> 988 </xsl:call-template> 989 </xsl:when> 990 <xsl:when test="../blockinfo/*[local-name(.) = $local.name]"> 991 <xsl:call-template name="emit-message"> 992 <xsl:with-param name="message"> 993 <xsl:text>Check </xsl:text> 994 <xsl:value-of select="$parent.name"/> 995 <xsl:text> title.</xsl:text> 996 </xsl:with-param> 997 </xsl:call-template> 998 </xsl:when> 999 <!-- always drop title, subtitle, and titleabbrev from refentryinfo --> 1000 <xsl:when test="$parent.name = 'refentryinfo'"> 1001 <xsl:call-template name="emit-message"> 1002 <xsl:with-param name="message"> 1003 <xsl:text>Removing title in refentryinfo.</xsl:text> 1004 </xsl:with-param> 1005 </xsl:call-template> 1006 </xsl:when> 1007 <!-- Also drop title, subtitle, and titleabbrev when they appear after info. 1008 The title is picked up and moved either into or before the info element 1009 in the templates that handle info elements. --> 1010 <xsl:when test="preceding-sibling::*[local-name(.) = concat($parent.name, 'info')]"> 1011 <xsl:call-template name="emit-message"> 1012 <xsl:with-param name="message"> 1013 <xsl:text>Removing </xsl:text><xsl:value-of select="$local.name"/> 1014 <xsl:text> after </xsl:text><xsl:value-of select="$parent.name"/><xsl:text>info. Moved before or inside info.</xsl:text> 1015 </xsl:with-param> 1016 </xsl:call-template> 1017 </xsl:when> 1018 <!-- this covers block elements that use blockinfo--> 1019 <xsl:when test="preceding-sibling::blockinfo"> 1020 <xsl:call-template name="emit-message"> 1021 <xsl:with-param name="message"> 1022 <xsl:text>Removing </xsl:text><xsl:value-of select="$local.name"/> 1023 <xsl:text> after blockinfo. Moved before or inside info.</xsl:text> 1024 </xsl:with-param> 1025 </xsl:call-template> 1026 </xsl:when> 1027 <!-- The next clause removes title, subtitle, or titleabbrev if it was 1028 moved inside the info block. Only happens when one or more of these 1029 elements occurs both inside and outside the info element. --> 1030 <xsl:when test="following-sibling::bookinfo[title|subtitle|titleabbrev] or 1031 following-sibling::articleinfo[title|subtitle|titleabbrev] or 1032 following-sibling::artheader[title|subtitle|titleabbrev] or 1033 following-sibling::setinfo[title|subtitle|titleabbrev]"> 1034 <xsl:call-template name="emit-message"> 1035 <xsl:with-param name="message"> 1036 <xsl:text>Removing </xsl:text><xsl:value-of select="$local.name"/> 1037 <xsl:text>. Has been moved inside info.</xsl:text> 1038 </xsl:with-param> 1039 </xsl:call-template> 1040 </xsl:when> 1041 <xsl:otherwise> 1042 <xsl:copy> 1043 <xsl:call-template name="copy.attributes"/> 1044 <xsl:apply-templates/> 1045 </xsl:copy> 1046 </xsl:otherwise> 1047 </xsl:choose> 1048</xsl:template> 1049 1050<!-- Allow abstract inside valid biblio* elements, and inside info elements, otherwise drop --> 1051<xsl:template match="abstract" priority="300"> 1052 <xsl:choose> 1053 <xsl:when test="not(contains(name(parent::*),'info')) 1054 and not(parent::biblioentry) and not(parent::bibliomixed) 1055 and not(parent::bibliomset) and not(parent::biblioset)"> 1056 <xsl:call-template name="emit-message"> 1057 <xsl:with-param name="message"> 1058 <xsl:text>CHECK abstract: removed from output (invalid location in 5.0).</xsl:text> 1059 </xsl:with-param> 1060 </xsl:call-template> 1061 </xsl:when> 1062 <xsl:otherwise> 1063 <xsl:apply-templates select="." mode="copy"/> 1064 </xsl:otherwise> 1065 </xsl:choose> 1066</xsl:template> 1067 1068<xsl:template match="indexterm"> 1069 <!-- don't copy the defaulted significance='normal' attribute --> 1070 <indexterm> 1071 <xsl:call-template name="copy.attributes"> 1072 <xsl:with-param name="suppress"> 1073 <xsl:if test="@significance = 'normal'">significance</xsl:if> 1074 </xsl:with-param> 1075 </xsl:call-template> 1076 <xsl:apply-templates/> 1077 </indexterm> 1078</xsl:template> 1079 1080<xsl:template match="ackno" priority="200"> 1081 <acknowledgements> 1082 <xsl:copy-of select="@*"/> 1083 <para> 1084 <xsl:apply-templates/> 1085 </para> 1086 </acknowledgements> 1087</xsl:template> 1088 1089<xsl:template match="lot|lotentry|tocback|tocchap|tocfront|toclevel1| 1090 toclevel2|toclevel3|toclevel4|toclevel5|tocpart" priority="200"> 1091 <tocdiv> 1092 <xsl:copy-of select="@*"/> 1093 <xsl:apply-templates/> 1094 </tocdiv> 1095</xsl:template> 1096 1097<xsl:template match="action" priority="200"> 1098 <phrase remap="action"> 1099 <xsl:call-template name="copy.attributes"/> 1100 <xsl:apply-templates/> 1101 </phrase> 1102</xsl:template> 1103 1104<xsl:template match="beginpage" priority="200"> 1105 <xsl:comment> beginpage pagenum=<xsl:value-of select="@pagenum"/> </xsl:comment> 1106 <xsl:call-template name="emit-message"> 1107 <xsl:with-param name="message"> 1108 <xsl:text>Replacing beginpage with comment</xsl:text> 1109 </xsl:with-param> 1110 </xsl:call-template> 1111</xsl:template> 1112 1113<xsl:template match="structname|structfield" priority="200"> 1114 <varname remap="{local-name(.)}"> 1115 <xsl:call-template name="copy.attributes"/> 1116 <xsl:apply-templates/> 1117 </varname> 1118</xsl:template> 1119 1120<!-- ====================================================================== --> 1121<!-- glossterm and term have broader content models in 4.x than 5.0. 1122 Warn when an unsupported element is found under glossterm. 1123 Because the synopsis elements can contain things that phrase cannot, 1124 leave them as is and warn. 1125 For other elements, change them into phrase recursively and lose attributes. 1126--> 1127<xsl:template match="glossterm|term"> 1128 <xsl:element name="{local-name(.)}"> 1129 <xsl:call-template name="copy.attributes"/> 1130 <xsl:apply-templates mode="clean-terms"/> 1131 </xsl:element> 1132</xsl:template> 1133 1134<!-- Any other elements inside term or glossterm which doesn't have a 1135 template rule are copied 1136--> 1137<xsl:template match="*" mode="clean-terms"> 1138 <xsl:apply-templates select="." mode="copy"/> 1139</xsl:template> 1140 1141 1142<!-- The synopsis elements have child elements that don't work inside phrase, plus 1143 they have attributes that shouldn't be lost. So, leave as is, but warn. --> 1144<xsl:template match="classsynopsis|cmdsynopsis|constructorsynopsis 1145 |destructorsynopsis|fieldsynopsis|methodsynopsis|synopsis" mode="clean-terms"> 1146 <xsl:call-template name="emit-message"> 1147 <xsl:with-param name="message"> 1148 <xsl:text>CHECK OUTPUT: Found </xsl:text><xsl:value-of select="local-name(.)"/> 1149 <xsl:text> inside </xsl:text><xsl:value-of select="local-name(..)"/> 1150 </xsl:with-param> 1151 </xsl:call-template> 1152 <xsl:element name="{local-name(.)}"> 1153 <xsl:call-template name="copy.attributes"/> 1154 <xsl:apply-templates/> 1155 </xsl:element> 1156</xsl:template> 1157 1158<!-- The following elements probably can be safely turned into phrase recursively --> 1159<xsl:template match="authorinitials|corpcredit|interface|medialabel|othercredit|revhistory" mode="clean-terms"> 1160 <xsl:call-template name="emit-message"> 1161 <xsl:with-param name="message"> 1162 <xsl:text>Replacing </xsl:text><xsl:value-of select="local-name(.)"/> 1163 <xsl:text> inside </xsl:text><xsl:value-of select="local-name(..)"/> 1164 <xsl:text> with phrase.</xsl:text> 1165 </xsl:with-param> 1166 </xsl:call-template> 1167 <phrase remap="{local-name(.)}"> 1168 <!-- Don't copy attributes --> 1169 <xsl:apply-templates mode="make-phrase"/> 1170 </phrase> 1171</xsl:template> 1172 1173<!-- affiliation can appear in a much smaller number of elements in 5.0. But, it contains 1174 elements that cannot appear in a phrase. So, replace all child elements, recursively, 1175 with <phrase remap="element name"... Don't keep attributes, which won't work on phrase. --> 1176 1177<xsl:template match="affiliation[not(parent::author) and not(parent::collab) and not(parent::editor) and not(parent::org) and not(parent::othercredit) and not(parent::person)]"> 1178 <xsl:call-template name="emit-message"> 1179 <xsl:with-param name="message"> 1180 <xsl:text>CHECK OUTPUT: Converting </xsl:text><xsl:value-of select="local-name(.)"/> 1181 <xsl:text> to phrase in </xsl:text><xsl:value-of select="local-name(..)"/> 1182 </xsl:with-param> 1183 </xsl:call-template> 1184 <phrase remap="{local-name(.)}"> 1185 <!-- Don't copy attributes --> 1186 <xsl:apply-templates mode="make-phrase"/> 1187 </phrase> 1188</xsl:template> 1189 1190<!-- This template recursively changes an element with remap="name of element". 1191 Does this recursively through children. --> 1192<xsl:template match="*" mode="make-phrase"> 1193 <phrase remap="{local-name(.)}"> 1194 <!-- Don't copy attributes --> 1195 <xsl:apply-templates mode="make-phrase"/> 1196 </phrase> 1197</xsl:template> 1198 1199<!-- ====================================================================== --> 1200 1201<!-- 6 Feb 2008, ndw changed mode=copy so that it only copies the first level, 1202 then it switches back to "normal" mode so that other rewriting templates 1203 catch embedded fixes --> 1204 1205<!-- 1206<xsl:template match="ulink" priority="200" mode="copy"> 1207 <xsl:choose> 1208 <xsl:when test="node()"> 1209 <xsl:call-template name="emit-message"> 1210 <xsl:with-param name="message"> 1211 <xsl:text>Converting ulink to phrase.</xsl:text> 1212 </xsl:with-param> 1213 </xsl:call-template> 1214 1215 <phrase xlink:href="{@url}"> 1216 <xsl:call-template name="copy.attributes"> 1217 <xsl:with-param name="suppress" select="'url'"/> 1218 </xsl:call-template> 1219 <xsl:apply-templates/> 1220 </phrase> 1221 </xsl:when> 1222 <xsl:otherwise> 1223 <xsl:call-template name="emit-message"> 1224 <xsl:with-param name="message"> 1225 <xsl:text>Converting ulink to uri.</xsl:text> 1226 </xsl:with-param> 1227 </xsl:call-template> 1228 1229 <uri xlink:href="{@url}"> 1230 <xsl:call-template name="copy.attributes"> 1231 <xsl:with-param name="suppress" select="'url'"/> 1232 </xsl:call-template> 1233 <xsl:value-of select="@url"/> 1234 </uri> 1235 </xsl:otherwise> 1236 </xsl:choose> 1237</xsl:template> 1238 1239<xsl:template match="sgmltag" priority="200" mode="copy"> 1240 <tag> 1241 <xsl:call-template name="copy.attributes"/> 1242 <xsl:apply-templates/> 1243 </tag> 1244</xsl:template> 1245--> 1246 1247<xsl:template match="*" mode="copy"> 1248 <xsl:copy> 1249 <xsl:call-template name="copy.attributes"/> 1250 <xsl:apply-templates/> 1251 </xsl:copy> 1252</xsl:template> 1253 1254<!-- 1255<xsl:template match="comment()|processing-instruction()|text()" mode="copy"> 1256 <xsl:copy/> 1257</xsl:template> 1258--> 1259 1260<!-- ====================================================================== --> 1261 1262<xsl:template match="*"> 1263 <xsl:copy> 1264 <xsl:call-template name="copy.attributes"/> 1265 <xsl:apply-templates/> 1266 </xsl:copy> 1267</xsl:template> 1268 1269<xsl:template match="comment()|processing-instruction()|text()"> 1270 <xsl:copy/> 1271</xsl:template> 1272 1273<!-- ====================================================================== --> 1274 1275<xsl:template name="copy.attributes"> 1276 <xsl:param name="src" select="."/> 1277 <xsl:param name="suppress" select="''"/> 1278 <xsl:param name="suppress.default" select="''"/> 1279 1280 <xsl:for-each select="$src/@*"> 1281 <xsl:variable name="suppressed.value"> 1282 <xsl:choose> 1283 <xsl:when test="not(contains($suppress.default, concat(local-name(.),'=')))"> 1284 <xsl:text>this-value-never-matches</xsl:text> 1285 </xsl:when> 1286 <xsl:otherwise> 1287 <xsl:value-of select="substring-before(substring-after(concat($suppress.default,' '), concat(local-name(.),'=')),' ')"/> 1288 </xsl:otherwise> 1289 </xsl:choose> 1290 </xsl:variable> 1291 1292 <xsl:choose> 1293 <xsl:when test="local-name(.) = 'moreinfo'"> 1294 <xsl:call-template name="emit-message"> 1295 <xsl:with-param name="message"> 1296 <xsl:text>Discarding moreinfo on </xsl:text> 1297 <xsl:value-of select="local-name($src)"/> 1298 </xsl:with-param> 1299 </xsl:call-template> 1300 </xsl:when> 1301 <xsl:when test="local-name(.) = 'lang'"> 1302 <xsl:attribute name="xml:lang"> 1303 <xsl:value-of select="."/> 1304 </xsl:attribute> 1305 </xsl:when> 1306 <xsl:when test="local-name(.) = 'id'"> 1307 <xsl:attribute name="xml:id"> 1308 <xsl:value-of select="."/> 1309 </xsl:attribute> 1310 </xsl:when> 1311 <xsl:when test="$suppress = local-name(.)"/> 1312 <xsl:when test=". = $suppressed.value"/> 1313 <xsl:when test="local-name(.) = 'float'"> 1314 <xsl:choose> 1315 <xsl:when test=". = '1'"> 1316 <xsl:call-template name="emit-message"> 1317 <xsl:with-param name="message"> 1318 <xsl:text>Discarding float on </xsl:text> 1319 <xsl:value-of select="local-name($src)"/> 1320 </xsl:with-param> 1321 </xsl:call-template> 1322 <xsl:if test="not($src/@floatstyle)"> 1323 <xsl:call-template name="emit-message"> 1324 <xsl:with-param name="message"> 1325 <xsl:text>Adding floatstyle='normal' on </xsl:text> 1326 <xsl:value-of select="local-name($src)"/> 1327 </xsl:with-param> 1328 </xsl:call-template> 1329 <xsl:attribute name="floatstyle"> 1330 <xsl:text>normal</xsl:text> 1331 </xsl:attribute> 1332 </xsl:if> 1333 </xsl:when> 1334 <xsl:when test=". = '0'"> 1335 <xsl:call-template name="emit-message"> 1336 <xsl:with-param name="message"> 1337 <xsl:text>Discarding float on </xsl:text> 1338 <xsl:value-of select="local-name($src)"/> 1339 </xsl:with-param> 1340 </xsl:call-template> 1341 </xsl:when> 1342 <xsl:otherwise> 1343 <xsl:call-template name="emit-message"> 1344 <xsl:with-param name="message"> 1345 <xsl:text>Discarding float on </xsl:text> 1346 <xsl:value-of select="local-name($src)"/> 1347 </xsl:with-param> 1348 </xsl:call-template> 1349 <xsl:if test="not($src/@floatstyle)"> 1350 <xsl:call-template name="emit-message"> 1351 <xsl:with-param name="message"> 1352 <xsl:text>Adding floatstyle='</xsl:text> 1353 <xsl:value-of select="."/> 1354 <xsl:text>' on </xsl:text> 1355 <xsl:value-of select="local-name($src)"/> 1356 </xsl:with-param> 1357 </xsl:call-template> 1358 <xsl:attribute name="floatstyle"> 1359 <xsl:value-of select="."/> 1360 </xsl:attribute> 1361 </xsl:if> 1362 </xsl:otherwise> 1363 </xsl:choose> 1364 </xsl:when> 1365 <xsl:when test="local-name(.) = 'entityref'"> 1366 <xsl:attribute name="fileref"> 1367 <xsl:value-of select="unparsed-entity-uri(@entityref)"/> 1368 </xsl:attribute> 1369 </xsl:when> 1370 1371 <xsl:when test="local-name($src) = 'simplemsgentry' 1372 and local-name(.) = 'audience'"> 1373 <xsl:attribute name="msgaud"> 1374 <xsl:value-of select="."/> 1375 </xsl:attribute> 1376 </xsl:when> 1377 <xsl:when test="local-name($src) = 'simplemsgentry' 1378 and local-name(.) = 'origin'"> 1379 <xsl:attribute name="msgorig"> 1380 <xsl:value-of select="."/> 1381 </xsl:attribute> 1382 </xsl:when> 1383 <xsl:when test="local-name($src) = 'simplemsgentry' 1384 and local-name(.) = 'level'"> 1385 <xsl:attribute name="msglevel"> 1386 <xsl:value-of select="."/> 1387 </xsl:attribute> 1388 </xsl:when> 1389 1390 <!-- * for upgrading XSL litprog params documentation --> 1391 <xsl:when test="local-name($src) = 'refmiscinfo' 1392 and local-name(.) = 'role' 1393 and . = 'type' 1394 "> 1395 <xsl:call-template name="emit-message"> 1396 <xsl:with-param name="message"> 1397 <xsl:text>Converting refmiscinfo@role=type to </xsl:text> 1398 <xsl:text>@class=other,otherclass=type</xsl:text> 1399 </xsl:with-param> 1400 </xsl:call-template> 1401 <xsl:attribute name="class">other</xsl:attribute> 1402 <xsl:attribute name="otherclass">type</xsl:attribute> 1403 </xsl:when> 1404 1405 <xsl:otherwise> 1406 <xsl:copy/> 1407 </xsl:otherwise> 1408 </xsl:choose> 1409 </xsl:for-each> 1410</xsl:template> 1411 1412<!-- ====================================================================== --> 1413 1414<xsl:template match="*" mode="addNS"> 1415 <xsl:choose> 1416 <xsl:when test="namespace-uri(.) = ''"> 1417 <xsl:element name="{local-name(.)}" 1418 namespace="http://docbook.org/ns/docbook"> 1419 <xsl:if test="not(ancestor::*[namespace-uri(.)=''])"> 1420 <xsl:attribute name="version"><xsl:value-of select="$db5.version.string"/></xsl:attribute> 1421 </xsl:if> 1422 <xsl:copy-of select="@*"/> 1423 <xsl:apply-templates mode="addNS"/> 1424 </xsl:element> 1425 </xsl:when> 1426 <xsl:otherwise> 1427 <xsl:copy> 1428 <xsl:if test="namespace-uri(.) = 'http://docbook.org/ns/docbook' and 1429 not(ancestor::*[namespace-uri(.)='http://docbook.org/ns/docbook'])"> 1430 <xsl:attribute name="version"><xsl:value-of select="$db5.version.string"/></xsl:attribute> 1431 </xsl:if> 1432 <xsl:copy-of select="@*"/> 1433 <xsl:apply-templates mode="addNS"/> 1434 </xsl:copy> 1435 </xsl:otherwise> 1436 </xsl:choose> 1437</xsl:template> 1438 1439<xsl:template match="comment()|processing-instruction()|text()" mode="addNS"> 1440 <xsl:copy/> 1441</xsl:template> 1442 1443<!-- ====================================================================== --> 1444 1445<xsl:template name="emit-message"> 1446 <xsl:param name="message"/> 1447 <xsl:message> 1448 <xsl:value-of select="$message"/> 1449 <xsl:text> (</xsl:text> 1450 <xsl:value-of select="$rootid"/> 1451 <xsl:text>)</xsl:text> 1452 </xsl:message> 1453</xsl:template> 1454 1455</xsl:stylesheet> 1456