pi.xsl 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. <?xml version='1.0'?>
  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. <!-- ********************************************************************
  6. $Id$
  7. ********************************************************************
  8. This file is part of the XSL DocBook Stylesheet distribution.
  9. See ../README or http://nwalsh.com/docbook/xsl/ for copyright
  10. and other information.
  11. ******************************************************************** -->
  12. <xsl:template match="processing-instruction()">
  13. </xsl:template>
  14. <!-- ==================================================================== -->
  15. <xsl:template name="dbfo-attribute">
  16. <xsl:param name="pis" select="processing-instruction('dbfo')"/>
  17. <xsl:param name="attribute">filename</xsl:param>
  18. <xsl:call-template name="pi-attribute">
  19. <xsl:with-param name="pis" select="$pis"/>
  20. <xsl:with-param name="attribute" select="$attribute"/>
  21. </xsl:call-template>
  22. </xsl:template>
  23. <xsl:template name="dbfo-filename">
  24. <xsl:param name="pis" select="./processing-instruction('dbfo')"/>
  25. <xsl:call-template name="dbfo-attribute">
  26. <xsl:with-param name="pis" select="$pis"/>
  27. <xsl:with-param name="attribute">filename</xsl:with-param>
  28. </xsl:call-template>
  29. </xsl:template>
  30. <xsl:template name="dbfo-dir">
  31. <xsl:param name="pis" select="./processing-instruction('dbfo')"/>
  32. <xsl:call-template name="dbfo-attribute">
  33. <xsl:with-param name="pis" select="$pis"/>
  34. <xsl:with-param name="attribute">dir</xsl:with-param>
  35. </xsl:call-template>
  36. </xsl:template>
  37. <!-- ==================================================================== -->
  38. <xsl:template name="process.cmdsynopsis.list">
  39. <xsl:param name="cmdsynopses"/><!-- empty node list by default -->
  40. <xsl:param name="count" select="1"/>
  41. <xsl:choose>
  42. <xsl:when test="$count>count($cmdsynopses)"></xsl:when>
  43. <xsl:otherwise>
  44. <xsl:variable name="cmdsyn" select="$cmdsynopses[$count]"/>
  45. <dt>
  46. <a>
  47. <xsl:attribute name="href">
  48. <xsl:call-template name="object.id">
  49. <xsl:with-param name="object" select="$cmdsyn"/>
  50. </xsl:call-template>
  51. </xsl:attribute>
  52. <xsl:choose>
  53. <xsl:when test="$cmdsyn/@xreflabel">
  54. <xsl:call-template name="xref.xreflabel">
  55. <xsl:with-param name="target" select="$cmdsyn"/>
  56. </xsl:call-template>
  57. </xsl:when>
  58. <xsl:otherwise>
  59. <xsl:apply-templates select="$cmdsyn" mode="xref-to">
  60. <xsl:with-param name="target" select="$cmdsyn"/>
  61. </xsl:apply-templates>
  62. </xsl:otherwise>
  63. </xsl:choose>
  64. </a>
  65. </dt>
  66. <xsl:call-template name="process.cmdsynopsis.list">
  67. <xsl:with-param name="cmdsynopses" select="$cmdsynopses"/>
  68. <xsl:with-param name="count" select="$count+1"/>
  69. </xsl:call-template>
  70. </xsl:otherwise>
  71. </xsl:choose>
  72. </xsl:template>
  73. <xsl:template match="processing-instruction('dbcmdlist')">
  74. <xsl:variable name="cmdsynopses" select="..//cmdsynopsis"/>
  75. <xsl:if test="count($cmdsynopses)&lt;1">
  76. <xsl:message><xsl:text>No cmdsynopsis elements matched dbcmdlist PI, perhaps it's nested too deep?</xsl:text>
  77. </xsl:message>
  78. </xsl:if>
  79. <dl>
  80. <xsl:call-template name="process.cmdsynopsis.list">
  81. <xsl:with-param name="cmdsynopses" select="$cmdsynopses"/>
  82. </xsl:call-template>
  83. </dl>
  84. </xsl:template>
  85. <!-- ==================================================================== -->
  86. <xsl:template name="process.funcsynopsis.list">
  87. <xsl:param name="funcsynopses"/><!-- empty node list by default -->
  88. <xsl:param name="count" select="1"/>
  89. <xsl:choose>
  90. <xsl:when test="$count>count($funcsynopses)"></xsl:when>
  91. <xsl:otherwise>
  92. <xsl:variable name="cmdsyn" select="$funcsynopses[$count]"/>
  93. <dt>
  94. <a>
  95. <xsl:attribute name="href">
  96. <xsl:call-template name="object.id">
  97. <xsl:with-param name="object" select="$cmdsyn"/>
  98. </xsl:call-template>
  99. </xsl:attribute>
  100. <xsl:choose>
  101. <xsl:when test="$cmdsyn/@xreflabel">
  102. <xsl:call-template name="xref.xreflabel">
  103. <xsl:with-param name="target" select="$cmdsyn"/>
  104. </xsl:call-template>
  105. </xsl:when>
  106. <xsl:otherwise>
  107. <xsl:apply-templates select="$cmdsyn" mode="xref-to">
  108. <xsl:with-param name="target" select="$cmdsyn"/>
  109. </xsl:apply-templates>
  110. </xsl:otherwise>
  111. </xsl:choose>
  112. </a>
  113. </dt>
  114. <xsl:call-template name="process.funcsynopsis.list">
  115. <xsl:with-param name="funcsynopses" select="$funcsynopses"/>
  116. <xsl:with-param name="count" select="$count+1"/>
  117. </xsl:call-template>
  118. </xsl:otherwise>
  119. </xsl:choose>
  120. </xsl:template>
  121. <xsl:template match="processing-instruction('dbfunclist')">
  122. <xsl:variable name="funcsynopses" select="..//funcsynopsis"/>
  123. <xsl:if test="count($funcsynopses)&lt;1">
  124. <xsl:message><xsl:text>No funcsynopsis elements matched dbfunclist PI, perhaps it's nested too deep?</xsl:text>
  125. </xsl:message>
  126. </xsl:if>
  127. <dl>
  128. <xsl:call-template name="process.funcsynopsis.list">
  129. <xsl:with-param name="funcsynopses" select="$funcsynopses"/>
  130. </xsl:call-template>
  131. </dl>
  132. </xsl:template>
  133. <!-- ==================================================================== -->
  134. <!-- "need" processing instruction, a kind of soft page break -->
  135. <!-- A "need" is a request for space on a page. If the requested space
  136. is not available, the page breaks and the content that follows
  137. the need request appears on the next page. If the requested
  138. space is available, then the request is ignored. -->
  139. <xsl:template match="processing-instruction('dbfo-need')">
  140. <xsl:variable name="pi-height">
  141. <xsl:call-template name="dbfo-attribute">
  142. <xsl:with-param name="pis" select="."/>
  143. <xsl:with-param name="attribute" select="'height'"/>
  144. </xsl:call-template>
  145. </xsl:variable>
  146. <xsl:variable name="height">
  147. <xsl:choose>
  148. <xsl:when test="$pi-height != ''">
  149. <xsl:value-of select="$pi-height"/>
  150. </xsl:when>
  151. <xsl:otherwise>0pt</xsl:otherwise>
  152. </xsl:choose>
  153. </xsl:variable>
  154. <xsl:variable name="pi-before">
  155. <xsl:call-template name="dbfo-attribute">
  156. <xsl:with-param name="pis" select="."/>
  157. <xsl:with-param name="attribute" select="'space-before'"/>
  158. </xsl:call-template>
  159. </xsl:variable>
  160. <xsl:variable name="spacer">
  161. <fo:block-container width="100%" height="{$height}">
  162. <fo:block><fo:leader leader-length="0pt"/></fo:block>
  163. </fo:block-container>
  164. </xsl:variable>
  165. <xsl:choose>
  166. <xsl:when test="$fop.extensions != 0">
  167. <!-- Doesn't work in fop -->
  168. </xsl:when>
  169. <xsl:when test="$pi-before != '' and
  170. not(following-sibling::listitem) and
  171. not(following-sibling::step)">
  172. <fo:block space-after="0pt" space-before="{$pi-before}">
  173. <xsl:copy-of select="$spacer"/>
  174. </fo:block>
  175. </xsl:when>
  176. <xsl:when test="following-sibling::para">
  177. <fo:block space-after="0pt"
  178. xsl:use-attribute-sets="normal.para.spacing">
  179. <xsl:copy-of select="$spacer"/>
  180. </fo:block>
  181. </xsl:when>
  182. <xsl:when test="following-sibling::table or
  183. following-sibling::figure or
  184. following-sibling::example or
  185. following-sibling::equation">
  186. <fo:block space-after="0pt"
  187. xsl:use-attribute-sets="formal.object.properties">
  188. <xsl:copy-of select="$spacer"/>
  189. </fo:block>
  190. </xsl:when>
  191. <xsl:when test="following-sibling::informaltable or
  192. following-sibling::informalfigure or
  193. following-sibling::informalexample or
  194. following-sibling::informalequation">
  195. <fo:block space-after="0pt"
  196. xsl:use-attribute-sets="informal.object.properties">
  197. <xsl:copy-of select="$spacer"/>
  198. </fo:block>
  199. </xsl:when>
  200. <xsl:when test="following-sibling::itemizedlist or
  201. following-sibling::orderedlist or
  202. following-sibling::variablelist or
  203. following-sibling::simplelist">
  204. <fo:block space-after="0pt"
  205. xsl:use-attribute-sets="informal.object.properties">
  206. <xsl:copy-of select="$spacer"/>
  207. </fo:block>
  208. </xsl:when>
  209. <xsl:when test="following-sibling::listitem or
  210. following-sibling::step">
  211. <fo:list-item space-after="0pt"
  212. xsl:use-attribute-sets="informal.object.properties">
  213. <fo:list-item-label/>
  214. <fo:list-item-body start-indent="0pt" end-indent="0pt">
  215. <xsl:copy-of select="$spacer"/>
  216. </fo:list-item-body>
  217. </fo:list-item>
  218. </xsl:when>
  219. <xsl:when test="following-sibling::sect1 or
  220. following-sibling::sect2 or
  221. following-sibling::sect3 or
  222. following-sibling::sect4 or
  223. following-sibling::sect5 or
  224. following-sibling::section">
  225. <fo:block space-after="0pt"
  226. xsl:use-attribute-sets="section.title.properties">
  227. <xsl:copy-of select="$spacer"/>
  228. </fo:block>
  229. </xsl:when>
  230. <xsl:otherwise>
  231. <fo:block space-after="0pt" space-before="0em">
  232. <xsl:copy-of select="$spacer"/>
  233. </fo:block>
  234. </xsl:otherwise>
  235. </xsl:choose>
  236. <xsl:choose>
  237. <xsl:when test="$fop.extensions != 0">
  238. <!-- Doesn't work in fop -->
  239. </xsl:when>
  240. <xsl:when test="following-sibling::listitem or
  241. following-sibling::step">
  242. <fo:list-item space-before.precedence="force"
  243. space-before="-{$height}"
  244. space-after="0pt"
  245. space-after.precedence="force">
  246. <fo:list-item-label/>
  247. <fo:list-item-body start-indent="0pt" end-indent="0pt"/>
  248. </fo:list-item>
  249. </xsl:when>
  250. <xsl:otherwise>
  251. <fo:block space-before.precedence="force"
  252. space-before="-{$height}"
  253. space-after="0pt"
  254. space-after.precedence="force">
  255. </fo:block>
  256. </xsl:otherwise>
  257. </xsl:choose>
  258. </xsl:template>
  259. <!-- ==================================================================== -->
  260. </xsl:stylesheet>