commons.xsl 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- This file is part of the DITA Open Toolkit project.
  3. See the accompanying license.txt file for applicable licenses. -->
  4. <!-- (c) Copyright IBM Corp. 2009, 2010 All Rights Reserved. -->
  5. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  6. xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
  7. xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
  8. xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
  9. xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
  10. xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
  11. xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
  12. xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/"
  13. xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"
  14. xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0"
  15. xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
  16. xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0"
  17. xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"
  18. xmlns:math="http://www.w3.org/1998/Math/MathML"
  19. xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0"
  20. xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0"
  21. xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms"
  22. xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  23. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  24. xmlns:anim="urn:oasis:names:tc:opendocument:xmlns:animation:1.0"
  25. xmlns:smil="urn:oasis:names:tc:opendocument:xmlns:smil-compatible:1.0"
  26. xmlns:prodtools="http://www.ibm.com/xmlns/prodtools"
  27. xmlns:dita2xslfo="http://dita-ot.sourceforge.net/ns/200910/dita2xslfo"
  28. xmlns:opentopic="http://www.idiominc.com/opentopic"
  29. xmlns:opentopic-index="http://www.idiominc.com/opentopic/index"
  30. exclude-result-prefixes="opentopic opentopic-index dita2xslfo"
  31. version="2.0">
  32. <xsl:template name="determineTopicType">
  33. <xsl:variable name="id" select="ancestor-or-self::*[contains(@class, ' topic/topic ')][1]/@id"/>
  34. <xsl:variable name="gid" select="generate-id(ancestor-or-self::*[contains(@class, ' topic/topic ')][1])"/>
  35. <xsl:variable name="topicNumber" select="count($topicNumbers/topic[@id = $id][following-sibling::topic[@guid = $gid]]) + 1"/>
  36. <xsl:variable name="mapTopic">
  37. <xsl:copy-of select="$map//*[@id = $id]"/>
  38. </xsl:variable>
  39. <xsl:variable name="foundTopicType">
  40. <xsl:apply-templates select="$mapTopic/*[position() = $topicNumber]" mode="determineTopicType"/>
  41. </xsl:variable>
  42. <xsl:choose>
  43. <xsl:when test="$foundTopicType!=''"><xsl:value-of select="$foundTopicType"/></xsl:when>
  44. <xsl:otherwise>topicSimple</xsl:otherwise>
  45. </xsl:choose>
  46. </xsl:template>
  47. <xsl:template match="*" mode="determineTopicType">
  48. <!-- Default, when not matching a bookmap type, is topicSimple -->
  49. <xsl:text>topicSimple</xsl:text>
  50. </xsl:template>
  51. <xsl:template match="*[contains(@class, ' bookmap/chapter ')]" mode="determineTopicType">
  52. <xsl:text>topicChapter</xsl:text>
  53. </xsl:template>
  54. <xsl:template match="*[contains(@class, ' bookmap/appendix ')]" mode="determineTopicType">
  55. <xsl:text>topicAppendix</xsl:text>
  56. </xsl:template>
  57. <xsl:template match="*[contains(@class, ' bookmap/preface ')]" mode="determineTopicType">
  58. <xsl:text>topicPreface</xsl:text>
  59. </xsl:template>
  60. <xsl:template match="*[contains(@class, ' bookmap/part ')]" mode="determineTopicType">
  61. <xsl:text>topicPart</xsl:text>
  62. </xsl:template>
  63. <xsl:template match="*[contains(@class, ' bookmap/abbrevlist ')]" mode="determineTopicType">
  64. <xsl:text>topicAbbrevList</xsl:text>
  65. </xsl:template>
  66. <xsl:template match="*[contains(@class, ' bookmap/bibliolist ')]" mode="determineTopicType">
  67. <xsl:text>topicBiblioList</xsl:text>
  68. </xsl:template>
  69. <xsl:template match="*[contains(@class, ' bookmap/booklist ')]" mode="determineTopicType">
  70. <xsl:text>topicBookList</xsl:text>
  71. </xsl:template>
  72. <xsl:template match="*[contains(@class, ' bookmap/figurelist ')]" mode="determineTopicType">
  73. <xsl:text>topicFigureList</xsl:text>
  74. </xsl:template>
  75. <xsl:template match="*[contains(@class, ' bookmap/indexlist ')]" mode="determineTopicType">
  76. <xsl:text>topicIndexList</xsl:text>
  77. </xsl:template>
  78. <xsl:template match="*[contains(@class, ' bookmap/toc ')]" mode="determineTopicType">
  79. <xsl:text>topicTocList</xsl:text>
  80. </xsl:template>
  81. <xsl:template match="*[contains(@class, ' bookmap/glossarylist ')]" mode="determineTopicType">
  82. <xsl:text>topicGlossaryList</xsl:text>
  83. </xsl:template>
  84. <xsl:template match="*[contains(@class, ' bookmap/trademarklist ')]" mode="determineTopicType">
  85. <xsl:text>topicTradeMarkList</xsl:text>
  86. </xsl:template>
  87. <xsl:template match="*[contains(@class, ' bookmap/notices ')]" mode="determineTopicType">
  88. <xsl:text>topicNotices</xsl:text>
  89. </xsl:template>
  90. <xsl:template match="*[contains(@class, ' bookmap/bookabstract ')]" mode="determineTopicType">
  91. <xsl:text>topicAbstract</xsl:text>
  92. </xsl:template>
  93. <!-- Bookmap Chapter processing -->
  94. <xsl:template name="processTopicChapter">
  95. <xsl:apply-templates/>
  96. <!--
  97. <text:p text:style-name="PB"/>
  98. <xsl:call-template name="startPageNumbering"/>
  99. <xsl:call-template name="insertBodyStaticContents"/>
  100. <fo:block xsl:use-attribute-sets="topic">
  101. <xsl:attribute name="id">
  102. <xsl:value-of select="@id"/>
  103. </xsl:attribute>
  104. <xsl:if test="not(ancestor::*[contains(@class, ' topic/topic ')])">
  105. <fo:marker marker-class-name="current-topic-number">
  106. <xsl:number format="1"/>
  107. </fo:marker>
  108. <fo:marker marker-class-name="current-header">
  109. <xsl:for-each select="child::*[contains(@class,' topic/title ')]">
  110. <xsl:call-template name="getTitle"/>
  111. </xsl:for-each>
  112. </fo:marker>
  113. </xsl:if>
  114. <xsl:apply-templates select="*[contains(@class,' topic/prolog ')]"/>
  115. <xsl:call-template name="insertChapterFirstpageStaticContent">
  116. <xsl:with-param name="type" select="'chapter'"/>
  117. </xsl:call-template>
  118. <xsl:apply-templates select="*[contains(@class,' topic/topic ')]"/>
  119. </fo:block>
  120. -->
  121. </xsl:template>
  122. </xsl:stylesheet>