lfs-sections.xsl 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. <!-- Force section1's onto a new page -->
  6. <xsl:attribute-set name="section.level1.properties">
  7. <xsl:attribute name="break-after">
  8. <xsl:choose>
  9. <xsl:when test="not(position()=last())">
  10. <xsl:text>page</xsl:text>
  11. </xsl:when>
  12. <xsl:otherwise>
  13. <xsl:text>auto</xsl:text>
  14. </xsl:otherwise>
  15. </xsl:choose>
  16. </xsl:attribute>
  17. </xsl:attribute-set>
  18. <!-- Sections numbering -->
  19. <xsl:param name="section.autolabel" select="1"/>
  20. <xsl:param name="section.label.includes.component.label" select="1"/>
  21. <!-- Skip numeraration for sections with empty title -->
  22. <xsl:template match="sect2|sect3|sect4|sect5" mode="label.markup">
  23. <xsl:if test="string-length(title) > 0">
  24. <!-- label the parent -->
  25. <xsl:variable name="parent.label">
  26. <xsl:apply-templates select=".." mode="label.markup"/>
  27. </xsl:variable>
  28. <xsl:if test="$parent.label != ''">
  29. <xsl:apply-templates select=".." mode="label.markup"/>
  30. <xsl:apply-templates select=".." mode="intralabel.punctuation"/>
  31. </xsl:if>
  32. <xsl:choose>
  33. <xsl:when test="@label">
  34. <xsl:value-of select="@label"/>
  35. </xsl:when>
  36. <xsl:when test="$section.autolabel != 0">
  37. <xsl:choose>
  38. <xsl:when test="local-name(.) = 'sect2'">
  39. <xsl:choose>
  40. <!-- If the first sect2 isn't numbered, renumber the remainig sections -->
  41. <xsl:when test="string-length(../sect2[1]/title) = 0">
  42. <xsl:variable name="totalsect2">
  43. <xsl:number count="sect2"/>
  44. </xsl:variable>
  45. <xsl:number value="$totalsect2 - 1"/>
  46. </xsl:when>
  47. <xsl:otherwise>
  48. <xsl:number count="sect2"/>
  49. </xsl:otherwise>
  50. </xsl:choose>
  51. </xsl:when>
  52. <xsl:when test="local-name(.) = 'sect3'">
  53. <xsl:number count="sect3"/>
  54. </xsl:when>
  55. <xsl:when test="local-name(.) = 'sect4'">
  56. <xsl:number count="sect4"/>
  57. </xsl:when>
  58. <xsl:when test="local-name(.) = 'sect5'">
  59. <xsl:number count="sect5"/>
  60. </xsl:when>
  61. <xsl:otherwise>
  62. <xsl:message>label.markup: this can't happen!</xsl:message>
  63. </xsl:otherwise>
  64. </xsl:choose>
  65. </xsl:when>
  66. </xsl:choose>
  67. </xsl:if>
  68. </xsl:template>
  69. <!-- Drop the trailing punctuation if title is empty -->
  70. <xsl:template match="section|sect1|sect2|sect3|sect4|sect5|simplesect
  71. |bridgehead"
  72. mode="object.title.template">
  73. <xsl:choose>
  74. <xsl:when test="$section.autolabel != 0">
  75. <xsl:if test="string-length(title) > 0">
  76. <xsl:call-template name="gentext.template">
  77. <xsl:with-param name="context" select="'title-numbered'"/>
  78. <xsl:with-param name="name">
  79. <xsl:call-template name="xpath.location"/>
  80. </xsl:with-param>
  81. </xsl:call-template>
  82. </xsl:if>
  83. </xsl:when>
  84. <xsl:otherwise>
  85. <xsl:call-template name="gentext.template">
  86. <xsl:with-param name="context" select="'title-unnumbered'"/>
  87. <xsl:with-param name="name">
  88. <xsl:call-template name="xpath.location"/>
  89. </xsl:with-param>
  90. </xsl:call-template>
  91. </xsl:otherwise>
  92. </xsl:choose>
  93. </xsl:template>
  94. </xsl:stylesheet>