hazard-d.xsl 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  7. xmlns:fo="http://www.w3.org/1999/XSL/Format"
  8. xmlns:xs="http://www.w3.org/2001/XMLSchema"
  9. xmlns:dita-ot="http://dita-ot.sourceforge.net/ns/201007/dita-ot"
  10. version="2.0"
  11. exclude-result-prefixes="xs dita-ot">
  12. <xsl:template match="*[contains(@class, ' hazard-d/hazardstatement ')]">
  13. <xsl:variable name="type" select="(@type, 'caution')[1]" as="xs:string"/>
  14. <xsl:variable name="number-cells" as="xs:integer" select="2"/>
  15. <xsl:apply-templates select="*[contains(@class,' ditaot-d/ditaval-startprop ')]" mode="outofline"/>
  16. <fo:table xsl:use-attribute-sets="hazardstatement">
  17. <xsl:call-template name="commonattributes"/>
  18. <xsl:call-template name="globalAtts"/>
  19. <xsl:call-template name="displayAtts">
  20. <xsl:with-param name="element" select="."/>
  21. </xsl:call-template>
  22. <fo:table-column xsl:use-attribute-sets="hazardstatement.image.column"/>
  23. <fo:table-column xsl:use-attribute-sets="hazardstatement.content.column"/>
  24. <fo:table-body>
  25. <fo:table-row keep-with-next="always">
  26. <fo:table-cell xsl:use-attribute-sets="hazardstatement.title">
  27. <xsl:variable name="atts" as="element()">
  28. <xsl:choose>
  29. <xsl:when test="$type = 'danger'">
  30. <w xsl:use-attribute-sets="hazardstatement.title.danger"/>
  31. </xsl:when>
  32. <xsl:when test="$type = 'warning'">
  33. <w xsl:use-attribute-sets="hazardstatement.title.warning"/>
  34. </xsl:when>
  35. <xsl:when test="$type = 'caution'">
  36. <w xsl:use-attribute-sets="hazardstatement.title.caution"/>
  37. </xsl:when>
  38. <xsl:otherwise>
  39. <w xsl:use-attribute-sets="hazardstatement.title.notice"/>
  40. </xsl:otherwise>
  41. </xsl:choose>
  42. </xsl:variable>
  43. <xsl:sequence select="$atts/@*"/>
  44. <fo:block>
  45. <xsl:if test="$type = ('danger', 'warning', 'caution')">
  46. <xsl:variable name="image" as="xs:string">
  47. <xsl:call-template name="getVariable">
  48. <xsl:with-param name="id" select="'hazard.image.default'"/>
  49. </xsl:call-template>
  50. </xsl:variable>
  51. <fo:external-graphic src="url('{concat($artworkPrefix, $image)}')"
  52. content-height="1em" padding-right="3pt"
  53. vertical-align="middle"
  54. baseline-shift="baseline"/>
  55. </xsl:if>
  56. <fo:inline>
  57. <xsl:choose>
  58. <xsl:when test="$type='other'"><xsl:value-of select="@othertype"/></xsl:when>
  59. <xsl:otherwise>
  60. <xsl:call-template name="getVariable">
  61. <xsl:with-param name="id" select="dita-ot:capitalize($type)"/>
  62. </xsl:call-template>
  63. </xsl:otherwise>
  64. </xsl:choose>
  65. </fo:inline>
  66. </fo:block>
  67. </fo:table-cell>
  68. </fo:table-row>
  69. <fo:table-row>
  70. <fo:table-cell xsl:use-attribute-sets="hazardstatement.image">
  71. <xsl:choose>
  72. <xsl:when test="exists(*[contains(@class, ' hazard-d/hazardsymbol ')])">
  73. <xsl:apply-templates select="*[contains(@class, ' hazard-d/hazardsymbol ')]"/>
  74. </xsl:when>
  75. <xsl:otherwise>
  76. <fo:block>
  77. <xsl:variable name="image" as="xs:string">
  78. <xsl:call-template name="getVariable">
  79. <xsl:with-param name="id" select="'hazard.image.default'"/>
  80. </xsl:call-template>
  81. </xsl:variable>
  82. <fo:external-graphic src="url('{concat($artworkPrefix, $image)}')"
  83. xsl:use-attribute-sets="hazardsymbol"/>
  84. </fo:block>
  85. </xsl:otherwise>
  86. </xsl:choose>
  87. </fo:table-cell>
  88. <fo:table-cell xsl:use-attribute-sets="hazardstatement.content">
  89. <xsl:apply-templates select="*[contains(@class, ' hazard-d/messagepanel ')]/*"/>
  90. </fo:table-cell>
  91. </fo:table-row>
  92. </fo:table-body>
  93. </fo:table>
  94. <xsl:apply-templates select="*[contains(@class,' ditaot-d/ditaval-endprop ')]" mode="outofline"/>
  95. </xsl:template>
  96. <xsl:template match="*[contains(@class, ' hazard-d/messagepanel ')]">
  97. <xsl:apply-templates/>
  98. </xsl:template>
  99. <xsl:template match="*[contains(@class, ' hazard-d/typeofhazard ')]">
  100. <fo:block xsl:use-attribute-sets="p">
  101. <xsl:call-template name="commonattributes"/>
  102. <xsl:apply-templates/>
  103. </fo:block>
  104. </xsl:template>
  105. <xsl:template match="*[contains(@class, ' hazard-d/consequence ')]">
  106. <fo:block xsl:use-attribute-sets="p">
  107. <xsl:call-template name="commonattributes"/>
  108. <xsl:apply-templates/>
  109. </fo:block>
  110. </xsl:template>
  111. <xsl:template match="*[contains(@class, ' hazard-d/howtoavoid ')]">
  112. <fo:block xsl:use-attribute-sets="p">
  113. <xsl:call-template name="commonattributes"/>
  114. <xsl:apply-templates/>
  115. </fo:block>
  116. </xsl:template>
  117. <xsl:template match="*[contains(@class, ' hazard-d/hazardsymbol ')]">
  118. <fo:block>
  119. <xsl:next-match/>
  120. </fo:block>
  121. </xsl:template>
  122. </xsl:stylesheet>