lfs-sections.xsl 3.2 KB

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