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'>
7 <!-- ********************************************************************
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.
13 ******************************************************************** -->
15 <!-- DO NOT USE THIS STYLESHEET!
17 This stylesheet is imported by the other dbk2* stylesheets.
18 Use one of those instead.
22 <xsl:include href='../VERSION.xsl'/>
24 <!-- doc:docprop.author mode is for creating document metadata -->
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'/>
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'/>
42 <!-- doc:toplevel mode is for processing whole documents -->
44 <xsl:template match='*' mode='doc:toplevel'>
45 <xsl:call-template name='doc:make-body'/>
48 <!-- doc:body mode is for processing components of a document -->
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'
53 <xsl:call-template name='doc:make-subsection'/>
56 <xsl:template match='d:articleinfo |
64 <xsl:apply-templates select='d:title|d:subtitle|d:titleabbrev |
65 doc:title|doc:subtitle|doc:titleabbrev'
67 <xsl:apply-templates select='d:author|d:releaseinfo|d:abstract |
68 doc:author|doc:releaseinfo|doc:abstract'
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'/>
77 <xsl:template match='d:title|d:subtitle|d:titleabbrev |
78 doc:title|doc:subtitle|doc:titleabbrev'
80 <xsl:call-template name='doc:make-paragraph'>
81 <xsl:with-param name='style'>
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>
89 <xsl:text>sect5-</xsl:text>
90 <xsl:value-of select='local-name()'/>
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()'/>
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()'/>
105 <xsl:value-of select='local-name(..)'/>
106 <xsl:text>-</xsl:text>
107 <xsl:value-of select='local-name()'/>
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'/>
122 <doc:template name='metadata' xmlns=''>
123 <title>Metadata</title>
125 <para>TODO: Handle all metadata elements, apart from titles.</para>
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)]'
131 <xsl:template match='d:author|d:editor|d:othercredit |
132 doc:author|doc:editor|doc:othercredit'
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'
144 <xsl:apply-templates select='d:affiliation|d:address |
145 doc:affiliation|doc:address'
147 <xsl:apply-templates select='d:authorblurb|d:personblurb |
148 doc:authorblurb|doc:personblurb'
151 <xsl:template match='d:affiliation|doc:affiliation'
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'/>
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]'
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'/>
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)]'
174 <xsl:apply-templates select='node()[not(self::d:affiliation|self::d:authorblurb|self::doc:affiliation|self::doc:authorblurb)]'/>
176 <xsl:template match='d:abstract|doc:abstract'
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()'
188 <xsl:apply-templates select='*[not(self::d:title|self::doc:title)]'
190 <xsl:with-param name='class'>abstract</xsl:with-param>
191 </xsl:apply-templates>
194 <xsl:template match='d:authorblurb|d:personblurb |
195 doc:authorblurb|doc:personblurb'
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'
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>
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()'/>
214 <xsl:template match='d:email|doc:email'
216 <xsl:variable name='address'>
218 <xsl:when test='starts-with(., "mailto:")'>
219 <xsl:value-of select='.'/>
222 <xsl:text>mailto:</xsl:text>
223 <xsl:value-of select='.'/>
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>
236 <!-- otheraddr often contains ulink -->
237 <xsl:template match='d:otheraddr|doc:otheraddr'
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]'/>
246 <xsl:when test='$prev'>
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>
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>
260 <xsl:apply-templates select='.'/>
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>
271 <xsl:call-template name='doc:handle-linebreaks'>
272 <xsl:with-param name='style'>otheraddr</xsl:with-param>
277 <xsl:template match='d:ulink|doc:ulink'
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>
289 <!-- Cannot round-trip this element -->
290 <xsl:template match='d:personname|doc:personname'
292 <xsl:apply-templates mode='doc:body'/>
295 <xsl:template match='d:releaseinfo|doc:releaseinfo'
297 <xsl:call-template name='doc:make-paragraph'>
298 <xsl:with-param name='style'
299 select='"d:releaseinfo"'/>
303 <xsl:template match='d:para|doc:para'
305 <xsl:param name='class'/>
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'/>
312 <xsl:when test='$block'>
313 <xsl:call-template name='doc:make-paragraph'>
314 <xsl:with-param name='style'>
316 <xsl:when test='$class != ""'>
317 <xsl:value-of select='$class'/>
319 <xsl:otherwise>para</xsl:otherwise>
322 <xsl:with-param name='content'
323 select='$block[1]/preceding-sibling::node()'/>
326 <xsl:for-each select='$block'>
327 <xsl:apply-templates select='.'/>
329 <xsl:call-template name='doc:make-paragraph'>
330 <xsl:with-param name='style'>
332 <xsl:when test='$class != ""'>
333 <xsl:value-of select='$class'/>
335 <xsl:otherwise>Normal</xsl:otherwise>
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())]'/>
344 <xsl:call-template name='doc:make-paragraph'>
345 <xsl:with-param name='style'>
347 <xsl:when test='$class != ""'>
348 <xsl:value-of select='$class'/>
350 <xsl:otherwise>Normal</xsl:otherwise>
357 <xsl:template match='d:simpara|doc:simpara'
359 <xsl:param name='class'/>
361 <xsl:call-template name='doc:make-paragraph'>
362 <xsl:with-param name='style'>
364 <xsl:when test='$class != ""'>
365 <xsl:value-of select='concat("sim-", $class)'/>
367 <xsl:otherwise>simpara</xsl:otherwise>
373 <xsl:template match='d:emphasis|doc:emphasis'
375 <xsl:call-template name='doc:make-phrase'>
376 <xsl:with-param name='italic'>
378 <xsl:when test='not(@role)'>1</xsl:when>
379 <xsl:otherwise>0</xsl:otherwise>
382 <xsl:with-param name='bold'>
384 <xsl:when test='@role = "bold" or @role = "d:strong"'>1</xsl:when>
385 <xsl:otherwise>0</xsl:otherwise>
391 <xsl:template match='d:informalfigure|doc:informalfigure'
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'
409 <xsl:apply-templates select='d:caption|doc:caption'
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'/>
416 <xsl:template match='d:mediaobject|d:mediaobjectco |
417 doc:mediaobject|doc:mediaobjectco'
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 -->
424 <xsl:apply-templates select='*[not(self::d:objectinfo|self::doc:objectinfo)]'/>
426 <xsl:template match='d:imageobject|d:imageobjectco|d:audioobject|d:videoobject |
427 doc:imageobject|doc:imageobjectco|doc:audioobject|doc:videoobject'
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 -->
433 <xsl:apply-templates select='d:areaspec|doc:areaspec'/>
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'
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'
467 <xsl:apply-templates select='d:calloutlist|doc:calloutlist'/>
469 <xsl:for-each select='*[not(self::d:imageobject |
474 self::d:calloutlist |
475 self::doc:imageobject |
476 self::doc:imagedata |
477 self::doc:audiodata |
478 self::doc:videodata |
480 self::doc:calloutlist)]'>
481 <xsl:call-template name='doc:nomatch'/>
484 <xsl:template match='d:textobject|doc:textobject'
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'
491 <xsl:apply-templates select='d:objectinfo/d:subtitle|doc:objectinfo/doc:subtitle'
493 <!-- TODO: indicate error for other children of objectinfo -->
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'/>
503 <!-- synthesize a title so that the parent textobject
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'/>
520 <xsl:apply-templates select='*[not(self::d:objectinfo|self::doc:objectinfo)]'
524 <xsl:template match='d:caption|doc:caption'
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/>
535 <xsl:when test='not(text()) and
536 count(*) = count(d:para|doc:para) and
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'/>
545 <xsl:when test='text()'>
546 <!-- Not valid DocBook -->
547 <xsl:call-template name='doc:nomatch'/>
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()'
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'/>
564 <xsl:template match='d:area|d:areaspec|doc:area|doc:areaspec'
566 <xsl:call-template name='doc:make-paragraph'>
567 <xsl:with-param name='style' select='local-name()'/>
568 <xsl:with-param name='content'/>
572 <xsl:template match='d:calloutlist|doc:calloutlist'
574 <xsl:apply-templates select='d:callout|doc:callout'/>
577 <xsl:template match='d:callout|doc:callout'
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()'
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.
591 <xsl:apply-templates select='*[1][not(self::d:para|self::doc:para)]'
594 <xsl:apply-templates select='*[position() != 1]'
598 <xsl:template match='d:table|d:informaltable |
599 doc:table|doc:informaltable'
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'
607 <xsl:apply-templates select='d:textobject|doc:textobject'
610 <xsl:when test='d:caption|doc:caption'>
611 <xsl:apply-templates select='d:caption|doc:caption'
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='/..'/>
625 <xsl:template match='d:colspec|doc:colspec' mode='doc:column'>
626 <xsl:variable name='width'>
628 <xsl:when test='contains(@colwidth, "*")'>
629 <!-- May need to resolve proportional width with other columns -->
630 <xsl:value-of select='substring-before(@colwidth, "*")'/>
633 <xsl:value-of select='@colwidth'/>
638 <xsl:call-template name='doc:make-column'>
639 <xsl:with-param name='width' select='$width'/>
643 <xsl:template match='d:colspec|doc:colspec' mode='doc:body'/>
645 <xsl:template name='doc:repeat'>
646 <xsl:param name='repeats' select='0'/>
647 <xsl:param name='content'/>
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'/>
657 <xsl:template match='d:tgroup|d:tbody|d:thead |
658 doc:tgroup|doc:tbody|doc:thead'
660 <xsl:apply-templates mode='doc:body'/>
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)'/>
668 <xsl:template match='d:entry|doc:entry' mode='doc:body'>
671 Position = Sum(i,preceding-sibling[@colspan = ""]) + entry[i].@colspan)
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='.'/>
681 <xsl:variable name='limit' select='$position + @colspan'/>
683 <xsl:variable name='width.raw'>
685 <xsl:when test='@colspan != ""'>
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.
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() < $position) and position() < $limit]'/>
695 <xsl:with-param name='sum' select='"0"'/>
698 <xsl:value-of select='$combinedWidth'/>
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'/>
706 <xsl:call-template name='doc:make-table-cell'>
707 <xsl:with-param name='width'>
709 <xsl:when test='contains($width.raw, "*")'>
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.
716 <xsl:value-of select='substring-before($width.raw, "*")'/>
719 <xsl:value-of select='$width.raw'/>
724 <xsl:with-param name='hidden' select='@hidden'/>
725 <xsl:with-param name='rowspan' select='@rowspan'/>
726 <xsl:with-param name='colspan' select='@colspan'/>
728 <xsl:with-param name='content'>
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'/>
739 <xsl:apply-templates mode='doc:body'/>
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.
751 <xsl:template name='doc:sum-sibling'>
752 <xsl:param name='sum'/>
753 <xsl:param name='node'/>
755 <xsl:variable name='add'>
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'/>
761 <xsl:value-of select='"1"'/>
767 <xsl:when test='count($node/preceding-sibling::*[self::d:entry|self::doc:entry]) > 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]'/>
775 <xsl:value-of select='$sum'/>
781 <xsl:template name='doc:sum'>
782 <xsl:param name='sum' select='"0"'/>
783 <xsl:param name='nodes'/>
785 <xsl:variable name='tmpSum' select='$sum + $nodes[1]/@colwidth'/>
788 <xsl:when test='count($nodes) > 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'/>
795 <xsl:value-of select='$tmpSum'/>
801 <xsl:template match='*[self::d:para|self::d:simpara|self::doc:para|self::doc:simpara]/text()[string-length(normalize-space(.)) != 0]'
803 <xsl:call-template name='doc:handle-linebreaks'/>
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]'
808 <xsl:call-template name='doc:handle-linebreaks'/>
810 <xsl:template match='text()[string-length(normalize-space(.)) = 0]'
812 <xsl:template match='d:literallayout/text()|d:programlisting/text() |
813 doc:literallayout/text()|doc:programlisting/text()'
815 <xsl:call-template name='doc:handle-linebreaks'/>
817 <xsl:template name='doc:handle-linebreaks'>
818 <xsl:param name='content' select='.'/>
819 <xsl:param name='style'/>
822 <xsl:when test='not($content)'/>
823 <xsl:when test='contains($content, "
")'>
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, "
")'/>
830 <xsl:call-template name='doc:handle-linebreaks-aux'>
831 <xsl:with-param name='content'
832 select='substring-after($content, "
")'/>
833 <xsl:with-param name='style' select='$style'/>
837 <xsl:call-template name='doc:make-phrase'>
838 <xsl:with-param name='style' select='$style'/>
839 <xsl:with-param name='content' select='$content'/>
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'/>
851 <xsl:when test='contains($content, "
")'>
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, "
")'/>
859 <xsl:call-template name='doc:handle-linebreaks-aux'>
860 <xsl:with-param name='content'
861 select='substring-after($content, "
")'/>
862 <xsl:with-param name='style' select='$style'/>
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'/>
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'
880 <xsl:apply-templates select='*'>
881 <xsl:with-param name='class'>
882 <xsl:value-of select='local-name()'/>
884 </xsl:apply-templates>
887 <xsl:template match='d:blockquote|doc:blockquote'
889 <xsl:apply-templates select='d:blockinfo|d:title|doc:info|doc:title'
891 <xsl:with-param name='class'>
892 <xsl:value-of select='local-name()'/>
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)]'
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()'/>
913 <xsl:template match='d:literallayout|d:programlisting|doc:literallayout|doc:programlisting'
915 <xsl:param name='class'/>
917 <xsl:call-template name='doc:make-paragraph'>
918 <xsl:with-param name='style' select='local-name()'/>
922 <xsl:template match='d:bridgehead|doc:bridgehead'
924 <xsl:call-template name='doc:make-paragraph'>
925 <xsl:with-param name='style' select='"d:bridgehead"'/>
929 <xsl:template match='d:itemizedlist|d:orderedlist |
930 doc:itemizedlist|doc:orderedlist'
932 <xsl:apply-templates select='d:listitem|doc:listitem'
936 <xsl:template match='d:listitem|doc:listitem'
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()'/>
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()'
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.
954 <xsl:apply-templates select='*[1][not(self::d:para|self::doc:para)]'
955 mode='doc:list-continue'/>
957 <xsl:apply-templates select='*[position() != 1]'
958 mode='doc:list-continue'/>
961 <xsl:template match='d:para|doc:para' mode='doc:list-continue'>
962 <xsl:apply-templates select='.'
964 <xsl:with-param name='class' select='"para-continue"'/>
965 </xsl:apply-templates>
967 <!-- non-paragraph elements in a listitem are rolled back into
968 the list item upon conversion.
970 <xsl:template match='*' mode='doc:list-continue'>
971 <xsl:apply-templates select='.' mode='doc:body'/>
974 <xsl:template match='d:variablelist|doc:variablelist'
976 <xsl:apply-templates select='*[not(self::d:varlistentry|self::doc:varlistentry)]'/>
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"'/>
983 <xsl:call-template name='doc:make-column'>
984 <xsl:with-param name='width' select='"3"'/>
987 <xsl:with-param name='rows'>
988 <xsl:apply-templates select='d:varlistentry|doc:varlistentry'/>
992 <xsl:template match='d:varlistentry|doc:varlistentry'
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()'
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'/>
1008 </xsl:call-template>
1009 <xsl:apply-templates/>
1012 </xsl:call-template>
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()'
1020 </xsl:call-template>
1022 </xsl:call-template>
1025 <!-- These elements are not displayed.
1026 - However, they may need to be added (perhaps as hidden text)
1027 - for round-tripping.
1029 <xsl:template match='d:anchor|d:areaset|d:audiodata|d:audioobject|
1032 d:indexterm|d:itermset|
1035 doc:anchor|doc:areaset|doc:audiodata|doc:audioobject|
1038 doc:indexterm|doc:itermset|
1043 <xsl:template match='*' name='doc:nomatch'>
1044 <xsl:param name='node' select='.'/>
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>
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::*)'/>
1058 <xsl:text>, but no template matches.</xsl:text>
1061 <xsl:for-each select='$node'>
1063 <xsl:when test='self::d:abstract |
1069 self::d:authorgroup |
1071 self::d:biblioentry |
1072 self::d:bibliography |
1073 self::d:bibliomixed |
1074 self::d:bibliomset |
1076 self::d:bridgehead |
1077 self::d:calloutlist |
1079 self::d:classsynopsis |
1081 self::d:constraintdef |
1083 self::d:dedication |
1088 self::d:funcsynopsis |
1092 self::d:glossentry |
1095 self::d:highlights |
1096 self::d:imageobject |
1097 self::d:imageobjectco |
1100 self::d:indexentry |
1101 self::d:informalequation |
1102 self::d:informalexample |
1103 self::d:informalfigure |
1106 self::d:mediaobject |
1107 self::d:mediaobjectco |
1113 self::d:personblurb |
1115 self::d:printhistory |
1117 self::d:programlisting |
1118 self::d:programlistingco |
1121 self::d:qandaentry |
1124 self::d:refdescriptor |
1126 self::d:refentrytitle |
1130 self::d:refnamediv |
1131 self::d:refpurpose |
1135 self::d:refsection |
1136 self::d:refsynopsisdiv |
1139 self::d:screenshot |
1141 self::d:seglistitem |
1142 self::d:segmentedlist |
1147 self::d:simplelist |
1148 self::d:simplemsgentry |
1150 self::d:stepalternatives |
1151 self::d:subjectset |
1154 self::d:textobject |
1157 self::d:videoobject |
1159 self::doc:abstract |
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 |
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 |
1184 self::doc:funcsynopsis |
1185 self::doc:glossary |
1186 self::doc:glossdef |
1187 self::doc:glossdiv |
1188 self::doc:glossentry |
1189 self::doc:glosslist |
1191 self::doc:highlights |
1192 self::doc:imageobject |
1193 self::doc:imageobjectco |
1195 self::doc:indexdiv |
1196 self::doc:indexentry |
1197 self::doc:informalequation |
1198 self::doc:informalexample |
1199 self::doc:informalfigure |
1201 self::doc:lotentry |
1202 self::doc:mediaobject |
1203 self::doc:mediaobjectco |
1205 self::doc:msgentry |
1208 self::doc:partintro |
1209 self::doc:personblurb |
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 |
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 |
1234 self::doc:screenco |
1235 self::doc:screenshot |
1237 self::doc:seglistitem |
1238 self::doc:segmentedlist |
1239 self::doc:segtitle |
1241 self::doc:setindex |
1243 self::doc:simplelist |
1244 self::doc:simplemsgentry |
1246 self::doc:stepalternatives |
1247 self::doc:subjectset |
1248 self::doc:substeps |
1250 self::doc:textobject |
1252 self::doc:videodata |
1253 self::doc:videoobject |
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>
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::*)'/>
1272 <xsl:text>, but no template matches.</xsl:text>
1274 </xsl:call-template>
1276 </xsl:call-template>
1278 <!-- Some elements are sometimes blocks, sometimes inline
1279 <xsl:when test='self::d:affiliation |
1281 self::d:attribution |
1283 self::d:collabname |
1287 self::d:confsponsor |
1289 self::d:contractnum |
1290 self::d:contractsponsor |
1292 self::d:corpauthor |
1293 self::d:corpcredit |
1298 self::d:personname |
1299 self::d:publishername |
1302 self::doc:affiliation |
1304 self::doc:attribution |
1306 self::doc:collabname |
1307 self::doc:confdates |
1308 self::doc:confgroup |
1310 self::doc:confsponsor |
1311 self::doc:conftitle |
1312 self::doc:contractnum |
1313 self::doc:contractsponsor |
1315 self::doc:corpauthor |
1316 self::doc:corpcredit |
1317 self::doc:corpname |
1320 self::doc:jobtitle |
1321 self::doc:personname |
1322 self::doc:publishername |
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::*)'/>
1337 <xsl:text>, but no template matches.</xsl:text>
1339 </xsl:call-template>
1345 <xsl:template match='*' mode='doc:copy'>
1347 <xsl:apply-templates select='@*' mode='doc:copy'/>
1348 <xsl:apply-templates mode='doc:copy'/>
1351 <xsl:template match='@*' mode='doc:copy'>
1355 <!-- Stubs: the importing stylesheet must override these -->
1357 <!-- stub template for creating a paragraph -->
1358 <xsl:template name='doc:make-paragraph'>
1360 <!-- stub template for creating a phrase -->
1361 <xsl:template name='doc:make-phrase'>
1364 <!-- stub template for inserting attributes -->
1365 <xsl:template name='doc:attributes'/>
1367 <!-- emit a message -->
1368 <xsl:template name='doc:warning'>
1369 <xsl:param name='message'/>
1371 <xsl:message>WARNING: <xsl:value-of select='$message'/></xsl:message>