]> git.stg.codes - stg.git/blob - doc/xslt/roundtrip/normalise2sections.xsl
Adjusted XML RPC documentation.
[stg.git] / doc / xslt / roundtrip / normalise2sections.xsl
1 <?xml version="1.0"?>
2 <axsl:stylesheet xmlns:axsl="http://www.w3.org/1999/XSL/Transform" xmlns:dbk="http://docbook.org/ns/docbook" xmlns:rnd="http://docbook.org/ns/docbook/roundtrip" version="1.0">
3 <!--====================================-->
4 <!--=                                  =-->
5 <!--=   DO NOT EDIT THIS STYLESHEET    =-->
6 <!--=                                  =-->
7 <!--= This stylesheet is generated     =-->
8 <!--= by makeSections.xsl and a        =-->
9 <!--= mapping specification.           =-->
10 <!--=                                  =-->
11 <!--= Revision history:                =-->
12 <!--=                                  =-->
13 <!--= $Id: normalise2sections.xsl 8107 2008-08-17 22:39:58Z balls $ =-->
14 <!--=                                  =-->
15 <!--====================================-->
16   <axsl:output indent="yes"/>
17   <axsl:strip-space elements="*"/>
18   <axsl:preserve-space elements="dbk:para dbk:emphasis"/>
19   <axsl:template match="dbk:article">
20     <axsl:copy>
21       <axsl:for-each select="@*">
22         <axsl:copy/>
23       </axsl:for-each>
24       <axsl:variable name="books" select="dbk:para[@rnd:style = &quot;book&quot; or @rnd:style = &quot;book-title&quot;]"/>
25       <axsl:variable name="toplevel-components" select="dbk:para[@rnd:style = &quot;article&quot; or @rnd:style = &quot;article-title&quot; or @rnd:style = &quot;appendix&quot; or @rnd:style = &quot;appendix-title&quot; or @rnd:style = &quot;chapter&quot; or @rnd:style = &quot;chapter-title&quot; or @rnd:style = &quot;preface&quot; or @rnd:style = &quot;preface-title&quot;]"/>
26       <axsl:choose>
27         <axsl:when test="$books">
28           <axsl:apply-templates select="$books[1]/preceding-sibling::*"/>
29           <axsl:apply-templates select="$books[1]" mode="book">
30             <axsl:with-param name="books" select="$books[position() != 1]"/>
31           </axsl:apply-templates>
32         </axsl:when>
33         <axsl:when test="$toplevel-components">
34           <axsl:apply-templates select="$toplevel-components[1]/preceding-sibling::*"/>
35           <axsl:apply-templates select="$toplevel-components[1]" mode="toplevel-component">
36             <axsl:with-param name="toplevel-components" select="$toplevel-components[position() != 1]"/>
37           </axsl:apply-templates>
38         </axsl:when>
39         <axsl:otherwise>
40           <axsl:apply-templates/>
41         </axsl:otherwise>
42       </axsl:choose>
43     </axsl:copy>
44   </axsl:template>
45   <axsl:template match="dbk:para" mode="book">
46     <axsl:param name="books" select="/.."/>
47     <axsl:choose>
48       <axsl:when test="$books and (@rnd:style = &quot;book&quot; or @rnd:style = &quot;book-title&quot;)">
49         <axsl:call-template name="make-book">
50           <axsl:with-param name="books" select="$books"/>
51           <axsl:with-param name="book-components" select="$books[1]/preceding-sibling::dbk:para[@rnd:style = &quot;part&quot; or @rnd:style = &quot;part-title&quot; or @rnd:style = &quot;article&quot; or @rnd:style = &quot;article-title&quot; or @rnd:style = &quot;appendix&quot; or @rnd:style = &quot;appendix-title&quot; or @rnd:style = &quot;chapter&quot; or @rnd:style = &quot;chapter-title&quot; or @rnd:style = &quot;preface&quot; or @rnd:style = &quot;preface-title&quot;]"/>
52         </axsl:call-template>
53       </axsl:when>
54       <axsl:otherwise>
55         <axsl:call-template name="make-book">
56           <axsl:with-param name="books" select="$books"/>
57           <axsl:with-param name="book-components" select="following-sibling::dbk:para[@rnd:style = &quot;part&quot; or @rnd:style = &quot;part-title&quot; or @rnd:style = &quot;article&quot; or @rnd:style = &quot;article-title&quot; or @rnd:style = &quot;appendix&quot; or @rnd:style = &quot;appendix-title&quot; or @rnd:style = &quot;chapter&quot; or @rnd:style = &quot;chapter-title&quot; or @rnd:style = &quot;preface&quot; or @rnd:style = &quot;preface-title&quot;]"/>
58         </axsl:call-template>
59       </axsl:otherwise>
60     </axsl:choose>
61   </axsl:template>
62   <axsl:template name="make-book">
63     <axsl:param name="books" select="/.."/>
64     <axsl:param name="book-components" select="/.."/>
65 <!-- mode toplevel-templates -->
66     <book xmlns="http://docbook.org/ns/docbook">
67       <axsl:call-template name="copy"/>
68       <axsl:apply-templates select="following-sibling::*[1]" mode="book-component">
69         <axsl:with-param name="nextbook" select="$books[1]"/>
70         <axsl:with-param name="book-components" select="$book-components"/>
71       </axsl:apply-templates>
72     </book>
73     <axsl:apply-templates select="$books[1]" mode="book">
74       <axsl:with-param name="books" select="$books[position() != 1]"/>
75     </axsl:apply-templates>
76   </axsl:template>
77   <axsl:template match="dbk:para" mode="toplevel-component">
78     <axsl:param name="toplevel-components" select="/.."/>
79     <axsl:choose>
80       <axsl:when test="$toplevel-components and (@rnd:style = &quot;article&quot; or @rnd:style = &quot;article-title&quot; or @rnd:style = &quot;appendix&quot; or @rnd:style = &quot;appendix-title&quot; or @rnd:style = &quot;chapter&quot; or @rnd:style = &quot;chapter-title&quot; or @rnd:style = &quot;preface&quot; or @rnd:style = &quot;preface-title&quot;)">
81         <axsl:call-template name="make-toplevel-component">
82           <axsl:with-param name="toplevel-components" select="$toplevel-components"/>
83           <axsl:with-param name="sect1s" select="$toplevel-components[1]/preceding-sibling::dbk:para[@rnd:style = &quot;sect1&quot; or @rnd:style = &quot;sect1-title&quot;]"/>
84         </axsl:call-template>
85       </axsl:when>
86       <axsl:otherwise>
87         <axsl:call-template name="make-toplevel-component">
88           <axsl:with-param name="toplevel-components" select="$toplevel-components"/>
89           <axsl:with-param name="sect1s" select="following-sibling::dbk:para[@rnd:style = &quot;sect1&quot; or @rnd:style = &quot;sect1-title&quot;]"/>
90         </axsl:call-template>
91       </axsl:otherwise>
92     </axsl:choose>
93   </axsl:template>
94   <axsl:template name="make-toplevel-component">
95     <axsl:param name="toplevel-components" select="/.."/>
96     <axsl:param name="sect1s" select="/.."/>
97 <!-- mode toplevel-templates: group:level - do not create element -->
98     <axsl:call-template name="copy"/>
99     <axsl:apply-templates select="following-sibling::*[1]" mode="toplevel-sect1">
100       <axsl:with-param name="nexttoplevel-component" select="$toplevel-components[1]"/>
101       <axsl:with-param name="sect1s" select="$sect1s"/>
102     </axsl:apply-templates>
103     <axsl:apply-templates select="$toplevel-components[1]" mode="toplevel-component">
104       <axsl:with-param name="toplevel-components" select="$toplevel-components[position() != 1]"/>
105     </axsl:apply-templates>
106   </axsl:template>
107   <axsl:template match="dbk:para" mode="book-component">
108     <axsl:param name="nextbook" select="/.."/>
109     <axsl:param select="/.." name="book-components"/>
110     <axsl:choose>
111       <axsl:when test="generate-id() = generate-id($nextbook)"/>
112       <axsl:when test="@rnd:style = &quot;part&quot; or @rnd:style = &quot;part-title&quot; or @rnd:style = &quot;article&quot; or @rnd:style = &quot;article-title&quot; or @rnd:style = &quot;appendix&quot; or @rnd:style = &quot;appendix-title&quot; or @rnd:style = &quot;chapter&quot; or @rnd:style = &quot;chapter-title&quot; or @rnd:style = &quot;preface&quot; or @rnd:style = &quot;preface-title&quot;">
113         <axsl:variable name="nextbook-component" select="following-sibling::dbk:para[@rnd:style = &quot;part&quot; or @rnd:style = &quot;part-title&quot; or @rnd:style = &quot;article&quot; or @rnd:style = &quot;article-title&quot; or @rnd:style = &quot;appendix&quot; or @rnd:style = &quot;appendix-title&quot; or @rnd:style = &quot;chapter&quot; or @rnd:style = &quot;chapter-title&quot; or @rnd:style = &quot;preface&quot; or @rnd:style = &quot;preface-title&quot;][1]"/>
114         <axsl:choose>
115           <axsl:when test="$nextbook-component">
116             <axsl:variable name="sect1s" select="$nextbook-component/preceding-sibling::dbk:para[@rnd:style = &quot;sect1&quot; or @rnd:style = &quot;sect1-title&quot;]"/>
117 <!-- mode sections 1 -->
118             <book-component xmlns="http://docbook.org/ns/docbook">
119               <axsl:call-template name="copy"/>
120               <axsl:apply-templates select="following-sibling::*[1]" mode="book-sect1">
121                 <axsl:with-param name="nextbook-component" select="$nextbook-component"/>
122                 <axsl:with-param name="nextbook" select="$nextbook"/>
123                 <axsl:with-param name="sect1s" select="$sect1s"/>
124                 <axsl:with-param name="book-components" select="$book-components"/>
125               </axsl:apply-templates>
126             </book-component>
127             <axsl:if test="count($book-components|$nextbook-component) = count($book-components)">
128               <axsl:apply-templates select="$nextbook-component" mode="book-component">
129                 <axsl:with-param name="nextbook" select="$nextbook"/>
130                 <axsl:with-param name="book-components" select="$book-components"/>
131               </axsl:apply-templates>
132             </axsl:if>
133           </axsl:when>
134           <axsl:otherwise>
135             <axsl:variable name="sect1s" select="following-sibling::dbk:para[@rnd:style = &quot;sect1&quot; or @rnd:style = &quot;sect1-title&quot;]"/>
136 <!-- mode sections 2 -->
137             <book-component xmlns="http://docbook.org/ns/docbook">
138               <axsl:call-template name="copy"/>
139               <axsl:apply-templates select="following-sibling::*[1]" mode="book-sect1">
140                 <axsl:with-param name="nextbook-component" select="$nextbook-component"/>
141                 <axsl:with-param name="nextbook" select="$nextbook"/>
142                 <axsl:with-param name="sect1s" select="$sect1s"/>
143                 <axsl:with-param name="book-components" select="$book-components"/>
144               </axsl:apply-templates>
145             </book-component>
146             <axsl:if test="count($book-components|$nextbook-component) = count($book-components)">
147               <axsl:apply-templates select="$nextbook-component" mode="book-component">
148                 <axsl:with-param name="nextbook" select="$nextbook"/>
149                 <axsl:with-param name="book-components" select="$book-components"/>
150               </axsl:apply-templates>
151             </axsl:if>
152           </axsl:otherwise>
153         </axsl:choose>
154       </axsl:when>
155       <axsl:otherwise>
156         <axsl:call-template name="copy"/>
157         <axsl:apply-templates select="following-sibling::*[1]" mode="book-component">
158           <axsl:with-param name="nextbook" select="$nextbook"/>
159           <axsl:with-param name="book-components" select="$book-components"/>
160         </axsl:apply-templates>
161       </axsl:otherwise>
162     </axsl:choose>
163   </axsl:template>
164   <axsl:template match="dbk:para" mode="book-sect1">
165     <axsl:param name="nextbook-component" select="/.."/>
166     <axsl:param name="nextbook" select="/.."/>
167     <axsl:param select="/.." name="sect1s"/>
168     <axsl:param select="/.." name="book-components"/>
169     <axsl:choose>
170       <axsl:when test="generate-id() = generate-id($nextbook-component)"/>
171       <axsl:when test="generate-id() = generate-id($nextbook)"/>
172       <axsl:when test="@rnd:style = &quot;sect1&quot; or @rnd:style = &quot;sect1-title&quot;">
173         <axsl:variable name="nextsect1" select="following-sibling::dbk:para[@rnd:style = &quot;sect1&quot; or @rnd:style = &quot;sect1-title&quot;][1]"/>
174         <axsl:choose>
175           <axsl:when test="$nextsect1">
176             <axsl:variable name="sect2s" select="$nextsect1/preceding-sibling::dbk:para[@rnd:style = &quot;sect2&quot; or @rnd:style = &quot;sect2-title&quot;]"/>
177 <!-- mode sections 1 -->
178             <sect1 xmlns="http://docbook.org/ns/docbook">
179               <axsl:call-template name="copy"/>
180               <axsl:apply-templates select="following-sibling::*[1]" mode="book-sect2">
181                 <axsl:with-param name="nextsect1" select="$nextsect1"/>
182                 <axsl:with-param name="nextbook-component" select="$nextbook-component"/>
183                 <axsl:with-param name="nextbook" select="$nextbook"/>
184                 <axsl:with-param name="sect2s" select="$sect2s"/>
185                 <axsl:with-param name="sect1s" select="$sect1s"/>
186                 <axsl:with-param name="book-components" select="$book-components"/>
187               </axsl:apply-templates>
188             </sect1>
189             <axsl:if test="$nextsect1 and (not($book-components) or count($sect1s|$nextsect1) = count($sect1s))">
190               <axsl:apply-templates select="$nextsect1" mode="book-sect1">
191                 <axsl:with-param name="nextbook-component" select="$nextbook-component"/>
192                 <axsl:with-param name="nextbook" select="$nextbook"/>
193                 <axsl:with-param name="sect1s" select="$sect1s"/>
194                 <axsl:with-param name="book-components" select="$book-components"/>
195               </axsl:apply-templates>
196             </axsl:if>
197           </axsl:when>
198           <axsl:otherwise>
199             <axsl:variable name="sect2s" select="following-sibling::dbk:para[@rnd:style = &quot;sect2&quot; or @rnd:style = &quot;sect2-title&quot;]"/>
200 <!-- mode sections 2 -->
201             <sect1 xmlns="http://docbook.org/ns/docbook">
202               <axsl:call-template name="copy"/>
203               <axsl:apply-templates select="following-sibling::*[1]" mode="book-sect2">
204                 <axsl:with-param name="nextsect1" select="$nextsect1"/>
205                 <axsl:with-param name="nextbook-component" select="$nextbook-component"/>
206                 <axsl:with-param name="nextbook" select="$nextbook"/>
207                 <axsl:with-param name="sect2s" select="$sect2s"/>
208                 <axsl:with-param name="sect1s" select="$sect1s"/>
209                 <axsl:with-param name="book-components" select="$book-components"/>
210               </axsl:apply-templates>
211             </sect1>
212             <axsl:if test="$nextsect1 and (not($book-components) or count($sect1s|$nextsect1) = count($sect1s))">
213               <axsl:apply-templates select="$nextsect1" mode="book-sect1">
214                 <axsl:with-param name="nextbook-component" select="$nextbook-component"/>
215                 <axsl:with-param name="nextbook" select="$nextbook"/>
216                 <axsl:with-param name="sect1s" select="$sect1s"/>
217                 <axsl:with-param name="book-components" select="$book-components"/>
218               </axsl:apply-templates>
219             </axsl:if>
220           </axsl:otherwise>
221         </axsl:choose>
222       </axsl:when>
223       <axsl:otherwise>
224         <axsl:call-template name="copy"/>
225         <axsl:apply-templates select="following-sibling::*[1]" mode="book-sect1">
226           <axsl:with-param name="nextbook-component" select="$nextbook-component"/>
227           <axsl:with-param name="nextbook" select="$nextbook"/>
228           <axsl:with-param name="sect1s" select="$sect1s"/>
229           <axsl:with-param name="book-components" select="$book-components"/>
230         </axsl:apply-templates>
231       </axsl:otherwise>
232     </axsl:choose>
233   </axsl:template>
234   <axsl:template match="dbk:para" mode="book-sect2">
235     <axsl:param name="nextsect1" select="/.."/>
236     <axsl:param name="nextbook-component" select="/.."/>
237     <axsl:param name="nextbook" select="/.."/>
238     <axsl:param select="/.." name="sect2s"/>
239     <axsl:param select="/.." name="sect1s"/>
240     <axsl:param select="/.." name="book-components"/>
241     <axsl:choose>
242       <axsl:when test="generate-id() = generate-id($nextsect1)"/>
243       <axsl:when test="generate-id() = generate-id($nextbook-component)"/>
244       <axsl:when test="generate-id() = generate-id($nextbook)"/>
245       <axsl:when test="@rnd:style = &quot;sect2&quot; or @rnd:style = &quot;sect2-title&quot;">
246         <axsl:variable name="nextsect2" select="following-sibling::dbk:para[@rnd:style = &quot;sect2&quot; or @rnd:style = &quot;sect2-title&quot;][1]"/>
247         <axsl:choose>
248           <axsl:when test="$nextsect2">
249             <axsl:variable name="sect3s" select="$nextsect2/preceding-sibling::dbk:para[@rnd:style = &quot;sect3&quot; or @rnd:style = &quot;sect3-title&quot;]"/>
250 <!-- mode sections 1 -->
251             <sect2 xmlns="http://docbook.org/ns/docbook">
252               <axsl:call-template name="copy"/>
253               <axsl:apply-templates select="following-sibling::*[1]" mode="book-sect3">
254                 <axsl:with-param name="nextsect2" select="$nextsect2"/>
255                 <axsl:with-param name="nextsect1" select="$nextsect1"/>
256                 <axsl:with-param name="nextbook-component" select="$nextbook-component"/>
257                 <axsl:with-param name="nextbook" select="$nextbook"/>
258                 <axsl:with-param name="sect3s" select="$sect3s"/>
259                 <axsl:with-param name="sect2s" select="$sect2s"/>
260                 <axsl:with-param name="sect1s" select="$sect1s"/>
261                 <axsl:with-param name="book-components" select="$book-components"/>
262               </axsl:apply-templates>
263             </sect2>
264             <axsl:if test="$nextsect2 and (not($sect1s) or count($sect2s|$nextsect2) = count($sect2s))">
265               <axsl:apply-templates select="$nextsect2" mode="book-sect2">
266                 <axsl:with-param name="nextsect1" select="$nextsect1"/>
267                 <axsl:with-param name="nextbook-component" select="$nextbook-component"/>
268                 <axsl:with-param name="nextbook" select="$nextbook"/>
269                 <axsl:with-param name="sect2s" select="$sect2s"/>
270                 <axsl:with-param name="sect1s" select="$sect1s"/>
271                 <axsl:with-param name="book-components" select="$book-components"/>
272               </axsl:apply-templates>
273             </axsl:if>
274           </axsl:when>
275           <axsl:otherwise>
276             <axsl:variable name="sect3s" select="following-sibling::dbk:para[@rnd:style = &quot;sect3&quot; or @rnd:style = &quot;sect3-title&quot;]"/>
277 <!-- mode sections 2 -->
278             <sect2 xmlns="http://docbook.org/ns/docbook">
279               <axsl:call-template name="copy"/>
280               <axsl:apply-templates select="following-sibling::*[1]" mode="book-sect3">
281                 <axsl:with-param name="nextsect2" select="$nextsect2"/>
282                 <axsl:with-param name="nextsect1" select="$nextsect1"/>
283                 <axsl:with-param name="nextbook-component" select="$nextbook-component"/>
284                 <axsl:with-param name="nextbook" select="$nextbook"/>
285                 <axsl:with-param name="sect3s" select="$sect3s"/>
286                 <axsl:with-param name="sect2s" select="$sect2s"/>
287                 <axsl:with-param name="sect1s" select="$sect1s"/>
288                 <axsl:with-param name="book-components" select="$book-components"/>
289               </axsl:apply-templates>
290             </sect2>
291             <axsl:if test="$nextsect2 and (not($sect1s) or count($sect2s|$nextsect2) = count($sect2s))">
292               <axsl:apply-templates select="$nextsect2" mode="book-sect2">
293                 <axsl:with-param name="nextsect1" select="$nextsect1"/>
294                 <axsl:with-param name="nextbook-component" select="$nextbook-component"/>
295                 <axsl:with-param name="nextbook" select="$nextbook"/>
296                 <axsl:with-param name="sect2s" select="$sect2s"/>
297                 <axsl:with-param name="sect1s" select="$sect1s"/>
298                 <axsl:with-param name="book-components" select="$book-components"/>
299               </axsl:apply-templates>
300             </axsl:if>
301           </axsl:otherwise>
302         </axsl:choose>
303       </axsl:when>
304       <axsl:otherwise>
305         <axsl:call-template name="copy"/>
306         <axsl:apply-templates select="following-sibling::*[1]" mode="book-sect2">
307           <axsl:with-param name="nextsect1" select="$nextsect1"/>
308           <axsl:with-param name="nextbook-component" select="$nextbook-component"/>
309           <axsl:with-param name="nextbook" select="$nextbook"/>
310           <axsl:with-param name="sect2s" select="$sect2s"/>
311           <axsl:with-param name="sect1s" select="$sect1s"/>
312           <axsl:with-param name="book-components" select="$book-components"/>
313         </axsl:apply-templates>
314       </axsl:otherwise>
315     </axsl:choose>
316   </axsl:template>
317   <axsl:template match="dbk:para" mode="book-sect3">
318     <axsl:param name="nextsect2" select="/.."/>
319     <axsl:param name="nextsect1" select="/.."/>
320     <axsl:param name="nextbook-component" select="/.."/>
321     <axsl:param name="nextbook" select="/.."/>
322     <axsl:param select="/.." name="sect3s"/>
323     <axsl:param select="/.." name="sect2s"/>
324     <axsl:param select="/.." name="sect1s"/>
325     <axsl:param select="/.." name="book-components"/>
326     <axsl:choose>
327       <axsl:when test="generate-id() = generate-id($nextsect2)"/>
328       <axsl:when test="generate-id() = generate-id($nextsect1)"/>
329       <axsl:when test="generate-id() = generate-id($nextbook-component)"/>
330       <axsl:when test="generate-id() = generate-id($nextbook)"/>
331       <axsl:when test="@rnd:style = &quot;sect3&quot; or @rnd:style = &quot;sect3-title&quot;">
332         <axsl:variable name="nextsect3" select="following-sibling::dbk:para[@rnd:style = &quot;sect3&quot; or @rnd:style = &quot;sect3-title&quot;][1]"/>
333         <axsl:choose>
334           <axsl:when test="$nextsect3">
335             <axsl:variable name="sect4s" select="$nextsect3/preceding-sibling::dbk:para[@rnd:style = &quot;sect4&quot; or @rnd:style = &quot;sect4-title&quot;]"/>
336 <!-- mode sections 1 -->
337             <sect3 xmlns="http://docbook.org/ns/docbook">
338               <axsl:call-template name="copy"/>
339               <axsl:apply-templates select="following-sibling::*[1]" mode="book-sect4">
340                 <axsl:with-param name="nextsect3" select="$nextsect3"/>
341                 <axsl:with-param name="nextsect2" select="$nextsect2"/>
342                 <axsl:with-param name="nextsect1" select="$nextsect1"/>
343                 <axsl:with-param name="nextbook-component" select="$nextbook-component"/>
344                 <axsl:with-param name="nextbook" select="$nextbook"/>
345                 <axsl:with-param name="sect4s" select="$sect4s"/>
346                 <axsl:with-param name="sect3s" select="$sect3s"/>
347                 <axsl:with-param name="sect2s" select="$sect2s"/>
348                 <axsl:with-param name="sect1s" select="$sect1s"/>
349                 <axsl:with-param name="book-components" select="$book-components"/>
350               </axsl:apply-templates>
351             </sect3>
352             <axsl:if test="$nextsect3 and (not($sect2s) or count($sect3s|$nextsect3) = count($sect3s))">
353               <axsl:apply-templates select="$nextsect3" mode="book-sect3">
354                 <axsl:with-param name="nextsect2" select="$nextsect2"/>
355                 <axsl:with-param name="nextsect1" select="$nextsect1"/>
356                 <axsl:with-param name="nextbook-component" select="$nextbook-component"/>
357                 <axsl:with-param name="nextbook" select="$nextbook"/>
358                 <axsl:with-param name="sect3s" select="$sect3s"/>
359                 <axsl:with-param name="sect2s" select="$sect2s"/>
360                 <axsl:with-param name="sect1s" select="$sect1s"/>
361                 <axsl:with-param name="book-components" select="$book-components"/>
362               </axsl:apply-templates>
363             </axsl:if>
364           </axsl:when>
365           <axsl:otherwise>
366             <axsl:variable name="sect4s" select="following-sibling::dbk:para[@rnd:style = &quot;sect4&quot; or @rnd:style = &quot;sect4-title&quot;]"/>
367 <!-- mode sections 2 -->
368             <sect3 xmlns="http://docbook.org/ns/docbook">
369               <axsl:call-template name="copy"/>
370               <axsl:apply-templates select="following-sibling::*[1]" mode="book-sect4">
371                 <axsl:with-param name="nextsect3" select="$nextsect3"/>
372                 <axsl:with-param name="nextsect2" select="$nextsect2"/>
373                 <axsl:with-param name="nextsect1" select="$nextsect1"/>
374                 <axsl:with-param name="nextbook-component" select="$nextbook-component"/>
375                 <axsl:with-param name="nextbook" select="$nextbook"/>
376                 <axsl:with-param name="sect4s" select="$sect4s"/>
377                 <axsl:with-param name="sect3s" select="$sect3s"/>
378                 <axsl:with-param name="sect2s" select="$sect2s"/>
379                 <axsl:with-param name="sect1s" select="$sect1s"/>
380                 <axsl:with-param name="book-components" select="$book-components"/>
381               </axsl:apply-templates>
382             </sect3>
383             <axsl:if test="$nextsect3 and (not($sect2s) or count($sect3s|$nextsect3) = count($sect3s))">
384               <axsl:apply-templates select="$nextsect3" mode="book-sect3">
385                 <axsl:with-param name="nextsect2" select="$nextsect2"/>
386                 <axsl:with-param name="nextsect1" select="$nextsect1"/>
387                 <axsl:with-param name="nextbook-component" select="$nextbook-component"/>
388                 <axsl:with-param name="nextbook" select="$nextbook"/>
389                 <axsl:with-param name="sect3s" select="$sect3s"/>
390                 <axsl:with-param name="sect2s" select="$sect2s"/>
391                 <axsl:with-param name="sect1s" select="$sect1s"/>
392                 <axsl:with-param name="book-components" select="$book-components"/>
393               </axsl:apply-templates>
394             </axsl:if>
395           </axsl:otherwise>
396         </axsl:choose>
397       </axsl:when>
398       <axsl:otherwise>
399         <axsl:call-template name="copy"/>
400         <axsl:apply-templates select="following-sibling::*[1]" mode="book-sect3">
401           <axsl:with-param name="nextsect2" select="$nextsect2"/>
402           <axsl:with-param name="nextsect1" select="$nextsect1"/>
403           <axsl:with-param name="nextbook-component" select="$nextbook-component"/>
404           <axsl:with-param name="nextbook" select="$nextbook"/>
405           <axsl:with-param name="sect3s" select="$sect3s"/>
406           <axsl:with-param name="sect2s" select="$sect2s"/>
407           <axsl:with-param name="sect1s" select="$sect1s"/>
408           <axsl:with-param name="book-components" select="$book-components"/>
409         </axsl:apply-templates>
410       </axsl:otherwise>
411     </axsl:choose>
412   </axsl:template>
413   <axsl:template match="dbk:para" mode="book-sect4">
414     <axsl:param name="nextsect3" select="/.."/>
415     <axsl:param name="nextsect2" select="/.."/>
416     <axsl:param name="nextsect1" select="/.."/>
417     <axsl:param name="nextbook-component" select="/.."/>
418     <axsl:param name="nextbook" select="/.."/>
419     <axsl:param select="/.." name="sect4s"/>
420     <axsl:param select="/.." name="sect3s"/>
421     <axsl:param select="/.." name="sect2s"/>
422     <axsl:param select="/.." name="sect1s"/>
423     <axsl:param select="/.." name="book-components"/>
424     <axsl:choose>
425       <axsl:when test="generate-id() = generate-id($nextsect3)"/>
426       <axsl:when test="generate-id() = generate-id($nextsect2)"/>
427       <axsl:when test="generate-id() = generate-id($nextsect1)"/>
428       <axsl:when test="generate-id() = generate-id($nextbook-component)"/>
429       <axsl:when test="generate-id() = generate-id($nextbook)"/>
430       <axsl:when test="@rnd:style = &quot;sect4&quot; or @rnd:style = &quot;sect4-title&quot;">
431         <axsl:variable name="nextsect4" select="following-sibling::dbk:para[@rnd:style = &quot;sect4&quot; or @rnd:style = &quot;sect4-title&quot;][1]"/>
432         <axsl:choose>
433           <axsl:when test="$nextsect4">
434             <axsl:variable name="sect5s" select="$nextsect4/preceding-sibling::dbk:para[@rnd:style = &quot;sect5&quot; or @rnd:style = &quot;sect5-title&quot;]"/>
435 <!-- mode sections 1 -->
436             <sect4 xmlns="http://docbook.org/ns/docbook">
437               <axsl:call-template name="copy"/>
438               <axsl:apply-templates select="following-sibling::*[1]" mode="book-sect5">
439                 <axsl:with-param name="nextsect4" select="$nextsect4"/>
440                 <axsl:with-param name="nextsect3" select="$nextsect3"/>
441                 <axsl:with-param name="nextsect2" select="$nextsect2"/>
442                 <axsl:with-param name="nextsect1" select="$nextsect1"/>
443                 <axsl:with-param name="nextbook-component" select="$nextbook-component"/>
444                 <axsl:with-param name="nextbook" select="$nextbook"/>
445                 <axsl:with-param name="sect5s" select="$sect5s"/>
446                 <axsl:with-param name="sect4s" select="$sect4s"/>
447                 <axsl:with-param name="sect3s" select="$sect3s"/>
448                 <axsl:with-param name="sect2s" select="$sect2s"/>
449                 <axsl:with-param name="sect1s" select="$sect1s"/>
450                 <axsl:with-param name="book-components" select="$book-components"/>
451               </axsl:apply-templates>
452             </sect4>
453             <axsl:if test="$nextsect4 and (not($sect3s) or count($sect4s|$nextsect4) = count($sect4s))">
454               <axsl:apply-templates select="$nextsect4" mode="book-sect4">
455                 <axsl:with-param name="nextsect3" select="$nextsect3"/>
456                 <axsl:with-param name="nextsect2" select="$nextsect2"/>
457                 <axsl:with-param name="nextsect1" select="$nextsect1"/>
458                 <axsl:with-param name="nextbook-component" select="$nextbook-component"/>
459                 <axsl:with-param name="nextbook" select="$nextbook"/>
460                 <axsl:with-param name="sect4s" select="$sect4s"/>
461                 <axsl:with-param name="sect3s" select="$sect3s"/>
462                 <axsl:with-param name="sect2s" select="$sect2s"/>
463                 <axsl:with-param name="sect1s" select="$sect1s"/>
464                 <axsl:with-param name="book-components" select="$book-components"/>
465               </axsl:apply-templates>
466             </axsl:if>
467           </axsl:when>
468           <axsl:otherwise>
469             <axsl:variable name="sect5s" select="following-sibling::dbk:para[@rnd:style = &quot;sect5&quot; or @rnd:style = &quot;sect5-title&quot;]"/>
470 <!-- mode sections 2 -->
471             <sect4 xmlns="http://docbook.org/ns/docbook">
472               <axsl:call-template name="copy"/>
473               <axsl:apply-templates select="following-sibling::*[1]" mode="book-sect5">
474                 <axsl:with-param name="nextsect4" select="$nextsect4"/>
475                 <axsl:with-param name="nextsect3" select="$nextsect3"/>
476                 <axsl:with-param name="nextsect2" select="$nextsect2"/>
477                 <axsl:with-param name="nextsect1" select="$nextsect1"/>
478                 <axsl:with-param name="nextbook-component" select="$nextbook-component"/>
479                 <axsl:with-param name="nextbook" select="$nextbook"/>
480                 <axsl:with-param name="sect5s" select="$sect5s"/>
481                 <axsl:with-param name="sect4s" select="$sect4s"/>
482                 <axsl:with-param name="sect3s" select="$sect3s"/>
483                 <axsl:with-param name="sect2s" select="$sect2s"/>
484                 <axsl:with-param name="sect1s" select="$sect1s"/>
485                 <axsl:with-param name="book-components" select="$book-components"/>
486               </axsl:apply-templates>
487             </sect4>
488             <axsl:if test="$nextsect4 and (not($sect3s) or count($sect4s|$nextsect4) = count($sect4s))">
489               <axsl:apply-templates select="$nextsect4" mode="book-sect4">
490                 <axsl:with-param name="nextsect3" select="$nextsect3"/>
491                 <axsl:with-param name="nextsect2" select="$nextsect2"/>
492                 <axsl:with-param name="nextsect1" select="$nextsect1"/>
493                 <axsl:with-param name="nextbook-component" select="$nextbook-component"/>
494                 <axsl:with-param name="nextbook" select="$nextbook"/>
495                 <axsl:with-param name="sect4s" select="$sect4s"/>
496                 <axsl:with-param name="sect3s" select="$sect3s"/>
497                 <axsl:with-param name="sect2s" select="$sect2s"/>
498                 <axsl:with-param name="sect1s" select="$sect1s"/>
499                 <axsl:with-param name="book-components" select="$book-components"/>
500               </axsl:apply-templates>
501             </axsl:if>
502           </axsl:otherwise>
503         </axsl:choose>
504       </axsl:when>
505       <axsl:otherwise>
506         <axsl:call-template name="copy"/>
507         <axsl:apply-templates select="following-sibling::*[1]" mode="book-sect4">
508           <axsl:with-param name="nextsect3" select="$nextsect3"/>
509           <axsl:with-param name="nextsect2" select="$nextsect2"/>
510           <axsl:with-param name="nextsect1" select="$nextsect1"/>
511           <axsl:with-param name="nextbook-component" select="$nextbook-component"/>
512           <axsl:with-param name="nextbook" select="$nextbook"/>
513           <axsl:with-param name="sect4s" select="$sect4s"/>
514           <axsl:with-param name="sect3s" select="$sect3s"/>
515           <axsl:with-param name="sect2s" select="$sect2s"/>
516           <axsl:with-param name="sect1s" select="$sect1s"/>
517           <axsl:with-param name="book-components" select="$book-components"/>
518         </axsl:apply-templates>
519       </axsl:otherwise>
520     </axsl:choose>
521   </axsl:template>
522   <axsl:template match="dbk:para" mode="book-sect5">
523     <axsl:param name="nextsect4" select="/.."/>
524     <axsl:param name="nextsect3" select="/.."/>
525     <axsl:param name="nextsect2" select="/.."/>
526     <axsl:param name="nextsect1" select="/.."/>
527     <axsl:param name="nextbook-component" select="/.."/>
528     <axsl:param name="nextbook" select="/.."/>
529     <axsl:param select="/.." name="sect5s"/>
530     <axsl:param select="/.." name="sect4s"/>
531     <axsl:param select="/.." name="sect3s"/>
532     <axsl:param select="/.." name="sect2s"/>
533     <axsl:param select="/.." name="sect1s"/>
534     <axsl:param select="/.." name="book-components"/>
535     <axsl:choose>
536       <axsl:when test="generate-id() = generate-id($nextsect4)"/>
537       <axsl:when test="generate-id() = generate-id($nextsect3)"/>
538       <axsl:when test="generate-id() = generate-id($nextsect2)"/>
539       <axsl:when test="generate-id() = generate-id($nextsect1)"/>
540       <axsl:when test="generate-id() = generate-id($nextbook-component)"/>
541       <axsl:when test="generate-id() = generate-id($nextbook)"/>
542       <axsl:when test="@rnd:style = &quot;sect5&quot; or @rnd:style = &quot;sect5-title&quot;">
543         <axsl:variable name="nextsect5" select="following-sibling::dbk:para[@rnd:style = &quot;sect5&quot; or @rnd:style = &quot;sect5-title&quot;][1]"/>
544 <!-- mode sections 3 -->
545         <sect5 xmlns="http://docbook.org/ns/docbook">
546           <axsl:call-template name="copy"/>
547           <axsl:apply-templates select="following-sibling::*[1]" mode="book-terminal">
548             <axsl:with-param name="nextsect5" select="$nextsect5"/>
549             <axsl:with-param name="nextsect4" select="$nextsect4"/>
550             <axsl:with-param name="nextsect3" select="$nextsect3"/>
551             <axsl:with-param name="nextsect2" select="$nextsect2"/>
552             <axsl:with-param name="nextsect1" select="$nextsect1"/>
553             <axsl:with-param name="nextbook-component" select="$nextbook-component"/>
554             <axsl:with-param name="nextbook" select="$nextbook"/>
555             <axsl:with-param name="sect5s" select="$sect5s"/>
556             <axsl:with-param name="sect4s" select="$sect4s"/>
557             <axsl:with-param name="sect3s" select="$sect3s"/>
558             <axsl:with-param name="sect2s" select="$sect2s"/>
559             <axsl:with-param name="sect1s" select="$sect1s"/>
560             <axsl:with-param name="book-components" select="$book-components"/>
561           </axsl:apply-templates>
562         </sect5>
563         <axsl:if test="$nextsect5 and (not($sect4s) or count($sect5s|$nextsect5) = count($sect5s))">
564           <axsl:apply-templates select="$nextsect5" mode="book-sect5">
565             <axsl:with-param name="nextsect4" select="$nextsect4"/>
566             <axsl:with-param name="nextsect3" select="$nextsect3"/>
567             <axsl:with-param name="nextsect2" select="$nextsect2"/>
568             <axsl:with-param name="nextsect1" select="$nextsect1"/>
569             <axsl:with-param name="nextbook-component" select="$nextbook-component"/>
570             <axsl:with-param name="nextbook" select="$nextbook"/>
571             <axsl:with-param name="sect5s" select="$sect5s"/>
572             <axsl:with-param name="sect4s" select="$sect4s"/>
573             <axsl:with-param name="sect3s" select="$sect3s"/>
574             <axsl:with-param name="sect2s" select="$sect2s"/>
575             <axsl:with-param name="sect1s" select="$sect1s"/>
576             <axsl:with-param name="book-components" select="$book-components"/>
577           </axsl:apply-templates>
578         </axsl:if>
579       </axsl:when>
580       <axsl:otherwise>
581         <axsl:call-template name="copy"/>
582         <axsl:apply-templates select="following-sibling::*[1]" mode="book-sect5">
583           <axsl:with-param name="nextsect4" select="$nextsect4"/>
584           <axsl:with-param name="nextsect3" select="$nextsect3"/>
585           <axsl:with-param name="nextsect2" select="$nextsect2"/>
586           <axsl:with-param name="nextsect1" select="$nextsect1"/>
587           <axsl:with-param name="nextbook-component" select="$nextbook-component"/>
588           <axsl:with-param name="nextbook" select="$nextbook"/>
589           <axsl:with-param name="sect5s" select="$sect5s"/>
590           <axsl:with-param name="sect4s" select="$sect4s"/>
591           <axsl:with-param name="sect3s" select="$sect3s"/>
592           <axsl:with-param name="sect2s" select="$sect2s"/>
593           <axsl:with-param name="sect1s" select="$sect1s"/>
594           <axsl:with-param name="book-components" select="$book-components"/>
595         </axsl:apply-templates>
596       </axsl:otherwise>
597     </axsl:choose>
598   </axsl:template>
599   <axsl:template match="dbk:para" mode="toplevel-sect1">
600     <axsl:param name="nexttoplevel-component" select="/.."/>
601     <axsl:param select="/.." name="sect1s"/>
602     <axsl:choose>
603       <axsl:when test="generate-id() = generate-id($nexttoplevel-component)"/>
604       <axsl:when test="@rnd:style = &quot;sect1&quot; or @rnd:style = &quot;sect1-title&quot;">
605         <axsl:variable name="nextsect1" select="following-sibling::dbk:para[@rnd:style = &quot;sect1&quot; or @rnd:style = &quot;sect1-title&quot;][1]"/>
606         <axsl:choose>
607           <axsl:when test="$nextsect1">
608             <axsl:variable name="sect2s" select="$nextsect1/preceding-sibling::dbk:para[@rnd:style = &quot;sect2&quot; or @rnd:style = &quot;sect2-title&quot;]"/>
609 <!-- mode sections 1 -->
610             <sect1 xmlns="http://docbook.org/ns/docbook">
611               <axsl:call-template name="copy"/>
612               <axsl:apply-templates select="following-sibling::*[1]" mode="toplevel-sect2">
613                 <axsl:with-param name="nextsect1" select="$nextsect1"/>
614                 <axsl:with-param name="nexttoplevel-component" select="$nexttoplevel-component"/>
615                 <axsl:with-param name="sect2s" select="$sect2s"/>
616                 <axsl:with-param name="sect1s" select="$sect1s"/>
617               </axsl:apply-templates>
618             </sect1>
619             <axsl:if test="count($sect1s|$nextsect1) = count($sect1s)">
620               <axsl:apply-templates select="$nextsect1" mode="toplevel-sect1">
621                 <axsl:with-param name="nexttoplevel-component" select="$nexttoplevel-component"/>
622                 <axsl:with-param name="sect1s" select="$sect1s"/>
623               </axsl:apply-templates>
624             </axsl:if>
625           </axsl:when>
626           <axsl:otherwise>
627             <axsl:variable name="sect2s" select="following-sibling::dbk:para[@rnd:style = &quot;sect2&quot; or @rnd:style = &quot;sect2-title&quot;]"/>
628 <!-- mode sections 2 -->
629             <sect1 xmlns="http://docbook.org/ns/docbook">
630               <axsl:call-template name="copy"/>
631               <axsl:apply-templates select="following-sibling::*[1]" mode="toplevel-sect2">
632                 <axsl:with-param name="nextsect1" select="$nextsect1"/>
633                 <axsl:with-param name="nexttoplevel-component" select="$nexttoplevel-component"/>
634                 <axsl:with-param name="sect2s" select="$sect2s"/>
635                 <axsl:with-param name="sect1s" select="$sect1s"/>
636               </axsl:apply-templates>
637             </sect1>
638             <axsl:if test="count($sect1s|$nextsect1) = count($sect1s)">
639               <axsl:apply-templates select="$nextsect1" mode="toplevel-sect1">
640                 <axsl:with-param name="nexttoplevel-component" select="$nexttoplevel-component"/>
641                 <axsl:with-param name="sect1s" select="$sect1s"/>
642               </axsl:apply-templates>
643             </axsl:if>
644           </axsl:otherwise>
645         </axsl:choose>
646       </axsl:when>
647       <axsl:otherwise>
648         <axsl:call-template name="copy"/>
649         <axsl:apply-templates select="following-sibling::*[1]" mode="toplevel-sect1">
650           <axsl:with-param name="nexttoplevel-component" select="$nexttoplevel-component"/>
651           <axsl:with-param name="sect1s" select="$sect1s"/>
652         </axsl:apply-templates>
653       </axsl:otherwise>
654     </axsl:choose>
655   </axsl:template>
656   <axsl:template match="dbk:para" mode="toplevel-sect2">
657     <axsl:param name="nextsect1" select="/.."/>
658     <axsl:param name="nexttoplevel-component" select="/.."/>
659     <axsl:param select="/.." name="sect2s"/>
660     <axsl:param select="/.." name="sect1s"/>
661     <axsl:choose>
662       <axsl:when test="generate-id() = generate-id($nextsect1)"/>
663       <axsl:when test="generate-id() = generate-id($nexttoplevel-component)"/>
664       <axsl:when test="@rnd:style = &quot;sect2&quot; or @rnd:style = &quot;sect2-title&quot;">
665         <axsl:variable name="nextsect2" select="following-sibling::dbk:para[@rnd:style = &quot;sect2&quot; or @rnd:style = &quot;sect2-title&quot;][1]"/>
666         <axsl:choose>
667           <axsl:when test="$nextsect2">
668             <axsl:variable name="sect3s" select="$nextsect2/preceding-sibling::dbk:para[@rnd:style = &quot;sect3&quot; or @rnd:style = &quot;sect3-title&quot;]"/>
669 <!-- mode sections 1 -->
670             <sect2 xmlns="http://docbook.org/ns/docbook">
671               <axsl:call-template name="copy"/>
672               <axsl:apply-templates select="following-sibling::*[1]" mode="toplevel-sect3">
673                 <axsl:with-param name="nextsect2" select="$nextsect2"/>
674                 <axsl:with-param name="nextsect1" select="$nextsect1"/>
675                 <axsl:with-param name="nexttoplevel-component" select="$nexttoplevel-component"/>
676                 <axsl:with-param name="sect3s" select="$sect3s"/>
677                 <axsl:with-param name="sect2s" select="$sect2s"/>
678                 <axsl:with-param name="sect1s" select="$sect1s"/>
679               </axsl:apply-templates>
680             </sect2>
681             <axsl:if test="$nextsect2 and (not($sect1s) or count($sect2s|$nextsect2) = count($sect2s))">
682               <axsl:apply-templates select="$nextsect2" mode="toplevel-sect2">
683                 <axsl:with-param name="nextsect1" select="$nextsect1"/>
684                 <axsl:with-param name="nexttoplevel-component" select="$nexttoplevel-component"/>
685                 <axsl:with-param name="sect2s" select="$sect2s"/>
686                 <axsl:with-param name="sect1s" select="$sect1s"/>
687               </axsl:apply-templates>
688             </axsl:if>
689           </axsl:when>
690           <axsl:otherwise>
691             <axsl:variable name="sect3s" select="following-sibling::dbk:para[@rnd:style = &quot;sect3&quot; or @rnd:style = &quot;sect3-title&quot;]"/>
692 <!-- mode sections 2 -->
693             <sect2 xmlns="http://docbook.org/ns/docbook">
694               <axsl:call-template name="copy"/>
695               <axsl:apply-templates select="following-sibling::*[1]" mode="toplevel-sect3">
696                 <axsl:with-param name="nextsect2" select="$nextsect2"/>
697                 <axsl:with-param name="nextsect1" select="$nextsect1"/>
698                 <axsl:with-param name="nexttoplevel-component" select="$nexttoplevel-component"/>
699                 <axsl:with-param name="sect3s" select="$sect3s"/>
700                 <axsl:with-param name="sect2s" select="$sect2s"/>
701                 <axsl:with-param name="sect1s" select="$sect1s"/>
702               </axsl:apply-templates>
703             </sect2>
704             <axsl:if test="$nextsect2 and (not($sect1s) or count($sect2s|$nextsect2) = count($sect2s))">
705               <axsl:apply-templates select="$nextsect2" mode="toplevel-sect2">
706                 <axsl:with-param name="nextsect1" select="$nextsect1"/>
707                 <axsl:with-param name="nexttoplevel-component" select="$nexttoplevel-component"/>
708                 <axsl:with-param name="sect2s" select="$sect2s"/>
709                 <axsl:with-param name="sect1s" select="$sect1s"/>
710               </axsl:apply-templates>
711             </axsl:if>
712           </axsl:otherwise>
713         </axsl:choose>
714       </axsl:when>
715       <axsl:otherwise>
716         <axsl:call-template name="copy"/>
717         <axsl:apply-templates select="following-sibling::*[1]" mode="toplevel-sect2">
718           <axsl:with-param name="nextsect1" select="$nextsect1"/>
719           <axsl:with-param name="nexttoplevel-component" select="$nexttoplevel-component"/>
720           <axsl:with-param name="sect2s" select="$sect2s"/>
721           <axsl:with-param name="sect1s" select="$sect1s"/>
722         </axsl:apply-templates>
723       </axsl:otherwise>
724     </axsl:choose>
725   </axsl:template>
726   <axsl:template match="dbk:para" mode="toplevel-sect3">
727     <axsl:param name="nextsect2" select="/.."/>
728     <axsl:param name="nextsect1" select="/.."/>
729     <axsl:param name="nexttoplevel-component" select="/.."/>
730     <axsl:param select="/.." name="sect3s"/>
731     <axsl:param select="/.." name="sect2s"/>
732     <axsl:param select="/.." name="sect1s"/>
733     <axsl:choose>
734       <axsl:when test="generate-id() = generate-id($nextsect2)"/>
735       <axsl:when test="generate-id() = generate-id($nextsect1)"/>
736       <axsl:when test="generate-id() = generate-id($nexttoplevel-component)"/>
737       <axsl:when test="@rnd:style = &quot;sect3&quot; or @rnd:style = &quot;sect3-title&quot;">
738         <axsl:variable name="nextsect3" select="following-sibling::dbk:para[@rnd:style = &quot;sect3&quot; or @rnd:style = &quot;sect3-title&quot;][1]"/>
739         <axsl:choose>
740           <axsl:when test="$nextsect3">
741             <axsl:variable name="sect4s" select="$nextsect3/preceding-sibling::dbk:para[@rnd:style = &quot;sect4&quot; or @rnd:style = &quot;sect4-title&quot;]"/>
742 <!-- mode sections 1 -->
743             <sect3 xmlns="http://docbook.org/ns/docbook">
744               <axsl:call-template name="copy"/>
745               <axsl:apply-templates select="following-sibling::*[1]" mode="toplevel-sect4">
746                 <axsl:with-param name="nextsect3" select="$nextsect3"/>
747                 <axsl:with-param name="nextsect2" select="$nextsect2"/>
748                 <axsl:with-param name="nextsect1" select="$nextsect1"/>
749                 <axsl:with-param name="nexttoplevel-component" select="$nexttoplevel-component"/>
750                 <axsl:with-param name="sect4s" select="$sect4s"/>
751                 <axsl:with-param name="sect3s" select="$sect3s"/>
752                 <axsl:with-param name="sect2s" select="$sect2s"/>
753                 <axsl:with-param name="sect1s" select="$sect1s"/>
754               </axsl:apply-templates>
755             </sect3>
756             <axsl:if test="$nextsect3 and (not($sect2s) or count($sect3s|$nextsect3) = count($sect3s))">
757               <axsl:apply-templates select="$nextsect3" mode="toplevel-sect3">
758                 <axsl:with-param name="nextsect2" select="$nextsect2"/>
759                 <axsl:with-param name="nextsect1" select="$nextsect1"/>
760                 <axsl:with-param name="nexttoplevel-component" select="$nexttoplevel-component"/>
761                 <axsl:with-param name="sect3s" select="$sect3s"/>
762                 <axsl:with-param name="sect2s" select="$sect2s"/>
763                 <axsl:with-param name="sect1s" select="$sect1s"/>
764               </axsl:apply-templates>
765             </axsl:if>
766           </axsl:when>
767           <axsl:otherwise>
768             <axsl:variable name="sect4s" select="following-sibling::dbk:para[@rnd:style = &quot;sect4&quot; or @rnd:style = &quot;sect4-title&quot;]"/>
769 <!-- mode sections 2 -->
770             <sect3 xmlns="http://docbook.org/ns/docbook">
771               <axsl:call-template name="copy"/>
772               <axsl:apply-templates select="following-sibling::*[1]" mode="toplevel-sect4">
773                 <axsl:with-param name="nextsect3" select="$nextsect3"/>
774                 <axsl:with-param name="nextsect2" select="$nextsect2"/>
775                 <axsl:with-param name="nextsect1" select="$nextsect1"/>
776                 <axsl:with-param name="nexttoplevel-component" select="$nexttoplevel-component"/>
777                 <axsl:with-param name="sect4s" select="$sect4s"/>
778                 <axsl:with-param name="sect3s" select="$sect3s"/>
779                 <axsl:with-param name="sect2s" select="$sect2s"/>
780                 <axsl:with-param name="sect1s" select="$sect1s"/>
781               </axsl:apply-templates>
782             </sect3>
783             <axsl:if test="$nextsect3 and (not($sect2s) or count($sect3s|$nextsect3) = count($sect3s))">
784               <axsl:apply-templates select="$nextsect3" mode="toplevel-sect3">
785                 <axsl:with-param name="nextsect2" select="$nextsect2"/>
786                 <axsl:with-param name="nextsect1" select="$nextsect1"/>
787                 <axsl:with-param name="nexttoplevel-component" select="$nexttoplevel-component"/>
788                 <axsl:with-param name="sect3s" select="$sect3s"/>
789                 <axsl:with-param name="sect2s" select="$sect2s"/>
790                 <axsl:with-param name="sect1s" select="$sect1s"/>
791               </axsl:apply-templates>
792             </axsl:if>
793           </axsl:otherwise>
794         </axsl:choose>
795       </axsl:when>
796       <axsl:otherwise>
797         <axsl:call-template name="copy"/>
798         <axsl:apply-templates select="following-sibling::*[1]" mode="toplevel-sect3">
799           <axsl:with-param name="nextsect2" select="$nextsect2"/>
800           <axsl:with-param name="nextsect1" select="$nextsect1"/>
801           <axsl:with-param name="nexttoplevel-component" select="$nexttoplevel-component"/>
802           <axsl:with-param name="sect3s" select="$sect3s"/>
803           <axsl:with-param name="sect2s" select="$sect2s"/>
804           <axsl:with-param name="sect1s" select="$sect1s"/>
805         </axsl:apply-templates>
806       </axsl:otherwise>
807     </axsl:choose>
808   </axsl:template>
809   <axsl:template match="dbk:para" mode="toplevel-sect4">
810     <axsl:param name="nextsect3" select="/.."/>
811     <axsl:param name="nextsect2" select="/.."/>
812     <axsl:param name="nextsect1" select="/.."/>
813     <axsl:param name="nexttoplevel-component" select="/.."/>
814     <axsl:param select="/.." name="sect4s"/>
815     <axsl:param select="/.." name="sect3s"/>
816     <axsl:param select="/.." name="sect2s"/>
817     <axsl:param select="/.." name="sect1s"/>
818     <axsl:choose>
819       <axsl:when test="generate-id() = generate-id($nextsect3)"/>
820       <axsl:when test="generate-id() = generate-id($nextsect2)"/>
821       <axsl:when test="generate-id() = generate-id($nextsect1)"/>
822       <axsl:when test="generate-id() = generate-id($nexttoplevel-component)"/>
823       <axsl:when test="@rnd:style = &quot;sect4&quot; or @rnd:style = &quot;sect4-title&quot;">
824         <axsl:variable name="nextsect4" select="following-sibling::dbk:para[@rnd:style = &quot;sect4&quot; or @rnd:style = &quot;sect4-title&quot;][1]"/>
825         <axsl:choose>
826           <axsl:when test="$nextsect4">
827             <axsl:variable name="sect5s" select="$nextsect4/preceding-sibling::dbk:para[@rnd:style = &quot;sect5&quot; or @rnd:style = &quot;sect5-title&quot;]"/>
828 <!-- mode sections 1 -->
829             <sect4 xmlns="http://docbook.org/ns/docbook">
830               <axsl:call-template name="copy"/>
831               <axsl:apply-templates select="following-sibling::*[1]" mode="toplevel-sect5">
832                 <axsl:with-param name="nextsect4" select="$nextsect4"/>
833                 <axsl:with-param name="nextsect3" select="$nextsect3"/>
834                 <axsl:with-param name="nextsect2" select="$nextsect2"/>
835                 <axsl:with-param name="nextsect1" select="$nextsect1"/>
836                 <axsl:with-param name="nexttoplevel-component" select="$nexttoplevel-component"/>
837                 <axsl:with-param name="sect5s" select="$sect5s"/>
838                 <axsl:with-param name="sect4s" select="$sect4s"/>
839                 <axsl:with-param name="sect3s" select="$sect3s"/>
840                 <axsl:with-param name="sect2s" select="$sect2s"/>
841                 <axsl:with-param name="sect1s" select="$sect1s"/>
842               </axsl:apply-templates>
843             </sect4>
844             <axsl:if test="$nextsect4 and (not($sect3s) or count($sect4s|$nextsect4) = count($sect4s))">
845               <axsl:apply-templates select="$nextsect4" mode="toplevel-sect4">
846                 <axsl:with-param name="nextsect3" select="$nextsect3"/>
847                 <axsl:with-param name="nextsect2" select="$nextsect2"/>
848                 <axsl:with-param name="nextsect1" select="$nextsect1"/>
849                 <axsl:with-param name="nexttoplevel-component" select="$nexttoplevel-component"/>
850                 <axsl:with-param name="sect4s" select="$sect4s"/>
851                 <axsl:with-param name="sect3s" select="$sect3s"/>
852                 <axsl:with-param name="sect2s" select="$sect2s"/>
853                 <axsl:with-param name="sect1s" select="$sect1s"/>
854               </axsl:apply-templates>
855             </axsl:if>
856           </axsl:when>
857           <axsl:otherwise>
858             <axsl:variable name="sect5s" select="following-sibling::dbk:para[@rnd:style = &quot;sect5&quot; or @rnd:style = &quot;sect5-title&quot;]"/>
859 <!-- mode sections 2 -->
860             <sect4 xmlns="http://docbook.org/ns/docbook">
861               <axsl:call-template name="copy"/>
862               <axsl:apply-templates select="following-sibling::*[1]" mode="toplevel-sect5">
863                 <axsl:with-param name="nextsect4" select="$nextsect4"/>
864                 <axsl:with-param name="nextsect3" select="$nextsect3"/>
865                 <axsl:with-param name="nextsect2" select="$nextsect2"/>
866                 <axsl:with-param name="nextsect1" select="$nextsect1"/>
867                 <axsl:with-param name="nexttoplevel-component" select="$nexttoplevel-component"/>
868                 <axsl:with-param name="sect5s" select="$sect5s"/>
869                 <axsl:with-param name="sect4s" select="$sect4s"/>
870                 <axsl:with-param name="sect3s" select="$sect3s"/>
871                 <axsl:with-param name="sect2s" select="$sect2s"/>
872                 <axsl:with-param name="sect1s" select="$sect1s"/>
873               </axsl:apply-templates>
874             </sect4>
875             <axsl:if test="$nextsect4 and (not($sect3s) or count($sect4s|$nextsect4) = count($sect4s))">
876               <axsl:apply-templates select="$nextsect4" mode="toplevel-sect4">
877                 <axsl:with-param name="nextsect3" select="$nextsect3"/>
878                 <axsl:with-param name="nextsect2" select="$nextsect2"/>
879                 <axsl:with-param name="nextsect1" select="$nextsect1"/>
880                 <axsl:with-param name="nexttoplevel-component" select="$nexttoplevel-component"/>
881                 <axsl:with-param name="sect4s" select="$sect4s"/>
882                 <axsl:with-param name="sect3s" select="$sect3s"/>
883                 <axsl:with-param name="sect2s" select="$sect2s"/>
884                 <axsl:with-param name="sect1s" select="$sect1s"/>
885               </axsl:apply-templates>
886             </axsl:if>
887           </axsl:otherwise>
888         </axsl:choose>
889       </axsl:when>
890       <axsl:otherwise>
891         <axsl:call-template name="copy"/>
892         <axsl:apply-templates select="following-sibling::*[1]" mode="toplevel-sect4">
893           <axsl:with-param name="nextsect3" select="$nextsect3"/>
894           <axsl:with-param name="nextsect2" select="$nextsect2"/>
895           <axsl:with-param name="nextsect1" select="$nextsect1"/>
896           <axsl:with-param name="nexttoplevel-component" select="$nexttoplevel-component"/>
897           <axsl:with-param name="sect4s" select="$sect4s"/>
898           <axsl:with-param name="sect3s" select="$sect3s"/>
899           <axsl:with-param name="sect2s" select="$sect2s"/>
900           <axsl:with-param name="sect1s" select="$sect1s"/>
901         </axsl:apply-templates>
902       </axsl:otherwise>
903     </axsl:choose>
904   </axsl:template>
905   <axsl:template match="dbk:para" mode="toplevel-sect5">
906     <axsl:param name="nextsect4" select="/.."/>
907     <axsl:param name="nextsect3" select="/.."/>
908     <axsl:param name="nextsect2" select="/.."/>
909     <axsl:param name="nextsect1" select="/.."/>
910     <axsl:param name="nexttoplevel-component" select="/.."/>
911     <axsl:param select="/.." name="sect5s"/>
912     <axsl:param select="/.." name="sect4s"/>
913     <axsl:param select="/.." name="sect3s"/>
914     <axsl:param select="/.." name="sect2s"/>
915     <axsl:param select="/.." name="sect1s"/>
916     <axsl:choose>
917       <axsl:when test="generate-id() = generate-id($nextsect4)"/>
918       <axsl:when test="generate-id() = generate-id($nextsect3)"/>
919       <axsl:when test="generate-id() = generate-id($nextsect2)"/>
920       <axsl:when test="generate-id() = generate-id($nextsect1)"/>
921       <axsl:when test="generate-id() = generate-id($nexttoplevel-component)"/>
922       <axsl:when test="@rnd:style = &quot;sect5&quot; or @rnd:style = &quot;sect5-title&quot;">
923         <axsl:variable name="nextsect5" select="following-sibling::dbk:para[@rnd:style = &quot;sect5&quot; or @rnd:style = &quot;sect5-title&quot;][1]"/>
924 <!-- mode sections 3 -->
925         <sect5 xmlns="http://docbook.org/ns/docbook">
926           <axsl:call-template name="copy"/>
927           <axsl:apply-templates select="following-sibling::*[1]" mode="toplevel-terminal">
928             <axsl:with-param name="nextsect5" select="$nextsect5"/>
929             <axsl:with-param name="nextsect4" select="$nextsect4"/>
930             <axsl:with-param name="nextsect3" select="$nextsect3"/>
931             <axsl:with-param name="nextsect2" select="$nextsect2"/>
932             <axsl:with-param name="nextsect1" select="$nextsect1"/>
933             <axsl:with-param name="nexttoplevel-component" select="$nexttoplevel-component"/>
934             <axsl:with-param name="sect5s" select="$sect5s"/>
935             <axsl:with-param name="sect4s" select="$sect4s"/>
936             <axsl:with-param name="sect3s" select="$sect3s"/>
937             <axsl:with-param name="sect2s" select="$sect2s"/>
938             <axsl:with-param name="sect1s" select="$sect1s"/>
939           </axsl:apply-templates>
940         </sect5>
941         <axsl:if test="$nextsect5 and (not($sect4s) or count($sect5s|$nextsect5) = count($sect5s))">
942           <axsl:apply-templates select="$nextsect5" mode="toplevel-sect5">
943             <axsl:with-param name="nextsect4" select="$nextsect4"/>
944             <axsl:with-param name="nextsect3" select="$nextsect3"/>
945             <axsl:with-param name="nextsect2" select="$nextsect2"/>
946             <axsl:with-param name="nextsect1" select="$nextsect1"/>
947             <axsl:with-param name="nexttoplevel-component" select="$nexttoplevel-component"/>
948             <axsl:with-param name="sect5s" select="$sect5s"/>
949             <axsl:with-param name="sect4s" select="$sect4s"/>
950             <axsl:with-param name="sect3s" select="$sect3s"/>
951             <axsl:with-param name="sect2s" select="$sect2s"/>
952             <axsl:with-param name="sect1s" select="$sect1s"/>
953           </axsl:apply-templates>
954         </axsl:if>
955       </axsl:when>
956       <axsl:otherwise>
957         <axsl:call-template name="copy"/>
958         <axsl:apply-templates select="following-sibling::*[1]" mode="toplevel-sect5">
959           <axsl:with-param name="nextsect4" select="$nextsect4"/>
960           <axsl:with-param name="nextsect3" select="$nextsect3"/>
961           <axsl:with-param name="nextsect2" select="$nextsect2"/>
962           <axsl:with-param name="nextsect1" select="$nextsect1"/>
963           <axsl:with-param name="nexttoplevel-component" select="$nexttoplevel-component"/>
964           <axsl:with-param name="sect5s" select="$sect5s"/>
965           <axsl:with-param name="sect4s" select="$sect4s"/>
966           <axsl:with-param name="sect3s" select="$sect3s"/>
967           <axsl:with-param name="sect2s" select="$sect2s"/>
968           <axsl:with-param name="sect1s" select="$sect1s"/>
969         </axsl:apply-templates>
970       </axsl:otherwise>
971     </axsl:choose>
972   </axsl:template>
973   <axsl:template match="dbk:para" mode="book-terminal">
974     <axsl:param name="nextsect5" select="/.."/>
975     <axsl:param name="nextsect4" select="/.."/>
976     <axsl:param name="nextsect3" select="/.."/>
977     <axsl:param name="nextsect2" select="/.."/>
978     <axsl:param name="nextsect1" select="/.."/>
979     <axsl:param name="nextbook-component" select="/.."/>
980     <axsl:param name="nextbook" select="/.."/>
981     <axsl:param select="/.." name="sect5s"/>
982     <axsl:param select="/.." name="sect4s"/>
983     <axsl:param select="/.." name="sect3s"/>
984     <axsl:param select="/.." name="sect2s"/>
985     <axsl:param select="/.." name="sect1s"/>
986     <axsl:param select="/.." name="book-components"/>
987     <axsl:choose>
988       <axsl:when test="generate-id() = generate-id($nextsect5)"/>
989       <axsl:when test="generate-id() = generate-id($nextsect4)"/>
990       <axsl:when test="generate-id() = generate-id($nextsect3)"/>
991       <axsl:when test="generate-id() = generate-id($nextsect2)"/>
992       <axsl:when test="generate-id() = generate-id($nextsect1)"/>
993       <axsl:when test="generate-id() = generate-id($nextbook-component)"/>
994       <axsl:when test="generate-id() = generate-id($nextbook)"/>
995       <axsl:otherwise>
996         <axsl:call-template name="copy"/>
997         <axsl:apply-templates select="following-sibling::*[1]" mode="book-terminal">
998           <axsl:with-param name="nextsect5" select="$nextsect5"/>
999           <axsl:with-param name="nextsect4" select="$nextsect4"/>
1000           <axsl:with-param name="nextsect3" select="$nextsect3"/>
1001           <axsl:with-param name="nextsect2" select="$nextsect2"/>
1002           <axsl:with-param name="nextsect1" select="$nextsect1"/>
1003           <axsl:with-param name="nextbook-component" select="$nextbook-component"/>
1004           <axsl:with-param name="nextbook" select="$nextbook"/>
1005           <axsl:with-param name="sect5s" select="$sect5s"/>
1006           <axsl:with-param name="sect4s" select="$sect4s"/>
1007           <axsl:with-param name="sect3s" select="$sect3s"/>
1008           <axsl:with-param name="sect2s" select="$sect2s"/>
1009           <axsl:with-param name="sect1s" select="$sect1s"/>
1010           <axsl:with-param name="book-components" select="$book-components"/>
1011         </axsl:apply-templates>
1012       </axsl:otherwise>
1013     </axsl:choose>
1014   </axsl:template>
1015   <axsl:template match="dbk:para" mode="toplevel-terminal">
1016     <axsl:param name="nextsect5" select="/.."/>
1017     <axsl:param name="nextsect4" select="/.."/>
1018     <axsl:param name="nextsect3" select="/.."/>
1019     <axsl:param name="nextsect2" select="/.."/>
1020     <axsl:param name="nextsect1" select="/.."/>
1021     <axsl:param name="nexttoplevel-component" select="/.."/>
1022     <axsl:param select="/.." name="sect5s"/>
1023     <axsl:param select="/.." name="sect4s"/>
1024     <axsl:param select="/.." name="sect3s"/>
1025     <axsl:param select="/.." name="sect2s"/>
1026     <axsl:param select="/.." name="sect1s"/>
1027     <axsl:choose>
1028       <axsl:when test="generate-id() = generate-id($nextsect5)"/>
1029       <axsl:when test="generate-id() = generate-id($nextsect4)"/>
1030       <axsl:when test="generate-id() = generate-id($nextsect3)"/>
1031       <axsl:when test="generate-id() = generate-id($nextsect2)"/>
1032       <axsl:when test="generate-id() = generate-id($nextsect1)"/>
1033       <axsl:when test="generate-id() = generate-id($nexttoplevel-component)"/>
1034       <axsl:otherwise>
1035         <axsl:call-template name="copy"/>
1036         <axsl:apply-templates select="following-sibling::*[1]" mode="toplevel-terminal">
1037           <axsl:with-param name="nextsect5" select="$nextsect5"/>
1038           <axsl:with-param name="nextsect4" select="$nextsect4"/>
1039           <axsl:with-param name="nextsect3" select="$nextsect3"/>
1040           <axsl:with-param name="nextsect2" select="$nextsect2"/>
1041           <axsl:with-param name="nextsect1" select="$nextsect1"/>
1042           <axsl:with-param name="nexttoplevel-component" select="$nexttoplevel-component"/>
1043           <axsl:with-param name="sect5s" select="$sect5s"/>
1044           <axsl:with-param name="sect4s" select="$sect4s"/>
1045           <axsl:with-param name="sect3s" select="$sect3s"/>
1046           <axsl:with-param name="sect2s" select="$sect2s"/>
1047           <axsl:with-param name="sect1s" select="$sect1s"/>
1048         </axsl:apply-templates>
1049       </axsl:otherwise>
1050     </axsl:choose>
1051   </axsl:template>
1052   <axsl:template match="*">
1053     <axsl:call-template name="copy"/>
1054   </axsl:template>
1055   <axsl:template match="*" mode="book">
1056     <axsl:call-template name="copy"/>
1057     <axsl:apply-templates select="following-sibling::*[1]" mode="book"/>
1058   </axsl:template>
1059   <axsl:template match="*" mode="book-component">
1060     <axsl:param name="nextbook" select="/.."/>
1061     <axsl:param select="/.." name="book-components"/>
1062     <axsl:call-template name="copy"/>
1063     <axsl:apply-templates select="following-sibling::*[1]" mode="book-component">
1064       <axsl:with-param name="nextbook" select="$nextbook"/>
1065       <axsl:with-param name="book-components" select="$book-components"/>
1066     </axsl:apply-templates>
1067   </axsl:template>
1068   <axsl:template match="*" mode="book-sect1">
1069     <axsl:param name="nextbook-component" select="/.."/>
1070     <axsl:param name="nextbook" select="/.."/>
1071     <axsl:param select="/.." name="sect1s"/>
1072     <axsl:param select="/.." name="book-components"/>
1073     <axsl:call-template name="copy"/>
1074     <axsl:apply-templates select="following-sibling::*[1]" mode="book-sect1">
1075       <axsl:with-param name="nextbook-component" select="$nextbook-component"/>
1076       <axsl:with-param name="nextbook" select="$nextbook"/>
1077       <axsl:with-param name="sect1s" select="$sect1s"/>
1078       <axsl:with-param name="book-components" select="$book-components"/>
1079     </axsl:apply-templates>
1080   </axsl:template>
1081   <axsl:template match="*" mode="book-sect2">
1082     <axsl:param name="nextsect1" select="/.."/>
1083     <axsl:param name="nextbook-component" select="/.."/>
1084     <axsl:param name="nextbook" select="/.."/>
1085     <axsl:param select="/.." name="sect2s"/>
1086     <axsl:param select="/.." name="sect1s"/>
1087     <axsl:param select="/.." name="book-components"/>
1088     <axsl:call-template name="copy"/>
1089     <axsl:apply-templates select="following-sibling::*[1]" mode="book-sect2">
1090       <axsl:with-param name="nextsect1" select="$nextsect1"/>
1091       <axsl:with-param name="nextbook-component" select="$nextbook-component"/>
1092       <axsl:with-param name="nextbook" select="$nextbook"/>
1093       <axsl:with-param name="sect2s" select="$sect2s"/>
1094       <axsl:with-param name="sect1s" select="$sect1s"/>
1095       <axsl:with-param name="book-components" select="$book-components"/>
1096     </axsl:apply-templates>
1097   </axsl:template>
1098   <axsl:template match="*" mode="book-sect3">
1099     <axsl:param name="nextsect2" select="/.."/>
1100     <axsl:param name="nextsect1" select="/.."/>
1101     <axsl:param name="nextbook-component" select="/.."/>
1102     <axsl:param name="nextbook" select="/.."/>
1103     <axsl:param select="/.." name="sect3s"/>
1104     <axsl:param select="/.." name="sect2s"/>
1105     <axsl:param select="/.." name="sect1s"/>
1106     <axsl:param select="/.." name="book-components"/>
1107     <axsl:call-template name="copy"/>
1108     <axsl:apply-templates select="following-sibling::*[1]" mode="book-sect3">
1109       <axsl:with-param name="nextsect2" select="$nextsect2"/>
1110       <axsl:with-param name="nextsect1" select="$nextsect1"/>
1111       <axsl:with-param name="nextbook-component" select="$nextbook-component"/>
1112       <axsl:with-param name="nextbook" select="$nextbook"/>
1113       <axsl:with-param name="sect3s" select="$sect3s"/>
1114       <axsl:with-param name="sect2s" select="$sect2s"/>
1115       <axsl:with-param name="sect1s" select="$sect1s"/>
1116       <axsl:with-param name="book-components" select="$book-components"/>
1117     </axsl:apply-templates>
1118   </axsl:template>
1119   <axsl:template match="*" mode="book-sect4">
1120     <axsl:param name="nextsect3" select="/.."/>
1121     <axsl:param name="nextsect2" select="/.."/>
1122     <axsl:param name="nextsect1" select="/.."/>
1123     <axsl:param name="nextbook-component" select="/.."/>
1124     <axsl:param name="nextbook" select="/.."/>
1125     <axsl:param select="/.." name="sect4s"/>
1126     <axsl:param select="/.." name="sect3s"/>
1127     <axsl:param select="/.." name="sect2s"/>
1128     <axsl:param select="/.." name="sect1s"/>
1129     <axsl:param select="/.." name="book-components"/>
1130     <axsl:call-template name="copy"/>
1131     <axsl:apply-templates select="following-sibling::*[1]" mode="book-sect4">
1132       <axsl:with-param name="nextsect3" select="$nextsect3"/>
1133       <axsl:with-param name="nextsect2" select="$nextsect2"/>
1134       <axsl:with-param name="nextsect1" select="$nextsect1"/>
1135       <axsl:with-param name="nextbook-component" select="$nextbook-component"/>
1136       <axsl:with-param name="nextbook" select="$nextbook"/>
1137       <axsl:with-param name="sect4s" select="$sect4s"/>
1138       <axsl:with-param name="sect3s" select="$sect3s"/>
1139       <axsl:with-param name="sect2s" select="$sect2s"/>
1140       <axsl:with-param name="sect1s" select="$sect1s"/>
1141       <axsl:with-param name="book-components" select="$book-components"/>
1142     </axsl:apply-templates>
1143   </axsl:template>
1144   <axsl:template match="*" mode="book-sect5">
1145     <axsl:param name="nextsect4" select="/.."/>
1146     <axsl:param name="nextsect3" select="/.."/>
1147     <axsl:param name="nextsect2" select="/.."/>
1148     <axsl:param name="nextsect1" select="/.."/>
1149     <axsl:param name="nextbook-component" select="/.."/>
1150     <axsl:param name="nextbook" select="/.."/>
1151     <axsl:param select="/.." name="sect5s"/>
1152     <axsl:param select="/.." name="sect4s"/>
1153     <axsl:param select="/.." name="sect3s"/>
1154     <axsl:param select="/.." name="sect2s"/>
1155     <axsl:param select="/.." name="sect1s"/>
1156     <axsl:param select="/.." name="book-components"/>
1157     <axsl:call-template name="copy"/>
1158     <axsl:apply-templates select="following-sibling::*[1]" mode="book-sect5">
1159       <axsl:with-param name="nextsect4" select="$nextsect4"/>
1160       <axsl:with-param name="nextsect3" select="$nextsect3"/>
1161       <axsl:with-param name="nextsect2" select="$nextsect2"/>
1162       <axsl:with-param name="nextsect1" select="$nextsect1"/>
1163       <axsl:with-param name="nextbook-component" select="$nextbook-component"/>
1164       <axsl:with-param name="nextbook" select="$nextbook"/>
1165       <axsl:with-param name="sect5s" select="$sect5s"/>
1166       <axsl:with-param name="sect4s" select="$sect4s"/>
1167       <axsl:with-param name="sect3s" select="$sect3s"/>
1168       <axsl:with-param name="sect2s" select="$sect2s"/>
1169       <axsl:with-param name="sect1s" select="$sect1s"/>
1170       <axsl:with-param name="book-components" select="$book-components"/>
1171     </axsl:apply-templates>
1172   </axsl:template>
1173   <axsl:template match="*" mode="toplevel-component">
1174     <axsl:call-template name="copy"/>
1175     <axsl:apply-templates select="following-sibling::*[1]" mode="toplevel-component"/>
1176   </axsl:template>
1177   <axsl:template match="*" mode="toplevel-sect1">
1178     <axsl:param name="nexttoplevel-component" select="/.."/>
1179     <axsl:param select="/.." name="sect1s"/>
1180     <axsl:call-template name="copy"/>
1181     <axsl:apply-templates select="following-sibling::*[1]" mode="toplevel-sect1">
1182       <axsl:with-param name="nexttoplevel-component" select="$nexttoplevel-component"/>
1183       <axsl:with-param name="sect1s" select="$sect1s"/>
1184     </axsl:apply-templates>
1185   </axsl:template>
1186   <axsl:template match="*" mode="toplevel-sect2">
1187     <axsl:param name="nextsect1" select="/.."/>
1188     <axsl:param name="nexttoplevel-component" select="/.."/>
1189     <axsl:param select="/.." name="sect2s"/>
1190     <axsl:param select="/.." name="sect1s"/>
1191     <axsl:call-template name="copy"/>
1192     <axsl:apply-templates select="following-sibling::*[1]" mode="toplevel-sect2">
1193       <axsl:with-param name="nextsect1" select="$nextsect1"/>
1194       <axsl:with-param name="nexttoplevel-component" select="$nexttoplevel-component"/>
1195       <axsl:with-param name="sect2s" select="$sect2s"/>
1196       <axsl:with-param name="sect1s" select="$sect1s"/>
1197     </axsl:apply-templates>
1198   </axsl:template>
1199   <axsl:template match="*" mode="toplevel-sect3">
1200     <axsl:param name="nextsect2" select="/.."/>
1201     <axsl:param name="nextsect1" select="/.."/>
1202     <axsl:param name="nexttoplevel-component" select="/.."/>
1203     <axsl:param select="/.." name="sect3s"/>
1204     <axsl:param select="/.." name="sect2s"/>
1205     <axsl:param select="/.." name="sect1s"/>
1206     <axsl:call-template name="copy"/>
1207     <axsl:apply-templates select="following-sibling::*[1]" mode="toplevel-sect3">
1208       <axsl:with-param name="nextsect2" select="$nextsect2"/>
1209       <axsl:with-param name="nextsect1" select="$nextsect1"/>
1210       <axsl:with-param name="nexttoplevel-component" select="$nexttoplevel-component"/>
1211       <axsl:with-param name="sect3s" select="$sect3s"/>
1212       <axsl:with-param name="sect2s" select="$sect2s"/>
1213       <axsl:with-param name="sect1s" select="$sect1s"/>
1214     </axsl:apply-templates>
1215   </axsl:template>
1216   <axsl:template match="*" mode="toplevel-sect4">
1217     <axsl:param name="nextsect3" select="/.."/>
1218     <axsl:param name="nextsect2" select="/.."/>
1219     <axsl:param name="nextsect1" select="/.."/>
1220     <axsl:param name="nexttoplevel-component" select="/.."/>
1221     <axsl:param select="/.." name="sect4s"/>
1222     <axsl:param select="/.." name="sect3s"/>
1223     <axsl:param select="/.." name="sect2s"/>
1224     <axsl:param select="/.." name="sect1s"/>
1225     <axsl:call-template name="copy"/>
1226     <axsl:apply-templates select="following-sibling::*[1]" mode="toplevel-sect4">
1227       <axsl:with-param name="nextsect3" select="$nextsect3"/>
1228       <axsl:with-param name="nextsect2" select="$nextsect2"/>
1229       <axsl:with-param name="nextsect1" select="$nextsect1"/>
1230       <axsl:with-param name="nexttoplevel-component" select="$nexttoplevel-component"/>
1231       <axsl:with-param name="sect4s" select="$sect4s"/>
1232       <axsl:with-param name="sect3s" select="$sect3s"/>
1233       <axsl:with-param name="sect2s" select="$sect2s"/>
1234       <axsl:with-param name="sect1s" select="$sect1s"/>
1235     </axsl:apply-templates>
1236   </axsl:template>
1237   <axsl:template match="*" mode="toplevel-sect5">
1238     <axsl:param name="nextsect4" select="/.."/>
1239     <axsl:param name="nextsect3" select="/.."/>
1240     <axsl:param name="nextsect2" select="/.."/>
1241     <axsl:param name="nextsect1" select="/.."/>
1242     <axsl:param name="nexttoplevel-component" select="/.."/>
1243     <axsl:param select="/.." name="sect5s"/>
1244     <axsl:param select="/.." name="sect4s"/>
1245     <axsl:param select="/.." name="sect3s"/>
1246     <axsl:param select="/.." name="sect2s"/>
1247     <axsl:param select="/.." name="sect1s"/>
1248     <axsl:call-template name="copy"/>
1249     <axsl:apply-templates select="following-sibling::*[1]" mode="toplevel-sect5">
1250       <axsl:with-param name="nextsect4" select="$nextsect4"/>
1251       <axsl:with-param name="nextsect3" select="$nextsect3"/>
1252       <axsl:with-param name="nextsect2" select="$nextsect2"/>
1253       <axsl:with-param name="nextsect1" select="$nextsect1"/>
1254       <axsl:with-param name="nexttoplevel-component" select="$nexttoplevel-component"/>
1255       <axsl:with-param name="sect5s" select="$sect5s"/>
1256       <axsl:with-param name="sect4s" select="$sect4s"/>
1257       <axsl:with-param name="sect3s" select="$sect3s"/>
1258       <axsl:with-param name="sect2s" select="$sect2s"/>
1259       <axsl:with-param name="sect1s" select="$sect1s"/>
1260     </axsl:apply-templates>
1261   </axsl:template>
1262   <axsl:template name="copy">
1263     <axsl:copy>
1264       <axsl:for-each select="@*">
1265         <axsl:copy/>
1266       </axsl:for-each>
1267       <axsl:apply-templates/>
1268     </axsl:copy>
1269   </axsl:template>
1270 </axsl:stylesheet>