lfs-index.xsl 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. <?xml version='1.0' encoding='ISO-8859-1'?>
  2. <!DOCTYPE xsl:stylesheet [
  3. <!ENTITY lowercase "'abcdefghijklmnopqrstuvwxyz'">
  4. <!ENTITY uppercase "'ABCDEFGHIJKLMNOPQRSTUVWXYZ'">
  5. <!ENTITY primary 'normalize-space(concat(primary/@sortas, primary[not(@sortas)]))'>
  6. <!ENTITY secondary 'normalize-space(concat(secondary/@sortas, secondary[not(@sortas)]))'>
  7. <!ENTITY scope 'count(ancestor::node()|$scope) = count(ancestor::node())'>
  8. <!ENTITY sep '" "'>
  9. ]>
  10. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  11. xmlns:fo="http://www.w3.org/1999/XSL/Format"
  12. version="1.0">
  13. <!--Only one column to fit the table layout-->
  14. <xsl:param name="column.count.index" select="1"/>
  15. <!--Title-->
  16. <xsl:template match="index" mode="title.markup">
  17. <xsl:text>Index of packages and important installed files</xsl:text>
  18. </xsl:template>
  19. <!-- Divisions-->
  20. <xsl:template match="indexterm" mode="index-div">
  21. <xsl:param name="scope" select="."/>
  22. <xsl:variable name="key"
  23. select="translate(substring(&primary;, 1, 1),&lowercase;,&uppercase;)"/>
  24. <xsl:variable name="divtitle" select="translate($key, &lowercase;, &uppercase;)"/>
  25. <xsl:if test="key('letter', $key)[&scope;]
  26. [count(.|key('primary', &primary;)[&scope;][1]) = 1]">
  27. <fo:block>
  28. <xsl:if test="contains(concat(&lowercase;, &uppercase;), $key)">
  29. <xsl:call-template name="indexdiv.title">
  30. <xsl:with-param name="titlecontent">
  31. <xsl:choose>
  32. <xsl:when test="$divtitle = 'A'">
  33. <xsl:text>Packages</xsl:text>
  34. </xsl:when>
  35. <xsl:when test="$divtitle = 'B'">
  36. <xsl:text>Programs</xsl:text>
  37. </xsl:when>
  38. <xsl:when test="$divtitle = 'C'">
  39. <xsl:text>Libraries</xsl:text>
  40. </xsl:when>
  41. <xsl:when test="$divtitle = 'D'">
  42. <xsl:text>Scripts</xsl:text>
  43. </xsl:when>
  44. <xsl:when test="$divtitle = 'E'">
  45. <xsl:text>Others</xsl:text>
  46. </xsl:when>
  47. <xsl:otherwise>
  48. <xsl:value-of select="$divtitle"/>
  49. </xsl:otherwise>
  50. </xsl:choose>
  51. </xsl:with-param>
  52. </xsl:call-template>
  53. </xsl:if>
  54. <fo:table table-layout="fixed" width="100%">
  55. <fo:table-column column-number="1" column-width="11em"/>
  56. <fo:table-column column-number="2" column-width="19em"/>
  57. <fo:table-column column-number="3"/>
  58. <fo:table-body>
  59. <xsl:apply-templates select="key('letter', $key)[&scope;]
  60. [count(.|key('primary', &primary;)[&scope;][1])=1]"
  61. mode="index-primary">
  62. <xsl:sort select="translate(&primary;, &lowercase;, &uppercase;)"/>
  63. <xsl:with-param name="scope" select="$scope"/>
  64. </xsl:apply-templates>
  65. </fo:table-body>
  66. </fo:table>
  67. </fo:block>
  68. </xsl:if>
  69. </xsl:template>
  70. <!-- Dropping the separator from here -->
  71. <xsl:template match="indexterm" mode="reference">
  72. <xsl:param name="scope" select="."/>
  73. <xsl:call-template name="reference">
  74. <xsl:with-param name="zones" select="normalize-space(@zone)"/>
  75. <xsl:with-param name="scope" select="$scope"/>
  76. </xsl:call-template>
  77. </xsl:template>
  78. <!-- Changing the output tags and re-addind the separator-->
  79. <xsl:template match="indexterm" mode="index-primary">
  80. <xsl:param name="scope" select="."/>
  81. <xsl:variable name="key" select="&primary;"/>
  82. <xsl:variable name="refs" select="key('primary', $key)[&scope;]"/>
  83. <fo:table-row>
  84. <fo:table-cell>
  85. <fo:block>
  86. <xsl:value-of select="primary"/>
  87. <xsl:text>: </xsl:text>
  88. </fo:block>
  89. </fo:table-cell>
  90. <xsl:for-each select="$refs[not(see) and not(seealso)
  91. and not(secondary)]">
  92. <xsl:apply-templates select="." mode="reference">
  93. <xsl:with-param name="scope" select="$scope"/>
  94. </xsl:apply-templates>
  95. </xsl:for-each>
  96. </fo:table-row>
  97. <xsl:if test="$refs/secondary">
  98. <xsl:apply-templates select="$refs[secondary and count(.|key('secondary',
  99. concat($key, &sep;, &secondary;))[&scope;][1]) = 1]" mode="index-secondary">
  100. <xsl:with-param name="scope" select="$scope"/>
  101. <xsl:sort select="translate(&secondary;, &lowercase;, &uppercase;)"/>
  102. </xsl:apply-templates>
  103. </xsl:if>
  104. </xsl:template>
  105. <xsl:template match="indexterm" mode="index-secondary">
  106. <xsl:param name="scope" select="."/>
  107. <xsl:variable name="key" select="concat(&primary;, &sep;, &secondary;)"/>
  108. <xsl:variable name="refs" select="key('secondary', $key)[&scope;]"/>
  109. <fo:table-row>
  110. <fo:table-cell>
  111. <fo:block start-indent="1pc">
  112. <xsl:value-of select="secondary"/>
  113. <xsl:text>: </xsl:text>
  114. </fo:block>
  115. </fo:table-cell>
  116. <xsl:for-each select="$refs[not(see) and not(seealso) and not(tertiary)]">
  117. <xsl:apply-templates select="." mode="reference">
  118. <xsl:with-param name="scope" select="$scope"/>
  119. </xsl:apply-templates>
  120. </xsl:for-each>
  121. </fo:table-row>
  122. </xsl:template>
  123. <!-- Targets titles and bookmarks-->
  124. <xsl:template name="reference">
  125. <xsl:param name="scope" select="."/>
  126. <xsl:param name="zones"/>
  127. <xsl:choose>
  128. <xsl:when test="contains($zones, ' ')">
  129. <xsl:variable name="zone" select="substring-before($zones, ' ')"/>
  130. <xsl:variable name="zone2" select="substring-after($zones, ' ')"/>
  131. <xsl:variable name="target" select="key('id', $zone)[&scope;]"/>
  132. <xsl:variable name="target2" select="key('id', $zone2)[&scope;]"/>
  133. <xsl:variable name="id">
  134. <xsl:call-template name="object.id">
  135. <xsl:with-param name="object" select="$target[1]"/>
  136. </xsl:call-template>
  137. </xsl:variable>
  138. <xsl:variable name="id2">
  139. <xsl:call-template name="object.id">
  140. <xsl:with-param name="object" select="$target2[1]"/>
  141. </xsl:call-template>
  142. </xsl:variable>
  143. <fo:table-cell>
  144. <fo:block>
  145. <fo:basic-link internal-destination="{$id}">
  146. <xsl:value-of select="$target/title"/>
  147. <xsl:apply-templates select="$target" mode="page.citation">
  148. <xsl:with-param name="id" select="$id"/>
  149. </xsl:apply-templates>
  150. </fo:basic-link>
  151. </fo:block>
  152. </fo:table-cell>
  153. <fo:table-cell>
  154. <fo:block>
  155. <fo:basic-link internal-destination="{$id2}">
  156. <xsl:text>description</xsl:text>
  157. <xsl:apply-templates select="$target2" mode="page.citation">
  158. <xsl:with-param name="id" select="$id2"/>
  159. </xsl:apply-templates>
  160. </fo:basic-link>
  161. </fo:block>
  162. </fo:table-cell>
  163. </xsl:when>
  164. <xsl:otherwise>
  165. <xsl:variable name="zone" select="$zones"/>
  166. <xsl:variable name="target" select="key('id', $zone)[&scope;]"/>
  167. <xsl:variable name="id">
  168. <xsl:call-template name="object.id">
  169. <xsl:with-param name="object" select="$target[1]"/>
  170. </xsl:call-template>
  171. </xsl:variable>
  172. <fo:table-cell>
  173. <fo:block>
  174. <fo:basic-link internal-destination="{$id}">
  175. <xsl:value-of select="$target/title"/>
  176. <xsl:apply-templates select="$target" mode="page.citation">
  177. <xsl:with-param name="id" select="$id"/>
  178. </xsl:apply-templates>
  179. </fo:basic-link>
  180. </fo:block>
  181. </fo:table-cell>
  182. </xsl:otherwise>
  183. </xsl:choose>
  184. </xsl:template>
  185. </xsl:stylesheet>