dita2odt_template.xsl 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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. 2004, 2005 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" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  23. xmlns:anim="urn:oasis:names:tc:opendocument:xmlns:animation:1.0"
  24. xmlns:smil="urn:oasis:names:tc:opendocument:xmlns:smil-compatible:1.0"
  25. xmlns:prodtools="http://www.ibm.com/xmlns/prodtools"
  26. version="2.0">
  27. <xsl:import href="plugin:org.dita.base:xsl/common/output-message.xsl"/>
  28. <xsl:import href="plugin:org.dita.base:xsl/common/dita-utilities.xsl"/>
  29. <xsl:import href="plugin:org.dita.base:xsl/common/related-links.xsl"/>
  30. <xsl:import href="plugin:org.dita.base:xsl/common/dita-textonly.xsl"/>
  31. <xsl:import href="plugin:org.dita.base:xsl/common/flag.xsl"/>
  32. <xsl:import href="xslodt/dita2odt-utilities.xsl"/>
  33. <xsl:import href="xslodt/dita2odt-table.xsl"/>
  34. <xsl:import href="xslodt/dita2odt-lists.xsl"/>
  35. <xsl:import href="xslodt/dita2odt-img.xsl"/>
  36. <xsl:import href="xslodt/dita2odt-map.xsl"/>
  37. <xsl:import href="xslodt/dita2odtImpl.xsl"/>
  38. <xsl:import href="xslodt/dita2odt-concept.xsl"/>
  39. <xsl:import href="xslodt/dita2odt-gloss.xsl"/>
  40. <xsl:import href="xslodt/dita2odt-task.xsl"/>
  41. <xsl:import href="xslodt/dita2odt-reference.xsl"/>
  42. <xsl:import href="xslodt/hi-d.xsl"/>
  43. <xsl:import href="xslodt/pr-d.xsl"/>
  44. <xsl:import href="xslodt/sw-d.xsl"/>
  45. <xsl:import href="xslodt/ui-d.xsl"/>
  46. <xsl:import href="xslodt/markup-d.xsl"/>
  47. <xsl:import href="xslodt/xml-d.xsl"/>
  48. <!--
  49. <xsl:import href="xslodt/common/vars.xsl"/>
  50. -->
  51. <xsl:import href="xslodt/commons.xsl"/>
  52. <xsl:import href="xslodt/dita2odt-links.xsl"/>
  53. <xsl:import href="xslodt/dita2odt-flagging.xsl"/>
  54. <!--
  55. <xsl:include href="xslodt/dita2odt-relinks.xsl"/>
  56. -->
  57. <dita:extension id="dita.xsl.odt" behavior="org.dita.dost.platform.ImportXSLAction" xmlns:dita="http://dita-ot.sourceforge.net"/>
  58. <!-- =========== DEFAULT VALUES FOR EXTERNALLY MODIFIABLE PARAMETERS =========== -->
  59. <xsl:param name="include.rellinks"/>
  60. <xsl:param name="DRAFT" select="'no'"/>
  61. <xsl:param name="OUTPUTDIR" select="''"/>
  62. <xsl:param name="FILTERFILE"/>
  63. <!-- default "hide index entries" processing parameter ('no' = hide them)-->
  64. <xsl:param name="INDEXSHOW" select="'no'"/><!-- "no" and "yes" are valid values; non-'yes' is ignored -->
  65. <xsl:param name="FILEREF">file:///</xsl:param>
  66. <!-- Transform type, such as 'xhtml', 'htmlhelp', or 'eclipsehelp' -->
  67. <xsl:param name="TRANSTYPE" select="'odt'"/>
  68. <!-- for now, disable breadcrumbs pending link group descision -->
  69. <xsl:param name="BREADCRUMBS" select="'no'"/> <!-- "no" and "yes" are valid values; non-'yes' is ignored -->
  70. <!-- the year for the copyright -->
  71. <xsl:param name="YEAR" select="format-date(current-date(), '[Y]')"/>
  72. <!-- the file name (file name and extension only - no path) of the document being transformed.
  73. Needed to help with debugging.
  74. default is 'myfile.xml')-->
  75. <xsl:param name="FILENAME"/>
  76. <xsl:param name="FILEDIR"/>
  77. <xsl:param name="CURRENTFILE">
  78. <xsl:choose>
  79. <!-- ditamap -->
  80. <xsl:when test="contains($FILENAME, '_MERGED')">
  81. <xsl:value-of select="concat($FILEDIR, '/', substring-before($FILENAME, '_MERGED'), '.ditamap')"/>
  82. </xsl:when>
  83. <!-- topic -->
  84. <xsl:otherwise>
  85. <xsl:value-of select="concat($FILEDIR, '/', $FILENAME)"/>
  86. </xsl:otherwise>
  87. </xsl:choose>
  88. </xsl:param>
  89. <!-- Debug mode - enables XSL debugging xsl-messages.
  90. Needed to help with debugging.
  91. default is 'no')-->
  92. <xsl:param name="DBG" select="'no'"/> <!-- "no" and "yes" are valid values; non-'yes' is ignored -->
  93. <!-- Name of the keyref file that contains key definitions -->
  94. <xsl:param name="KEYREF-FILE" select="concat($WORKDIR,$PATH2PROJ,'keydef.xml')"/>
  95. <xsl:param name="BASEDIR"/>
  96. <xsl:param name="TEMPDIR"/>
  97. <xsl:param name="includeRelatedLinkRoles" select="concat(' ', normalize-space($include.rellinks), ' ')"/>
  98. <xsl:variable name="tempfiledir">
  99. <xsl:choose>
  100. <xsl:when test="contains($TEMPDIR, ':\') or contains($TEMPDIR, ':/')">
  101. <xsl:value-of select="'file:/'"/><xsl:value-of select="concat($TEMPDIR, '/')"/>
  102. </xsl:when>
  103. <xsl:when test="starts-with($TEMPDIR, '/')">
  104. <xsl:value-of select="'file://'"/><xsl:value-of select="concat($TEMPDIR, '/')"/>
  105. </xsl:when>
  106. <xsl:when test="starts-with($BASEDIR, '/')">
  107. <xsl:value-of select="'file://'"/><xsl:value-of select="concat($BASEDIR, '/')"/><xsl:value-of select="concat($TEMPDIR, '/')"/>
  108. </xsl:when>
  109. <xsl:otherwise>
  110. <xsl:value-of select="'file:/'"/><xsl:value-of select="concat($BASEDIR, '/')"/><xsl:value-of select="concat($TEMPDIR, '/')"/>
  111. </xsl:otherwise>
  112. </xsl:choose>
  113. </xsl:variable>
  114. <!-- current file with path -->
  115. <xsl:variable name="currentfile" select="concat($tempfiledir, $CURRENTFILE)"/>
  116. <!-- the working directory that contains the document being transformed.
  117. Needed as a directory prefix for the @conref "document()" function calls.
  118. default is '../doc/')-->
  119. <xsl:variable name="WORKDIR">
  120. <xsl:apply-templates select="document($currentfile, /)/processing-instruction('workdir-uri')[1]" mode="get-work-dir"/>
  121. </xsl:variable>
  122. <!-- the path back to the project. Used for c.gif, delta.gif, css to allow user's to have
  123. these files in 1 location. -->
  124. <xsl:variable name="PATH2PROJ">
  125. <xsl:apply-templates select="document($currentfile, /)/processing-instruction('path2project-uri')[1]" mode="get-path2project"/>
  126. </xsl:variable>
  127. <xsl:output method="xml" encoding="UTF-8" indent="yes"/>
  128. <xsl:strip-space elements="*"/>
  129. <xsl:attribute-set name="root">
  130. <xsl:attribute name="office:version">1.1</xsl:attribute>
  131. </xsl:attribute-set>
  132. <xsl:template match="/">
  133. <office:document-content xsl:use-attribute-sets="root">
  134. <xsl:call-template name="root"/>
  135. </office:document-content>
  136. </xsl:template>
  137. <xsl:template name="root">
  138. <!--xsl:call-template name="gen-list-table"/-->
  139. <office:scripts/>
  140. <office:automatic-styles>
  141. <xsl:if test="//*[contains(@class, ' topic/table ')]|//*[contains(@class, ' topic/simpletable ')]">
  142. <xsl:call-template name="create_table_cell_styles"/>
  143. </xsl:if>
  144. <xsl:apply-templates select="//text()|//*[contains(@class, ' topic/state ')]" mode="create_hi_style"/>
  145. <xsl:call-template name="create_flagging_styles"/>
  146. </office:automatic-styles>
  147. <office:body>
  148. <office:text>
  149. <text:sequence-decls>
  150. <text:sequence-decl text:display-outline-level="0" text:name="Illustration"/>
  151. <text:sequence-decl text:display-outline-level="0" text:name="Table"/>
  152. <text:sequence-decl text:display-outline-level="0" text:name="Text"/>
  153. <text:sequence-decl text:display-outline-level="0" text:name="Drawing"/>
  154. </text:sequence-decls>
  155. <xsl:choose>
  156. <!-- bookmap -->
  157. <xsl:when test="$mapType = 'bookmap'">
  158. <xsl:call-template name="create_book_title"/>
  159. <xsl:call-template name="create_book_abstract"/>
  160. <xsl:call-template name="create_book_notices"/>
  161. </xsl:when>
  162. <!-- normal map -->
  163. <xsl:when test="$mapType = 'ditamap'">
  164. <xsl:call-template name="create_map_title"/>
  165. </xsl:when>
  166. <!-- topic -->
  167. <xsl:otherwise>
  168. <xsl:call-template name="create_topic_title"/>
  169. </xsl:otherwise>
  170. </xsl:choose>
  171. <xsl:call-template name="create_toc"/>
  172. <xsl:apply-templates/>
  173. </office:text>
  174. </office:body>
  175. </xsl:template>
  176. </xsl:stylesheet>