tables_fop.xsl 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. This file is part of the DITA Open Toolkit project.
  4. Copyright 2016 IBM Corporation
  5. See the accompanying LICENSE file for applicable license.
  6. -->
  7. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  8. xmlns:fo="http://www.w3.org/1999/XSL/Format"
  9. xmlns:xs="http://www.w3.org/2001/XMLSchema"
  10. xmlns:dita-ot="http://dita-ot.sourceforge.net/ns/201007/dita-ot"
  11. version="2.0"
  12. exclude-result-prefixes="xs dita-ot">
  13. <xsl:template match="*[contains(@class, ' topic/dt ')]">
  14. <fo:block xsl:use-attribute-sets="dlentry.dt__content">
  15. <xsl:call-template name="commonattributes"/>
  16. <xsl:if test="not(preceding-sibling::*[contains(@class,' topic/dt ')])">
  17. <xsl:apply-templates select="../@id" mode="dlentry-id-for-fop"/>
  18. <xsl:apply-templates select="../*[contains(@class,' ditaot-d/ditaval-startprop ')]" mode="outofline"/>
  19. </xsl:if>
  20. <xsl:apply-templates select="." mode="inlineTextOptionalKeyref"/>
  21. </fo:block>
  22. </xsl:template>
  23. <xsl:template match="*[contains(@class,' topic/dlentry ')]/@id">
  24. <!-- FOP does not support @id on table rows; drop from the row and add to an <fo:inline> in the first term. -->
  25. </xsl:template>
  26. <xsl:template match="@id" mode="dlentry-id-for-fop">
  27. <fo:inline id="{.}"/>
  28. </xsl:template>
  29. <xsl:template match="*[contains(@class,' topic/entry ')]">
  30. <xsl:choose>
  31. <xsl:when test="dita-ot:get-entry-end-position(.) gt number(ancestor::*[contains(@class,' topic/tgroup ')][1]/@cols)">
  32. <!-- FOP crashes if an entry extends beyond the table width -->
  33. <xsl:call-template name="output-message">
  34. <xsl:with-param name="id" select="'PDFX012E'"/>
  35. </xsl:call-template>
  36. </xsl:when>
  37. <xsl:otherwise>
  38. <xsl:next-match/>
  39. </xsl:otherwise>
  40. </xsl:choose>
  41. </xsl:template>
  42. <!-- By default in FOP, rotated text in a table entry does not change the cell size, so rotated text will overwrite other cells.
  43. To enable rotation, explicitly set the height and width as follows:
  44. 1) Uncomment the fo:block-container
  45. 2) Adjust the height and width values to either
  46. 2a) An appropriate default that is acceptable for all of your rotated cells, or
  47. 2b) A specific or calculated value based on the cell content -->
  48. <xsl:template match="*[contains(@class, ' topic/thead ')]/*[contains(@class, ' topic/row ')]/*[contains(@class, ' topic/entry ')]" mode="rotateTableEntryContent">
  49. <!--<fo:block-container reference-orientation="90" width="150px" height="80px">-->
  50. <fo:block xsl:use-attribute-sets="thead.row.entry__content">
  51. <xsl:call-template name="processEntryContent"/>
  52. </fo:block>
  53. <!--</fo:block-container>-->
  54. </xsl:template>
  55. <xsl:template match="*[contains(@class, ' topic/tbody ')]/*[contains(@class, ' topic/row ')]/*[contains(@class, ' topic/entry ')]" mode="rotateTableEntryContent">
  56. <!--<fo:block-container reference-orientation="90" width="150px" height="80px">-->
  57. <fo:block xsl:use-attribute-sets="tbody.row.entry__content">
  58. <xsl:call-template name="processEntryContent"/>
  59. </fo:block>
  60. <!--</fo:block-container>-->
  61. </xsl:template>
  62. </xsl:stylesheet>