lfs-admon.xsl 3.8 KB

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