lfs-sections.xsl 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. <!-- This stylesheet controls how sections are handled -->
  6. <!-- Are sections enumerated? 1 = yes, 0 = no -->
  7. <xsl:param name="section.autolabel" select="1"/>
  8. <!-- Do section labels include the component label? 1 = yes, 0 = no -->
  9. <xsl:param name="section.label.includes.component.label" select="1"/>
  10. <!-- Force sect1 onto a new page -->
  11. <xsl:attribute-set name="section.level1.properties">
  12. <xsl:attribute name="break-before">
  13. <xsl:choose>
  14. <xsl:when test="not(. = //*/sect1[1])">
  15. <xsl:text>page</xsl:text>
  16. </xsl:when>
  17. <xsl:otherwise>
  18. <xsl:text>auto</xsl:text>
  19. </xsl:otherwise>
  20. </xsl:choose>
  21. </xsl:attribute>
  22. </xsl:attribute-set>
  23. <!-- sect2:
  24. Skip sect2.titlepage run when title is empty.
  25. Removed unused code. -->
  26. <!-- The original template is in {docbook-xsl}/fo/sections.xsl -->
  27. <xsl:template match="sect2">
  28. <xsl:variable name="id">
  29. <xsl:call-template name="object.id"/>
  30. </xsl:variable>
  31. <fo:block xsl:use-attribute-sets="section.level2.properties">
  32. <xsl:attribute name="id">
  33. <xsl:value-of select="$id"/>
  34. </xsl:attribute>
  35. <xsl:if test="not(string-length(title)=0)">
  36. <xsl:call-template name="sect2.titlepage"/>
  37. </xsl:if>
  38. <xsl:apply-templates/>
  39. </fo:block>
  40. </xsl:template>
  41. <!-- sect2 label.markup:
  42. Skip numeration for sect2 with empty title -->
  43. <!-- The original template is in {docbook-xsl}/common/labels.xsl
  44. It match also sect3, sect4, and sect5, that are unchanged. -->
  45. <xsl:template match="sect2" mode="label.markup">
  46. <xsl:if test="string-length(title) > 0">
  47. <!-- label the parent -->
  48. <xsl:variable name="parent.section.label">
  49. <xsl:call-template name="label.this.section">
  50. <xsl:with-param name="section" select=".."/>
  51. </xsl:call-template>
  52. </xsl:variable>
  53. <xsl:if test="$parent.section.label != '0'">
  54. <xsl:apply-templates select=".." mode="label.markup"/>
  55. <xsl:apply-templates select=".." mode="intralabel.punctuation"/>
  56. </xsl:if>
  57. <xsl:choose>
  58. <xsl:when test="@label">
  59. <xsl:value-of select="@label"/>
  60. </xsl:when>
  61. <xsl:when test="$section.autolabel != 0">
  62. <xsl:choose>
  63. <!-- If the first sect2 isn't numbered, renumber the remainig sections -->
  64. <xsl:when test="string-length(../sect2[1]/title) = 0">
  65. <xsl:variable name="totalsect2">
  66. <xsl:number count="sect2"/>
  67. </xsl:variable>
  68. <xsl:number value="$totalsect2 - 1"/>
  69. </xsl:when>
  70. <xsl:otherwise>
  71. <xsl:number count="sect2"/>
  72. </xsl:otherwise>
  73. </xsl:choose>
  74. </xsl:when>
  75. <xsl:otherwise>
  76. <xsl:message>label.markup: this can't happen!</xsl:message>
  77. </xsl:otherwise>
  78. </xsl:choose>
  79. </xsl:if>
  80. </xsl:template>
  81. </xsl:stylesheet>