lfs-sections.xsl 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <?xml version='1.0' encoding='ISO-8859-1'?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3. xmlns="http://www.w3.org/1999/xhtml"
  4. version="1.0">
  5. <!-- Sect1 attributes -->
  6. <xsl:template match="sect1">
  7. <div>
  8. <xsl:choose>
  9. <xsl:when test="@role">
  10. <xsl:attribute name="class">
  11. <xsl:value-of select="@role"/>
  12. </xsl:attribute>
  13. </xsl:when>
  14. <xsl:otherwise>
  15. <xsl:attribute name="class">
  16. <xsl:value-of select="name(.)"/>
  17. </xsl:attribute>
  18. </xsl:otherwise>
  19. </xsl:choose>
  20. <xsl:call-template name="language.attribute"/>
  21. <xsl:call-template name="sect1.titlepage"/>
  22. <xsl:apply-templates/>
  23. <xsl:call-template name="process.chunk.footnotes"/>
  24. </div>
  25. </xsl:template>
  26. <!-- Sect2 attributes -->
  27. <xsl:template match="sect2">
  28. <div>
  29. <xsl:choose>
  30. <xsl:when test="@role">
  31. <xsl:attribute name="class">
  32. <xsl:value-of select="@role"/>
  33. </xsl:attribute>
  34. </xsl:when>
  35. <xsl:otherwise>
  36. <xsl:attribute name="class">
  37. <xsl:value-of select="name(.)"/>
  38. </xsl:attribute>
  39. </xsl:otherwise>
  40. </xsl:choose>
  41. <xsl:call-template name="language.attribute"/>
  42. <xsl:call-template name="sect2.titlepage"/>
  43. <xsl:apply-templates/>
  44. <xsl:call-template name="process.chunk.footnotes"/>
  45. </div>
  46. </xsl:template>
  47. <!-- Sections numbering -->
  48. <xsl:param name="section.autolabel" select="1"/>
  49. <xsl:param name="section.label.includes.component.label" select="1"/>
  50. <!-- Skip numeraration for sections with empty title -->
  51. <xsl:template match="sect2|sect3|sect4|sect5" mode="label.markup">
  52. <xsl:if test="string-length(title) > 0">
  53. <!-- label the parent -->
  54. <xsl:variable name="parent.label">
  55. <xsl:apply-templates select=".." mode="label.markup"/>
  56. </xsl:variable>
  57. <xsl:if test="$parent.label != ''">
  58. <xsl:apply-templates select=".." mode="label.markup"/>
  59. <xsl:apply-templates select=".." mode="intralabel.punctuation"/>
  60. </xsl:if>
  61. <xsl:choose>
  62. <xsl:when test="@label">
  63. <xsl:value-of select="@label"/>
  64. </xsl:when>
  65. <xsl:when test="$section.autolabel != 0">
  66. <xsl:choose>
  67. <xsl:when test="local-name(.) = 'sect2'">
  68. <xsl:choose>
  69. <!-- If the first sect2 isn't numbered, renumber the remainig sections -->
  70. <xsl:when test="string-length(../sect2[1]/title) = 0">
  71. <xsl:variable name="totalsect2">
  72. <xsl:number count="sect2"/>
  73. </xsl:variable>
  74. <xsl:number value="$totalsect2 - 1"/>
  75. </xsl:when>
  76. <xsl:otherwise>
  77. <xsl:number count="sect2"/>
  78. </xsl:otherwise>
  79. </xsl:choose>
  80. </xsl:when>
  81. <xsl:when test="local-name(.) = 'sect3'">
  82. <xsl:number count="sect3"/>
  83. </xsl:when>
  84. <xsl:when test="local-name(.) = 'sect4'">
  85. <xsl:number count="sect4"/>
  86. </xsl:when>
  87. <xsl:when test="local-name(.) = 'sect5'">
  88. <xsl:number count="sect5"/>
  89. </xsl:when>
  90. <xsl:otherwise>
  91. <xsl:message>label.markup: this can't happen!</xsl:message>
  92. </xsl:otherwise>
  93. </xsl:choose>
  94. </xsl:when>
  95. </xsl:choose>
  96. </xsl:if>
  97. </xsl:template>
  98. </xsl:stylesheet>