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