]> git.stg.codes - stg.git/blob - doc/xslt/roundtrip/dbk2wp.xsl
Fixed receiving partial streams.
[stg.git] / doc / xslt / roundtrip / dbk2wp.xsl
1 <xsl:stylesheet version="1.0"
2   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3   xmlns:doc='http://docbook.org/ns/docbook'
4   exclude-result-prefixes='doc'>
5
6   <!-- ********************************************************************
7        $Id: dbk2wp.xsl 8047 2008-06-10 12:46:53Z balls $
8        ********************************************************************
9
10        This file is part of the XSL DocBook Stylesheet distribution.
11        See ../README or http://docbook.sf.net/release/xsl/current/ for
12        copyright and other information.
13
14        ******************************************************************** -->
15
16   <!-- DO NOT USE THIS STYLESHEET!
17
18        This stylesheet is imported by the other dbk2* stylesheets.
19        Use one of those instead.
20
21     -->
22
23   <xsl:include href='../VERSION'/>
24
25   <!-- doc:docprop.author mode is for creating document metadata -->
26
27   <xsl:template match='author|doc:author|editor|doc:editor' mode='doc:docprop.author'>
28     <xsl:apply-templates select='firstname|doc:firstname |
29                                  personname/firstname|doc:personname/doc:firstname'
30       mode='doc:docprop.author'/>
31     <xsl:text> </xsl:text>
32     <xsl:apply-templates select='surname|doc:surname |
33                                  personname/surname|doc:personname/doc:surname'
34       mode='doc:docprop.author'/>
35   </xsl:template>
36
37   <xsl:template match='firstname|doc:firstname |
38                        surname|doc:surname'
39     mode='doc:docprop.author'>
40     <xsl:apply-templates select='.' mode='doc:body'/>
41   </xsl:template>
42
43   <!-- doc:toplevel mode is for processing whole documents -->
44
45   <xsl:template match='*' mode='doc:toplevel'>
46     <xsl:call-template name='doc:make-body'/>
47   </xsl:template>
48
49   <!-- doc:body mode is for processing components of a document -->
50
51   <xsl:template match='book|article|chapter|section|sect1|sect2|sect3|sect4|sect5|simplesect |
52                        doc:book|doc:article|doc:chapter|doc:section|doc:sect1|doc:sect2|doc:sect3|doc:sect4|doc:sect5|doc:simplesect'
53     mode='doc:body'>
54     <xsl:call-template name='doc:make-subsection'/>
55   </xsl:template>
56
57   <xsl:template match='articleinfo |
58                        chapterinfo |
59                        bookinfo |
60                        doc:info |
61                        doc:articleinfo |
62                        doc:chapterinfo |
63                        doc:bookinfo'
64     mode='doc:body'>
65     <xsl:apply-templates select='title|subtitle|titleabbrev |
66                                  doc:title|doc:subtitle|doc:titleabbrev'
67       mode='doc:body'/>
68     <xsl:apply-templates select='author|releaseinfo|abstract |
69                                  doc:author|doc:releaseinfo|doc:abstract'
70       mode='doc:body'/>
71     <!-- current implementation ignores all other metadata -->
72     <xsl:for-each select='*[not(self::title|self::subtitle|self::titleabbrev|self::author|self::releaseinfo|self::abstract |
73                           self::doc:title|self::doc:subtitle|self::doc:titleabbrev|self::doc:author|self::doc:releaseinfo|self::doc:abstract)]'>
74       <xsl:call-template name='doc:nomatch'/>
75     </xsl:for-each>
76   </xsl:template>
77
78   <xsl:template match='title|subtitle|titleabbrev |
79                        doc:title|doc:subtitle|doc:titleabbrev'
80     mode='doc:body'>
81     <xsl:call-template name='doc:make-paragraph'>
82       <xsl:with-param name='style'>
83         <xsl:choose>
84           <xsl:when test='(parent::section|parent::doc:section or
85                           parent::sectioninfo/parent::section|parent::doc:sectioninfo/parent::doc:section) and
86                           count(ancestor::section|ancestor::doc:section) > 5'>
87             <xsl:call-template name='doc:warning'>
88               <xsl:with-param name='message'>section nested deeper than 5 levels</xsl:with-param>
89             </xsl:call-template>
90             <xsl:text>sect5-</xsl:text>
91             <xsl:value-of select='local-name()'/>
92           </xsl:when>
93           <xsl:when test='parent::section|parent::doc:section or
94                           parent::sectioninfo/parent::section|parent::doc:sectioninfo/parent::doc:section'>
95             <xsl:text>sect</xsl:text>
96             <xsl:value-of select='count(ancestor::section|ancestor::doc:section)'/>
97             <xsl:text>-</xsl:text>
98             <xsl:value-of select='local-name()'/>
99           </xsl:when>
100           <xsl:when test='contains(local-name(..), "info")'>
101             <xsl:value-of select='local-name(../..)'/>
102             <xsl:text>-</xsl:text>
103             <xsl:value-of select='local-name()'/>
104           </xsl:when>
105           <xsl:otherwise>
106             <xsl:value-of select='local-name(..)'/>
107             <xsl:text>-</xsl:text>
108             <xsl:value-of select='local-name()'/>
109           </xsl:otherwise>
110         </xsl:choose>
111       </xsl:with-param>
112       <xsl:with-param name='outline.level'
113                       select='count(ancestor::*) - count(parent::*[contains(local-name(), "info")]) - 1'/>
114       <xsl:with-param name='attributes.node'
115                       select='../parent::*[contains(local-name(current()), "info")] |
116                               parent::*[not(contains(local-name(current()), "info"))]'/>
117       <xsl:with-param name='content'>
118         <xsl:apply-templates mode='doc:body'/>
119       </xsl:with-param>
120     </xsl:call-template>
121   </xsl:template>
122
123   <doc:template name='metadata' xmlns=''>
124     <title>Metadata</title>
125
126     <para>TODO: Handle all metadata elements, apart from titles.</para>
127   </doc:template>
128   <xsl:template match='*[contains(local-name(), "info")]/*[not(self::title|self::subtitle|self::titleabbrev|self::doc:title|self::doc:subtitle|self::doc:titleabbrev)]'
129                 priority='0'
130                 mode='doc:body'/>
131
132   <xsl:template match='author|editor|othercredit |
133                        doc:author|doc:editor|doc:othercredit'
134     mode='doc:body'>
135     <xsl:call-template name='doc:make-paragraph'>
136       <xsl:with-param name='style'
137                       select='local-name()'/>
138       <xsl:with-param name='content'>
139         <xsl:apply-templates select='personname|surname|firstname|honorific|lineage|othername|contrib |
140                                      doc:personname|doc:surname|doc:firstname|doc:honorific|doc:lineage|doc:othername|doc:contrib'
141                              mode='doc:body'/>
142       </xsl:with-param>
143     </xsl:call-template>
144
145     <xsl:apply-templates select='affiliation|address |
146                                  doc:affiliation|doc:address'
147       mode='doc:body'/>
148     <xsl:apply-templates select='authorblurb|personblurb |
149                                  doc:authorblurb|doc:personblurb'
150       mode='doc:body'/>
151   </xsl:template>
152   <xsl:template match='affiliation|doc:affiliation'
153     mode='doc:body'>
154     <xsl:call-template name='doc:make-paragraph'>
155       <xsl:with-param name='style' select='"affiliation"'/>
156       <xsl:with-param name='content'>
157         <xsl:apply-templates mode='doc:body'/>
158       </xsl:with-param>
159     </xsl:call-template>
160   </xsl:template>
161   <xsl:template match='address[parent::author|parent::editor|parent::othercredit] |
162                        doc:address[parent::doc:author|parent::doc:editor|parent::doc:othercredit]'
163                 mode='doc:body'>
164     <xsl:call-template name='doc:make-paragraph'>
165       <xsl:with-param name='style' select='"address"'/>
166       <xsl:with-param name='content'>
167         <xsl:apply-templates mode='doc:body'/>
168       </xsl:with-param>
169     </xsl:call-template>
170   </xsl:template>
171   <!-- do not attempt to handle recursive structures -->
172   <xsl:template match='address[not(parent::author|parent::editor|parent::othercredit)] |
173                        doc:address[not(parent::doc:author|parent::doc:editor|parent::doc:othercredit)]'
174     mode='doc:body'>
175     <xsl:apply-templates select='node()[not(self::affiliation|self::authorblurb|self::doc:affiliation|self::doc:authorblurb)]'/>
176   </xsl:template>
177   <xsl:template match='abstract|doc:abstract'
178     mode='doc:body'>
179     <xsl:if test='title|doc:title'>
180       <xsl:call-template name='doc:make-paragraph'>
181         <xsl:with-param name='style' select='"abstract-title"'/>
182         <xsl:with-param name='content'>
183           <xsl:apply-templates select='title/node()|doc:title/node()'
184             mode='doc:body'/>
185         </xsl:with-param>
186       </xsl:call-template>
187     </xsl:if>
188
189     <xsl:apply-templates select='*[not(self::title|self::doc:title)]'
190       mode='doc:body'>
191       <xsl:with-param name='class'>abstract</xsl:with-param>
192     </xsl:apply-templates>
193   </xsl:template>
194   <!-- TODO -->
195   <xsl:template match='authorblurb|personblurb |
196                        doc:authorblurb|doc:personblurb'
197     mode='doc:body'/>
198
199   <!-- TODO: handle inline markup (eg. emphasis) -->
200   <xsl:template match='surname|firstname|honorific|lineage|othername|contrib|email|shortaffil|jobtitle|orgname|orgdiv|street|pob|postcode|city|state|country|phone|fax|citetitle |
201                        doc:surname|doc:firstname|doc:honorific|doc:lineage|doc:othername|doc:contrib|doc:email|doc:shortaffil|doc:jobtitle|doc:orgname|doc:orgdiv|doc:street|doc:pob|doc:postcode|doc:city|doc:state|doc:country|doc:phone|doc:fax|doc:citetitle'
202     mode='doc:body'>
203     <xsl:if test='preceding-sibling::*'>
204       <xsl:call-template name='doc:make-phrase'>
205         <xsl:with-param name='content'>
206           <xsl:text> </xsl:text>
207         </xsl:with-param>
208       </xsl:call-template>
209     </xsl:if>
210     <xsl:call-template name='doc:handle-linebreaks'>
211       <xsl:with-param name='style' select='local-name()'/>
212       <xsl:with-param name='content' select='node()'/>
213     </xsl:call-template>
214   </xsl:template>
215   <xsl:template match='email|doc:email'
216     mode='doc:body'>
217     <xsl:variable name='address'>
218       <xsl:choose>
219         <xsl:when test='starts-with(., "mailto:")'>
220           <xsl:value-of select='.'/>
221         </xsl:when>
222         <xsl:otherwise>
223           <xsl:text>mailto:</xsl:text>
224           <xsl:value-of select='.'/>
225         </xsl:otherwise>
226       </xsl:choose>
227     </xsl:variable>
228     <xsl:call-template name='doc:make-hyperlink'>
229       <xsl:with-param name='target' select='$address'/>
230       <xsl:with-param name='content'>
231         <xsl:call-template name='doc:handle-linebreaks'>
232           <xsl:with-param name='style'>Hyperlink</xsl:with-param>
233         </xsl:call-template>
234       </xsl:with-param>
235     </xsl:call-template>
236   </xsl:template>
237   <!-- otheraddr often contains ulink -->
238   <xsl:template match='otheraddr|doc:otheraddr'
239     mode='doc:body'>
240     <xsl:choose>
241       <xsl:when test='ulink|doc:ulink'>
242         <xsl:for-each select='ulink|doc:ulink'>
243           <xsl:variable name='prev'
244             select='preceding-sibling::ulink[1] |
245                     preceding-sibling::doc:ulink[1]'/>
246           <xsl:choose>
247             <xsl:when test='$prev'>
248               <xsl:for-each
249                 select='preceding-sibling::node()[generate-id(following-sibling::*[self::ulink|self::doc:ulink][1]) = generate-id(current())]'>
250                 <xsl:call-template name='doc:handle-linebreaks'>
251                   <xsl:with-param name='style'>otheraddr</xsl:with-param>
252                 </xsl:call-template>
253               </xsl:for-each>
254             </xsl:when>
255             <xsl:when test='preceding-sibling::node()'>
256               <xsl:call-template name='doc:handle-linebreaks'>
257                 <xsl:with-param name='style'>otheraddr</xsl:with-param>
258               </xsl:call-template>
259             </xsl:when>
260           </xsl:choose>
261           <xsl:apply-templates select='.'/>
262         </xsl:for-each>
263         <xsl:if test='*[self::ulink|self::doc:ulink][last()]/following-sibling::node()'>
264           <xsl:call-template name='doc:handle-linebreaks'>
265             <xsl:with-param name='content'
266               select='*[self::ulink|self::doc:ulink][last()]/following-sibling::node()'/>
267             <xsl:with-param name='style'>otheraddr</xsl:with-param>
268           </xsl:call-template>
269         </xsl:if>
270       </xsl:when>
271       <xsl:otherwise>
272         <xsl:call-template name='doc:handle-linebreaks'>
273           <xsl:with-param name='style'>otheraddr</xsl:with-param>
274         </xsl:call-template>
275       </xsl:otherwise>
276     </xsl:choose>
277   </xsl:template>
278   <xsl:template match='ulink|doc:ulink'
279     mode='doc:body'>
280     <xsl:call-template name='doc:make-hyperlink'>
281       <xsl:with-param name='target' select='@url'/>
282       <xsl:with-param name='content'>
283         <xsl:call-template name='doc:handle-linebreaks'>
284           <xsl:with-param name='style'>Hyperlink</xsl:with-param>
285         </xsl:call-template>
286       </xsl:with-param>
287     </xsl:call-template>
288   </xsl:template>
289
290   <!-- Cannot round-trip this element -->
291   <xsl:template match='personname|doc:personname'
292     mode='doc:body'>
293     <xsl:apply-templates mode='doc:body'/>
294   </xsl:template>
295
296   <xsl:template match='releaseinfo|doc:releaseinfo'
297     mode='doc:body'>
298     <xsl:call-template name='doc:make-paragraph'>
299       <xsl:with-param name='style'
300         select='"releaseinfo"'/>
301     </xsl:call-template>
302   </xsl:template>
303
304   <xsl:template match='para|doc:para'
305     mode='doc:body'>
306     <xsl:param name='class'/>
307
308     <xsl:variable name='block'
309       select='blockquote|calloutlist|classsynopsis|funcsynopsis|figure|glosslist|graphic|informalfigure|informaltable|itemizedlist|literallayout|mediaobject|mediaobjectco|note|caution|warning|important|tip|orderedlist|programlisting|revhistory|segmentedlist|simplelist|table|variablelist |
310               doc:blockquote|doc:calloutlist|doc:classsynopsis|doc:funcsynopsis|doc:figure|doc:glosslist|doc:graphic|doc:informalfigure|doc:informaltable|doc:itemizedlist|doc:literallayout|doc:mediaobject|doc:mediaobjectco|doc:note|doc:caution|doc:warning|doc:important|doc:tip|doc:orderedlist|doc:programlisting|doc:revhistory|doc:segmentedlist|doc:simplelist|doc:table|doc:variablelist'/>
311
312     <xsl:choose>
313       <xsl:when test='$block'>
314         <xsl:call-template name='doc:make-paragraph'>
315           <xsl:with-param name='style'>
316             <xsl:choose>
317               <xsl:when test='$class != ""'>
318                 <xsl:value-of select='$class'/>
319               </xsl:when>
320               <xsl:otherwise>para</xsl:otherwise>
321             </xsl:choose>
322           </xsl:with-param>
323           <xsl:with-param name='content'
324                           select='$block[1]/preceding-sibling::node()'/>
325         </xsl:call-template>
326
327         <xsl:for-each select='$block'>
328           <xsl:apply-templates select='.'/>
329
330           <xsl:call-template name='doc:make-paragraph'>
331             <xsl:with-param name='style'>
332               <xsl:choose>
333                 <xsl:when test='$class != ""'>
334                   <xsl:value-of select='$class'/>
335                 </xsl:when>
336                 <xsl:otherwise>Normal</xsl:otherwise>
337               </xsl:choose>
338             </xsl:with-param>
339             <xsl:with-param name='content'
340                             select='following-sibling::node()[generate-id(preceding-sibling::*[self::blockquote|self::calloutlist|self::figure|self::glosslist|self::graphic|self::informalfigure|self::informaltable|self::itemizedlist|self::literallayout|self::mediaobject|self::mediaobjectco|self::note|self::caution|self::warning|self::important|self::tip|self::orderedlist|self::programlisting|self::revhistory|self::segmentedlist|self::simplelist|self::table|self::variablelist | self::doc:blockquote|self::doc:calloutlist|self::doc:figure|self::doc:glosslist|self::doc:graphic|self::doc:informalfigure|self::doc:informaltable|self::doc:itemizedlist|self::doc:literallayout|self::doc:mediaobject|self::doc:mediaobjectco|self::doc:note|self::doc:caution|self::doc:warning|self::doc:important|self::doc:tip|self::doc:orderedlist|self::doc:programlisting|self::doc:revhistory|self::doc:segmentedlist|self::doc:simplelist|self::doc:table|self::doc:variablelist][1]) = generate-id(current())]'/>
341           </xsl:call-template>
342         </xsl:for-each>
343       </xsl:when>
344       <xsl:otherwise>
345         <xsl:call-template name='doc:make-paragraph'>
346           <xsl:with-param name='style'>
347             <xsl:choose>
348               <xsl:when test='$class != ""'>
349                 <xsl:value-of select='$class'/>
350               </xsl:when>
351               <xsl:otherwise>Normal</xsl:otherwise>
352             </xsl:choose>
353           </xsl:with-param>
354         </xsl:call-template>
355       </xsl:otherwise>
356     </xsl:choose>
357   </xsl:template>
358   <xsl:template match='simpara|doc:simpara'
359     mode='doc:body'>
360     <xsl:param name='class'/>
361
362     <xsl:call-template name='doc:make-paragraph'>
363       <xsl:with-param name='style'>
364         <xsl:choose>
365           <xsl:when test='$class != ""'>
366             <xsl:value-of select='concat("sim-", $class)'/>
367           </xsl:when>
368           <xsl:otherwise>simpara</xsl:otherwise>
369         </xsl:choose>
370       </xsl:with-param>
371     </xsl:call-template>
372   </xsl:template>
373
374   <xsl:template match='emphasis|doc:emphasis'
375     mode='doc:body'>
376     <xsl:call-template name='doc:make-phrase'>
377       <xsl:with-param name='italic'>
378         <xsl:choose>
379           <xsl:when test='not(@role)'>1</xsl:when>
380           <xsl:otherwise>0</xsl:otherwise>
381         </xsl:choose>
382       </xsl:with-param>
383       <xsl:with-param name='bold'>
384         <xsl:choose>
385           <xsl:when test='@role = "bold" or @role = "strong"'>1</xsl:when>
386           <xsl:otherwise>0</xsl:otherwise>
387         </xsl:choose>
388       </xsl:with-param>
389     </xsl:call-template>
390   </xsl:template>
391
392   <xsl:template match='informalfigure|doc:informalfigure'
393     mode='doc:body'>
394     <xsl:if test='mediaobject/imageobject/imagedata |
395                   doc:mediaobject/doc:imageobject/doc:imagedata'>
396       <xsl:call-template name='doc:make-paragraph'>
397         <xsl:with-param name='style' select='"informalfigure-imagedata"'/>
398         <xsl:with-param name='content'>
399           <xsl:call-template name='doc:make-phrase'>
400             <xsl:with-param name='style'/>
401             <xsl:with-param name='content'>
402               <xsl:apply-templates select='mediaobject/imageobject/imagedata/@fileref |
403                                            doc:mediaobject/doc:imageobject/doc:imagedata/@fileref'
404                                    mode='textonly'/>
405             </xsl:with-param>
406           </xsl:call-template>
407         </xsl:with-param>
408       </xsl:call-template>
409     </xsl:if>
410     <xsl:apply-templates select='caption|doc:caption'
411       mode='doc:body'/>
412     <xsl:for-each select='*[not(self::mediaobject|self::doc:mediaobject|self::caption|self::doc:caption)]'>
413       <xsl:call-template name='doc:nomatch'/>
414     </xsl:for-each>
415   </xsl:template>
416
417   <xsl:template match='mediaobject|mediaobjectco |
418                        doc:mediaobject|doc:mediaobjectco'
419     mode='doc:body'>
420     <xsl:apply-templates select='objectinfo/title|doc:objectinfo/doc:title'/>
421     <xsl:apply-templates select='objectinfo/subtitle|objectinfo/subtitle |
422                                  doc:objectinfo/doc:subtitle|doc:objectinfo/doc:subtitle'/>
423     <!-- TODO: indicate error for other children of objectinfo -->
424
425     <xsl:apply-templates select='*[not(self::objectinfo|self::doc:objectinfo)]'/>
426   </xsl:template>
427   <xsl:template match='imageobject|imageobjectco|audioobject|videoobject |
428                        doc:imageobject|doc:imageobjectco|doc:audioobject|doc:videoobject'
429     mode='doc:body'>
430     <xsl:apply-templates select='objectinfo/title|doc:objectinfo/doc:title'/>
431     <xsl:apply-templates select='objectinfo/subtitle|doc:objectinfo/doc:subtitle'/>
432     <!-- TODO: indicate error for other children of objectinfo -->
433
434     <xsl:apply-templates select='areaspec|doc:areaspec'/>
435
436     <xsl:choose>
437       <xsl:when test='imagedata|audiodata|videodata |
438                       doc:imagedata|doc:audiodata|doc:videodata'>
439         <xsl:call-template name='doc:make-paragraph'>
440           <xsl:with-param name='style'
441                           select='concat(local-name(), "-", local-name(imagedata|audiodata|videodata|doc:imagedata|doc:audiodata|doc:videodata))'/>
442           <xsl:with-param name='content'>
443             <xsl:call-template name='doc:make-phrase'>
444               <xsl:with-param name='content'>
445                 <xsl:apply-templates select='*/@fileref'
446                                      mode='textonly'/>
447               </xsl:with-param>
448             </xsl:call-template>
449           </xsl:with-param>
450         </xsl:call-template>
451       </xsl:when>
452       <xsl:when test='self::imageobjectco/imageobject/imagedata |
453                       self::doc:imageobjectco/doc:imageobject/doc:imagedata'>
454         <xsl:call-template name='doc:make-paragraph'>
455           <xsl:with-param name='style'
456                           select='concat(local-name(), "-imagedata")'/>
457           <xsl:with-param name='content'>
458             <xsl:call-template name='doc:make-phrase'>
459               <xsl:with-param name='content'>
460                 <xsl:apply-templates select='*/@fileref'
461                                      mode='textonly'/>
462               </xsl:with-param>
463             </xsl:call-template>
464           </xsl:with-param>
465         </xsl:call-template>
466       </xsl:when>
467     </xsl:choose>
468     <xsl:apply-templates select='calloutlist|doc:calloutlist'/>
469
470     <xsl:for-each select='*[not(self::imageobject |
471                                 self::imagedata |
472                                 self::audiodata |
473                                 self::videodata |
474                                 self::areaspec  |
475                                 self::calloutlist |
476                                 self::doc:imageobject |
477                                 self::doc:imagedata |
478                                 self::doc:audiodata |
479                                 self::doc:videodata |
480                                 self::doc:areaspec  |
481                                 self::doc:calloutlist)]'>
482       <xsl:call-template name='doc:nomatch'/>
483     </xsl:for-each>
484   </xsl:template>
485   <xsl:template match='textobject|doc:textobject'
486     mode='doc:body'>
487     <xsl:choose>
488       <xsl:when test='objectinfo/title|objectinfo|subtitle |
489                       doc:objectinfo/doc:title|doc:objectinfo|doc:subtitle'>
490         <xsl:apply-templates select='objectinfo/title|doc:objectinfo/doc:title'
491           mode='doc:body'/>
492         <xsl:apply-templates select='objectinfo/subtitle|doc:objectinfo/doc:subtitle'
493           mode='doc:body'/>
494         <!-- TODO: indicate error for other children of objectinfo -->
495       </xsl:when>
496
497       <!-- In a table, the table itself and the caption delimit the textobject -->
498       <xsl:when test='ancestor::table |
499                       ancestor::doc:table |
500                       ancestor::informaltable |
501                       ancestor::doc:informaltable'/>
502
503       <xsl:otherwise>
504         <!-- synthesize a title so that the parent textobject
505              can be recreated.
506           -->
507         <xsl:call-template name='doc:make-paragraph'>
508           <xsl:with-param name='style' select='"textobject-title"'/>
509           <xsl:with-param name='content'>
510             <xsl:call-template name='doc:make-phrase'>
511               <xsl:with-param name='content'>
512                 <xsl:text>Text Object </xsl:text>
513                 <xsl:number level='any'/>
514               </xsl:with-param>
515             </xsl:call-template>
516           </xsl:with-param>
517         </xsl:call-template>
518       </xsl:otherwise>
519     </xsl:choose>
520
521     <xsl:apply-templates select='*[not(self::objectinfo|self::doc:objectinfo)]'
522       mode='doc:body'/>
523   </xsl:template>
524
525   <xsl:template match='caption|doc:caption'
526     mode='doc:body'>
527     <xsl:choose>
528       <xsl:when test='not(*)'>
529         <xsl:call-template name='doc:make-paragraph'>
530           <xsl:with-param name='style' select='"Caption"'/>
531           <xsl:with-param name='content'>
532             <xsl:apply-templates/>
533           </xsl:with-param>
534         </xsl:call-template>
535       </xsl:when>
536       <xsl:when test='not(text()) and
537                       count(*) = count(para|doc:para) and
538                       count(*) = 1'>
539         <xsl:call-template name='doc:make-paragraph'>
540           <xsl:with-param name='style' select='"caption"'/>
541           <xsl:with-param name='content'>
542             <xsl:apply-templates select='*/node()' mode='doc:body'/>
543           </xsl:with-param>
544         </xsl:call-template>
545       </xsl:when>
546       <xsl:when test='text()'>
547         <!-- Not valid DocBook -->
548         <xsl:call-template name='doc:nomatch'/>
549       </xsl:when>
550       <xsl:otherwise>
551         <xsl:call-template name='doc:make-paragraph'>
552           <xsl:with-param name='style' select='"Caption"'/>
553           <xsl:with-param name='content'>
554             <xsl:apply-templates select='*[self::para|self::doc:para][1]/node()'
555               mode='doc:body'/>
556           </xsl:with-param>
557         </xsl:call-template>
558         <xsl:for-each select='text()|*[not(self::para|self::doc:para)]|*[self::para|self::doc:para][position() != 1]'>
559           <xsl:call-template name='doc:nomatch'/>
560         </xsl:for-each>
561       </xsl:otherwise>
562     </xsl:choose>
563   </xsl:template>
564
565   <xsl:template match='area|areaspec|doc:area|doc:areaspec'
566     mode='doc:body'>
567     <xsl:call-template name='doc:make-paragraph'>
568       <xsl:with-param name='style' select='local-name()'/>
569       <xsl:with-param name='content'/>
570     </xsl:call-template>
571   </xsl:template>
572
573   <xsl:template match='calloutlist|doc:calloutlist'
574     mode='doc:body'>
575     <xsl:apply-templates select='callout|doc:callout'/>
576   </xsl:template>
577
578   <xsl:template match='callout|doc:callout'
579     mode='doc:body'>
580     <xsl:call-template name='doc:make-paragraph'>
581       <xsl:with-param name='style' select='"callout"'/>
582       <xsl:with-param name='content'>
583         <!-- Normally a para would be the first child of a callout -->
584         <xsl:apply-templates select='*[1][self::para|self::doc:para]/node()'
585           mode='list'/>
586       </xsl:with-param>
587     </xsl:call-template>
588
589     <!-- This is to catch the case where a listitem's first child is not a paragraph.
590        - We may not be able to represent this properly.
591       -->
592     <xsl:apply-templates select='*[1][not(self::para|self::doc:para)]'
593       mode='list'/>
594
595     <xsl:apply-templates select='*[position() != 1]'
596       mode='list'/>
597   </xsl:template>
598
599   <xsl:template match='table|informaltable |
600                        doc:table|doc:informaltable'
601     mode='doc:body'>
602     <xsl:call-template name='doc:make-table'>
603       <xsl:with-param name='columns'>
604         <xsl:apply-templates select='tgroup/colspec|doc:tgroup/doc:colspec'
605           mode='doc:column'/>
606       </xsl:with-param>
607     </xsl:call-template>
608     <xsl:apply-templates select='textobject|doc:textobject'
609       mode='doc:body'/>
610     <xsl:choose>
611       <xsl:when test='caption|doc:caption'>
612         <xsl:apply-templates select='caption|doc:caption'
613           mode='doc:body'/>
614       </xsl:when>
615       <xsl:when test='textobject|doc:textobject'>
616         <!-- Synthesize a caption to delimit the textobject -->
617         <xsl:call-template name='doc:make-paragraph'>
618           <xsl:with-param name='style'>Caption</xsl:with-param>
619           <xsl:with-param name='content'/>
620           <xsl:with-param name='attributes.node' select='/..'/>
621         </xsl:call-template>
622       </xsl:when>
623     </xsl:choose>
624   </xsl:template>
625
626   <xsl:template match='colspec|doc:colspec' mode='doc:column'>
627     <xsl:variable name='width'>
628       <xsl:choose>
629         <xsl:when test='contains(@colwidth, "*")'>
630           <!-- May need to resolve proportional width with other columns -->
631           <xsl:value-of select='substring-before(@colwidth, "*")'/>
632         </xsl:when>
633         <xsl:otherwise>
634           <xsl:value-of select='@colwidth'/>
635         </xsl:otherwise>
636       </xsl:choose>
637     </xsl:variable>
638
639     <xsl:call-template name='doc:make-column'>
640       <xsl:with-param name='width' select='$width'/>
641     </xsl:call-template>
642   </xsl:template>
643
644   <xsl:template match='colspec|doc:colspec' mode='doc:body'/>
645
646   <xsl:template name='doc:repeat'>
647     <xsl:param name='repeats' select='0'/>
648     <xsl:param name='content'/>
649
650     <xsl:if test='$repeats > 0'>
651       <xsl:copy-of select='$content'/>
652       <xsl:call-template name='doc:repeat'>
653         <xsl:with-param name='repeats' select='$repeats - 1'/>
654         <xsl:with-param name='content' select='$content'/>
655       </xsl:call-template>
656     </xsl:if>
657   </xsl:template>
658   <xsl:template match='tgroup|tbody|thead |
659                        doc:tgroup|doc:tbody|doc:thead'
660     mode='doc:body'>
661     <xsl:apply-templates mode='doc:body'/>
662   </xsl:template>
663   <xsl:template match='row|doc:row' mode='doc:body'>
664     <xsl:call-template name='doc:make-table-row'>
665       <xsl:with-param name='is-header' select='boolean(parent::thead|parent::doc:thead)'/>
666     </xsl:call-template>
667   </xsl:template>
668
669   <xsl:template match='entry|doc:entry' mode='doc:body'>
670
671     <!-- 
672          Position = Sum(i,preceding-sibling[@colspan = ""]) + entry[i].@colspan)
673       -->
674
675     <xsl:variable name='position'>
676       <xsl:call-template name='doc:sum-sibling'>
677         <xsl:with-param name='sum' select='"1"'/>
678         <xsl:with-param name='node' select='.'/>
679       </xsl:call-template>
680     </xsl:variable>
681
682     <xsl:variable name='limit' select='$position + @colspan'/>
683
684     <xsl:variable name='width.raw'>
685       <xsl:choose>
686         <xsl:when test='@colspan != ""'>
687
688           <!-- Select all the colspec nodes which correspond to the
689                column. That is all the nodes between the current 
690                column number and the column number plus the span.
691             -->
692
693           <xsl:variable name='combinedWidth'>
694             <xsl:call-template name='doc:sum'>
695               <xsl:with-param name='nodes' select='ancestor::*[self::table|self::doc:table|self::informaltable|self::doc:informaltable][1]/*[self::tgroup|self::doc:tgroup]/*[self::colspec|self::doc:colspec][not(position() &lt; $position) and position() &lt; $limit]'/>
696               <xsl:with-param name='sum' select='"0"'/>
697             </xsl:call-template>
698           </xsl:variable>
699           <xsl:value-of select='$combinedWidth'/>
700         </xsl:when>
701         <xsl:otherwise>
702           <xsl:value-of select='ancestor::*[self::table|self::doc:table|self::informaltable|self::doc:informaltable][1]/*[self::tgroup|self::doc:tgroup]/*[self::colspec|self::doc:colspec][position() = $position]/@colwidth'/>
703         </xsl:otherwise>
704       </xsl:choose>
705     </xsl:variable>
706
707     <xsl:call-template name='doc:make-table-cell'>
708       <xsl:with-param name='width'>
709         <xsl:choose>
710           <xsl:when test='contains($width.raw, "*")'>
711
712             <!-- Select all the colspec nodes which correspond to the
713                  column. That is all the nodes between the current 
714                  column number and the column number plus the span.
715               -->
716
717             <xsl:value-of select='substring-before($width.raw, "*")'/>
718           </xsl:when>
719           <xsl:otherwise>
720             <xsl:value-of select='$width.raw'/>
721           </xsl:otherwise>
722         </xsl:choose>
723       </xsl:with-param>
724
725       <xsl:with-param name='hidden' select='@hidden'/>
726       <xsl:with-param name='rowspan' select='@rowspan'/>
727       <xsl:with-param name='colspan' select='@colspan'/>
728
729       <xsl:with-param name='content'>
730         <xsl:choose>
731           <xsl:when test='not(para|doc:para)'>
732             <!-- TODO: check for any block elements -->
733             <xsl:call-template name='doc:make-paragraph'>
734               <xsl:with-param name='style'/>
735               <xsl:with-param name='attributes.node' select='/..'/>
736               <xsl:with-param name='content'/>
737             </xsl:call-template>
738           </xsl:when>
739           <xsl:otherwise>
740             <xsl:apply-templates mode='doc:body'/>
741           </xsl:otherwise>
742         </xsl:choose>
743       </xsl:with-param>
744     </xsl:call-template>
745   </xsl:template>
746
747   <!-- Calculates the position by adding the 
748        count of the preceding siblings where they aren't colspans
749        and adding the colspans of those entries which do.
750     -->
751
752   <xsl:template name='doc:sum-sibling'>    
753     <xsl:param name='sum'/>
754     <xsl:param name='node'/>
755
756     <xsl:variable name='add'>
757       <xsl:choose>
758         <xsl:when test='$node/preceding-sibling::*[self::entry|self::doc:entry]/@colspan != ""'>
759           <xsl:value-of select='$node/preceding-sibling::*[self::entry|self::doc:entry]/@colspan'/>
760         </xsl:when>
761         <xsl:otherwise>
762           <xsl:value-of select='"1"'/>
763         </xsl:otherwise>
764       </xsl:choose>
765     </xsl:variable>
766
767     <xsl:choose>
768       <xsl:when test='count($node/preceding-sibling::*[self::entry|self::doc:entry]) &gt; 0'>
769         <xsl:call-template name='doc:sum-sibling'>
770           <xsl:with-param name='sum' select='$sum + $add'/>
771           <xsl:with-param name='node'
772             select='$node/preceding-sibling::*[self::entry|self::doc:entry][1]'/>
773         </xsl:call-template>
774       </xsl:when>
775       <xsl:otherwise>
776         <xsl:value-of select='$sum'/>
777       </xsl:otherwise>
778     </xsl:choose>
779
780   </xsl:template>
781
782   <xsl:template name='doc:sum'>
783     <xsl:param name='sum' select='"0"'/>
784     <xsl:param name='nodes'/>
785
786     <xsl:variable name='tmpSum' select='$sum + $nodes[1]/@colwidth'/>
787
788     <xsl:choose>
789       <xsl:when test='count($nodes) &gt; 1'>
790         <xsl:call-template name='doc:sum'>
791           <xsl:with-param name='nodes' select='$nodes[position() != 1]'/>
792           <xsl:with-param name='sum' select='$tmpSum'/>
793         </xsl:call-template>
794       </xsl:when>
795       <xsl:otherwise>
796         <xsl:value-of select='$tmpSum'/>
797       </xsl:otherwise>
798     </xsl:choose>
799
800   </xsl:template>
801
802   <xsl:template match='*[self::para|self::simpara|self::doc:para|self::doc:simpara]/text()[string-length(normalize-space(.)) != 0]'
803     mode='doc:body'>
804     <xsl:call-template name='doc:handle-linebreaks'/>
805   </xsl:template>
806
807   <xsl:template match='text()[not(parent::para|parent::simpara|parent::literallayout|parent::programlisting | parent::doc:para|parent::doc:simpara|parent::doc:literallayout|parent::doc:programlisting)][string-length(normalize-space(.)) != 0]'
808     mode='doc:body'>
809     <xsl:call-template name='doc:handle-linebreaks'/>
810   </xsl:template>
811   <xsl:template match='text()[string-length(normalize-space(.)) = 0]'
812     mode='doc:body'/>
813   <xsl:template match='literallayout/text()|programlisting/text() |
814                        doc:literallayout/text()|doc:programlisting/text()'
815     mode='doc:body'>
816     <xsl:call-template name='doc:handle-linebreaks'/>
817   </xsl:template>
818   <xsl:template name='doc:handle-linebreaks'>
819     <xsl:param name='content' select='.'/>
820     <xsl:param name='style'/>
821
822     <xsl:choose>
823       <xsl:when test='not($content)'/>
824       <xsl:when test='contains($content, "&#xa;")'>
825         <xsl:call-template name='doc:make-phrase'>
826           <xsl:with-param name='style' select='$style'/>
827           <xsl:with-param name='content'
828                           select='substring-before($content, "&#xa;")'/>
829         </xsl:call-template>
830
831         <xsl:call-template name='doc:handle-linebreaks-aux'>
832           <xsl:with-param name='content'
833             select='substring-after($content, "&#xa;")'/>
834           <xsl:with-param name='style' select='$style'/>
835         </xsl:call-template>
836       </xsl:when>
837       <xsl:otherwise>
838         <xsl:call-template name='doc:make-phrase'>
839           <xsl:with-param name='style' select='$style'/>
840           <xsl:with-param name='content' select='$content'/>
841         </xsl:call-template>
842       </xsl:otherwise>
843     </xsl:choose>
844   </xsl:template>
845
846   <!-- pre-condition: leading linefeed has been stripped -->
847   <xsl:template name='doc:handle-linebreaks-aux'>
848     <xsl:param name='content'/>
849     <xsl:param name='style'/>
850
851     <xsl:choose>
852       <xsl:when test='contains($content, "&#xa;")'>
853         <xsl:call-template name='doc:make-phrase'>
854           <xsl:with-param name='style' select='$style'/>
855           <xsl:with-param name='content'>
856             <xsl:call-template name='doc:make-soft-break'/>
857             <xsl:value-of select='substring-before($content, "&#xa;")'/>
858           </xsl:with-param>
859         </xsl:call-template>
860         <xsl:call-template name='doc:handle-linebreaks-aux'>
861           <xsl:with-param name='content'
862                           select='substring-after($content, "&#xa;")'/>
863           <xsl:with-param name='style' select='$style'/>
864         </xsl:call-template>
865       </xsl:when>
866       <xsl:otherwise>
867         <xsl:call-template name='doc:make-phrase'>
868           <xsl:with-param name='style' select='$style'/>
869           <xsl:with-param name='content'>
870             <xsl:call-template name='doc:make-soft-break'/>
871             <xsl:value-of select='$content'/>
872           </xsl:with-param>
873         </xsl:call-template>
874       </xsl:otherwise>
875     </xsl:choose>
876   </xsl:template>
877
878   <xsl:template match='authorblurb|formalpara|legalnotice|note|caution|warning|important|tip |
879                        doc:authorblurb|doc:formalpara|doc:legalnotice|doc:note|doc:caution|doc:warning|doc:important|doc:tip'
880     mode='doc:body'>
881     <xsl:apply-templates select='*'>
882       <xsl:with-param name='class'>
883         <xsl:value-of select='local-name()'/>
884       </xsl:with-param>
885     </xsl:apply-templates>
886   </xsl:template>
887
888   <xsl:template match='blockquote|doc:blockquote'
889     mode='doc:body'>
890     <xsl:apply-templates select='blockinfo|title|doc:info|doc:title'
891       mode='doc:body'>
892       <xsl:with-param name='class'>
893         <xsl:value-of select='local-name()'/>
894       </xsl:with-param>
895     </xsl:apply-templates>
896     <xsl:apply-templates select='*[not(self::blockinfo|self::title|self::attribution|self::doc:info|self::doc:title|self::doc:attribution)]'
897       mode='doc:body'>
898       <xsl:with-param name='class' select='"blockquote"'/>
899     </xsl:apply-templates>
900     <xsl:if test='attribution|doc:attribution'>
901       <xsl:call-template name='doc:make-paragraph'>
902         <xsl:with-param name='style' select='"blockquote-attribution"'/>
903         <xsl:with-param name='content'>
904           <xsl:call-template name='doc:make-phrase'>
905             <xsl:with-param name='content'>
906               <xsl:apply-templates select='attribution/node()|doc:attribution/node()'/>
907             </xsl:with-param>
908           </xsl:call-template>
909         </xsl:with-param>
910       </xsl:call-template>
911     </xsl:if>
912   </xsl:template>
913
914   <xsl:template match='literallayout|programlisting|doc:literallayout|doc:programlisting'
915     mode='doc:body'>
916     <xsl:param name='class'/>
917
918     <xsl:call-template name='doc:make-paragraph'>
919       <xsl:with-param name='style' select='local-name()'/>
920     </xsl:call-template>
921   </xsl:template>
922
923   <xsl:template match='bridgehead|doc:bridgehead'
924     mode='doc:body'>
925     <xsl:call-template name='doc:make-paragraph'>
926       <xsl:with-param name='style' select='"bridgehead"'/>
927     </xsl:call-template>
928   </xsl:template>
929
930   <xsl:template match='itemizedlist|orderedlist |
931                        doc:itemizedlist|doc:orderedlist'
932     mode='doc:body'>
933     <xsl:apply-templates select='listitem|doc:listitem'
934       mode='doc:body'/>
935   </xsl:template>
936
937   <xsl:template match='listitem|doc:listitem'
938     mode='doc:body'>
939     <xsl:call-template name='doc:make-paragraph'>
940       <xsl:with-param name='style'
941                       select='concat(local-name(..), 
942                               count(ancestor::itemizedlist|ancestor::orderedlist|ancestor::doc:itemizedlist|ancestor::doc:orderedlist))'/>
943       <xsl:with-param name='is-listitem' select='true()'/>
944
945       <xsl:with-param name='content'>
946         <!-- Normally a para would be the first child of a listitem -->
947         <xsl:apply-templates select='*[1][self::para|self::doc:para]/node()'
948           mode='doc:body'/>
949       </xsl:with-param>
950     </xsl:call-template>
951
952     <!-- This is to catch the case where a listitem's first child is not a paragraph.
953        - We may not be able to represent this properly.
954       -->
955     <xsl:apply-templates select='*[1][not(self::para|self::doc:para)]'
956       mode='doc:list-continue'/>
957
958     <xsl:apply-templates select='*[position() != 1]'
959       mode='doc:list-continue'/>
960   </xsl:template>  
961
962   <xsl:template match='para|doc:para' mode='doc:list-continue'>
963     <xsl:apply-templates select='.'
964       mode='doc:body'>
965       <xsl:with-param name='class' select='"para-continue"'/>
966     </xsl:apply-templates>
967   </xsl:template>
968   <!-- non-paragraph elements in a listitem are rolled back into
969        the list item upon conversion.
970        -->
971   <xsl:template match='*' mode='doc:list-continue'>
972     <xsl:apply-templates select='.' mode='doc:body'/>
973   </xsl:template>
974
975   <xsl:template match='variablelist|doc:variablelist'
976     mode='doc:body'>
977     <xsl:apply-templates select='*[not(self::varlistentry|self::doc:varlistentry)]'/>
978
979     <xsl:call-template name='doc:make-table'>
980       <xsl:with-param name='columns'>
981         <xsl:call-template name='doc:make-column'>
982           <xsl:with-param name='width' select='"1"'/>
983         </xsl:call-template>
984         <xsl:call-template name='doc:make-column'>
985           <xsl:with-param name='width' select='"3"'/>
986         </xsl:call-template>
987       </xsl:with-param>
988       <xsl:with-param name='rows'>
989         <xsl:apply-templates select='varlistentry|doc:varlistentry'/>
990       </xsl:with-param>
991     </xsl:call-template>
992   </xsl:template>
993   <xsl:template match='varlistentry|doc:varlistentry'
994     mode='doc:body'>
995     <xsl:call-template name='doc:make-table-row'>
996       <xsl:with-param name='content'>
997         <xsl:call-template name='doc:make-table-cell'>
998           <xsl:with-param name='content'>
999             <xsl:call-template name='doc:make-paragraph'>
1000               <xsl:with-param name='style' select='"variablelist-term"'/>
1001               <xsl:with-param name='content'>
1002                 <xsl:apply-templates select='*[self::term|self::doc:term][1]/node()'
1003                   mode='doc:body'/>
1004                 <xsl:for-each select='*[self::term|self::doc:term][position() != 1]'>
1005                   <xsl:call-template name='doc:make-phrase'>
1006                     <xsl:with-param name='content'>
1007                       <xsl:call-template name='doc:make-soft-break'/>
1008                     </xsl:with-param>
1009                   </xsl:call-template>
1010                   <xsl:apply-templates/>
1011                 </xsl:for-each>
1012               </xsl:with-param>
1013             </xsl:call-template>
1014           </xsl:with-param>
1015         </xsl:call-template>
1016         <xsl:call-template name='doc:make-table-cell'>
1017           <xsl:with-param name='content'>
1018             <xsl:apply-templates select='listitem/node()|doc:listitem/node()'
1019               mode='doc:body'/>
1020           </xsl:with-param>
1021         </xsl:call-template>
1022       </xsl:with-param>
1023     </xsl:call-template>
1024   </xsl:template>
1025
1026   <!-- These elements are not displayed.
1027      - However, they may need to be added (perhaps as hidden text)
1028      - for round-tripping.
1029     -->
1030   <xsl:template match='anchor|areaset|audiodata|audioobject|
1031                        beginpage|
1032                        constraint|
1033                        indexterm|itermset|
1034                        keywordset|
1035                        msg |
1036                        doc:anchor|doc:areaset|doc:audiodata|doc:audioobject|
1037                        doc:beginpage|
1038                        doc:constraint|
1039                        doc:indexterm|doc:itermset|
1040                        doc:keywordset|
1041                        doc:msg'
1042     mode='doc:body'/>
1043
1044   <xsl:template match='*' name='doc:nomatch'>
1045     <xsl:param name='node' select='.'/>
1046
1047     <xsl:message>
1048       <xsl:value-of select='local-name($node)'/>
1049       <xsl:if test='namespace-uri($node) != ""'>
1050         <xsl:text> [</xsl:text>
1051         <xsl:value-of select='namespace-uri($node)'/>
1052         <xsl:text>]</xsl:text>
1053       </xsl:if>
1054       <xsl:text> encountered</xsl:text>
1055       <xsl:if test='$node/parent::*'>
1056         <xsl:text> in </xsl:text>
1057         <xsl:value-of select='local-name($node/parent::*)'/>
1058       </xsl:if>
1059       <xsl:text>, but no template matches.</xsl:text>
1060     </xsl:message>
1061
1062     <xsl:for-each select='$node'>
1063       <xsl:choose>
1064         <xsl:when test='self::abstract |
1065                         self::ackno |
1066                         self::address |
1067                         self::answer |
1068                         self::appendix |
1069                         self::artheader |
1070                         self::authorgroup |
1071                         self::bibliodiv |
1072                         self::biblioentry |
1073                         self::bibliography |
1074                         self::bibliomixed |
1075                         self::bibliomset |
1076                         self::biblioset |
1077                         self::bridgehead |
1078                         self::calloutlist |
1079                         self::caption |
1080                         self::classsynopsis |
1081                         self::colophon |
1082                         self::constraintdef |
1083                         self::copyright |
1084                         self::dedication |
1085                         self::epigraph |
1086                         self::equation |
1087                         self::example |
1088                         self::figure |
1089                         self::funcsynopsis |
1090                         self::glossary |
1091                         self::glossdef |
1092                         self::glossdiv |
1093                         self::glossentry |
1094                         self::glosslist |
1095                         self::graphic |
1096                         self::highlights |
1097                         self::imageobject |
1098                         self::imageobjectco |
1099                         self::index |
1100                         self::indexdiv |
1101                         self::indexentry |
1102                         self::informalequation |
1103                         self::informalexample |
1104                         self::informalfigure |
1105                         self::lot |
1106                         self::lotentry |
1107                         self::mediaobject |
1108                         self::mediaobjectco |
1109                         self::member |
1110                         self::msgentry |
1111                         self::msgset |
1112                         self::part |
1113                         self::partintro |
1114                         self::personblurb |
1115                         self::preface |
1116                         self::printhistory |
1117                         self::procedure |
1118                         self::programlisting |
1119                         self::programlistingco |
1120                         self::publisher |
1121                         self::qandadiv |
1122                         self::qandaentry |
1123                         self::qandaset |
1124                         self::question |
1125                         self::refdescriptor |
1126                         self::refentry |
1127                         self::refentrytitle |
1128                         self::reference |
1129                         self::refmeta |
1130                         self::refname |
1131                         self::refnamediv |
1132                         self::refpurpose |
1133                         self::refsect1 |
1134                         self::refsect2 |
1135                         self::refsect3 |
1136                         self::refsection |
1137                         self::refsynopsisdiv |
1138                         self::screen |
1139                         self::screenco |
1140                         self::screenshot |
1141                         self::seg |
1142                         self::seglistitem |
1143                         self::segmentedlist |
1144                         self::segtitle |
1145                         self::set |
1146                         self::setindex |
1147                         self::sidebar |
1148                         self::simplelist |
1149                         self::simplemsgentry |
1150                         self::step |
1151                         self::stepalternatives |
1152                         self::subjectset |
1153                         self::substeps |
1154                         self::task |
1155                         self::textobject |
1156                         self::toc |
1157                         self::videodata |
1158                         self::videoobject |
1159
1160                         self::doc:abstract |
1161                         self::doc:ackno |
1162                         self::doc:address |
1163                         self::doc:answer |
1164                         self::doc:appendix |
1165                         self::doc:artheader |
1166                         self::doc:authorgroup |
1167                         self::doc:bibliodiv |
1168                         self::doc:biblioentry |
1169                         self::doc:bibliography |
1170                         self::doc:bibliomixed |
1171                         self::doc:bibliomset |
1172                         self::doc:biblioset |
1173                         self::doc:bridgehead |
1174                         self::doc:calloutlist |
1175                         self::doc:caption |
1176                         self::doc:classsynopsis |
1177                         self::doc:colophon |
1178                         self::doc:constraintdef |
1179                         self::doc:copyright |
1180                         self::doc:dedication |
1181                         self::doc:epigraph |
1182                         self::doc:equation |
1183                         self::doc:example |
1184                         self::doc:figure |
1185                         self::doc:funcsynopsis |
1186                         self::doc:glossary |
1187                         self::doc:glossdef |
1188                         self::doc:glossdiv |
1189                         self::doc:glossentry |
1190                         self::doc:glosslist |
1191                         self::doc:graphic |
1192                         self::doc:highlights |
1193                         self::doc:imageobject |
1194                         self::doc:imageobjectco |
1195                         self::doc:index |
1196                         self::doc:indexdiv |
1197                         self::doc:indexentry |
1198                         self::doc:informalequation |
1199                         self::doc:informalexample |
1200                         self::doc:informalfigure |
1201                         self::doc:lot |
1202                         self::doc:lotentry |
1203                         self::doc:mediaobject |
1204                         self::doc:mediaobjectco |
1205                         self::doc:member |
1206                         self::doc:msgentry |
1207                         self::doc:msgset |
1208                         self::doc:part |
1209                         self::doc:partintro |
1210                         self::doc:personblurb |
1211                         self::doc:preface |
1212                         self::doc:printhistory |
1213                         self::doc:procedure |
1214                         self::doc:programlisting |
1215                         self::doc:programlistingco |
1216                         self::doc:publisher |
1217                         self::doc:qandadiv |
1218                         self::doc:qandaentry |
1219                         self::doc:qandaset |
1220                         self::doc:question |
1221                         self::doc:refdescriptor |
1222                         self::doc:refentry |
1223                         self::doc:refentrytitle |
1224                         self::doc:reference |
1225                         self::doc:refmeta |
1226                         self::doc:refname |
1227                         self::doc:refnamediv |
1228                         self::doc:refpurpose |
1229                         self::doc:refsect1 |
1230                         self::doc:refsect2 |
1231                         self::doc:refsect3 |
1232                         self::doc:refsection |
1233                         self::doc:refsynopsisdiv |
1234                         self::doc:screen |
1235                         self::doc:screenco |
1236                         self::doc:screenshot |
1237                         self::doc:seg |
1238                         self::doc:seglistitem |
1239                         self::doc:segmentedlist |
1240                         self::doc:segtitle |
1241                         self::doc:set |
1242                         self::doc:setindex |
1243                         self::doc:sidebar |
1244                         self::doc:simplelist |
1245                         self::doc:simplemsgentry |
1246                         self::doc:step |
1247                         self::doc:stepalternatives |
1248                         self::doc:subjectset |
1249                         self::doc:substeps |
1250                         self::doc:task |
1251                         self::doc:textobject |
1252                         self::doc:toc |
1253                         self::doc:videodata |
1254                         self::doc:videoobject |
1255
1256                         self::*[not(starts-with(local-name(), "informal")) and contains(local-name(), "info")]'>
1257           <xsl:call-template name='doc:make-paragraph'>
1258             <xsl:with-param name='style' select='"blockerror"'/>
1259             <xsl:with-param name='content'>
1260               <xsl:call-template name='doc:make-phrase'>
1261                 <xsl:with-param name='content'>
1262                   <xsl:value-of select='local-name()'/>
1263                   <xsl:if test='namespace-uri() != ""'>
1264                     <xsl:text> [</xsl:text>
1265                     <xsl:value-of select='namespace-uri()'/>
1266                     <xsl:text>]</xsl:text>
1267                   </xsl:if>
1268                   <xsl:text> encountered</xsl:text>
1269                   <xsl:if test='parent::*'>
1270                     <xsl:text> in </xsl:text>
1271                     <xsl:value-of select='local-name(parent::*)'/>
1272                   </xsl:if>
1273                   <xsl:text>, but no template matches.</xsl:text>
1274                 </xsl:with-param>
1275               </xsl:call-template>
1276             </xsl:with-param>
1277           </xsl:call-template>
1278         </xsl:when>
1279         <!-- Some elements are sometimes blocks, sometimes inline
1280              <xsl:when test='self::affiliation |
1281                              self::alt |
1282                              self::attribution |
1283                              self::collab |
1284                              self::collabname |
1285                              self::confdates |
1286                              self::confgroup |
1287                              self::confnum |
1288                              self::confsponsor |
1289                              self::conftitle |
1290                              self::contractnum |
1291                              self::contractsponsor |
1292                              self::contrib |
1293                              self::corpauthor |
1294                              self::corpcredit |
1295                              self::corpname |
1296                              self::edition |
1297                              self::editor |
1298                              self::jobtitle |
1299                              self::personname |
1300                              self::publishername |
1301                              self::remark |
1302
1303                              self::doc:affiliation |
1304                              self::doc:alt |
1305                              self::doc:attribution |
1306                              self::doc:collab |
1307                              self::doc:collabname |
1308                              self::doc:confdates |
1309                              self::doc:confgroup |
1310                              self::doc:confnum |
1311                              self::doc:confsponsor |
1312                              self::doc:conftitle |
1313                              self::doc:contractnum |
1314                              self::doc:contractsponsor |
1315                              self::doc:contrib |
1316                              self::doc:corpauthor |
1317                              self::doc:corpcredit |
1318                              self::doc:corpname |
1319                              self::doc:edition |
1320                              self::doc:editor |
1321                              self::doc:jobtitle |
1322                              self::doc:personname |
1323                              self::doc:publishername |
1324                              self::doc:remark'>
1325
1326              </xsl:when>
1327              -->
1328         <xsl:otherwise>
1329           <xsl:call-template name='doc:make-phrase'>
1330             <xsl:with-param name='style' select='"inlineerror"'/>
1331             <xsl:with-param name='content'>
1332               <xsl:value-of select='local-name()'/>
1333               <xsl:text> encountered</xsl:text>
1334               <xsl:if test='parent::*'>
1335                 <xsl:text> in </xsl:text>
1336                 <xsl:value-of select='local-name(parent::*)'/>
1337               </xsl:if>
1338               <xsl:text>, but no template matches.</xsl:text>
1339             </xsl:with-param>
1340           </xsl:call-template>
1341         </xsl:otherwise>
1342       </xsl:choose>
1343     </xsl:for-each>
1344   </xsl:template>
1345
1346   <xsl:template match='*' mode='doc:copy'>
1347     <xsl:copy>
1348       <xsl:apply-templates select='@*' mode='doc:copy'/>
1349       <xsl:apply-templates mode='doc:copy'/>
1350     </xsl:copy>
1351   </xsl:template>
1352   <xsl:template match='@*' mode='doc:copy'>
1353     <xsl:copy/>
1354   </xsl:template>
1355
1356   <!-- Stubs: the importing stylesheet must override these -->
1357
1358   <!-- stub template for creating a paragraph -->
1359   <xsl:template name='doc:make-paragraph'>
1360   </xsl:template>
1361   <!-- stub template for creating a phrase -->
1362   <xsl:template name='doc:make-phrase'>
1363   </xsl:template>
1364
1365   <!-- stub template for inserting attributes -->
1366   <xsl:template name='doc:attributes'/>
1367
1368   <!-- emit a message -->
1369   <xsl:template name='doc:warning'>
1370     <xsl:param name='message'/>
1371
1372     <xsl:message>WARNING: <xsl:value-of select='$message'/></xsl:message>
1373   </xsl:template>
1374
1375 </xsl:stylesheet>