]> git.stg.codes - stg.git/blob - doc/xslt/roundtrip/sections2blocks.xsl
Register smux plugin as .stg24, not as a root
[stg.git] / doc / xslt / roundtrip / sections2blocks.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 makeSubsections.xsl and a     =-->
9 <!--= mapping specification.           =-->
10 <!--=                                  =-->
11 <!--= Revision history:                =-->
12 <!--=  1.1 2007-01-10 SRB              =-->
13 <!--=   Output DocBook 5.0.            =-->
14 <!--=  1.0 2005-11-08 SRB              =-->
15 <!--=   Initial version.               =-->
16 <!--=                                  =-->
17 <!--= $Id: sections2blocks.xsl 8107 2008-08-17 22:39:58Z balls $ =-->
18 <!--=                                  =-->
19 <!--====================================-->
20   <axsl:output indent="yes"/>
21   <axsl:strip-space elements="*"/>
22   <axsl:preserve-space elements="dbk:para dbk:emphasis"/>
23   <axsl:template match="dbk:appendix |&#10;  dbk:article |&#10;  dbk:book |&#10;  dbk:chapter |&#10;  dbk:part |&#10;  dbk:preface |&#10;  dbk:section |&#10;  dbk:sect1 |&#10;  dbk:sect2 |&#10;  dbk:sect3 |&#10;  dbk:sect4 |&#10;  dbk:sect5">
24     <axsl:variable name="subsections" select="dbk:para[@rnd:style = &quot;bibliography&quot; or @rnd:style = &quot;bibliography-title&quot; or @rnd:style = &quot;glossary&quot; or @rnd:style = &quot;glossary-title&quot; or @rnd:style = &quot;qandaset&quot; or @rnd:style = &quot;qandaset-title&quot;]"/>
25     <axsl:copy>
26       <axsl:apply-templates select="@*"/>
27       <axsl:choose>
28         <axsl:when test="$subsections">
29           <axsl:apply-templates select="$subsections[1]/preceding-sibling::node()"/>
30           <axsl:apply-templates select="$subsections[1]" mode="subsections">
31             <axsl:with-param name="subsections" select="$subsections[position() != 1]"/>
32           </axsl:apply-templates>
33         </axsl:when>
34         <axsl:when test="dbk:appendix |&#10;  dbk:article |&#10;  dbk:book |&#10;  dbk:chapter |&#10;  dbk:part |&#10;  dbk:preface |&#10;  dbk:section |&#10;  dbk:sect1 |&#10;  dbk:sect2 |&#10;  dbk:sect3 |&#10;  dbk:sect4 |&#10;  dbk:sect5">
35           <axsl:apply-templates select="*[self::dbk:appendix |&#10;  self::dbk:article |&#10;  self::dbk:book |&#10;  self::dbk:chapter |&#10;  self::dbk:part |&#10;  self::dbk:preface |&#10;  self::dbk:section |&#10;  self::dbk:sect1 |&#10;  self::dbk:sect2 |&#10;  self::dbk:sect3 |&#10;  self::dbk:sect4 |&#10;  self::dbk:sect5][1]/preceding-sibling::node()"/>
36           <axsl:apply-templates select="dbk:appendix |&#10;  dbk:article |&#10;  dbk:book |&#10;  dbk:chapter |&#10;  dbk:part |&#10;  dbk:preface |&#10;  dbk:section |&#10;  dbk:sect1 |&#10;  dbk:sect2 |&#10;  dbk:sect3 |&#10;  dbk:sect4 |&#10;  dbk:sect5"/>
37         </axsl:when>
38         <axsl:otherwise>
39           <axsl:apply-templates/>
40         </axsl:otherwise>
41       </axsl:choose>
42     </axsl:copy>
43     <axsl:choose>
44       <axsl:when test="following-sibling::*[self::dbk:appendix |&#10;  self::dbk:article |&#10;  self::dbk:book |&#10;  self::dbk:chapter |&#10;  self::dbk:part |&#10;  self::dbk:preface |&#10;  self::dbk:section |&#10;  self::dbk:sect1 |&#10;  self::dbk:sect2 |&#10;  self::dbk:sect3 |&#10;  self::dbk:sect4 |&#10;  self::dbk:sect5] | following-sibling::dbk:para[@rnd:style = &quot;bibliography&quot; or @rnd:style = &quot;bibliography-title&quot; or @rnd:style = &quot;glossary&quot; or @rnd:style = &quot;glossary-title&quot; or @rnd:style = &quot;qandaset&quot; or @rnd:style = &quot;qandaset-title&quot;]">
45         <axsl:variable name="nextComponent" select="following-sibling::*[self::dbk:appendix |&#10;  self::dbk:article |&#10;  self::dbk:book |&#10;  self::dbk:chapter |&#10;  self::dbk:part |&#10;  self::dbk:preface |&#10;  self::dbk:section |&#10;  self::dbk:sect1 |&#10;  self::dbk:sect2 |&#10;  self::dbk:sect3 |&#10;  self::dbk:sect4 |&#10;  self::dbk:sect5|self::dbk:para[@rnd:style = &quot;bibliography&quot; or @rnd:style = &quot;bibliography-title&quot; or @rnd:style = &quot;glossary&quot; or @rnd:style = &quot;glossary-title&quot; or @rnd:style = &quot;qandaset&quot; or @rnd:style = &quot;qandaset-title&quot;]][1]"/>
46         <axsl:apply-templates select="following-sibling::*[generate-id(following-sibling::*[self::dbk:appendix |&#10;  self::dbk:article |&#10;  self::dbk:book |&#10;  self::dbk:chapter |&#10;  self::dbk:part |&#10;  self::dbk:preface |&#10;  self::dbk:section |&#10;  self::dbk:sect1 |&#10;  self::dbk:sect2 |&#10;  self::dbk:sect3 |&#10;  self::dbk:sect4 |&#10;  self::dbk:sect5|self::dbk:para[@rnd:style = &quot;bibliography&quot; or @rnd:style = &quot;bibliography-title&quot; or @rnd:style = &quot;glossary&quot; or @rnd:style = &quot;glossary-title&quot; or @rnd:style = &quot;qandaset&quot; or @rnd:style = &quot;qandaset-title&quot;]][1]) = generate-id($nextComponent)]"/>
47       </axsl:when>
48       <axsl:otherwise>
49         <axsl:apply-templates select="following-sibling::*"/>
50       </axsl:otherwise>
51     </axsl:choose>
52   </axsl:template>
53   <axsl:template match="dbk:para" mode="subsections">
54     <axsl:param name="subsections" select="/.."/>
55     <axsl:choose>
56       <axsl:when test="@rnd:style = &quot;bibliography&quot; or @rnd:style = &quot;bibliography-title&quot;">
57         <bibliography xmlns="http://docbook.org/ns/docbook">
58           <axsl:call-template name="copy"/>
59           <axsl:variable name="bibliodivs" select="following-sibling::dbk:para[@rnd:style = &quot;bibliodiv&quot; or @rnd:style = &quot;bibliodiv-title&quot;]"/>
60           <axsl:choose>
61             <axsl:when test="$bibliodivs">
62               <axsl:apply-templates select="following-sibling::*[1]" mode="bibliodivs">
63                 <axsl:with-param name="nextSubsection" select="$subsections[1]"/>
64                 <axsl:with-param name="bibliodivs" select="$bibliodivs[position() != 1]"/>
65               </axsl:apply-templates>
66             </axsl:when>
67             <axsl:otherwise>
68               <axsl:apply-templates select="following-sibling::*[1]" mode="terminal">
69                 <axsl:with-param name="nextSubsection" select="$subsections[1]"/>
70               </axsl:apply-templates>
71             </axsl:otherwise>
72           </axsl:choose>
73         </bibliography>
74       </axsl:when>
75       <axsl:when test="@rnd:style = &quot;glossary&quot; or @rnd:style = &quot;glossary-title&quot;">
76         <glossary xmlns="http://docbook.org/ns/docbook">
77           <axsl:call-template name="copy"/>
78           <axsl:variable name="glossdivs" select="following-sibling::dbk:para[@rnd:style = &quot;glossdiv&quot; or @rnd:style = &quot;glossdiv-title&quot;]"/>
79           <axsl:choose>
80             <axsl:when test="$glossdivs">
81               <axsl:apply-templates select="following-sibling::*[1]" mode="glossdivs">
82                 <axsl:with-param name="nextSubsection" select="$subsections[1]"/>
83                 <axsl:with-param name="glossdivs" select="$glossdivs[position() != 1]"/>
84               </axsl:apply-templates>
85             </axsl:when>
86             <axsl:otherwise>
87               <axsl:apply-templates select="following-sibling::*[1]" mode="terminal">
88                 <axsl:with-param name="nextSubsection" select="$subsections[1]"/>
89               </axsl:apply-templates>
90             </axsl:otherwise>
91           </axsl:choose>
92         </glossary>
93       </axsl:when>
94       <axsl:when test="@rnd:style = &quot;qandaset&quot; or @rnd:style = &quot;qandaset-title&quot;">
95         <qandaset xmlns="http://docbook.org/ns/docbook">
96           <axsl:call-template name="copy"/>
97           <axsl:variable name="qandadivs" select="following-sibling::dbk:para[@rnd:style = &quot;qandadiv&quot; or @rnd:style = &quot;qandadiv-title&quot;]"/>
98           <axsl:choose>
99             <axsl:when test="$qandadivs">
100               <axsl:apply-templates select="following-sibling::*[1]" mode="qandadivs">
101                 <axsl:with-param name="nextSubsection" select="$subsections[1]"/>
102                 <axsl:with-param name="qandadivs" select="$qandadivs[position() != 1]"/>
103               </axsl:apply-templates>
104             </axsl:when>
105             <axsl:otherwise>
106               <axsl:apply-templates select="following-sibling::*[1]" mode="terminal">
107                 <axsl:with-param name="nextSubsection" select="$subsections[1]"/>
108               </axsl:apply-templates>
109             </axsl:otherwise>
110           </axsl:choose>
111         </qandaset>
112       </axsl:when>
113     </axsl:choose>
114   </axsl:template>
115   <axsl:template match="*" mode="subsections">
116     <axsl:param name="subsections" select="/.."/>
117     <axsl:copy>
118       <axsl:apply-templates select="@*"/>
119       <axsl:apply-templates mode="subsections"/>
120     </axsl:copy>
121   </axsl:template>
122   <axsl:template match="dbk:para" mode="bibliodivs">
123     <axsl:param name="nextSubsection" select="/.."/>
124     <axsl:param name="bibliodivs" select="/.."/>
125     <axsl:choose>
126       <axsl:when test="generate-id() = generate-id($nextSubsection)"/>
127       <axsl:when test="@rnd:style = &quot;bibliodiv&quot; or @rnd:style = &quot;bibliodiv-title&quot;">
128         <bibliodiv xmlns="http://docbook.org/ns/docbook">
129           <axsl:call-template name="copy"/>
130           <axsl:apply-templates select="following-sibling::*[1]" mode="terminal">
131             <axsl:with-param name="nextSubsection" select="$nextSubsection"/>
132             <axsl:with-param name="nextbibliodiv" select="$bibliodivs[1]"/>
133           </axsl:apply-templates>
134         </bibliodiv>
135         <axsl:choose>
136           <axsl:when test="$nextSubsection and         $bibliodivs and         count($nextSubsection/preceding-sibling::* | $bibliodivs[1]) = count($nextSubsection/preceding-sibling::*)">
137             <axsl:apply-templates select="$bibliodivs[1]" mode="bibliodivs">
138               <axsl:with-param name="nextSubsection" select="$nextSubsection"/>
139               <axsl:with-param name="bibliodivs" select="$bibliodivs[position() != 1]"/>
140             </axsl:apply-templates>
141           </axsl:when>
142           <axsl:when test="$bibliodivs">
143             <axsl:apply-templates select="$bibliodivs[1]" mode="bibliodivs">
144               <axsl:with-param name="bibliodivs" select="$bibliodivs[position() != 1]"/>
145             </axsl:apply-templates>
146           </axsl:when>
147         </axsl:choose>
148       </axsl:when>
149       <axsl:otherwise>
150         <axsl:call-template name="copy"/>
151         <axsl:apply-templates select="following-sibling::*[1]" mode="bibliodivs">
152           <axsl:with-param name="nextSubsection" select="$nextSubsection"/>
153         </axsl:apply-templates>
154       </axsl:otherwise>
155     </axsl:choose>
156   </axsl:template>
157   <axsl:template match="dbk:para" mode="glossdivs">
158     <axsl:param name="nextSubsection" select="/.."/>
159     <axsl:param name="glossdivs" select="/.."/>
160     <axsl:choose>
161       <axsl:when test="generate-id() = generate-id($nextSubsection)"/>
162       <axsl:when test="@rnd:style = &quot;glossdiv&quot; or @rnd:style = &quot;glossdiv-title&quot;">
163         <glossdiv xmlns="http://docbook.org/ns/docbook">
164           <axsl:call-template name="copy"/>
165           <axsl:apply-templates select="following-sibling::*[1]" mode="terminal">
166             <axsl:with-param name="nextSubsection" select="$nextSubsection"/>
167             <axsl:with-param name="nextglossdiv" select="$glossdivs[1]"/>
168           </axsl:apply-templates>
169         </glossdiv>
170         <axsl:choose>
171           <axsl:when test="$nextSubsection and         $glossdivs and         count($nextSubsection/preceding-sibling::* | $glossdivs[1]) = count($nextSubsection/preceding-sibling::*)">
172             <axsl:apply-templates select="$glossdivs[1]" mode="glossdivs">
173               <axsl:with-param name="nextSubsection" select="$nextSubsection"/>
174               <axsl:with-param name="glossdivs" select="$glossdivs[position() != 1]"/>
175             </axsl:apply-templates>
176           </axsl:when>
177           <axsl:when test="$glossdivs">
178             <axsl:apply-templates select="$glossdivs[1]" mode="glossdivs">
179               <axsl:with-param name="glossdivs" select="$glossdivs[position() != 1]"/>
180             </axsl:apply-templates>
181           </axsl:when>
182         </axsl:choose>
183       </axsl:when>
184       <axsl:otherwise>
185         <axsl:call-template name="copy"/>
186         <axsl:apply-templates select="following-sibling::*[1]" mode="glossdivs">
187           <axsl:with-param name="nextSubsection" select="$nextSubsection"/>
188         </axsl:apply-templates>
189       </axsl:otherwise>
190     </axsl:choose>
191   </axsl:template>
192   <axsl:template match="dbk:para" mode="qandadivs">
193     <axsl:param name="nextSubsection" select="/.."/>
194     <axsl:param name="qandadivs" select="/.."/>
195     <axsl:choose>
196       <axsl:when test="generate-id() = generate-id($nextSubsection)"/>
197       <axsl:when test="@rnd:style = &quot;qandadiv&quot; or @rnd:style = &quot;qandadiv-title&quot;">
198         <qandadiv xmlns="http://docbook.org/ns/docbook">
199           <axsl:call-template name="copy"/>
200           <axsl:apply-templates select="following-sibling::*[1]" mode="terminal">
201             <axsl:with-param name="nextSubsection" select="$nextSubsection"/>
202             <axsl:with-param name="nextqandadiv" select="$qandadivs[1]"/>
203           </axsl:apply-templates>
204         </qandadiv>
205         <axsl:choose>
206           <axsl:when test="$nextSubsection and         $qandadivs and         count($nextSubsection/preceding-sibling::* | $qandadivs[1]) = count($nextSubsection/preceding-sibling::*)">
207             <axsl:apply-templates select="$qandadivs[1]" mode="qandadivs">
208               <axsl:with-param name="nextSubsection" select="$nextSubsection"/>
209               <axsl:with-param name="qandadivs" select="$qandadivs[position() != 1]"/>
210             </axsl:apply-templates>
211           </axsl:when>
212           <axsl:when test="$qandadivs">
213             <axsl:apply-templates select="$qandadivs[1]" mode="qandadivs">
214               <axsl:with-param name="qandadivs" select="$qandadivs[position() != 1]"/>
215             </axsl:apply-templates>
216           </axsl:when>
217         </axsl:choose>
218       </axsl:when>
219       <axsl:otherwise>
220         <axsl:call-template name="copy"/>
221         <axsl:apply-templates select="following-sibling::*[1]" mode="qandadivs">
222           <axsl:with-param name="nextSubsection" select="$nextSubsection"/>
223         </axsl:apply-templates>
224       </axsl:otherwise>
225     </axsl:choose>
226   </axsl:template>
227   <axsl:template match="*" mode="terminal">
228     <axsl:param name="nextSubsection" select="/.."/>
229     <axsl:param name="nextbibliodiv" select="/.."/>
230     <axsl:param name="nextglossdiv" select="/.."/>
231     <axsl:param name="nextqandadiv" select="/.."/>
232     <axsl:choose>
233       <axsl:when test="generate-id() = generate-id($nextSubsection)"/>
234       <axsl:when test="generate-id() = generate-id($nextbibliodiv)"/>
235       <axsl:when test="generate-id() = generate-id($nextglossdiv)"/>
236       <axsl:when test="generate-id() = generate-id($nextqandadiv)"/>
237       <axsl:otherwise>
238         <axsl:call-template name="copy"/>
239         <axsl:apply-templates select="following-sibling::*[1]" mode="terminal">
240           <axsl:with-param name="nextSubsection" select="$nextSubsection"/>
241           <axsl:with-param name="nextbibliodiv" select="$nextbibliodiv"/>
242           <axsl:with-param name="nextglossdiv" select="$nextglossdiv"/>
243           <axsl:with-param name="nextqandadiv" select="$nextqandadiv"/>
244         </axsl:apply-templates>
245       </axsl:otherwise>
246     </axsl:choose>
247   </axsl:template>
248   <axsl:template match="*">
249     <axsl:copy>
250       <axsl:apply-templates select="@*"/>
251       <axsl:apply-templates/>
252     </axsl:copy>
253   </axsl:template>
254   <axsl:template name="copy">
255     <axsl:copy>
256       <axsl:apply-templates select="@*"/>
257       <axsl:apply-templates/>
258     </axsl:copy>
259   </axsl:template>
260   <axsl:template match="@*">
261     <axsl:copy/>
262   </axsl:template>
263 </axsl:stylesheet>