htmltbl.xsl 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <?xml version="1.0"?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3. version="1.0">
  4. <!-- ********************************************************************
  5. $Id: htmltbl.xsl 9501 2012-07-16 00:14:50Z bobstayton $
  6. ********************************************************************
  7. This file is part of the XSL DocBook Stylesheet distribution.
  8. See ../README or http://docbook.sf.net/release/xsl/current/ for
  9. copyright and other information.
  10. ******************************************************************** -->
  11. <!-- ==================================================================== -->
  12. <xsl:template match="table" mode="htmlTable">
  13. <xsl:element name="table" namespace="">
  14. <xsl:apply-templates select="@*" mode="htmlTableAtt"/>
  15. <xsl:call-template name="htmlTable"/>
  16. </xsl:element>
  17. </xsl:template>
  18. <xsl:template match="colgroup" mode="htmlTable">
  19. <xsl:element name="{local-name()}" namespace="">
  20. <xsl:apply-templates select="@*" mode="htmlTableAtt"/>
  21. <xsl:apply-templates mode="htmlTable"/>
  22. </xsl:element>
  23. </xsl:template>
  24. <xsl:template match="col" mode="htmlTable">
  25. <xsl:element name="{local-name()}" namespace="">
  26. <xsl:apply-templates select="@*" mode="htmlTableAtt"/>
  27. </xsl:element>
  28. </xsl:template>
  29. <!-- Handled by formal.object.title template -->
  30. <xsl:template match="caption" mode="htmlTable"/>
  31. <xsl:template match="tbody|thead|tfoot|tr" mode="htmlTable">
  32. <xsl:element name="{local-name(.)}">
  33. <xsl:apply-templates select="@*" mode="htmlTableAtt"/>
  34. <xsl:apply-templates mode="htmlTable"/>
  35. </xsl:element>
  36. </xsl:template>
  37. <xsl:template match="th|td" mode="htmlTable">
  38. <xsl:element name="{local-name(.)}">
  39. <xsl:apply-templates select="@*" mode="htmlTableAtt"/>
  40. <xsl:apply-templates/> <!-- *not* mode=htmlTable -->
  41. </xsl:element>
  42. </xsl:template>
  43. <!-- don't copy through DocBook-specific attributes on HTML table markup -->
  44. <!-- default behavior is to not copy through because there are more
  45. DocBook attributes than HTML attributes -->
  46. <xsl:template mode="htmlTableAtt" match="@*"/>
  47. <!-- copy these through -->
  48. <xsl:template mode="htmlTableAtt"
  49. match="@abbr
  50. | @align
  51. | @axis
  52. | @bgcolor
  53. | @border
  54. | @cellpadding
  55. | @cellspacing
  56. | @char
  57. | @charoff
  58. | @class
  59. | @dir
  60. | @frame
  61. | @headers
  62. | @height
  63. | @lang
  64. | @nowrap
  65. | @onclick
  66. | @ondblclick
  67. | @onkeydown
  68. | @onkeypress
  69. | @onkeyup
  70. | @onmousedown
  71. | @onmousemove
  72. | @onmouseout
  73. | @onmouseover
  74. | @onmouseup
  75. | @rules
  76. | @style
  77. | @summary
  78. | @title
  79. | @valign
  80. | @valign
  81. | @width
  82. | @xml:lang">
  83. <xsl:copy-of select="."/>
  84. </xsl:template>
  85. <xsl:template match="@span|@rowspan|@colspan" mode="htmlTableAtt">
  86. <!-- No need to copy through the DTD's default value "1" of the attribute -->
  87. <xsl:if test="number(.) != 1">
  88. <xsl:attribute name="{local-name(.)}">
  89. <xsl:value-of select="."/>
  90. </xsl:attribute>
  91. </xsl:if>
  92. </xsl:template>
  93. <!-- map floatstyle to HTML float values -->
  94. <xsl:template match="@floatstyle" mode="htmlTableAtt">
  95. <xsl:attribute name="style">
  96. <xsl:text>float: </xsl:text>
  97. <xsl:choose>
  98. <xsl:when test="contains(., 'left')">left</xsl:when>
  99. <xsl:when test="contains(., 'right')">right</xsl:when>
  100. <xsl:when test="contains(., 'start')">
  101. <xsl:value-of select="$direction.align.start"/>
  102. </xsl:when>
  103. <xsl:when test="contains(., 'end')">
  104. <xsl:value-of select="$direction.align.end"/>
  105. </xsl:when>
  106. <xsl:when test="contains(., 'inside')">
  107. <xsl:value-of select="$direction.align.start"/>
  108. </xsl:when>
  109. <xsl:when test="contains(., 'outside')">
  110. <xsl:value-of select="$direction.align.end"/>
  111. </xsl:when>
  112. <xsl:when test="contains(., 'before')">none</xsl:when>
  113. <xsl:when test="contains(., 'none')">none</xsl:when>
  114. </xsl:choose>
  115. <xsl:text>;</xsl:text>
  116. </xsl:attribute>
  117. </xsl:template>
  118. </xsl:stylesheet>