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