dita2odt.xsl 8.7 KB

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