1 <xsl:stylesheet version="1.0"
2 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3 xmlns:doc='http://docbook.org/ns/docbook'
4 exclude-result-prefixes='doc'>
6 <!-- ********************************************************************
7 $Id: dbk2wp.xsl 8047 2008-06-10 12:46:53Z balls $
8 ********************************************************************
10 This file is part of the XSL DocBook Stylesheet distribution.
11 See ../README or http://docbook.sf.net/release/xsl/current/ for
12 copyright and other information.
14 ******************************************************************** -->
16 <!-- DO NOT USE THIS STYLESHEET!
18 This stylesheet is imported by the other dbk2* stylesheets.
19 Use one of those instead.
23 <xsl:include href='../VERSION'/>
25 <!-- doc:docprop.author mode is for creating document metadata -->
27 <xsl:template match='author|doc:author|editor|doc:editor' mode='doc:docprop.author'>
28 <xsl:apply-templates select='firstname|doc:firstname |
29 personname/firstname|doc:personname/doc:firstname'
30 mode='doc:docprop.author'/>
31 <xsl:text> </xsl:text>
32 <xsl:apply-templates select='surname|doc:surname |
33 personname/surname|doc:personname/doc:surname'
34 mode='doc:docprop.author'/>
37 <xsl:template match='firstname|doc:firstname |
39 mode='doc:docprop.author'>
40 <xsl:apply-templates select='.' mode='doc:body'/>
43 <!-- doc:toplevel mode is for processing whole documents -->
45 <xsl:template match='*' mode='doc:toplevel'>
46 <xsl:call-template name='doc:make-body'/>
49 <!-- doc:body mode is for processing components of a document -->
51 <xsl:template match='book|article|chapter|section|sect1|sect2|sect3|sect4|sect5|simplesect |
52 doc:book|doc:article|doc:chapter|doc:section|doc:sect1|doc:sect2|doc:sect3|doc:sect4|doc:sect5|doc:simplesect'
54 <xsl:call-template name='doc:make-subsection'/>
57 <xsl:template match='articleinfo |
65 <xsl:apply-templates select='title|subtitle|titleabbrev |
66 doc:title|doc:subtitle|doc:titleabbrev'
68 <xsl:apply-templates select='author|releaseinfo|abstract |
69 doc:author|doc:releaseinfo|doc:abstract'
71 <!-- current implementation ignores all other metadata -->
72 <xsl:for-each select='*[not(self::title|self::subtitle|self::titleabbrev|self::author|self::releaseinfo|self::abstract |
73 self::doc:title|self::doc:subtitle|self::doc:titleabbrev|self::doc:author|self::doc:releaseinfo|self::doc:abstract)]'>
74 <xsl:call-template name='doc:nomatch'/>
78 <xsl:template match='title|subtitle|titleabbrev |
79 doc:title|doc:subtitle|doc:titleabbrev'
81 <xsl:call-template name='doc:make-paragraph'>
82 <xsl:with-param name='style'>
84 <xsl:when test='(parent::section|parent::doc:section or
85 parent::sectioninfo/parent::section|parent::doc:sectioninfo/parent::doc:section) and
86 count(ancestor::section|ancestor::doc:section) > 5'>
87 <xsl:call-template name='doc:warning'>
88 <xsl:with-param name='message'>section nested deeper than 5 levels</xsl:with-param>
90 <xsl:text>sect5-</xsl:text>
91 <xsl:value-of select='local-name()'/>
93 <xsl:when test='parent::section|parent::doc:section or
94 parent::sectioninfo/parent::section|parent::doc:sectioninfo/parent::doc:section'>
95 <xsl:text>sect</xsl:text>
96 <xsl:value-of select='count(ancestor::section|ancestor::doc:section)'/>
97 <xsl:text>-</xsl:text>
98 <xsl:value-of select='local-name()'/>
100 <xsl:when test='contains(local-name(..), "info")'>
101 <xsl:value-of select='local-name(../..)'/>
102 <xsl:text>-</xsl:text>
103 <xsl:value-of select='local-name()'/>
106 <xsl:value-of select='local-name(..)'/>
107 <xsl:text>-</xsl:text>
108 <xsl:value-of select='local-name()'/>
112 <xsl:with-param name='outline.level'
113 select='count(ancestor::*) - count(parent::*[contains(local-name(), "info")]) - 1'/>
114 <xsl:with-param name='attributes.node'
115 select='../parent::*[contains(local-name(current()), "info")] |
116 parent::*[not(contains(local-name(current()), "info"))]'/>
117 <xsl:with-param name='content'>
118 <xsl:apply-templates mode='doc:body'/>
123 <doc:template name='metadata' xmlns=''>
124 <title>Metadata</title>
126 <para>TODO: Handle all metadata elements, apart from titles.</para>
128 <xsl:template match='*[contains(local-name(), "info")]/*[not(self::title|self::subtitle|self::titleabbrev|self::doc:title|self::doc:subtitle|self::doc:titleabbrev)]'
132 <xsl:template match='author|editor|othercredit |
133 doc:author|doc:editor|doc:othercredit'
135 <xsl:call-template name='doc:make-paragraph'>
136 <xsl:with-param name='style'
137 select='local-name()'/>
138 <xsl:with-param name='content'>
139 <xsl:apply-templates select='personname|surname|firstname|honorific|lineage|othername|contrib |
140 doc:personname|doc:surname|doc:firstname|doc:honorific|doc:lineage|doc:othername|doc:contrib'
145 <xsl:apply-templates select='affiliation|address |
146 doc:affiliation|doc:address'
148 <xsl:apply-templates select='authorblurb|personblurb |
149 doc:authorblurb|doc:personblurb'
152 <xsl:template match='affiliation|doc:affiliation'
154 <xsl:call-template name='doc:make-paragraph'>
155 <xsl:with-param name='style' select='"affiliation"'/>
156 <xsl:with-param name='content'>
157 <xsl:apply-templates mode='doc:body'/>
161 <xsl:template match='address[parent::author|parent::editor|parent::othercredit] |
162 doc:address[parent::doc:author|parent::doc:editor|parent::doc:othercredit]'
164 <xsl:call-template name='doc:make-paragraph'>
165 <xsl:with-param name='style' select='"address"'/>
166 <xsl:with-param name='content'>
167 <xsl:apply-templates mode='doc:body'/>
171 <!-- do not attempt to handle recursive structures -->
172 <xsl:template match='address[not(parent::author|parent::editor|parent::othercredit)] |
173 doc:address[not(parent::doc:author|parent::doc:editor|parent::doc:othercredit)]'
175 <xsl:apply-templates select='node()[not(self::affiliation|self::authorblurb|self::doc:affiliation|self::doc:authorblurb)]'/>
177 <xsl:template match='abstract|doc:abstract'
179 <xsl:if test='title|doc:title'>
180 <xsl:call-template name='doc:make-paragraph'>
181 <xsl:with-param name='style' select='"abstract-title"'/>
182 <xsl:with-param name='content'>
183 <xsl:apply-templates select='title/node()|doc:title/node()'
189 <xsl:apply-templates select='*[not(self::title|self::doc:title)]'
191 <xsl:with-param name='class'>abstract</xsl:with-param>
192 </xsl:apply-templates>
195 <xsl:template match='authorblurb|personblurb |
196 doc:authorblurb|doc:personblurb'
199 <!-- TODO: handle inline markup (eg. emphasis) -->
200 <xsl:template match='surname|firstname|honorific|lineage|othername|contrib|email|shortaffil|jobtitle|orgname|orgdiv|street|pob|postcode|city|state|country|phone|fax|citetitle |
201 doc:surname|doc:firstname|doc:honorific|doc:lineage|doc:othername|doc:contrib|doc:email|doc:shortaffil|doc:jobtitle|doc:orgname|doc:orgdiv|doc:street|doc:pob|doc:postcode|doc:city|doc:state|doc:country|doc:phone|doc:fax|doc:citetitle'
203 <xsl:if test='preceding-sibling::*'>
204 <xsl:call-template name='doc:make-phrase'>
205 <xsl:with-param name='content'>
206 <xsl:text> </xsl:text>
210 <xsl:call-template name='doc:handle-linebreaks'>
211 <xsl:with-param name='style' select='local-name()'/>
212 <xsl:with-param name='content' select='node()'/>
215 <xsl:template match='email|doc:email'
217 <xsl:variable name='address'>
219 <xsl:when test='starts-with(., "mailto:")'>
220 <xsl:value-of select='.'/>
223 <xsl:text>mailto:</xsl:text>
224 <xsl:value-of select='.'/>
228 <xsl:call-template name='doc:make-hyperlink'>
229 <xsl:with-param name='target' select='$address'/>
230 <xsl:with-param name='content'>
231 <xsl:call-template name='doc:handle-linebreaks'>
232 <xsl:with-param name='style'>Hyperlink</xsl:with-param>
237 <!-- otheraddr often contains ulink -->
238 <xsl:template match='otheraddr|doc:otheraddr'
241 <xsl:when test='ulink|doc:ulink'>
242 <xsl:for-each select='ulink|doc:ulink'>
243 <xsl:variable name='prev'
244 select='preceding-sibling::ulink[1] |
245 preceding-sibling::doc:ulink[1]'/>
247 <xsl:when test='$prev'>
249 select='preceding-sibling::node()[generate-id(following-sibling::*[self::ulink|self::doc:ulink][1]) = generate-id(current())]'>
250 <xsl:call-template name='doc:handle-linebreaks'>
251 <xsl:with-param name='style'>otheraddr</xsl:with-param>
255 <xsl:when test='preceding-sibling::node()'>
256 <xsl:call-template name='doc:handle-linebreaks'>
257 <xsl:with-param name='style'>otheraddr</xsl:with-param>
261 <xsl:apply-templates select='.'/>
263 <xsl:if test='*[self::ulink|self::doc:ulink][last()]/following-sibling::node()'>
264 <xsl:call-template name='doc:handle-linebreaks'>
265 <xsl:with-param name='content'
266 select='*[self::ulink|self::doc:ulink][last()]/following-sibling::node()'/>
267 <xsl:with-param name='style'>otheraddr</xsl:with-param>
272 <xsl:call-template name='doc:handle-linebreaks'>
273 <xsl:with-param name='style'>otheraddr</xsl:with-param>
278 <xsl:template match='ulink|doc:ulink'
280 <xsl:call-template name='doc:make-hyperlink'>
281 <xsl:with-param name='target' select='@url'/>
282 <xsl:with-param name='content'>
283 <xsl:call-template name='doc:handle-linebreaks'>
284 <xsl:with-param name='style'>Hyperlink</xsl:with-param>
290 <!-- Cannot round-trip this element -->
291 <xsl:template match='personname|doc:personname'
293 <xsl:apply-templates mode='doc:body'/>
296 <xsl:template match='releaseinfo|doc:releaseinfo'
298 <xsl:call-template name='doc:make-paragraph'>
299 <xsl:with-param name='style'
300 select='"releaseinfo"'/>
304 <xsl:template match='para|doc:para'
306 <xsl:param name='class'/>
308 <xsl:variable name='block'
309 select='blockquote|calloutlist|classsynopsis|funcsynopsis|figure|glosslist|graphic|informalfigure|informaltable|itemizedlist|literallayout|mediaobject|mediaobjectco|note|caution|warning|important|tip|orderedlist|programlisting|revhistory|segmentedlist|simplelist|table|variablelist |
310 doc:blockquote|doc:calloutlist|doc:classsynopsis|doc:funcsynopsis|doc:figure|doc:glosslist|doc:graphic|doc:informalfigure|doc:informaltable|doc:itemizedlist|doc:literallayout|doc:mediaobject|doc:mediaobjectco|doc:note|doc:caution|doc:warning|doc:important|doc:tip|doc:orderedlist|doc:programlisting|doc:revhistory|doc:segmentedlist|doc:simplelist|doc:table|doc:variablelist'/>
313 <xsl:when test='$block'>
314 <xsl:call-template name='doc:make-paragraph'>
315 <xsl:with-param name='style'>
317 <xsl:when test='$class != ""'>
318 <xsl:value-of select='$class'/>
320 <xsl:otherwise>para</xsl:otherwise>
323 <xsl:with-param name='content'
324 select='$block[1]/preceding-sibling::node()'/>
327 <xsl:for-each select='$block'>
328 <xsl:apply-templates select='.'/>
330 <xsl:call-template name='doc:make-paragraph'>
331 <xsl:with-param name='style'>
333 <xsl:when test='$class != ""'>
334 <xsl:value-of select='$class'/>
336 <xsl:otherwise>Normal</xsl:otherwise>
339 <xsl:with-param name='content'
340 select='following-sibling::node()[generate-id(preceding-sibling::*[self::blockquote|self::calloutlist|self::figure|self::glosslist|self::graphic|self::informalfigure|self::informaltable|self::itemizedlist|self::literallayout|self::mediaobject|self::mediaobjectco|self::note|self::caution|self::warning|self::important|self::tip|self::orderedlist|self::programlisting|self::revhistory|self::segmentedlist|self::simplelist|self::table|self::variablelist | self::doc:blockquote|self::doc:calloutlist|self::doc:figure|self::doc:glosslist|self::doc:graphic|self::doc:informalfigure|self::doc:informaltable|self::doc:itemizedlist|self::doc:literallayout|self::doc:mediaobject|self::doc:mediaobjectco|self::doc:note|self::doc:caution|self::doc:warning|self::doc:important|self::doc:tip|self::doc:orderedlist|self::doc:programlisting|self::doc:revhistory|self::doc:segmentedlist|self::doc:simplelist|self::doc:table|self::doc:variablelist][1]) = generate-id(current())]'/>
345 <xsl:call-template name='doc:make-paragraph'>
346 <xsl:with-param name='style'>
348 <xsl:when test='$class != ""'>
349 <xsl:value-of select='$class'/>
351 <xsl:otherwise>Normal</xsl:otherwise>
358 <xsl:template match='simpara|doc:simpara'
360 <xsl:param name='class'/>
362 <xsl:call-template name='doc:make-paragraph'>
363 <xsl:with-param name='style'>
365 <xsl:when test='$class != ""'>
366 <xsl:value-of select='concat("sim-", $class)'/>
368 <xsl:otherwise>simpara</xsl:otherwise>
374 <xsl:template match='emphasis|doc:emphasis'
376 <xsl:call-template name='doc:make-phrase'>
377 <xsl:with-param name='italic'>
379 <xsl:when test='not(@role)'>1</xsl:when>
380 <xsl:otherwise>0</xsl:otherwise>
383 <xsl:with-param name='bold'>
385 <xsl:when test='@role = "bold" or @role = "strong"'>1</xsl:when>
386 <xsl:otherwise>0</xsl:otherwise>
392 <xsl:template match='informalfigure|doc:informalfigure'
394 <xsl:if test='mediaobject/imageobject/imagedata |
395 doc:mediaobject/doc:imageobject/doc:imagedata'>
396 <xsl:call-template name='doc:make-paragraph'>
397 <xsl:with-param name='style' select='"informalfigure-imagedata"'/>
398 <xsl:with-param name='content'>
399 <xsl:call-template name='doc:make-phrase'>
400 <xsl:with-param name='style'/>
401 <xsl:with-param name='content'>
402 <xsl:apply-templates select='mediaobject/imageobject/imagedata/@fileref |
403 doc:mediaobject/doc:imageobject/doc:imagedata/@fileref'
410 <xsl:apply-templates select='caption|doc:caption'
412 <xsl:for-each select='*[not(self::mediaobject|self::doc:mediaobject|self::caption|self::doc:caption)]'>
413 <xsl:call-template name='doc:nomatch'/>
417 <xsl:template match='mediaobject|mediaobjectco |
418 doc:mediaobject|doc:mediaobjectco'
420 <xsl:apply-templates select='objectinfo/title|doc:objectinfo/doc:title'/>
421 <xsl:apply-templates select='objectinfo/subtitle|objectinfo/subtitle |
422 doc:objectinfo/doc:subtitle|doc:objectinfo/doc:subtitle'/>
423 <!-- TODO: indicate error for other children of objectinfo -->
425 <xsl:apply-templates select='*[not(self::objectinfo|self::doc:objectinfo)]'/>
427 <xsl:template match='imageobject|imageobjectco|audioobject|videoobject |
428 doc:imageobject|doc:imageobjectco|doc:audioobject|doc:videoobject'
430 <xsl:apply-templates select='objectinfo/title|doc:objectinfo/doc:title'/>
431 <xsl:apply-templates select='objectinfo/subtitle|doc:objectinfo/doc:subtitle'/>
432 <!-- TODO: indicate error for other children of objectinfo -->
434 <xsl:apply-templates select='areaspec|doc:areaspec'/>
437 <xsl:when test='imagedata|audiodata|videodata |
438 doc:imagedata|doc:audiodata|doc:videodata'>
439 <xsl:call-template name='doc:make-paragraph'>
440 <xsl:with-param name='style'
441 select='concat(local-name(), "-", local-name(imagedata|audiodata|videodata|doc:imagedata|doc:audiodata|doc:videodata))'/>
442 <xsl:with-param name='content'>
443 <xsl:call-template name='doc:make-phrase'>
444 <xsl:with-param name='content'>
445 <xsl:apply-templates select='*/@fileref'
452 <xsl:when test='self::imageobjectco/imageobject/imagedata |
453 self::doc:imageobjectco/doc:imageobject/doc:imagedata'>
454 <xsl:call-template name='doc:make-paragraph'>
455 <xsl:with-param name='style'
456 select='concat(local-name(), "-imagedata")'/>
457 <xsl:with-param name='content'>
458 <xsl:call-template name='doc:make-phrase'>
459 <xsl:with-param name='content'>
460 <xsl:apply-templates select='*/@fileref'
468 <xsl:apply-templates select='calloutlist|doc:calloutlist'/>
470 <xsl:for-each select='*[not(self::imageobject |
476 self::doc:imageobject |
477 self::doc:imagedata |
478 self::doc:audiodata |
479 self::doc:videodata |
481 self::doc:calloutlist)]'>
482 <xsl:call-template name='doc:nomatch'/>
485 <xsl:template match='textobject|doc:textobject'
488 <xsl:when test='objectinfo/title|objectinfo|subtitle |
489 doc:objectinfo/doc:title|doc:objectinfo|doc:subtitle'>
490 <xsl:apply-templates select='objectinfo/title|doc:objectinfo/doc:title'
492 <xsl:apply-templates select='objectinfo/subtitle|doc:objectinfo/doc:subtitle'
494 <!-- TODO: indicate error for other children of objectinfo -->
497 <!-- In a table, the table itself and the caption delimit the textobject -->
498 <xsl:when test='ancestor::table |
499 ancestor::doc:table |
500 ancestor::informaltable |
501 ancestor::doc:informaltable'/>
504 <!-- synthesize a title so that the parent textobject
507 <xsl:call-template name='doc:make-paragraph'>
508 <xsl:with-param name='style' select='"textobject-title"'/>
509 <xsl:with-param name='content'>
510 <xsl:call-template name='doc:make-phrase'>
511 <xsl:with-param name='content'>
512 <xsl:text>Text Object </xsl:text>
513 <xsl:number level='any'/>
521 <xsl:apply-templates select='*[not(self::objectinfo|self::doc:objectinfo)]'
525 <xsl:template match='caption|doc:caption'
528 <xsl:when test='not(*)'>
529 <xsl:call-template name='doc:make-paragraph'>
530 <xsl:with-param name='style' select='"Caption"'/>
531 <xsl:with-param name='content'>
532 <xsl:apply-templates/>
536 <xsl:when test='not(text()) and
537 count(*) = count(para|doc:para) and
539 <xsl:call-template name='doc:make-paragraph'>
540 <xsl:with-param name='style' select='"caption"'/>
541 <xsl:with-param name='content'>
542 <xsl:apply-templates select='*/node()' mode='doc:body'/>
546 <xsl:when test='text()'>
547 <!-- Not valid DocBook -->
548 <xsl:call-template name='doc:nomatch'/>
551 <xsl:call-template name='doc:make-paragraph'>
552 <xsl:with-param name='style' select='"Caption"'/>
553 <xsl:with-param name='content'>
554 <xsl:apply-templates select='*[self::para|self::doc:para][1]/node()'
558 <xsl:for-each select='text()|*[not(self::para|self::doc:para)]|*[self::para|self::doc:para][position() != 1]'>
559 <xsl:call-template name='doc:nomatch'/>
565 <xsl:template match='area|areaspec|doc:area|doc:areaspec'
567 <xsl:call-template name='doc:make-paragraph'>
568 <xsl:with-param name='style' select='local-name()'/>
569 <xsl:with-param name='content'/>
573 <xsl:template match='calloutlist|doc:calloutlist'
575 <xsl:apply-templates select='callout|doc:callout'/>
578 <xsl:template match='callout|doc:callout'
580 <xsl:call-template name='doc:make-paragraph'>
581 <xsl:with-param name='style' select='"callout"'/>
582 <xsl:with-param name='content'>
583 <!-- Normally a para would be the first child of a callout -->
584 <xsl:apply-templates select='*[1][self::para|self::doc:para]/node()'
589 <!-- This is to catch the case where a listitem's first child is not a paragraph.
590 - We may not be able to represent this properly.
592 <xsl:apply-templates select='*[1][not(self::para|self::doc:para)]'
595 <xsl:apply-templates select='*[position() != 1]'
599 <xsl:template match='table|informaltable |
600 doc:table|doc:informaltable'
602 <xsl:call-template name='doc:make-table'>
603 <xsl:with-param name='columns'>
604 <xsl:apply-templates select='tgroup/colspec|doc:tgroup/doc:colspec'
608 <xsl:apply-templates select='textobject|doc:textobject'
611 <xsl:when test='caption|doc:caption'>
612 <xsl:apply-templates select='caption|doc:caption'
615 <xsl:when test='textobject|doc:textobject'>
616 <!-- Synthesize a caption to delimit the textobject -->
617 <xsl:call-template name='doc:make-paragraph'>
618 <xsl:with-param name='style'>Caption</xsl:with-param>
619 <xsl:with-param name='content'/>
620 <xsl:with-param name='attributes.node' select='/..'/>
626 <xsl:template match='colspec|doc:colspec' mode='doc:column'>
627 <xsl:variable name='width'>
629 <xsl:when test='contains(@colwidth, "*")'>
630 <!-- May need to resolve proportional width with other columns -->
631 <xsl:value-of select='substring-before(@colwidth, "*")'/>
634 <xsl:value-of select='@colwidth'/>
639 <xsl:call-template name='doc:make-column'>
640 <xsl:with-param name='width' select='$width'/>
644 <xsl:template match='colspec|doc:colspec' mode='doc:body'/>
646 <xsl:template name='doc:repeat'>
647 <xsl:param name='repeats' select='0'/>
648 <xsl:param name='content'/>
650 <xsl:if test='$repeats > 0'>
651 <xsl:copy-of select='$content'/>
652 <xsl:call-template name='doc:repeat'>
653 <xsl:with-param name='repeats' select='$repeats - 1'/>
654 <xsl:with-param name='content' select='$content'/>
658 <xsl:template match='tgroup|tbody|thead |
659 doc:tgroup|doc:tbody|doc:thead'
661 <xsl:apply-templates mode='doc:body'/>
663 <xsl:template match='row|doc:row' mode='doc:body'>
664 <xsl:call-template name='doc:make-table-row'>
665 <xsl:with-param name='is-header' select='boolean(parent::thead|parent::doc:thead)'/>
669 <xsl:template match='entry|doc:entry' mode='doc:body'>
672 Position = Sum(i,preceding-sibling[@colspan = ""]) + entry[i].@colspan)
675 <xsl:variable name='position'>
676 <xsl:call-template name='doc:sum-sibling'>
677 <xsl:with-param name='sum' select='"1"'/>
678 <xsl:with-param name='node' select='.'/>
682 <xsl:variable name='limit' select='$position + @colspan'/>
684 <xsl:variable name='width.raw'>
686 <xsl:when test='@colspan != ""'>
688 <!-- Select all the colspec nodes which correspond to the
689 column. That is all the nodes between the current
690 column number and the column number plus the span.
693 <xsl:variable name='combinedWidth'>
694 <xsl:call-template name='doc:sum'>
695 <xsl:with-param name='nodes' select='ancestor::*[self::table|self::doc:table|self::informaltable|self::doc:informaltable][1]/*[self::tgroup|self::doc:tgroup]/*[self::colspec|self::doc:colspec][not(position() < $position) and position() < $limit]'/>
696 <xsl:with-param name='sum' select='"0"'/>
699 <xsl:value-of select='$combinedWidth'/>
702 <xsl:value-of select='ancestor::*[self::table|self::doc:table|self::informaltable|self::doc:informaltable][1]/*[self::tgroup|self::doc:tgroup]/*[self::colspec|self::doc:colspec][position() = $position]/@colwidth'/>
707 <xsl:call-template name='doc:make-table-cell'>
708 <xsl:with-param name='width'>
710 <xsl:when test='contains($width.raw, "*")'>
712 <!-- Select all the colspec nodes which correspond to the
713 column. That is all the nodes between the current
714 column number and the column number plus the span.
717 <xsl:value-of select='substring-before($width.raw, "*")'/>
720 <xsl:value-of select='$width.raw'/>
725 <xsl:with-param name='hidden' select='@hidden'/>
726 <xsl:with-param name='rowspan' select='@rowspan'/>
727 <xsl:with-param name='colspan' select='@colspan'/>
729 <xsl:with-param name='content'>
731 <xsl:when test='not(para|doc:para)'>
732 <!-- TODO: check for any block elements -->
733 <xsl:call-template name='doc:make-paragraph'>
734 <xsl:with-param name='style'/>
735 <xsl:with-param name='attributes.node' select='/..'/>
736 <xsl:with-param name='content'/>
740 <xsl:apply-templates mode='doc:body'/>
747 <!-- Calculates the position by adding the
748 count of the preceding siblings where they aren't colspans
749 and adding the colspans of those entries which do.
752 <xsl:template name='doc:sum-sibling'>
753 <xsl:param name='sum'/>
754 <xsl:param name='node'/>
756 <xsl:variable name='add'>
758 <xsl:when test='$node/preceding-sibling::*[self::entry|self::doc:entry]/@colspan != ""'>
759 <xsl:value-of select='$node/preceding-sibling::*[self::entry|self::doc:entry]/@colspan'/>
762 <xsl:value-of select='"1"'/>
768 <xsl:when test='count($node/preceding-sibling::*[self::entry|self::doc:entry]) > 0'>
769 <xsl:call-template name='doc:sum-sibling'>
770 <xsl:with-param name='sum' select='$sum + $add'/>
771 <xsl:with-param name='node'
772 select='$node/preceding-sibling::*[self::entry|self::doc:entry][1]'/>
776 <xsl:value-of select='$sum'/>
782 <xsl:template name='doc:sum'>
783 <xsl:param name='sum' select='"0"'/>
784 <xsl:param name='nodes'/>
786 <xsl:variable name='tmpSum' select='$sum + $nodes[1]/@colwidth'/>
789 <xsl:when test='count($nodes) > 1'>
790 <xsl:call-template name='doc:sum'>
791 <xsl:with-param name='nodes' select='$nodes[position() != 1]'/>
792 <xsl:with-param name='sum' select='$tmpSum'/>
796 <xsl:value-of select='$tmpSum'/>
802 <xsl:template match='*[self::para|self::simpara|self::doc:para|self::doc:simpara]/text()[string-length(normalize-space(.)) != 0]'
804 <xsl:call-template name='doc:handle-linebreaks'/>
807 <xsl:template match='text()[not(parent::para|parent::simpara|parent::literallayout|parent::programlisting | parent::doc:para|parent::doc:simpara|parent::doc:literallayout|parent::doc:programlisting)][string-length(normalize-space(.)) != 0]'
809 <xsl:call-template name='doc:handle-linebreaks'/>
811 <xsl:template match='text()[string-length(normalize-space(.)) = 0]'
813 <xsl:template match='literallayout/text()|programlisting/text() |
814 doc:literallayout/text()|doc:programlisting/text()'
816 <xsl:call-template name='doc:handle-linebreaks'/>
818 <xsl:template name='doc:handle-linebreaks'>
819 <xsl:param name='content' select='.'/>
820 <xsl:param name='style'/>
823 <xsl:when test='not($content)'/>
824 <xsl:when test='contains($content, "
")'>
825 <xsl:call-template name='doc:make-phrase'>
826 <xsl:with-param name='style' select='$style'/>
827 <xsl:with-param name='content'
828 select='substring-before($content, "
")'/>
831 <xsl:call-template name='doc:handle-linebreaks-aux'>
832 <xsl:with-param name='content'
833 select='substring-after($content, "
")'/>
834 <xsl:with-param name='style' select='$style'/>
838 <xsl:call-template name='doc:make-phrase'>
839 <xsl:with-param name='style' select='$style'/>
840 <xsl:with-param name='content' select='$content'/>
846 <!-- pre-condition: leading linefeed has been stripped -->
847 <xsl:template name='doc:handle-linebreaks-aux'>
848 <xsl:param name='content'/>
849 <xsl:param name='style'/>
852 <xsl:when test='contains($content, "
")'>
853 <xsl:call-template name='doc:make-phrase'>
854 <xsl:with-param name='style' select='$style'/>
855 <xsl:with-param name='content'>
856 <xsl:call-template name='doc:make-soft-break'/>
857 <xsl:value-of select='substring-before($content, "
")'/>
860 <xsl:call-template name='doc:handle-linebreaks-aux'>
861 <xsl:with-param name='content'
862 select='substring-after($content, "
")'/>
863 <xsl:with-param name='style' select='$style'/>
867 <xsl:call-template name='doc:make-phrase'>
868 <xsl:with-param name='style' select='$style'/>
869 <xsl:with-param name='content'>
870 <xsl:call-template name='doc:make-soft-break'/>
871 <xsl:value-of select='$content'/>
878 <xsl:template match='authorblurb|formalpara|legalnotice|note|caution|warning|important|tip |
879 doc:authorblurb|doc:formalpara|doc:legalnotice|doc:note|doc:caution|doc:warning|doc:important|doc:tip'
881 <xsl:apply-templates select='*'>
882 <xsl:with-param name='class'>
883 <xsl:value-of select='local-name()'/>
885 </xsl:apply-templates>
888 <xsl:template match='blockquote|doc:blockquote'
890 <xsl:apply-templates select='blockinfo|title|doc:info|doc:title'
892 <xsl:with-param name='class'>
893 <xsl:value-of select='local-name()'/>
895 </xsl:apply-templates>
896 <xsl:apply-templates select='*[not(self::blockinfo|self::title|self::attribution|self::doc:info|self::doc:title|self::doc:attribution)]'
898 <xsl:with-param name='class' select='"blockquote"'/>
899 </xsl:apply-templates>
900 <xsl:if test='attribution|doc:attribution'>
901 <xsl:call-template name='doc:make-paragraph'>
902 <xsl:with-param name='style' select='"blockquote-attribution"'/>
903 <xsl:with-param name='content'>
904 <xsl:call-template name='doc:make-phrase'>
905 <xsl:with-param name='content'>
906 <xsl:apply-templates select='attribution/node()|doc:attribution/node()'/>
914 <xsl:template match='literallayout|programlisting|doc:literallayout|doc:programlisting'
916 <xsl:param name='class'/>
918 <xsl:call-template name='doc:make-paragraph'>
919 <xsl:with-param name='style' select='local-name()'/>
923 <xsl:template match='bridgehead|doc:bridgehead'
925 <xsl:call-template name='doc:make-paragraph'>
926 <xsl:with-param name='style' select='"bridgehead"'/>
930 <xsl:template match='itemizedlist|orderedlist |
931 doc:itemizedlist|doc:orderedlist'
933 <xsl:apply-templates select='listitem|doc:listitem'
937 <xsl:template match='listitem|doc:listitem'
939 <xsl:call-template name='doc:make-paragraph'>
940 <xsl:with-param name='style'
941 select='concat(local-name(..),
942 count(ancestor::itemizedlist|ancestor::orderedlist|ancestor::doc:itemizedlist|ancestor::doc:orderedlist))'/>
943 <xsl:with-param name='is-listitem' select='true()'/>
945 <xsl:with-param name='content'>
946 <!-- Normally a para would be the first child of a listitem -->
947 <xsl:apply-templates select='*[1][self::para|self::doc:para]/node()'
952 <!-- This is to catch the case where a listitem's first child is not a paragraph.
953 - We may not be able to represent this properly.
955 <xsl:apply-templates select='*[1][not(self::para|self::doc:para)]'
956 mode='doc:list-continue'/>
958 <xsl:apply-templates select='*[position() != 1]'
959 mode='doc:list-continue'/>
962 <xsl:template match='para|doc:para' mode='doc:list-continue'>
963 <xsl:apply-templates select='.'
965 <xsl:with-param name='class' select='"para-continue"'/>
966 </xsl:apply-templates>
968 <!-- non-paragraph elements in a listitem are rolled back into
969 the list item upon conversion.
971 <xsl:template match='*' mode='doc:list-continue'>
972 <xsl:apply-templates select='.' mode='doc:body'/>
975 <xsl:template match='variablelist|doc:variablelist'
977 <xsl:apply-templates select='*[not(self::varlistentry|self::doc:varlistentry)]'/>
979 <xsl:call-template name='doc:make-table'>
980 <xsl:with-param name='columns'>
981 <xsl:call-template name='doc:make-column'>
982 <xsl:with-param name='width' select='"1"'/>
984 <xsl:call-template name='doc:make-column'>
985 <xsl:with-param name='width' select='"3"'/>
988 <xsl:with-param name='rows'>
989 <xsl:apply-templates select='varlistentry|doc:varlistentry'/>
993 <xsl:template match='varlistentry|doc:varlistentry'
995 <xsl:call-template name='doc:make-table-row'>
996 <xsl:with-param name='content'>
997 <xsl:call-template name='doc:make-table-cell'>
998 <xsl:with-param name='content'>
999 <xsl:call-template name='doc:make-paragraph'>
1000 <xsl:with-param name='style' select='"variablelist-term"'/>
1001 <xsl:with-param name='content'>
1002 <xsl:apply-templates select='*[self::term|self::doc:term][1]/node()'
1004 <xsl:for-each select='*[self::term|self::doc:term][position() != 1]'>
1005 <xsl:call-template name='doc:make-phrase'>
1006 <xsl:with-param name='content'>
1007 <xsl:call-template name='doc:make-soft-break'/>
1009 </xsl:call-template>
1010 <xsl:apply-templates/>
1013 </xsl:call-template>
1015 </xsl:call-template>
1016 <xsl:call-template name='doc:make-table-cell'>
1017 <xsl:with-param name='content'>
1018 <xsl:apply-templates select='listitem/node()|doc:listitem/node()'
1021 </xsl:call-template>
1023 </xsl:call-template>
1026 <!-- These elements are not displayed.
1027 - However, they may need to be added (perhaps as hidden text)
1028 - for round-tripping.
1030 <xsl:template match='anchor|areaset|audiodata|audioobject|
1036 doc:anchor|doc:areaset|doc:audiodata|doc:audioobject|
1039 doc:indexterm|doc:itermset|
1044 <xsl:template match='*' name='doc:nomatch'>
1045 <xsl:param name='node' select='.'/>
1048 <xsl:value-of select='local-name($node)'/>
1049 <xsl:if test='namespace-uri($node) != ""'>
1050 <xsl:text> [</xsl:text>
1051 <xsl:value-of select='namespace-uri($node)'/>
1052 <xsl:text>]</xsl:text>
1054 <xsl:text> encountered</xsl:text>
1055 <xsl:if test='$node/parent::*'>
1056 <xsl:text> in </xsl:text>
1057 <xsl:value-of select='local-name($node/parent::*)'/>
1059 <xsl:text>, but no template matches.</xsl:text>
1062 <xsl:for-each select='$node'>
1064 <xsl:when test='self::abstract |
1073 self::bibliography |
1080 self::classsynopsis |
1082 self::constraintdef |
1089 self::funcsynopsis |
1098 self::imageobjectco |
1102 self::informalequation |
1103 self::informalexample |
1104 self::informalfigure |
1108 self::mediaobjectco |
1116 self::printhistory |
1118 self::programlisting |
1119 self::programlistingco |
1125 self::refdescriptor |
1127 self::refentrytitle |
1137 self::refsynopsisdiv |
1143 self::segmentedlist |
1149 self::simplemsgentry |
1151 self::stepalternatives |
1160 self::doc:abstract |
1164 self::doc:appendix |
1165 self::doc:artheader |
1166 self::doc:authorgroup |
1167 self::doc:bibliodiv |
1168 self::doc:biblioentry |
1169 self::doc:bibliography |
1170 self::doc:bibliomixed |
1171 self::doc:bibliomset |
1172 self::doc:biblioset |
1173 self::doc:bridgehead |
1174 self::doc:calloutlist |
1176 self::doc:classsynopsis |
1177 self::doc:colophon |
1178 self::doc:constraintdef |
1179 self::doc:copyright |
1180 self::doc:dedication |
1181 self::doc:epigraph |
1182 self::doc:equation |
1185 self::doc:funcsynopsis |
1186 self::doc:glossary |
1187 self::doc:glossdef |
1188 self::doc:glossdiv |
1189 self::doc:glossentry |
1190 self::doc:glosslist |
1192 self::doc:highlights |
1193 self::doc:imageobject |
1194 self::doc:imageobjectco |
1196 self::doc:indexdiv |
1197 self::doc:indexentry |
1198 self::doc:informalequation |
1199 self::doc:informalexample |
1200 self::doc:informalfigure |
1202 self::doc:lotentry |
1203 self::doc:mediaobject |
1204 self::doc:mediaobjectco |
1206 self::doc:msgentry |
1209 self::doc:partintro |
1210 self::doc:personblurb |
1212 self::doc:printhistory |
1213 self::doc:procedure |
1214 self::doc:programlisting |
1215 self::doc:programlistingco |
1216 self::doc:publisher |
1217 self::doc:qandadiv |
1218 self::doc:qandaentry |
1219 self::doc:qandaset |
1220 self::doc:question |
1221 self::doc:refdescriptor |
1222 self::doc:refentry |
1223 self::doc:refentrytitle |
1224 self::doc:reference |
1227 self::doc:refnamediv |
1228 self::doc:refpurpose |
1229 self::doc:refsect1 |
1230 self::doc:refsect2 |
1231 self::doc:refsect3 |
1232 self::doc:refsection |
1233 self::doc:refsynopsisdiv |
1235 self::doc:screenco |
1236 self::doc:screenshot |
1238 self::doc:seglistitem |
1239 self::doc:segmentedlist |
1240 self::doc:segtitle |
1242 self::doc:setindex |
1244 self::doc:simplelist |
1245 self::doc:simplemsgentry |
1247 self::doc:stepalternatives |
1248 self::doc:subjectset |
1249 self::doc:substeps |
1251 self::doc:textobject |
1253 self::doc:videodata |
1254 self::doc:videoobject |
1256 self::*[not(starts-with(local-name(), "informal")) and contains(local-name(), "info")]'>
1257 <xsl:call-template name='doc:make-paragraph'>
1258 <xsl:with-param name='style' select='"blockerror"'/>
1259 <xsl:with-param name='content'>
1260 <xsl:call-template name='doc:make-phrase'>
1261 <xsl:with-param name='content'>
1262 <xsl:value-of select='local-name()'/>
1263 <xsl:if test='namespace-uri() != ""'>
1264 <xsl:text> [</xsl:text>
1265 <xsl:value-of select='namespace-uri()'/>
1266 <xsl:text>]</xsl:text>
1268 <xsl:text> encountered</xsl:text>
1269 <xsl:if test='parent::*'>
1270 <xsl:text> in </xsl:text>
1271 <xsl:value-of select='local-name(parent::*)'/>
1273 <xsl:text>, but no template matches.</xsl:text>
1275 </xsl:call-template>
1277 </xsl:call-template>
1279 <!-- Some elements are sometimes blocks, sometimes inline
1280 <xsl:when test='self::affiliation |
1291 self::contractsponsor |
1300 self::publishername |
1303 self::doc:affiliation |
1305 self::doc:attribution |
1307 self::doc:collabname |
1308 self::doc:confdates |
1309 self::doc:confgroup |
1311 self::doc:confsponsor |
1312 self::doc:conftitle |
1313 self::doc:contractnum |
1314 self::doc:contractsponsor |
1316 self::doc:corpauthor |
1317 self::doc:corpcredit |
1318 self::doc:corpname |
1321 self::doc:jobtitle |
1322 self::doc:personname |
1323 self::doc:publishername |
1329 <xsl:call-template name='doc:make-phrase'>
1330 <xsl:with-param name='style' select='"inlineerror"'/>
1331 <xsl:with-param name='content'>
1332 <xsl:value-of select='local-name()'/>
1333 <xsl:text> encountered</xsl:text>
1334 <xsl:if test='parent::*'>
1335 <xsl:text> in </xsl:text>
1336 <xsl:value-of select='local-name(parent::*)'/>
1338 <xsl:text>, but no template matches.</xsl:text>
1340 </xsl:call-template>
1346 <xsl:template match='*' mode='doc:copy'>
1348 <xsl:apply-templates select='@*' mode='doc:copy'/>
1349 <xsl:apply-templates mode='doc:copy'/>
1352 <xsl:template match='@*' mode='doc:copy'>
1356 <!-- Stubs: the importing stylesheet must override these -->
1358 <!-- stub template for creating a paragraph -->
1359 <xsl:template name='doc:make-paragraph'>
1361 <!-- stub template for creating a phrase -->
1362 <xsl:template name='doc:make-phrase'>
1365 <!-- stub template for inserting attributes -->
1366 <xsl:template name='doc:attributes'/>
1368 <!-- emit a message -->
1369 <xsl:template name='doc:warning'>
1370 <xsl:param name='message'/>
1372 <xsl:message>WARNING: <xsl:value-of select='$message'/></xsl:message>