lfs-admon.xsl 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?xml version='1.0' encoding='ISO-8859-1'?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3. xmlns:fo="http://www.w3.org/1999/XSL/Format"
  4. version="1.0">
  5. <!-- Graphics in admonitions -->
  6. <xsl:param name="admon.graphics" select="1"/>
  7. <xsl:param name="admon.graphics.path" select="'images/'"/>
  8. <!-- Admonition block properties -->
  9. <xsl:template match="important|warning|caution">
  10. <xsl:choose>
  11. <xsl:when test="$admon.graphics != 0">
  12. <fo:block space-before.minimum="0.4em" space-before.optimum="0.6em"
  13. space-before.maximum="0.8em" border-style="solid" border-width="1pt"
  14. border-color="#500" background-color="#FFFFE6">
  15. <xsl:call-template name="graphical.admonition"/>
  16. </fo:block>
  17. </xsl:when>
  18. <xsl:otherwise>
  19. <xsl:call-template name="nongraphical.admonition"/>
  20. </xsl:otherwise>
  21. </xsl:choose>
  22. </xsl:template>
  23. <xsl:template match="note|tip">
  24. <xsl:choose>
  25. <xsl:when test="$admon.graphics != 0">
  26. <fo:block space-before.minimum="0.4em" space-before.optimum="0.6em"
  27. space-before.maximum="0.8em" border-style="solid" border-width="1pt"
  28. border-color="#E0E0E0" background-color="#FFFFE6">
  29. <xsl:call-template name="graphical.admonition"/>
  30. </fo:block>
  31. </xsl:when>
  32. <xsl:otherwise>
  33. <xsl:call-template name="nongraphical.admonition"/>
  34. </xsl:otherwise>
  35. </xsl:choose>
  36. </xsl:template>
  37. <!-- Admonitions text properties -->
  38. <xsl:attribute-set name="admonition.properties">
  39. <xsl:attribute name="margin-right">6pt</xsl:attribute>
  40. </xsl:attribute-set>
  41. <!-- Adding left space to the graphics and color to the titles -->
  42. <xsl:template name="graphical.admonition">
  43. <xsl:variable name="id">
  44. <xsl:call-template name="object.id"/>
  45. </xsl:variable>
  46. <xsl:variable name="graphic.width">
  47. <xsl:apply-templates select="." mode="admon.graphic.width"/>
  48. </xsl:variable>
  49. <fo:block id="{$id}">
  50. <fo:list-block provisional-distance-between-starts="{$graphic.width} + 18pt"
  51. provisional-label-separation="18pt" xsl:use-attribute-sets="list.block.spacing">
  52. <fo:list-item>
  53. <fo:list-item-label end-indent="label-end()">
  54. <fo:block margin-left="18pt">
  55. <fo:external-graphic width="auto" height="auto"
  56. content-width="{$graphic.width}" >
  57. <xsl:attribute name="src">
  58. <xsl:call-template name="admon.graphic"/>
  59. </xsl:attribute>
  60. </fo:external-graphic>
  61. </fo:block>
  62. </fo:list-item-label>
  63. <fo:list-item-body start-indent="body-start()">
  64. <xsl:if test="$admon.textlabel != 0 or title">
  65. <fo:block xsl:use-attribute-sets="admonition.title.properties">
  66. <xsl:if test="ancestor-or-self::important">
  67. <xsl:attribute name="color">#500</xsl:attribute>
  68. </xsl:if>
  69. <xsl:if test="ancestor-or-self::warning">
  70. <xsl:attribute name="color">#500</xsl:attribute>
  71. </xsl:if>
  72. <xsl:if test="ancestor-or-self::caution">
  73. <xsl:attribute name="color">#500</xsl:attribute>
  74. </xsl:if>
  75. <xsl:apply-templates select="." mode="object.title.markup"/>
  76. </fo:block>
  77. </xsl:if>
  78. <fo:block xsl:use-attribute-sets="admonition.properties">
  79. <xsl:apply-templates/>
  80. </fo:block>
  81. </fo:list-item-body>
  82. </fo:list-item>
  83. </fo:list-block>
  84. </fo:block>
  85. </xsl:template>
  86. </xsl:stylesheet>