|
5 | 5 | - komplexa sub, sup |
6 | 6 | - länkar, e-postadresser |
7 | 7 | --> |
8 | | -<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
| 8 | +<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
9 | 9 | xmlns:dtb="http://www.daisy.org/z3986/2005/dtbook/" |
10 | 10 | xmlns:xs="http://www.w3.org/2001/XMLSchema" |
11 | 11 | exclude-result-prefixes="dtb xs obfl dotify xtd" |
|
40 | 40 | <xsl:param name="l10nEndnotesPageHeader" select="'Footnotes'"/> |
41 | 41 | <xsl:param name="l10ntable" select="'Table'"/> |
42 | 42 | <xsl:param name="l10ntablepart" select="'Table part'"/> |
43 | | - |
| 43 | + |
44 | 44 | <xsl:key name="noterefs" match="dtb:noteref" use="substring-after(@idref, '#')"/> |
45 | 45 |
|
46 | 46 | <xsl:template match="/"> |
|
54 | 54 | <xsl:apply-templates/> |
55 | 55 | </obfl> |
56 | 56 | </xsl:template> |
57 | | - |
| 57 | + |
58 | 58 | <xsl:template name="insertLayoutMaster"> |
59 | 59 | <xsl:copy-of select="obfl:insertLayoutMaster( |
60 | 60 | count(//dtb:note[key('noterefs', @id)[ancestor::dtb:frontmatter]]), |
61 | 61 | count(//dtb:note[key('noterefs', @id)[not(ancestor::dtb:frontmatter)]]))"/> |
62 | 62 | </xsl:template> |
63 | | - |
| 63 | + |
64 | 64 | <xsl:template name="insertTOCVolumeTemplate"> |
65 | 65 | <xsl:variable name="insertToc" select="$toc-depth > 0 and (//dtb:level1[@class='toc'] or //dtb:level1[dtb:list[@class='toc']])" as="xs:boolean"/> |
66 | 66 | <xsl:if test="$insertToc"> |
|
106 | 106 | </xsl:template> |
107 | 107 |
|
108 | 108 | <xsl:template name="insertNoteCollection"> |
109 | | - <xsl:param name="footnotesInFrontMatter" select="//dtb:note[key('noterefs', @id)[ancestor::dtb:frontmatter]]"/> |
| 109 | + <xsl:param name="footnotesInFrontMatter" select="//dtb:note[key('noterefs', @id)[ancestor::dtb:frontmatter]]"/> |
110 | 110 | <xsl:param name="footnotesNotInFrontMatter" select="//dtb:note[key('noterefs', @id)[not(ancestor::dtb:frontmatter)]]"/> |
111 | 111 | <xsl:if test="count($footnotesInFrontMatter)>0"> |
112 | 112 | <collection name="footnotes-front"> |
113 | 113 | <xsl:apply-templates select="$footnotesInFrontMatter" mode="collectNotes"> |
114 | 114 | <xsl:with-param name="afix">.A</xsl:with-param> |
115 | 115 | </xsl:apply-templates> |
116 | | - <!-- |
| 116 | + <!-- |
117 | 117 | <item id="note1" text-indent="4">1).</item> --> |
118 | 118 | </collection> |
119 | 119 | </xsl:if> |
|
122 | 122 | <xsl:apply-templates select="$footnotesNotInFrontMatter" mode="collectNotes"> |
123 | 123 | <xsl:with-param name="afix">.B</xsl:with-param> |
124 | 124 | </xsl:apply-templates> |
125 | | - <!-- |
| 125 | + <!-- |
126 | 126 | <item id="note1" text-indent="4">1).</item> --> |
127 | 127 | </collection> |
128 | 128 | </xsl:if> |
129 | 129 | </xsl:template> |
130 | | - |
| 130 | + |
131 | 131 | <xsl:template match="dtb:noteref" priority="10"> |
132 | 132 | <xsl:apply-templates select="." mode="inline-mode"/> |
133 | 133 | <xsl:variable name="afix"> |
|
141 | 141 | <xsl:otherwise><xsl:message terminate="no">Only fragment identifier supported: <xsl:value-of select="@idref"/></xsl:message></xsl:otherwise> |
142 | 142 | </xsl:choose> |
143 | 143 | </xsl:template> |
144 | | - |
| 144 | + |
145 | 145 | <xsl:template match="dtb:note" mode="collectNotes"> |
146 | 146 | <xsl:param name="afix"/> |
147 | 147 | <item id="{concat(@id, $afix)}"> |
|
152 | 152 | <xsl:choose> |
153 | 153 | <xsl:when test="self::text()"> |
154 | 154 | <xsl:message terminate="yes">Unexpected text contents in "note" element.</xsl:message> |
155 | | - </xsl:when> |
| 155 | + </xsl:when> |
156 | 156 | <xsl:when test="position()=1 and count(text())>0"> <!-- and an element --> |
157 | 157 | <xsl:copy> |
158 | 158 | <xsl:copy-of select="@*[not(local-name()='first-line-indent' or local-name()='text-indent' or local-name()='block-indent')]"/> |
|
181 | 181 | </sequence> |
182 | 182 | </xsl:if> |
183 | 183 | </xsl:template> |
184 | | - |
| 184 | + |
185 | 185 | <!-- Don't output a sequence if there is nothing left when level1@class='backCoverText', level1@class='rearjacketcopy' and level1@class='colophon' has been moved --> |
186 | 186 | <xsl:template match="dtb:rearmatter" mode="sequence-mode"> |
187 | 187 | <xsl:if test="*[not(self::dtb:level1[@class='backCoverText' or @class='rearjacketcopy' or @class='colophon' or @class='toc' or dtb:list[@class='toc'] |
|
193 | 193 | </sequence> |
194 | 194 | </xsl:if> |
195 | 195 | </xsl:template> |
196 | | - |
| 196 | + |
197 | 197 | <!-- Don't output a sequence if there is nothing left when doctitle, docauthor and level1@class='backCoverText', level1@class='rearjacketcopy' and level1@class='colophon' has been moved --> |
198 | 198 | <xsl:template match="dtb:frontmatter" mode="pre-volume-mode"> |
199 | 199 | <xsl:if test="*[not(self::dtb:doctitle or self::dtb:docauthor or self::dtb:level1[@class='backCoverText' or @class='rearjacketcopy' or @class='colophon' or @class='toc' or dtb:list[@class='toc']])]"> |
200 | 200 | <sequence master="front"> |
201 | 201 | <block break-before="page"> |
202 | 202 | <xsl:apply-templates/> |
203 | | - <!-- |
| 203 | + <!-- |
204 | 204 | <xsl:variable name="tree"> |
205 | 205 | <xsl:apply-templates/> |
206 | 206 | </xsl:variable> |
|
213 | 213 | <xsl:template match="*|comment()|processing-instruction()" mode="strip-id"> |
214 | 214 | <xsl:call-template name="copy-without-id"/> |
215 | 215 | </xsl:template> |
216 | | - |
| 216 | + |
217 | 217 | <xsl:template name="copy-without-id"> |
218 | 218 | <xsl:copy> |
219 | 219 | <xsl:copy-of select="@*[name()!='id']"/> |
220 | 220 | <xsl:apply-templates mode="strip-id"/> |
221 | 221 | </xsl:copy> |
222 | 222 | </xsl:template> |
223 | | - |
| 223 | + |
224 | 224 | <xsl:template match="dtb:level1[@class='toc' or dtb:list[@class='toc']]"></xsl:template> |
225 | 225 | <xsl:template match="dtb:level1[@class='toc' or dtb:list[@class='toc']]" mode="toc"></xsl:template> |
226 | 226 |
|
227 | 227 | <xsl:template match="dtb:level1[(@class='backCoverText' or @class='rearjacketcopy' or @class='colophon') and (parent::dtb:frontmatter or parent::dtb:rearmatter)]" mode="toc"></xsl:template> |
228 | | - |
| 228 | + |
229 | 229 | <xsl:template match="dtb:level1[ |
230 | 230 | count(descendant::dtb:note)>0 and |
231 | 231 | count(descendant::*[not(ancestor::dtb:note) and (self::dtb:level2 or self::dtb:level3 or self::dtb:level4 or self::dtb:level5 or self::dtb:level6 or self::dtb:h1 or self::dtb:h2 or self::dtb:h3 or self::dtb:h4 or self::dtb:h5 or self::dtb:h6 or self::dtb:note or self::dtb:pagenum)]) |
|
238 | 238 | <xsl:next-match /> |
239 | 239 | </xsl:if> |
240 | 240 | </xsl:template> |
241 | | - |
| 241 | + |
242 | 242 | <xsl:template match="dtb:level2" mode="toc" priority="0.6"> |
243 | 243 | <xsl:if test="$toc-depth > 1"> |
244 | 244 | <xsl:next-match/> |
|
264 | 264 | <xsl:next-match/> |
265 | 265 | </xsl:if> |
266 | 266 | </xsl:template> |
267 | | - |
| 267 | + |
268 | 268 | <xsl:template match="dtb:level1|dtb:level2" mode="toc"> |
269 | 269 | <xsl:if test="dtb:h1|dtb:h2"> |
270 | | - <block> |
| 270 | + <toc-block> |
271 | 271 | <toc-entry ref-id="{generate-id(dtb:h1|dtb:h2)}" block-indent="{$toc-indent-multiplier}" |
272 | 272 | text-indent="{2*$toc-indent-multiplier}" keep="page"> |
273 | 273 | <xsl:apply-templates select="dtb:h1|dtb:h2" mode="toc-hd"/> |
274 | 274 | </toc-entry> |
275 | 275 | <xsl:apply-templates mode="toc"/> |
276 | | - </block> |
| 276 | + </toc-block> |
277 | 277 | </xsl:if> |
278 | 278 | </xsl:template> |
279 | | - |
| 279 | + |
280 | 280 | <xsl:template match="dtb:level3|dtb:level4|dtb:level5|dtb:level6" mode="toc"> |
281 | 281 | <xsl:if test="dtb:h3|dtb:h4|dtb:h5|dtb:h6"> |
282 | | - <block> |
| 282 | + <toc-block> |
283 | 283 | <toc-entry ref-id="{generate-id(dtb:h3|dtb:h4|dtb:h5|dtb:h6)}" block-indent="{$toc-indent-multiplier}" |
284 | 284 | text-indent="{$toc-indent-multiplier}" keep="page"> |
285 | 285 | <xsl:apply-templates select="dtb:h3|dtb:h4|dtb:h5|dtb:h6" mode="toc-hd"/> |
|
290 | 290 | <xsl:if test="not(dtb:level3 and ancestor::dtb:level1[@class='part'])"> |
291 | 291 | <xsl:apply-templates mode="toc"/> |
292 | 292 | </xsl:if> |
293 | | - </block> |
| 293 | + </toc-block> |
294 | 294 | </xsl:if> |
295 | 295 | </xsl:template> |
296 | 296 | <!-- |
297 | 297 | <xsl:template name="addBottomMarginIfPart"> |
298 | | - |
| 298 | +
|
299 | 299 | <xsl:if test="(following::*[self::dtb:level1|self::dtb:level2|self::dtb:level3|self::dtb:level4|self::dtb:level5|self::dtb:level6][1])[self::dtb:level1[@class='part']]"> |
300 | 300 | <xsl:attribute name="padding-bottom">1</xsl:attribute> |
301 | 301 | </xsl:if> |
302 | 302 | </xsl:template> |
303 | 303 | --> |
304 | | - |
| 304 | + |
305 | 305 | <xsl:template match="dtb:h1|dtb:h2|dtb:h3|dtb:h4|dtb:h5|dtb:h6" mode="toc-hd"> |
306 | 306 | <!-- <xsl:value-of select="descendant::text()"/>--> |
307 | 307 | <xsl:apply-templates mode="toc-text"/> |
|
324 | 324 | <xsl:template match="dtb:br" mode="toc-text"> |
325 | 325 | <xsl:text> </xsl:text> |
326 | 326 | </xsl:template> |
327 | | - |
| 327 | + |
328 | 328 | <xsl:template match="node()" mode="toc"/> |
329 | | - |
| 329 | + |
330 | 330 | <xsl:template name="insertProcessorRenderer"> |
331 | 331 | <xsl:copy-of select="obfl:insertProcessorRenderer()"/> |
332 | 332 | </xsl:template> |
333 | 333 |
|
334 | 334 | <xsl:template match="dtb:table"> |
335 | 335 | <xml-data renderer="table-renderer" xmlns:dotify="http://brailleapps.github.io/ns/dotify"> |
336 | 336 | <dotify:node> |
337 | | - <block keep="page" keep-with-next="1"><xsl:value-of select="concat('== ', $l10ntable, ' ')"/><leader position="100%" pattern="="/></block> |
| 337 | + <block keep="page" keep-with-next="1"><xsl:value-of select="concat('== ', $l10ntable, ' ')"/><leader position="100%" pattern="="/></block> |
338 | 338 | <xsl:apply-templates select="dtb:caption"/> |
339 | 339 | <xsl:apply-templates select="." mode="matrixTable"/> |
340 | 340 | <block><leader align="right" position="100%" pattern="="/></block> |
341 | 341 | <xsl:apply-templates select="descendant::dtb:pagenum"/> |
342 | 342 | </dotify:node> |
343 | 343 | </xml-data> |
344 | 344 | </xsl:template> |
345 | | - |
| 345 | + |
346 | 346 | <xsl:template match="dtb:table" mode="matrixTable"> |
347 | 347 | <table table-col-spacing="2"> |
348 | 348 | <xsl:choose> |
349 | | - <xsl:when test="dtb:thead"> |
| 349 | + <xsl:when test="dtb:thead"> |
350 | 350 | <thead> |
351 | 351 | <xsl:apply-templates select="dtb:thead/dtb:tr" mode="matrixRow"/> |
352 | 352 | </thead> |
|
366 | 366 | </xsl:choose> |
367 | 367 | </table> |
368 | 368 | </xsl:template> |
369 | | - |
| 369 | + |
370 | 370 | <xsl:template match="dtb:tr" mode="matrixRow"> |
371 | 371 | <tr> |
372 | 372 | <xsl:apply-templates mode="matrixCell"/> |
373 | 373 | </tr> |
374 | 374 | </xsl:template> |
375 | | - |
| 375 | + |
376 | 376 | <xsl:template match="dtb:td | dtb:th" mode="matrixCell"> |
377 | 377 | <td> |
378 | 378 | <xsl:if test="@colspan"> |
|
0 commit comments