1 <xsl:stylesheet version="1.0"
2 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3 xmlns:sfa="http://developer.apple.com/namespaces/sfa"
4 xmlns:sf="http://developer.apple.com/namespaces/sf"
5 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6 xmlns:sl="http://developer.apple.com/namespaces/sl"
7 xmlns:xi="http://www.w3.org/2001/XInclude"
8 xmlns:doc='http://docbook.org/ns/docbook'
9 xmlns:rnd='http://docbook.org/ns/docbook/roundtrip'
10 exclude-result-prefixes='doc rnd xi'>
12 <xsl:import href='dbk2wp.xsl'/>
14 <xsl:output method="xml" indent='yes' encoding='ascii'/>
16 <!-- ********************************************************************
17 $Id: dbk2pages.xsl 7701 2008-02-22 06:07:31Z balls $
18 ********************************************************************
20 This file is part of the XSL DocBook Stylesheet distribution.
21 See ../README or http://docbook.sf.net/release/xsl/current/ for
22 copyright and other information.
24 ******************************************************************** -->
26 <xsl:include href='../VERSION'/>
27 <xsl:include href='param.xsl'/>
29 <xsl:variable name='templatedoc' select='document($pages.template)'/>
31 <!-- Find all tables in the document once,
32 as we will be iterating over them in more than one place.
34 <xsl:variable name='rnd:pages-tables'
35 select='//doc:table|//doc:informaltable'/>
37 <!-- Lookup style identifiers from their user-visible name -->
38 <xsl:variable name='paragraph-styles'
39 select='$templatedoc//sf:paragraphstyle'/>
40 <xsl:variable name='character-styles'
41 select='$templatedoc//sf:characterstyle'/>
43 <xsl:template match="/" name='pages.top'>
44 <xsl:param name='doc' select='/'/>
46 <xsl:if test='not($pages.template)'>
47 <xsl:message terminate='yes'>Please specify the template document with the "pages.template" parameter</xsl:message>
49 <xsl:if test='not($templatedoc)'>
50 <xsl:message terminate='yes'>Unable to open template document "<xsl:value-of select='$pages.template'/>"</xsl:message>
54 sfa:ID="SLPublicationModel-0"
55 sl:version="72007061400"
56 sl:generator="slingshot"
57 sl:app_build_date="Sep 26 2007, 14:46:11">
59 <xsl:apply-templates select='$templatedoc/sl:document/*[not(self::sf:text-storage)]'
62 <xsl:apply-templates select='$doc/*'
65 <xsl:apply-templates select='$templatedoc/sl:document/sf:text-storage/following-sibling::*'
70 <xsl:template match='sf:calc-engine' mode='doc:copy'>
72 <xsl:apply-templates select='@*' mode='doc:copy'/>
75 <xsl:when test='not(sf:calc-engine-entities)'>
76 <xsl:call-template name='rnd:pages-make-calc-engine-entities'/>
77 <xsl:apply-templates mode='doc:copy'/>
80 <xsl:apply-templates mode='doc:copy'/>
85 <xsl:template name='rnd:pages-make-calc-engine-entities'
86 match='sf:calc-engine-entities' mode='doc:copy'>
87 <sf:calc-engine-entities>
89 <xsl:when test='self::calc-engine-entities'>
90 <xsl:apply-templates select='@*' mode='doc:copy'/>
91 <xsl:apply-templates mode='doc:copy'/>
94 <xsl:attribute name='sfa:ID'>
95 <xsl:text>DocBookRoundtrip-1</xsl:text>
100 <xsl:for-each select='$rnd:pages-tables'>
101 <xsl:variable name='num' select='position()'/>
103 <xsl:variable name='num-cells'
104 select='count(doc:tgroup/*/doc:row/doc:entry)'/>
105 <xsl:variable name='num-rows' select='count(doc:tgroup/*/doc:row)'/>
106 <xsl:variable name='num-cols' select='$num-cells div $num-rows'/>
108 <sf:tabular-model sfa:ID='SFTTableModel-{$num}' sf:name='Unnamed Table'
110 sf:num-header-rows='{count(doc:tgroup/doc:thead/doc:row)}' sf:num-footer-rows='{count(doc:tgroup/doc:tfoot/doc:row)}'
111 sf:num-header-columns='0' sf:name-is-visible='false' sf:grouping-enabled='false'>
112 <sf:grid sfa:ID='SFTTableGrid-{$num}'
113 sf:ocnt='{$num-cells}'
114 sf:numcols='{$num-cols}'
115 sf:numrows='{$num-rows}'
116 sf:hiddennumcols='0' sf:hiddennumrows='0'>
117 <sf:columns sf:count='{$num-cols}'>
118 <xsl:apply-templates select='doc:tgroup/doc:colspec'
119 mode='rnd:pages-table-colspec'/>
121 <sf:vertical-gridline-styles sf:array-size='0'/> <!-- TODO: borders -->
122 <sf:rows sf:count='{$num-rows}'>
123 <xsl:call-template name='rnd:pages-make-table-rowspecs'>
124 <xsl:with-param name='number' select='$num-rows'/>
127 <sf:horizontal-gridline-styles sf:array-size='0'/> <!-- TODO: borders -->
128 <sf:datasource sfa:ID='SFTConcreteTableDataSource-{$num}'>
129 <xsl:apply-templates select='doc:tgroup/doc:thead/doc:row'
130 mode='rnd:pages-table-data'>
131 <xsl:with-param name='start-row' select='0'/>
132 </xsl:apply-templates>
133 <xsl:apply-templates select='doc:tgroup/doc:tbody/doc:row'
134 mode='rnd:pages-table-data'>
135 <xsl:with-param name='start-row' select='count(doc:tgroup/doc:thead/doc:row)'/>
136 </xsl:apply-templates>
137 <xsl:apply-templates select='doc:tgroup/doc:tfoot/doc:row'
138 mode='rnd:pages-table-data'>
139 <xsl:with-param name='start-row' select='count(doc:tgroup/doc:thead/doc:row) + count(doc:tgroup/doc:tbody/doc:row)'/>
140 </xsl:apply-templates>
142 <sf:sort sfa:ID='DocBookPagesTableNSArray-{$num}'>
143 <sf:sort-spec sfa:ID='SFTTableSortSpec-{$num}'
144 sf:sort-col='0' sf:sort-order='true'/>
146 <sf:filterset sfa:ID='SFTTableFilterSet-{$num}'
147 sf:type='0' sf:enabled='false' sf:spec-count='1'>
148 <sf:filterspec sfa:ID='SFTTableFilterSpec-{$num}'
149 sf:filtercol='0' sf:predicate='1' sf:keyscale='0' sf:key1=''/>
151 <sf:cell-comment-mapping sfa:ID='DocBookPagesTableCellCommentNSMutableDictionary-{$num}'/>
152 <sf:error_warning_mapping sfa:ID='DocBookPagesTableErrorWarningNSMutableDictionary-{$num}'/>
156 </sf:calc-engine-entities>
159 <xsl:template match='doc:row' mode='rnd:pages-table-data'>
160 <xsl:param name='start-row' select='0'/>
161 <xsl:apply-templates mode='rnd:pages-table-data'>
162 <xsl:with-param name='row'
163 select='$start-row + count(preceding-sibling::doc:row)'/>
164 </xsl:apply-templates>
166 <xsl:template match='doc:entry' mode='rnd:pages-table-data'>
167 <xsl:param name='row' select='0'/>
168 <sf:text-cell sf:flags='4' sf:col='{count(preceding-sibling::doc:entry)}' sf:row='{$row}'>
169 <sf:cell-style-ref sfa:IDREF='SFTCellStyle-3'/>
170 <sf:content-size sfa:w='60' sfa:h='25'/>
173 <xsl:when test='count(.//*) > 2'>
175 <sf:stylesheet-ref sfa:IDREF="SFSStylesheet-1"/>
177 <xsl:apply-templates/>
182 <xsl:attribute name='sfa:string'>
183 <xsl:apply-templates mode='rnd:pages-table-text'/>
191 <xsl:template name='rnd:pages-make-table-rowspecs'>
192 <xsl:param name='number' select='0'/>
195 <xsl:when test='$number <= 0'/>
197 <sf:grid-row sf:height='25' sf:fitting-height='25'/>
198 <xsl:call-template name='rnd:pages-make-table-rowspecs'>
199 <xsl:with-param name='number' select='$number - 1'/>
205 <xsl:template match='doc:colspec' mode='rnd:pages-table-colspec'>
206 <sf:grid-column sf:width='{@colwidth}' sf:preferred-width='{@colwidth}'
207 sf:fitting-width='{@colwidth}'/>
210 <xsl:template name='doc:make-body'>
211 <xsl:param name='content'>
212 <xsl:apply-templates mode='doc:body'/>
215 <sf:text-storage sf:kind='body' sfa:ID='SFWPStorage-7'>
216 <sf:stylesheet-ref sfa:IDREF='SFSStylesheet-1'/>
218 <xsl:if test='$rnd:pages-tables'>
220 <xsl:for-each select='$rnd:pages-tables'>
221 <xsl:variable name='num' select='position()'/>
223 <sf:attachment sfa:ID='SFTTableAttachment-{$num}'
224 sfa:sfclass='' sf:kind='tabular-attachment'>
225 <sf:tabular-info sfa:ID='SFTTableInfo-{$num}'>
226 <sf:geometry sfa:ID='DocBookAffineGeometry-{$num}'
227 sf:sizesLocked='true'>
228 <sf:naturalSize sfa:w='480' sfa:h='126'/>
229 <sf:size sfa:w='480' sfa:h='126'/>
230 <sf:position sfa:x='0' sfa:y='0'/>
233 <sf:tabular-style-ref sfa:IDREF='SFTTableStyle-0'/>
235 <sf:tabular-model-ref sfa:IDREF='SFTTableModel-{$num}'/>
237 <sf:position sfa:x='0' sfa:y='0'/>
245 <sf:page-start sf:page-index='0'/>
246 <sf:container-hint sf:page-index="0" sf:cindex="0" sf:sindex="0" sf:lindex="0" sf:frame-x="56.692913055419922" sf:frame-y="56.692913055419922" sf:frame-w="481.61416625976562" sf:frame-h="714" sf:anchor-loc="0"/>
248 <sf:section sf:name="Chapter 1" sf:style="section-style-0">
249 <sf:layout sf:style="layout-style-20">
250 <xsl:copy-of select='$content'/>
257 <xsl:template name='doc:make-subsection'>
258 <xsl:param name='content'>
259 <xsl:apply-templates mode='doc:body'/>
262 <xsl:copy-of select='$content'/>
265 <xsl:template name='doc:make-paragraph'>
266 <xsl:param name='style' select='"unknown"'/>
267 <xsl:param name='content'>
268 <xsl:apply-templates mode='doc:body'/>
270 <xsl:param name='outline.level' select='0'/>
271 <xsl:param name='attributes.node' select='.'/>
274 <xsl:if test='$style != ""'>
275 <xsl:attribute name='sf:style'>
276 <xsl:call-template name='doc:lookup-paragraph-style'>
277 <xsl:with-param name='style' select='$style'/>
282 <xsl:call-template name='attributes'>
283 <xsl:with-param name='node' select='$attributes.node'/>
286 <xsl:copy-of select='$content'/>
291 <xsl:template name='doc:make-phrase'>
292 <xsl:param name='style' select='""'/>
293 <xsl:param name='italic' select='0'/>
294 <xsl:param name='bold' select='0'/>
295 <xsl:param name='content'>
296 <xsl:apply-templates mode='doc:phrase'/>
299 <!-- TODO: handle italic and bold parameters -->
302 <xsl:when test='$style != ""'>
304 <xsl:attribute name='sf:style'>
305 <xsl:call-template name='doc:lookup-character-style'>
306 <xsl:with-param name='style' select='$style'/>
310 <xsl:copy-of select='$content'/>
314 <xsl:copy-of select='$content'/>
319 <xsl:template name='doc:make-hyperlink'>
320 <xsl:param name='target'/>
321 <xsl:param name='content'>
322 <xsl:apply-templates mode='doc:body'/>
325 <sf:link href='{$target}'>
327 <xsl:attribute name='sf:style'>
328 <xsl:call-template name='doc:lookup-character-style'>
329 <xsl:with-param name='style'>email</xsl:with-param>
332 <xsl:copy-of select='$content'/>
337 <xsl:template name='doc:make-table'>
338 <xsl:param name='columns'/>
339 <xsl:param name='content'>
340 <xsl:apply-templates mode='doc:body'/>
343 <xsl:variable name='this' select='.'/>
346 <xsl:attribute name='sf:style'>
347 <xsl:call-template name='doc:lookup-paragraph-style'>
348 <xsl:with-param name='style' select='"para"'/>
352 <sf:attachment-ref sf:kind='tabular-attachment'>
353 <xsl:attribute name='sfa:IDREF'>
354 <xsl:text>SFTTableAttachment-</xsl:text>
355 <xsl:for-each select='$rnd:pages-tables'>
356 <xsl:if test='generate-id() = generate-id($this)'>
357 <xsl:value-of select='position()'/>
366 <xsl:template name='doc:make-column'>
367 <xsl:param name='width' select='0'/>
370 <xsl:template name='doc:make-table-row'>
371 <xsl:param name='content'>
372 <xsl:apply-templates mode='doc:body'/>
374 <xsl:param name='is-header' select='false()'/>
377 <xsl:template name='doc:make-table-cell'>
378 <xsl:param name='width' select='0'/>
379 <xsl:param name='hidden' select='false()'/>
380 <xsl:param name='rowspan' select='1'/>
381 <xsl:param name='colspan' select='1'/>
382 <xsl:param name='content'>
383 <xsl:apply-templates mode='doc:body'/>
387 <xsl:template name='doc:make-soft-break'>
391 <xsl:template name='attributes'>
392 <xsl:param name='node' select='.'/>
394 <xsl:for-each select='$node/@*'>
396 <xsl:attribute name='sf:style'>
397 <xsl:call-template name='doc:lookup-character-style'>
398 <xsl:with-param name='style'>attribute-name</xsl:with-param>
401 <xsl:value-of select='name()'/>
404 <xsl:attribute name='sf:style'>
405 <xsl:call-template name='doc:lookup-character-style'>
406 <xsl:with-param name='style'>attribute-value</xsl:with-param>
409 <xsl:value-of select='.'/>
414 <xsl:template name='doc:lookup-paragraph-style'>
415 <xsl:param name='style'/>
417 <xsl:variable name='style.cooked'>
419 <xsl:when test='$style = "Normal"'>para</xsl:when>
421 <xsl:value-of select='$style'/>
426 <xsl:if test='not($paragraph-styles[@sf:name = $style.cooked])'>
427 <xsl:message>unable to find paragraph style "<xsl:value-of select='$style.cooked'/>"</xsl:message>
430 <xsl:value-of select='$paragraph-styles[@sf:name = $style.cooked]/@sf:ident'/>
432 <xsl:template name='doc:lookup-character-style'>
433 <xsl:param name='style'/>
435 <xsl:if test='not($character-styles[@sf:name = $style])'>
436 <xsl:message>unable to find character style "<xsl:value-of select='$style'/>"</xsl:message>
439 <xsl:value-of select='$character-styles[@sf:name = $style]/@sf:ident'/>