simpletable.xsl 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  5. xmlns:xs="http://www.w3.org/2001/XMLSchema"
  6. xmlns:dita2html="http://dita-ot.sourceforge.net/ns/200801/dita2html"
  7. xmlns:dita-ot="http://dita-ot.sourceforge.net/ns/201007/dita-ot"
  8. xmlns:table="http://dita-ot.sourceforge.net/ns/201007/dita-ot/table"
  9. xmlns:simpletable="http://dita-ot.sourceforge.net/ns/201007/dita-ot/simpletable"
  10. version="2.0"
  11. exclude-result-prefixes="xs dita2html dita-ot table simpletable">
  12. <xsl:function name="simpletable:generate-headers" as="xs:string">
  13. <xsl:param name="el" as="element()"/>
  14. <xsl:param name="suffix" as="xs:string"/>
  15. <xsl:sequence select="string-join((generate-id($el), $suffix), '-')"/>
  16. </xsl:function>
  17. <xsl:template match="*[contains(@class, ' topic/simpletable ')]" name="topic.simpletable">
  18. <xsl:apply-templates select="*[contains(@class, ' ditaot-d/ditaval-startprop ')]" mode="out-of-line"/>
  19. <table>
  20. <xsl:apply-templates select="." mode="table:common"/>
  21. <xsl:call-template name="dita2html:simpletable-cols"/>
  22. <xsl:apply-templates select="*[contains(@class, ' topic/sthead ')]"/>
  23. <xsl:apply-templates select="." mode="generate-table-header"/>
  24. <tbody>
  25. <xsl:apply-templates select="*[contains(@class, ' topic/strow ')]"/>
  26. </tbody>
  27. </table>
  28. <xsl:apply-templates select="*[contains(@class, ' ditaot-d/ditaval-endprop ')]" mode="out-of-line"/>
  29. </xsl:template>
  30. <xsl:template match="*[contains(@class, ' topic/simpletable ')]" mode="css-class">
  31. <xsl:apply-templates select="@frame, @expanse, @scale" mode="#current"/>
  32. </xsl:template>
  33. <xsl:template match="*[contains(@class, ' topic/strow ')]">
  34. <tr>
  35. <xsl:apply-templates select="." mode="table:common"/>
  36. <xsl:apply-templates/>
  37. </tr>
  38. </xsl:template>
  39. <xsl:template match="*[contains(@class, ' topic/sthead ')]">
  40. <thead>
  41. <tr>
  42. <xsl:apply-templates select="." mode="table:common"/>
  43. <xsl:apply-templates/>
  44. </tr>
  45. </thead>
  46. </xsl:template>
  47. <xsl:template match="*[simpletable:is-head-entry(.)]">
  48. <th>
  49. <xsl:apply-templates select="." mode="simpletable:entry"/>
  50. </th>
  51. </xsl:template>
  52. <xsl:template match="*[simpletable:is-body-entry(.)][simpletable:is-keycol-entry(.)]">
  53. <th scope="row">
  54. <xsl:apply-templates select="." mode="simpletable:entry"/>
  55. </th>
  56. </xsl:template>
  57. <xsl:template match="*[simpletable:is-body-entry(.)][not(simpletable:is-keycol-entry(.))]">
  58. <td>
  59. <xsl:apply-templates select="." mode="simpletable:entry"/>
  60. </td>
  61. </xsl:template>
  62. <xsl:template match="*[contains(@class, ' topic/stentry ')]" mode="simpletable:entry">
  63. <xsl:apply-templates select="." mode="table:common"/>
  64. <xsl:apply-templates select="." mode="headers"/>
  65. <xsl:apply-templates/>
  66. </xsl:template>
  67. <xsl:template match="*[simpletable:is-head-entry(.)]" mode="headers">
  68. <xsl:attribute name="id" select="dita-ot:generate-html-id(.)"/>
  69. </xsl:template>
  70. <xsl:template match="*[simpletable:is-body-entry(.)]" mode="headers">
  71. <xsl:call-template name="set.stentry.headers"/>
  72. </xsl:template>
  73. </xsl:stylesheet>