hazard-d.xsl 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!--
  3. This file is part of the DITA Open Toolkit project.
  4. See the accompanying license.txt file for applicable licenses.
  5. -->
  6. <xsl:stylesheet version="2.0"
  7. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  8. xmlns:ditamsg="http://dita-ot.sourceforge.net/ns/200704/ditamsg"
  9. xmlns:dita-ot="http://dita-ot.sourceforge.net/ns/201007/dita-ot"
  10. xmlns:xs="http://www.w3.org/2001/XMLSchema"
  11. exclude-result-prefixes="ditamsg dita-ot xs">
  12. <xsl:param name="inline-hazard-svg" as="element()" select="document('plugin:org.dita.html5:resources/ISO_7010_W001_html.svg')/*"/>
  13. <xsl:template match="*[contains(@class,' hazard-d/messagepanel ')]" mode="get-element-ancestry"><xsl:value-of select="name()"/></xsl:template>
  14. <xsl:template match="*[contains(@class,' hazard-d/messagepanel ')]/*" mode="get-element-ancestry"><xsl:value-of select="name()"/></xsl:template>
  15. <xsl:template match="*[contains(@class,' hazard-d/hazardstatement ')]">
  16. <xsl:variable name="type" select="(@type, 'caution')[1]" as="xs:string"/>
  17. <xsl:apply-templates select="*[contains(@class,' ditaot-d/ditaval-startprop ')]"/>
  18. <table role="presentation" border="1">
  19. <xsl:call-template name="commonattributes"/>
  20. <tr>
  21. <th colspan="2" class="hazardstatement--{$type}">
  22. <xsl:if test="$type = ('danger', 'warning', 'caution')">
  23. <xsl:for-each select="$inline-hazard-svg">
  24. <xsl:copy>
  25. <xsl:sequence select="@*"/>
  26. <xsl:attribute name="height" select="'1em'"/>
  27. <xsl:sequence select="*"/>
  28. </xsl:copy>
  29. </xsl:for-each>
  30. <xsl:text> </xsl:text>
  31. </xsl:if>
  32. <xsl:choose>
  33. <xsl:when test="$type='other'"><xsl:value-of select="@othertype"></xsl:value-of></xsl:when>
  34. <xsl:otherwise>
  35. <xsl:call-template name="getVariable">
  36. <xsl:with-param name="id" select="dita-ot:capitalize($type)"/>
  37. </xsl:call-template>
  38. </xsl:otherwise>
  39. </xsl:choose>
  40. </th>
  41. </tr>
  42. <tr>
  43. <td>
  44. <xsl:apply-templates select="*[contains(@class,' hazard-d/hazardsymbol ')]"/>
  45. <xsl:if test="empty(*[contains(@class,' hazard-d/hazardsymbol ')])">
  46. <xsl:sequence select="$inline-hazard-svg"/>
  47. </xsl:if>
  48. </td>
  49. <td>
  50. <xsl:apply-templates select="*[contains(@class,' hazard-d/messagepanel ')]"/>
  51. </td>
  52. </tr>
  53. </table>
  54. <xsl:apply-templates select="*[contains(@class,' ditaot-d/ditaval-endprop ')]"/>
  55. </xsl:template>
  56. <xsl:template match="*[contains(@class,' hazard-d/messagepanel ')]">
  57. <div>
  58. <xsl:call-template name="commonattributes"/>
  59. <xsl:apply-templates/>
  60. </div>
  61. </xsl:template>
  62. <xsl:template match="*[contains(@class,' hazard-d/messagepanel ')]/*">
  63. <div>
  64. <xsl:call-template name="commonattributes"/>
  65. <xsl:apply-templates/>
  66. </div>
  67. </xsl:template>
  68. </xsl:stylesheet>