metanorma-cc 2.4.7 → 2.4.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,4 @@
1
- <?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:csd="https://www.metanorma.org/ns/csd" xmlns:mathml="http://www.w3.org/1998/Math/MathML" xmlns:xalan="http://xml.apache.org/xalan" xmlns:fox="http://xmlgraphics.apache.org/fop/extensions" xmlns:java="http://xml.apache.org/xalan/java" exclude-result-prefixes="java" version="1.0">
1
+ <?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:csd="https://www.metanorma.org/ns/csd" xmlns:mathml="http://www.w3.org/1998/Math/MathML" xmlns:xalan="http://xml.apache.org/xalan" xmlns:fox="http://xmlgraphics.apache.org/fop/extensions" xmlns:java="http://xml.apache.org/xalan/java" xmlns:redirect="http://xml.apache.org/xalan/redirect" exclude-result-prefixes="java xalan" extension-element-prefixes="redirect" version="1.0">
2
2
 
3
3
  <xsl:output version="1.0" method="xml" encoding="UTF-8" indent="no"/>
4
4
 
@@ -48,26 +48,49 @@
48
48
 
49
49
  <!-- Document pages -->
50
50
 
51
+ <xsl:variable name="prefaceMarginTop">17</xsl:variable>
52
+ <xsl:variable name="prefaceMarginBottom">10</xsl:variable>
51
53
  <!-- Preface odd pages -->
52
54
  <fo:simple-page-master master-name="odd-preface" page-width="{$pageWidth}mm" page-height="{$pageHeight}mm">
53
- <fo:region-body margin-top="17mm" margin-bottom="10mm" margin-left="{$marginLeftRight1}mm" margin-right="{$marginLeftRight2}mm"/>
54
- <fo:region-before region-name="header-odd" extent="17mm"/>
55
- <fo:region-after region-name="footer-odd" extent="10mm"/>
55
+ <fo:region-body margin-top="{$prefaceMarginTop}mm" margin-bottom="{$prefaceMarginBottom}mm" margin-left="{$marginLeftRight1}mm" margin-right="{$marginLeftRight2}mm"/>
56
+ <fo:region-before region-name="header-odd" extent="{$prefaceMarginTop}mm"/>
57
+ <fo:region-after region-name="footer-odd" extent="{$prefaceMarginBottom}mm"/>
58
+ <fo:region-start region-name="left-region" extent="{$marginLeftRight1}mm"/>
59
+ <fo:region-end region-name="right-region" extent="{$marginLeftRight2}mm"/>
60
+ </fo:simple-page-master>
61
+ <fo:simple-page-master master-name="odd-preface-landscape" page-width="{$pageHeight}mm" page-height="{$pageWidth}mm">
62
+ <fo:region-body margin-top="{$prefaceMarginTop}mm" margin-bottom="{$prefaceMarginBottom}mm" margin-left="{$marginLeftRight1}mm" margin-right="{$marginLeftRight2}mm"/>
63
+ <fo:region-before region-name="header-odd" extent="{$prefaceMarginTop}mm"/>
64
+ <fo:region-after region-name="footer-odd" extent="{$prefaceMarginBottom}mm"/>
56
65
  <fo:region-start region-name="left-region" extent="{$marginLeftRight1}mm"/>
57
66
  <fo:region-end region-name="right-region" extent="{$marginLeftRight2}mm"/>
58
67
  </fo:simple-page-master>
59
68
  <!-- Preface even pages -->
60
69
  <fo:simple-page-master master-name="even-preface" page-width="{$pageWidth}mm" page-height="{$pageHeight}mm">
61
- <fo:region-body margin-top="17mm" margin-bottom="10mm" margin-left="{$marginLeftRight1}mm" margin-right="{$marginLeftRight2}mm"/>
62
- <fo:region-before region-name="header-even" extent="17mm"/>
63
- <fo:region-after region-name="footer-even" extent="10mm"/>
70
+ <fo:region-body margin-top="{$prefaceMarginTop}mm" margin-bottom="{$prefaceMarginBottom}mm" margin-left="{$marginLeftRight1}mm" margin-right="{$marginLeftRight2}mm"/>
71
+ <fo:region-before region-name="header-even" extent="{$prefaceMarginTop}mm"/>
72
+ <fo:region-after region-name="footer-even" extent="{$prefaceMarginBottom}mm"/>
73
+ <fo:region-start region-name="left-region" extent="{$marginLeftRight1}mm"/>
74
+ <fo:region-end region-name="right-region" extent="{$marginLeftRight2}mm"/>
75
+ </fo:simple-page-master>
76
+ <fo:simple-page-master master-name="even-preface-landscape" page-width="{$pageHeight}mm" page-height="{$pageWidth}mm">
77
+ <fo:region-body margin-top="{$prefaceMarginTop}mm" margin-bottom="{$prefaceMarginBottom}mm" margin-left="{$marginLeftRight1}mm" margin-right="{$marginLeftRight2}mm"/>
78
+ <fo:region-before region-name="header-even" extent="{$prefaceMarginTop}mm"/>
79
+ <fo:region-after region-name="footer-even" extent="{$prefaceMarginBottom}mm"/>
64
80
  <fo:region-start region-name="left-region" extent="{$marginLeftRight1}mm"/>
65
81
  <fo:region-end region-name="right-region" extent="{$marginLeftRight2}mm"/>
66
82
  </fo:simple-page-master>
67
83
  <fo:simple-page-master master-name="blankpage" page-width="{$pageWidth}mm" page-height="{$pageHeight}mm">
68
- <fo:region-body margin-top="17mm" margin-bottom="10mm" margin-left="{$marginLeftRight1}mm" margin-right="{$marginLeftRight2}mm"/>
69
- <fo:region-before region-name="header" extent="17mm"/>
70
- <fo:region-after region-name="footer" extent="10mm"/>
84
+ <fo:region-body margin-top="{$prefaceMarginTop}mm" margin-bottom="{$prefaceMarginBottom}mm" margin-left="{$marginLeftRight1}mm" margin-right="{$marginLeftRight2}mm"/>
85
+ <fo:region-before region-name="header" extent="{$prefaceMarginTop}mm"/>
86
+ <fo:region-after region-name="footer" extent="{$prefaceMarginBottom}mm"/>
87
+ <fo:region-start region-name="left" extent="{$marginLeftRight1}mm"/>
88
+ <fo:region-end region-name="right" extent="{$marginLeftRight2}mm"/>
89
+ </fo:simple-page-master>
90
+ <fo:simple-page-master master-name="blankpage-landscape" page-width="{$pageHeight}mm" page-height="{$pageWidth}mm">
91
+ <fo:region-body margin-top="{$prefaceMarginTop}mm" margin-bottom="{$prefaceMarginBottom}mm" margin-left="{$marginLeftRight1}mm" margin-right="{$marginLeftRight2}mm"/>
92
+ <fo:region-before region-name="header" extent="{$prefaceMarginTop}mm"/>
93
+ <fo:region-after region-name="footer" extent="{$prefaceMarginBottom}mm"/>
71
94
  <fo:region-start region-name="left" extent="{$marginLeftRight1}mm"/>
72
95
  <fo:region-end region-name="right" extent="{$marginLeftRight2}mm"/>
73
96
  </fo:simple-page-master>
@@ -78,6 +101,13 @@
78
101
  <fo:conditional-page-master-reference odd-or-even="odd" master-reference="odd-preface"/>
79
102
  </fo:repeatable-page-master-alternatives>
80
103
  </fo:page-sequence-master>
104
+ <fo:page-sequence-master master-name="preface-landscape">
105
+ <fo:repeatable-page-master-alternatives>
106
+ <fo:conditional-page-master-reference master-reference="blankpage-landscape" blank-or-not-blank="blank"/>
107
+ <fo:conditional-page-master-reference odd-or-even="even" master-reference="even-preface-landscape"/>
108
+ <fo:conditional-page-master-reference odd-or-even="odd" master-reference="odd-preface-landscape"/>
109
+ </fo:repeatable-page-master-alternatives>
110
+ </fo:page-sequence-master>
81
111
 
82
112
  <!-- Document odd pages -->
83
113
  <fo:simple-page-master master-name="odd" page-width="{$pageWidth}mm" page-height="{$pageHeight}mm">
@@ -87,6 +117,13 @@
87
117
  <fo:region-start region-name="left-region" extent="{$marginLeftRight1}mm"/>
88
118
  <fo:region-end region-name="right-region" extent="{$marginLeftRight2}mm"/>
89
119
  </fo:simple-page-master>
120
+ <fo:simple-page-master master-name="odd-landscape" page-width="{$pageHeight}mm" page-height="{$pageWidth}mm">
121
+ <fo:region-body margin-top="{$marginTop}mm" margin-bottom="{$marginBottom}mm" margin-left="{$marginLeftRight1}mm" margin-right="{$marginLeftRight2}mm"/>
122
+ <fo:region-before region-name="header-odd" extent="{$marginTop}mm"/>
123
+ <fo:region-after region-name="footer-odd" extent="{$marginBottom}mm"/>
124
+ <fo:region-start region-name="left-region" extent="{$marginLeftRight1}mm"/>
125
+ <fo:region-end region-name="right-region" extent="{$marginLeftRight2}mm"/>
126
+ </fo:simple-page-master>
90
127
  <!-- Preface even pages -->
91
128
  <fo:simple-page-master master-name="even" page-width="{$pageWidth}mm" page-height="{$pageHeight}mm">
92
129
  <fo:region-body margin-top="{$marginTop}mm" margin-bottom="{$marginBottom}mm" margin-left="{$marginLeftRight1}mm" margin-right="{$marginLeftRight2}mm"/>
@@ -95,6 +132,13 @@
95
132
  <fo:region-start region-name="left-region" extent="{$marginLeftRight1}mm"/>
96
133
  <fo:region-end region-name="right-region" extent="{$marginLeftRight2}mm"/>
97
134
  </fo:simple-page-master>
135
+ <fo:simple-page-master master-name="even-landscape" page-width="{$pageHeight}mm" page-height="{$pageWidth}mm">
136
+ <fo:region-body margin-top="{$marginTop}mm" margin-bottom="{$marginBottom}mm" margin-left="{$marginLeftRight1}mm" margin-right="{$marginLeftRight2}mm"/>
137
+ <fo:region-before region-name="header-even" extent="{$marginTop}mm"/>
138
+ <fo:region-after region-name="footer-even" extent="{$marginBottom}mm"/>
139
+ <fo:region-start region-name="left-region" extent="{$marginLeftRight1}mm"/>
140
+ <fo:region-end region-name="right-region" extent="{$marginLeftRight2}mm"/>
141
+ </fo:simple-page-master>
98
142
  <fo:page-sequence-master master-name="document">
99
143
  <fo:repeatable-page-master-alternatives>
100
144
  <fo:conditional-page-master-reference master-reference="blankpage" blank-or-not-blank="blank"/>
@@ -102,6 +146,13 @@
102
146
  <fo:conditional-page-master-reference odd-or-even="odd" master-reference="odd"/>
103
147
  </fo:repeatable-page-master-alternatives>
104
148
  </fo:page-sequence-master>
149
+ <fo:page-sequence-master master-name="document-landscape">
150
+ <fo:repeatable-page-master-alternatives>
151
+ <fo:conditional-page-master-reference master-reference="blankpage-landscape" blank-or-not-blank="blank"/>
152
+ <fo:conditional-page-master-reference odd-or-even="even" master-reference="even-landscape"/>
153
+ <fo:conditional-page-master-reference odd-or-even="odd" master-reference="odd-landscape"/>
154
+ </fo:repeatable-page-master-alternatives>
155
+ </fo:page-sequence-master>
105
156
 
106
157
  </fo:layout-master-set>
107
158
 
@@ -181,69 +232,122 @@
181
232
  </fo:page-sequence>
182
233
  <!-- End Cover Page -->
183
234
 
184
- <!-- Copyright, Content, Foreword, etc. pages -->
185
- <fo:page-sequence master-reference="preface" initial-page-number="2" format="i" force-page-count="end-on-even">
186
- <fo:static-content flow-name="xsl-footnote-separator">
187
- <fo:block>
188
- <fo:leader leader-pattern="rule" leader-length="30%"/>
189
- </fo:block>
190
- </fo:static-content>
191
- <xsl:call-template name="insertHeaderFooter"/>
192
- <fo:flow flow-name="xsl-region-body">
235
+ <xsl:variable name="updated_xml">
236
+ <xsl:call-template name="updateXML"/>
237
+ </xsl:variable>
193
238
 
194
- <xsl:if test="$debug = 'true'">
195
- <xsl:text disable-output-escaping="yes">&lt;!--</xsl:text>
196
- DEBUG
197
- contents=<xsl:copy-of select="$contents"/>
198
- <xsl:text disable-output-escaping="yes">--&gt;</xsl:text>
199
- </xsl:if>
239
+ <xsl:for-each select="xalan:nodeset($updated_xml)/*">
200
240
 
201
- <fo:block margin-bottom="15pt"> </fo:block>
202
- <fo:block margin-bottom="14pt">
203
- <xsl:text>© </xsl:text>
204
- <xsl:value-of select="/csd:csd-standard/csd:bibdata/csd:copyright/csd:from"/>
205
- <xsl:text> </xsl:text>
206
- <fo:inline>
207
- <xsl:apply-templates select="/csd:csd-standard/csd:boilerplate/csd:feedback-statement/csd:clause/csd:p[@id = 'boilerplate-name']"/>
208
- </fo:inline>
209
- </fo:block>
210
- <fo:block margin-bottom="12pt">
211
- <xsl:apply-templates select="/csd:csd-standard/csd:boilerplate/csd:legal-statement"/>
212
- </fo:block>
213
- <fo:block margin-bottom="12pt">
214
- <xsl:apply-templates select="/csd:csd-standard/csd:boilerplate/csd:feedback-statement/csd:clause/csd:p[@id = 'boilerplate-name']"/>
215
- </fo:block>
216
- <fo:block>
217
- <xsl:apply-templates select="/csd:csd-standard/csd:boilerplate/csd:feedback-statement/csd:clause/csd:p[@id = 'boilerplate-address']"/>
218
- </fo:block>
241
+ <xsl:variable name="updated_xml_with_pages_preface">
242
+ <xsl:call-template name="processPrefaceSectionsDefault_items"/>
243
+ </xsl:variable>
219
244
 
220
- <fo:block break-after="page"/>
245
+ <xsl:for-each select="xalan:nodeset($updated_xml_with_pages_preface)"> <!-- set context to preface -->
246
+ <xsl:for-each select=".//*[local-name() = 'page_sequence'][normalize-space() != '' or .//image or .//svg]">
221
247
 
222
- <!-- Table of contents, Foreword, Introduction -->
223
- <xsl:call-template name="processPrefaceSectionsDefault"/>
248
+ <!-- Copyright, Content, Foreword, etc. pages -->
249
+ <fo:page-sequence master-reference="preface" format="i">
224
250
 
225
- </fo:flow>
226
- </fo:page-sequence>
251
+ <xsl:attribute name="master-reference">
252
+ <xsl:text>preface</xsl:text>
253
+ <xsl:call-template name="getPageSequenceOrientation"/>
254
+ </xsl:attribute>
227
255
 
228
- <!-- Document Pages -->
229
- <fo:page-sequence master-reference="document" initial-page-number="1" format="1" force-page-count="no-force">
230
- <fo:static-content flow-name="xsl-footnote-separator">
231
- <fo:block>
232
- <fo:leader leader-pattern="rule" leader-length="30%"/>
233
- </fo:block>
234
- </fo:static-content>
235
- <xsl:call-template name="insertHeaderFooter"/>
236
- <fo:flow flow-name="xsl-region-body">
237
- <!-- <fo:block font-size="16pt" font-weight="bold" margin-bottom="17pt" role="H1">
238
- <xsl:value-of select="/csd:csd-standard/csd:bibdata/csd:title[@language = 'en']"/>
239
- </fo:block> -->
240
- <fo:block>
241
- <xsl:call-template name="processMainSectionsDefault"/>
242
- </fo:block>
243
- </fo:flow>
244
- </fo:page-sequence>
256
+ <xsl:if test="position() = 1">
257
+ <xsl:attribute name="initial-page-number">2</xsl:attribute>
258
+ </xsl:if>
259
+ <xsl:if test="position() = last()">
260
+ <xsl:attribute name="force-page-count">end-on-even</xsl:attribute>
261
+ </xsl:if>
262
+
263
+ <fo:static-content flow-name="xsl-footnote-separator">
264
+ <fo:block>
265
+ <fo:leader leader-pattern="rule" leader-length="30%"/>
266
+ </fo:block>
267
+ </fo:static-content>
268
+ <xsl:call-template name="insertHeaderFooter"/>
269
+ <fo:flow flow-name="xsl-region-body">
270
+
271
+ <!-- <xsl:if test="$debug = 'true'">
272
+ <redirect:write file="contents_{java:getTime(java:java.util.Date.new())}.xml">
273
+ <xsl:copy-of select="$contents"/>
274
+ </redirect:write>
275
+ </xsl:if> -->
276
+
277
+ <xsl:if test="position() = 1">
278
+ <fo:block margin-bottom="15pt"> </fo:block>
279
+ <fo:block margin-bottom="14pt">
280
+ <xsl:text>© </xsl:text>
281
+ <xsl:value-of select="/csd:csd-standard/csd:bibdata/csd:copyright/csd:from"/>
282
+ <xsl:text> </xsl:text>
283
+ <fo:inline>
284
+ <xsl:apply-templates select="/csd:csd-standard/csd:boilerplate/csd:feedback-statement/csd:clause/csd:p[@id = 'boilerplate-name']"/>
285
+ </fo:inline>
286
+ </fo:block>
287
+ <fo:block margin-bottom="12pt">
288
+ <xsl:apply-templates select="/csd:csd-standard/csd:boilerplate/csd:legal-statement"/>
289
+ </fo:block>
290
+ <fo:block margin-bottom="12pt">
291
+ <xsl:apply-templates select="/csd:csd-standard/csd:boilerplate/csd:feedback-statement/csd:clause/csd:p[@id = 'boilerplate-name']"/>
292
+ </fo:block>
293
+ <fo:block>
294
+ <xsl:apply-templates select="/csd:csd-standard/csd:boilerplate/csd:feedback-statement/csd:clause/csd:p[@id = 'boilerplate-address']"/>
295
+ </fo:block>
296
+
297
+ <fo:block break-after="page"/>
298
+ </xsl:if> <!-- for 1st page_sequence only -->
299
+
300
+ <!-- Table of contents, Foreword, Introduction -->
301
+ <!-- <xsl:call-template name="processPrefaceSectionsDefault"/> -->
302
+ <xsl:apply-templates/>
303
+
304
+ <fo:block/> <!-- for prevent empty preface -->
305
+ </fo:flow>
306
+ </fo:page-sequence>
307
+ </xsl:for-each>
308
+ </xsl:for-each>
309
+
310
+ <xsl:variable name="updated_xml_with_pages_main">
311
+ <xsl:call-template name="processMainSectionsDefault_items"/>
312
+ </xsl:variable>
313
+
314
+ <xsl:for-each select="xalan:nodeset($updated_xml_with_pages_main)"> <!-- set context to preface -->
315
+ <xsl:for-each select=".//*[local-name() = 'page_sequence'][normalize-space() != '' or .//image or .//svg]">
245
316
 
246
- <!-- End Document Pages -->
317
+ <!-- Document Pages -->
318
+ <fo:page-sequence master-reference="document" format="1" force-page-count="no-force">
319
+
320
+ <xsl:attribute name="master-reference">
321
+ <xsl:text>document</xsl:text>
322
+ <xsl:call-template name="getPageSequenceOrientation"/>
323
+ </xsl:attribute>
324
+
325
+ <xsl:if test="position() = 1">
326
+ <xsl:attribute name="initial-page-number">1</xsl:attribute>
327
+ </xsl:if>
328
+
329
+ <fo:static-content flow-name="xsl-footnote-separator">
330
+ <fo:block>
331
+ <fo:leader leader-pattern="rule" leader-length="30%"/>
332
+ </fo:block>
333
+ </fo:static-content>
334
+ <xsl:call-template name="insertHeaderFooter"/>
335
+ <fo:flow flow-name="xsl-region-body">
336
+ <!-- <fo:block font-size="16pt" font-weight="bold" margin-bottom="17pt" role="H1">
337
+ <xsl:value-of select="/csd:csd-standard/csd:bibdata/csd:title[@language = 'en']"/>
338
+ </fo:block> -->
339
+ <fo:block>
340
+ <!-- <xsl:call-template name="processMainSectionsDefault"/> -->
341
+ <xsl:apply-templates/>
342
+ </fo:block>
343
+ </fo:flow>
344
+ </fo:page-sequence>
345
+
346
+ <!-- End Document Pages -->
347
+ </xsl:for-each>
348
+ </xsl:for-each>
349
+
350
+ </xsl:for-each>
247
351
 
248
352
  </fo:root>
249
353
  </xsl:template>
@@ -281,7 +385,7 @@
281
385
  </fo:block>
282
386
  </xsl:template>
283
387
 
284
- <xsl:template match="csd:preface/csd:clause[@type = 'toc']" priority="3">
388
+ <xsl:template match="csd:preface//csd:clause[@type = 'toc']" priority="3">
285
389
  <fo:block-container font-weight="bold" line-height="115%">
286
390
  <fo:block role="TOC">
287
391
 
@@ -350,7 +454,7 @@
350
454
  </fo:block-container>
351
455
  </xsl:template>
352
456
 
353
- <xsl:template match="csd:preface/csd:clause[@type = 'toc']/csd:title" priority="3">
457
+ <xsl:template match="csd:preface//csd:clause[@type = 'toc']/csd:title" priority="3">
354
458
  <!-- <xsl:variable name="title-toc">
355
459
  <xsl:call-template name="getTitle">
356
460
  <xsl:with-param name="name" select="'title-toc'"/>
@@ -417,7 +521,7 @@
417
521
  <!-- ============================= -->
418
522
  <!-- ============================= -->
419
523
 
420
- <xsl:template match="csd:sections/csd:p[@class = 'zzSTDTitle1']" priority="4">
524
+ <xsl:template match="csd:sections//csd:p[@class = 'zzSTDTitle1']" priority="4">
421
525
  <fo:block font-size="16pt" font-weight="bold" margin-bottom="17pt" role="H1">
422
526
  <xsl:apply-templates/>
423
527
  </fo:block>
@@ -477,13 +581,9 @@
477
581
  </xsl:choose>
478
582
  </xsl:variable>
479
583
  <xsl:element name="{$element-name}">
480
- <xsl:attribute name="text-align">
481
- <xsl:choose>
482
- <!-- <xsl:when test="ancestor::csd:preface">justify</xsl:when> -->
483
- <xsl:when test="@align"><xsl:value-of select="@align"/></xsl:when>
484
- <xsl:otherwise>left</xsl:otherwise><!-- justify -->
485
- </xsl:choose>
486
- </xsl:attribute>
584
+
585
+ <xsl:call-template name="setBlockAttributes"/>
586
+
487
587
  <xsl:attribute name="margin-bottom">
488
588
  <xsl:choose>
489
589
  <xsl:when test="ancestor::csd:li">0pt</xsl:when>
@@ -581,6 +681,9 @@
581
681
 
582
682
  <xsl:strip-space elements="csd:xref"/>
583
683
 
684
+ <xsl:variable name="namespace_full" select="namespace-uri(/*)"/> <!-- example: https://www.metanorma.org/ns/iso -->
685
+ <xsl:variable name="root_element" select="local-name(/*)"/> <!-- example: iso-standard -->
686
+
584
687
  <!-- external parameters -->
585
688
 
586
689
  <xsl:param name="svg_images"/> <!-- svg images array -->
@@ -588,6 +691,7 @@
588
691
  <xsl:param name="basepath"/> <!-- base path for images -->
589
692
  <xsl:param name="inputxml_basepath"/> <!-- input xml file path -->
590
693
  <xsl:param name="inputxml_filename"/> <!-- input xml file name -->
694
+ <xsl:param name="output_path"/> <!-- output PDF file name -->
591
695
  <xsl:param name="external_index"/><!-- path to index xml, generated on 1st pass, based on FOP Intermediate Format -->
592
696
  <xsl:param name="syntax-highlight">false</xsl:param> <!-- syntax highlighting feature, default - off -->
593
697
  <xsl:param name="add_math_as_text">true</xsl:param> <!-- add math in text behind svg formula, to copy-paste formula from PDF as text -->
@@ -740,6 +844,15 @@
740
844
  </xsl:variable>
741
845
  <xsl:variable name="marginBottom" select="normalize-space($marginBottom_)"/>
742
846
 
847
+ <xsl:variable name="layout_columns_default">1</xsl:variable>
848
+ <xsl:variable name="layout_columns_" select="normalize-space((//*[contains(local-name(), '-standard')])[1]/*[local-name() = 'metanorma-extension']/*[local-name() = 'presentation-metadata']/*[local-name() = 'layout-columns'])"/>
849
+ <xsl:variable name="layout_columns">
850
+ <xsl:choose>
851
+ <xsl:when test="$layout_columns_ != ''"><xsl:value-of select="$layout_columns_"/></xsl:when>
852
+ <xsl:otherwise><xsl:value-of select="$layout_columns_default"/></xsl:otherwise>
853
+ </xsl:choose>
854
+ </xsl:variable>
855
+
743
856
  <!-- Note 2: almost all localized string determined in the element //localized-strings in metanorma xml, but there are a few cases when:
744
857
  - string didn't determined yet
745
858
  - we need to put the string on two-languages (for instance, on English and French both), but xml contains only localized strings for one language
@@ -2208,6 +2321,58 @@
2208
2321
  </xsl:for-each>
2209
2322
  </xsl:template>
2210
2323
 
2324
+ <xsl:template name="processPrefaceSectionsDefault_items">
2325
+
2326
+ <xsl:variable name="updated_xml_step_move_pagebreak">
2327
+
2328
+ <xsl:element name="{$root_element}" namespace="{$namespace_full}">
2329
+
2330
+ <xsl:call-template name="copyCommonElements"/>
2331
+
2332
+ <xsl:element name="preface" namespace="{$namespace_full}"> <!-- save context element -->
2333
+ <xsl:element name="page_sequence" namespace="{$namespace_full}">
2334
+ <xsl:for-each select="/*/*[local-name()='preface']/*[not(local-name() = 'note' or local-name() = 'admonition')]">
2335
+ <xsl:sort select="@displayorder" data-type="number"/>
2336
+ <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"/>
2337
+ </xsl:for-each>
2338
+ </xsl:element>
2339
+ </xsl:element>
2340
+ </xsl:element>
2341
+ </xsl:variable>
2342
+
2343
+ <xsl:variable name="updated_xml_step_move_pagebreak_filename" select="concat($output_path,'_preface_', java:getTime(java:java.util.Date.new()), '.xml')"/>
2344
+ <!-- <xsl:message>updated_xml_step_move_pagebreak_filename=<xsl:value-of select="$updated_xml_step_move_pagebreak_filename"/></xsl:message>
2345
+ <xsl:message>start write updated_xml_step_move_pagebreak_filename</xsl:message> -->
2346
+ <redirect:write file="{$updated_xml_step_move_pagebreak_filename}">
2347
+ <xsl:copy-of select="$updated_xml_step_move_pagebreak"/>
2348
+ </redirect:write>
2349
+ <!-- <xsl:message>end write updated_xml_step_move_pagebreak_filename</xsl:message> -->
2350
+
2351
+ <xsl:copy-of select="document($updated_xml_step_move_pagebreak_filename)"/>
2352
+
2353
+ <!-- TODO: instead of
2354
+ <xsl:for-each select=".//*[local-name() = 'page_sequence'][normalize-space() != '' or .//image or .//svg]">
2355
+ in each template, add removing empty page_sequence here
2356
+ -->
2357
+
2358
+ <xsl:if test="$debug = 'true'">
2359
+ <redirect:write file="page_sequence_preface.xml">
2360
+ <xsl:copy-of select="document($updated_xml_step_move_pagebreak_filename)"/>
2361
+ </redirect:write>
2362
+ </xsl:if>
2363
+
2364
+ <!-- <xsl:message>start delete updated_xml_step_move_pagebreak_filename</xsl:message> -->
2365
+ <xsl:call-template name="deleteFile">
2366
+ <xsl:with-param name="filepath" select="$updated_xml_step_move_pagebreak_filename"/>
2367
+ </xsl:call-template>
2368
+ <!-- <xsl:message>end delete updated_xml_step_move_pagebreak_filename</xsl:message> -->
2369
+ </xsl:template> <!-- END: processPrefaceSectionsDefault_items -->
2370
+
2371
+ <xsl:template name="copyCommonElements">
2372
+ <!-- copy bibdata, localized-strings, metanorma-extension and boilerplate -->
2373
+ <xsl:copy-of select="/*/*[local-name() != 'preface' and local-name() != 'sections' and local-name() != 'annex' and local-name() != 'bibliography']"/>
2374
+ </xsl:template>
2375
+
2211
2376
  <xsl:template name="processMainSectionsDefault">
2212
2377
  <xsl:for-each select="/*/*[local-name()='sections']/* | /*/*[local-name()='bibliography']/*[local-name()='references'][@normative='true']">
2213
2378
  <xsl:sort select="@displayorder" data-type="number"/>
@@ -2224,36 +2389,94 @@
2224
2389
  <xsl:sort select="@displayorder" data-type="number"/>
2225
2390
  <xsl:apply-templates select="."/>
2226
2391
  </xsl:for-each>
2227
- </xsl:template>
2392
+ </xsl:template><!-- END: processMainSectionsDefault -->
2393
+
2394
+ <!-- Example:
2395
+ <iso-standard>
2396
+ <sections>
2397
+ <page_sequence>
2398
+ <clause...
2399
+ </page_sequence>
2400
+ <page_sequence>
2401
+ <clause...
2402
+ </page_sequence>
2403
+ </sections>
2404
+ <page_sequence>
2405
+ <annex ..
2406
+ </page_sequence>
2407
+ <page_sequence>
2408
+ <annex ..
2409
+ </page_sequence>
2410
+ </iso-standard>
2411
+ -->
2412
+ <xsl:template name="processMainSectionsDefault_items">
2228
2413
 
2229
- <xsl:template name="processMainSectionsDefault_flatxml">
2230
- <xsl:for-each select="/*/*[local-name()='sections']/* | /*/*[local-name()='bibliography']/*[local-name()='references'][@normative='true']">
2231
- <xsl:sort select="@displayorder" data-type="number"/>
2232
- <xsl:variable name="flatxml">
2233
- <xsl:apply-templates select="." mode="flatxml"/>
2234
- </xsl:variable>
2235
- <!-- debug_flatxml='<xsl:copy-of select="$flatxml"/>' -->
2236
- <xsl:apply-templates select="xalan:nodeset($flatxml)/*"/>
2414
+ <xsl:variable name="updated_xml_step_move_pagebreak">
2237
2415
 
2238
- </xsl:for-each>
2416
+ <xsl:element name="{$root_element}" namespace="{$namespace_full}">
2239
2417
 
2240
- <xsl:for-each select="/*/*[local-name()='annex']">
2241
- <xsl:sort select="@displayorder" data-type="number"/>
2242
- <xsl:variable name="flatxml">
2243
- <xsl:apply-templates select="." mode="flatxml"/>
2244
- </xsl:variable>
2245
- <!-- debug_flatxml='<xsl:copy-of select="$flatxml"/>' -->
2246
- <xsl:apply-templates select="xalan:nodeset($flatxml)/*"/>
2247
- </xsl:for-each>
2418
+ <xsl:call-template name="copyCommonElements"/>
2248
2419
 
2249
- <xsl:for-each select="/*/*[local-name()='bibliography']/*[not(@normative='true')] | /*/*[local-name()='bibliography']/*[local-name()='clause'][*[local-name()='references'][not(@normative='true')]]">
2250
- <xsl:sort select="@displayorder" data-type="number"/>
2251
- <xsl:variable name="flatxml">
2252
- <xsl:apply-templates select="." mode="flatxml"/>
2253
- </xsl:variable>
2254
- <!-- debug_flatxml='<xsl:copy-of select="$flatxml"/>' -->
2255
- <xsl:apply-templates select="xalan:nodeset($flatxml)/*"/>
2256
- </xsl:for-each>
2420
+ <xsl:element name="sections" namespace="{$namespace_full}"> <!-- save context element -->
2421
+ <xsl:element name="page_sequence" namespace="{$namespace_full}">
2422
+ <xsl:for-each select="/*/*[local-name()='sections']/* | /*/*[local-name()='bibliography']/*[local-name()='references'][@normative='true']">
2423
+ <xsl:sort select="@displayorder" data-type="number"/>
2424
+ <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"/>
2425
+
2426
+ </xsl:for-each>
2427
+ </xsl:element>
2428
+ </xsl:element>
2429
+
2430
+ <xsl:element name="page_sequence" namespace="{$namespace_full}">
2431
+ <xsl:for-each select="/*/*[local-name()='annex']">
2432
+ <xsl:sort select="@displayorder" data-type="number"/>
2433
+ <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"/>
2434
+ </xsl:for-each>
2435
+ </xsl:element>
2436
+
2437
+ <xsl:element name="page_sequence" namespace="{$namespace_full}">
2438
+ <xsl:element name="bibliography" namespace="{$namespace_full}"> <!-- save context element -->
2439
+ <xsl:for-each select="/*/*[local-name()='bibliography']/*[not(@normative='true')] | /*/*[local-name()='bibliography']/*[local-name()='clause'][*[local-name()='references'][not(@normative='true')]]">
2440
+ <xsl:sort select="@displayorder" data-type="number"/>
2441
+ <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"/>
2442
+ </xsl:for-each>
2443
+ </xsl:element>
2444
+ </xsl:element>
2445
+ </xsl:element>
2446
+ </xsl:variable>
2447
+
2448
+ <xsl:variable name="updated_xml_step_move_pagebreak_filename" select="concat($output_path,'_main_', java:getTime(java:java.util.Date.new()), '.xml')"/>
2449
+
2450
+ <redirect:write file="{$updated_xml_step_move_pagebreak_filename}">
2451
+ <xsl:copy-of select="$updated_xml_step_move_pagebreak"/>
2452
+ </redirect:write>
2453
+
2454
+ <xsl:copy-of select="document($updated_xml_step_move_pagebreak_filename)"/>
2455
+
2456
+ <xsl:if test="$debug = 'true'">
2457
+ <redirect:write file="page_sequence_main.xml">
2458
+ <xsl:copy-of select="document($updated_xml_step_move_pagebreak_filename)"/>
2459
+ </redirect:write>
2460
+ </xsl:if>
2461
+
2462
+ <xsl:call-template name="deleteFile">
2463
+ <xsl:with-param name="filepath" select="$updated_xml_step_move_pagebreak_filename"/>
2464
+ </xsl:call-template>
2465
+ </xsl:template> <!-- END: processMainSectionsDefault_items -->
2466
+
2467
+ <xsl:template name="deleteFile">
2468
+ <xsl:param name="filepath"/>
2469
+ <xsl:variable name="xml_file" select="java:java.io.File.new($filepath)"/>
2470
+ <xsl:variable name="xml_file_path" select="java:toPath($xml_file)"/>
2471
+ <xsl:variable name="deletefile" select="java:java.nio.file.Files.deleteIfExists($xml_file_path)"/>
2472
+ </xsl:template>
2473
+
2474
+ <xsl:template name="getPageSequenceOrientation">
2475
+ <xsl:variable name="previous_orientation" select="preceding-sibling::*[local-name() = 'page_sequence'][@orientation][1]/@orientation"/>
2476
+ <xsl:choose>
2477
+ <xsl:when test="@orientation = 'landscape'">-<xsl:value-of select="@orientation"/></xsl:when>
2478
+ <xsl:when test="$previous_orientation = 'landscape' and not(@orientation = 'portrait')">-<xsl:value-of select="$previous_orientation"/></xsl:when>
2479
+ </xsl:choose>
2257
2480
  </xsl:template>
2258
2481
 
2259
2482
  <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
@@ -2456,7 +2679,9 @@
2456
2679
  </xsl:for-each>
2457
2680
  </xsl:template>
2458
2681
 
2459
- <xsl:param name="table_only_with_id"/><!-- Example: table1, for table auto-layout algorithm -->
2682
+ <!-- for table auto-layout algorithm -->
2683
+ <xsl:param name="table_only_with_id"/> <!-- Example: 'table1' -->
2684
+ <xsl:param name="table_only_with_ids"/> <!-- Example: 'table1 table2 table3 ' -->
2460
2685
 
2461
2686
  <xsl:template match="*[local-name()='table']" priority="2">
2462
2687
  <xsl:choose>
@@ -2464,6 +2689,10 @@
2464
2689
  <xsl:call-template name="table"/>
2465
2690
  </xsl:when>
2466
2691
  <xsl:when test="$table_only_with_id != ''"><fo:block/><!-- to prevent empty fo:block-container --></xsl:when>
2692
+ <xsl:when test="$table_only_with_ids != '' and contains($table_only_with_ids, concat(@id, ' '))">
2693
+ <xsl:call-template name="table"/>
2694
+ </xsl:when>
2695
+ <xsl:when test="$table_only_with_ids != ''"><fo:block/><!-- to prevent empty fo:block-container --></xsl:when>
2467
2696
  <xsl:otherwise>
2468
2697
  <xsl:call-template name="table"/>
2469
2698
  </xsl:otherwise>
@@ -2525,6 +2754,7 @@
2525
2754
  <xsl:variable name="margin-side">
2526
2755
  <xsl:choose>
2527
2756
  <xsl:when test="$isApplyAutolayoutAlgorithm = 'true'">0</xsl:when>
2757
+ <xsl:when test="$isApplyAutolayoutAlgorithm = 'skip'">0</xsl:when>
2528
2758
  <xsl:when test="sum(xalan:nodeset($colwidths)//column) &gt; 75">15</xsl:when>
2529
2759
  <xsl:otherwise>0</xsl:otherwise>
2530
2760
  </xsl:choose>
@@ -2581,7 +2811,9 @@
2581
2811
 
2582
2812
  <xsl:variable name="isNoteOrFnExist" select="./*[local-name()='note'][not(@type = 'units')] or ./*[local-name()='example'] or .//*[local-name()='fn'][local-name(..) != 'name'] or ./*[local-name()='source']"/>
2583
2813
  <xsl:if test="$isNoteOrFnExist = 'true'">
2584
- <xsl:attribute name="border-bottom">0pt solid black</xsl:attribute><!-- set 0pt border, because there is a separete table below for footer -->
2814
+
2815
+ <xsl:attribute name="border-bottom">0pt solid black</xsl:attribute><!-- set 0pt border, because there is a separete table below for footer -->
2816
+
2585
2817
  </xsl:if>
2586
2818
 
2587
2819
  <xsl:choose>
@@ -2638,13 +2870,14 @@
2638
2870
  </fo:table>
2639
2871
 
2640
2872
  <xsl:variable name="colgroup" select="*[local-name()='colgroup']"/>
2641
- <xsl:for-each select="*[local-name()='tbody']"><!-- select context to tbody -->
2642
- <xsl:call-template name="insertTableFooterInSeparateTable">
2643
- <xsl:with-param name="table_attributes" select="$table_attributes"/>
2644
- <xsl:with-param name="colwidths" select="$colwidths"/>
2645
- <xsl:with-param name="colgroup" select="$colgroup"/>
2646
- </xsl:call-template>
2647
- </xsl:for-each>
2873
+
2874
+ <xsl:for-each select="*[local-name()='tbody']"><!-- select context to tbody -->
2875
+ <xsl:call-template name="insertTableFooterInSeparateTable">
2876
+ <xsl:with-param name="table_attributes" select="$table_attributes"/>
2877
+ <xsl:with-param name="colwidths" select="$colwidths"/>
2878
+ <xsl:with-param name="colgroup" select="$colgroup"/>
2879
+ </xsl:call-template>
2880
+ </xsl:for-each>
2648
2881
 
2649
2882
  <xsl:if test="*[local-name()='bookmark']"> <!-- special case: table/bookmark -->
2650
2883
  <fo:block keep-with-previous="always" line-height="0.1">
@@ -2776,6 +3009,7 @@
2776
3009
  <xsl:when test="$isApplyAutolayoutAlgorithm = 'true'">
2777
3010
  <xsl:call-template name="get-calculated-column-widths-autolayout-algorithm"/>
2778
3011
  </xsl:when>
3012
+ <xsl:when test="$isApplyAutolayoutAlgorithm = 'skip'"/>
2779
3013
  <xsl:otherwise>
2780
3014
  <xsl:call-template name="calculate-column-widths-proportional">
2781
3015
  <xsl:with-param name="cols-count" select="$cols-count"/>
@@ -3033,8 +3267,10 @@
3033
3267
  <width_min><xsl:value-of select="@width_min"/></width_min>
3034
3268
  <e><xsl:value-of select="$d * $W div $D"/></e>
3035
3269
  <!-- set the column's width to the minimum width plus d times W over D. -->
3270
+ <xsl:variable name="column_width_" select="round(@width_min + $d * $W div $D)"/> <!-- * 10 -->
3271
+ <xsl:variable name="column_width" select="$column_width_*($column_width_ &gt;= 0) - $column_width_*($column_width_ &lt; 0)"/> <!-- absolute value -->
3036
3272
  <column divider="100">
3037
- <xsl:value-of select="round(@width_min + $d * $W div $D)"/> <!-- * 10 -->
3273
+ <xsl:value-of select="$column_width"/>
3038
3274
  </column>
3039
3275
  </xsl:for-each>
3040
3276
 
@@ -3442,6 +3678,22 @@
3442
3678
 
3443
3679
  <xsl:call-template name="refine_table-header-cell-style"/>
3444
3680
 
3681
+ <!-- experimental feature, see https://github.com/metanorma/metanorma-plateau/issues/30#issuecomment-2145461828 -->
3682
+ <!-- <xsl:choose>
3683
+ <xsl:when test="count(node()) = 1 and *[local-name() = 'span'][contains(@style, 'text-orientation')]">
3684
+ <fo:block-container reference-orientation="270">
3685
+ <fo:block role="SKIP" text-align="start">
3686
+ <xsl:apply-templates />
3687
+ </fo:block>
3688
+ </fo:block-container>
3689
+ </xsl:when>
3690
+ <xsl:otherwise>
3691
+ <fo:block role="SKIP">
3692
+ <xsl:apply-templates />
3693
+ </fo:block>
3694
+ </xsl:otherwise>
3695
+ </xsl:choose> -->
3696
+
3445
3697
  <fo:block role="SKIP">
3446
3698
  <xsl:apply-templates/>
3447
3699
  </fo:block>
@@ -3672,7 +3924,7 @@
3672
3924
  <xsl:copy-of select="node()"/>
3673
3925
  </fn>
3674
3926
  </xsl:for-each>
3675
- <xsl:for-each select="ancestor::*[contains(local-name(), '-standard')]/*[local-name()='boilerplate']/* | ancestor::*[contains(local-name(), '-standard')]/*[local-name()='preface']/* | ancestor::*[contains(local-name(), '-standard')]/*[local-name()='sections']/* | ancestor::*[contains(local-name(), '-standard')]/*[local-name()='annex'] | ancestor::*[contains(local-name(), '-standard')]/*[local-name()='bibliography']/*">
3927
+ <xsl:for-each select="ancestor::*[contains(local-name(), '-standard')]/*[local-name()='boilerplate']/* | ancestor::*[contains(local-name(), '-standard')]/*[local-name()='preface']/* | ancestor::*[contains(local-name(), '-standard')]/*[local-name()='sections']/* | ancestor::*[contains(local-name(), '-standard')]//*[local-name()='annex'] | ancestor::*[contains(local-name(), '-standard')]//*[local-name()='bibliography']/*">
3676
3928
  <xsl:sort select="@displayorder" data-type="number"/>
3677
3929
  <!-- commented:
3678
3930
  .//*[local-name() = 'bibitem'][ancestor::*[local-name() = 'references']]/*[local-name() = 'note'] |
@@ -3920,6 +4172,10 @@
3920
4172
  <xsl:call-template name="dl"/>
3921
4173
  </xsl:when>
3922
4174
  <xsl:when test="$table_only_with_id != ''"><fo:block/><!-- to prevent empty fo:block-container --></xsl:when>
4175
+ <xsl:when test="$table_only_with_ids != '' and contains($table_only_with_ids, concat(@id, ' '))">
4176
+ <xsl:call-template name="dl"/>
4177
+ </xsl:when>
4178
+ <xsl:when test="$table_only_with_ids != ''"><fo:block/><!-- to prevent empty fo:block-container --></xsl:when>
3923
4179
  <xsl:otherwise>
3924
4180
  <xsl:call-template name="dl"/>
3925
4181
  </xsl:otherwise>
@@ -4083,7 +4339,7 @@
4083
4339
 
4084
4340
  <!-- create virtual html table for dl/[dt and dd] -->
4085
4341
  <xsl:variable name="simple-table">
4086
-
4342
+ <!-- initial='<xsl:copy-of select="."/>' -->
4087
4343
  <xsl:variable name="dl_table">
4088
4344
  <tbody>
4089
4345
  <xsl:apply-templates mode="dl_if">
@@ -6809,17 +7065,19 @@
6809
7065
  </xsl:variable>
6810
7066
  <xsl:value-of select="concat('scale=', $scale,', indent=', $indent)"/>
6811
7067
  </fo:block> -->
6812
- <fo:external-graphic src="{$src}" fox:alt-text="Image {@alt}" xsl:use-attribute-sets="image-graphic-style">
6813
- <xsl:if test="not(@mimetype = 'image/svg+xml') and (../*[local-name() = 'name'] or parent::*[local-name() = 'figure'][@unnumbered = 'true']) and not(ancestor::*[local-name() = 'table'])">
6814
7068
 
6815
- <xsl:call-template name="setImageWidthHeight"/>
7069
+ <fo:external-graphic src="{$src}" fox:alt-text="Image {@alt}">
6816
7070
 
6817
- <xsl:choose>
6818
- <xsl:when test="@width != '' and @width != 'auto' and @height != '' and @height != 'auto'">
6819
- <xsl:attribute name="scaling">non-uniform</xsl:attribute>
6820
- </xsl:when>
6821
- <xsl:otherwise>
7071
+ <xsl:choose>
7072
+ <!-- default -->
7073
+ <xsl:when test="((@width = 'auto' or @width = 'text-width' or @width = 'full-page-width' or @width = 'narrow') and @height = 'auto') or (normalize-space(@width) = '' and normalize-space(@height) = '') ">
7074
+ <!-- add attribute for automatic scaling -->
7075
+ <xsl:variable name="image-graphic-style_attributes">
7076
+ <attributes xsl:use-attribute-sets="image-graphic-style"/>
7077
+ </xsl:variable>
7078
+ <xsl:copy-of select="xalan:nodeset($image-graphic-style_attributes)/attributes/@*"/>
6822
7079
 
7080
+ <xsl:if test="not(@mimetype = 'image/svg+xml') and not(ancestor::*[local-name() = 'table'])">
6823
7081
  <xsl:variable name="scale">
6824
7082
  <xsl:call-template name="getImageScale">
6825
7083
  <xsl:with-param name="indent" select="$indent"/>
@@ -6833,10 +7091,30 @@
6833
7091
  <xsl:if test="number($scale) &lt; 100">
6834
7092
  <xsl:attribute name="content-width"><xsl:value-of select="number($scale) * number($scaleRatio)"/>%</xsl:attribute>
6835
7093
  </xsl:if>
6836
- </xsl:otherwise>
6837
- </xsl:choose>
7094
+ </xsl:if>
6838
7095
 
6839
- </xsl:if>
7096
+ </xsl:when> <!-- default -->
7097
+ <xsl:otherwise>
7098
+
7099
+ <xsl:variable name="width_height_">
7100
+ <attributes>
7101
+ <xsl:call-template name="setImageWidthHeight"/>
7102
+ </attributes>
7103
+ </xsl:variable>
7104
+ <xsl:variable name="width_height" select="xalan:nodeset($width_height_)"/>
7105
+
7106
+ <xsl:copy-of select="$width_height/attributes/@*"/>
7107
+
7108
+ <xsl:if test="$width_height/attributes/@content-width != '' and $width_height/attributes/@content-height != ''">
7109
+ <xsl:attribute name="scaling">non-uniform</xsl:attribute>
7110
+ </xsl:if>
7111
+
7112
+ </xsl:otherwise>
7113
+ </xsl:choose>
7114
+
7115
+ <!--
7116
+ <xsl:if test="not(@mimetype = 'image/svg+xml') and (../*[local-name() = 'name'] or parent::*[local-name() = 'figure'][@unnumbered = 'true']) and not(ancestor::*[local-name() = 'table'])">
7117
+ -->
6840
7118
 
6841
7119
  </fo:external-graphic>
6842
7120
  </xsl:otherwise>
@@ -6862,7 +7140,7 @@
6862
7140
  <xsl:call-template name="setImageWidth"/>
6863
7141
  </xsl:variable>
6864
7142
  <xsl:if test="$width != ''">
6865
- <xsl:attribute name="width">
7143
+ <xsl:attribute name="content-width">
6866
7144
  <xsl:value-of select="$width"/>
6867
7145
  </xsl:attribute>
6868
7146
  </xsl:if>
@@ -6870,7 +7148,7 @@
6870
7148
  <xsl:call-template name="setImageHeight"/>
6871
7149
  </xsl:variable>
6872
7150
  <xsl:if test="$height != ''">
6873
- <xsl:attribute name="height">
7151
+ <xsl:attribute name="content-height">
6874
7152
  <xsl:value-of select="$height"/>
6875
7153
  </xsl:attribute>
6876
7154
  </xsl:if>
@@ -6908,6 +7186,15 @@
6908
7186
  <xsl:when test="@mimetype = 'image/svg+xml' and $images/images/image[@id = current()/@id]">
6909
7187
  <xsl:value-of select="$images/images/image[@id = current()/@id]/@src"/>
6910
7188
  </xsl:when>
7189
+ <!-- in WebP format, then convert image into PNG -->
7190
+ <xsl:when test="starts-with(@src, 'data:image/webp')">
7191
+ <xsl:variable name="src_png" select="java:org.metanorma.fop.utils.ImageUtils.convertWebPtoPNG(@src)"/>
7192
+ <xsl:value-of select="$src_png"/>
7193
+ </xsl:when>
7194
+ <xsl:when test="not(starts-with(@src, 'data:')) and (java:endsWith(java:java.lang.String.new(@src), '.webp') or java:endsWith(java:java.lang.String.new(@src), '.WEBP'))">
7195
+ <xsl:variable name="src_png" select="java:org.metanorma.fop.utils.ImageUtils.convertWebPtoPNG(@src)"/>
7196
+ <xsl:value-of select="concat('url(file:///',$basepath, $src_png, ')')"/>
7197
+ </xsl:when>
6911
7198
  <xsl:when test="not(starts-with(@src, 'data:'))">
6912
7199
  <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
6913
7200
  </xsl:when>
@@ -9308,7 +9595,7 @@
9308
9595
  <!-- ========== -->
9309
9596
 
9310
9597
  <!-- main sections -->
9311
- <xsl:template match="/*/*[local-name() = 'sections']/*" priority="2">
9598
+ <xsl:template match="/*/*[local-name() = 'sections']/*" name="sections_node" priority="2">
9312
9599
 
9313
9600
  <fo:block>
9314
9601
  <xsl:call-template name="setId"/>
@@ -9320,16 +9607,21 @@
9320
9607
 
9321
9608
  </xsl:template>
9322
9609
 
9610
+ <!-- note: @top-level added in mode=" update_xml_step_move_pagebreak" -->
9611
+ <xsl:template match="*[local-name() = 'sections']/*[local-name() = 'page_sequence']/*[not(@top-level)]" priority="2">
9612
+ <xsl:call-template name="sections_node"/>
9613
+ </xsl:template>
9614
+
9323
9615
  <xsl:template name="sections_element_style">
9324
9616
 
9325
- <xsl:variable name="pos"><xsl:number count="csd:sections/csd:clause | csd:sections/csd:terms"/></xsl:variable>
9617
+ <xsl:variable name="pos"><xsl:number count="csd:sections/*/csd:clause | csd:sections/*/csd:terms"/></xsl:variable>
9326
9618
  <xsl:if test="$pos &gt;= 2">
9327
9619
  <xsl:attribute name="space-before">18pt</xsl:attribute>
9328
9620
  </xsl:if>
9329
9621
 
9330
9622
  </xsl:template> <!-- sections_element_style -->
9331
9623
 
9332
- <xsl:template match="//*[contains(local-name(), '-standard')]/*[local-name() = 'preface']/*" priority="2"> <!-- /*/*[local-name() = 'preface']/* -->
9624
+ <xsl:template match="//*[contains(local-name(), '-standard')]/*[local-name() = 'preface']/*" priority="2" name="preface_node"> <!-- /*/*[local-name() = 'preface']/* -->
9333
9625
 
9334
9626
  <fo:block break-after="page"/>
9335
9627
 
@@ -9339,7 +9631,11 @@
9339
9631
  </fo:block>
9340
9632
  </xsl:template>
9341
9633
 
9342
- <xsl:template match="*[local-name() = 'clause']">
9634
+ <xsl:template match="*[local-name() = 'preface']/*[local-name() = 'page_sequence']/*" priority="2"> <!-- /*/*[local-name() = 'preface']/* -->
9635
+ <xsl:call-template name="preface_node"/>
9636
+ </xsl:template>
9637
+
9638
+ <xsl:template match="*[local-name() = 'clause'][normalize-space() != '' or *[local-name() = 'figure'] or @id]" name="template_clause"> <!-- if clause isn't empty -->
9343
9639
  <fo:block>
9344
9640
  <xsl:if test="parent::*[local-name() = 'copyright-statement']">
9345
9641
  <xsl:attribute name="role">SKIP</xsl:attribute>
@@ -9365,18 +9661,31 @@
9365
9661
  </fo:block>
9366
9662
  </xsl:template>
9367
9663
 
9368
- <xsl:template match="*[local-name() = 'annex']">
9369
- <fo:block break-after="page"/>
9370
- <fo:block>
9664
+ <xsl:template match="*[local-name() = 'annex'][normalize-space() != '']">
9665
+ <xsl:choose>
9666
+ <xsl:when test="@continue = 'true'"> <!-- it's using for figure/table on top level for block span -->
9667
+ <fo:block>
9668
+ <xsl:apply-templates/>
9669
+ </fo:block>
9670
+ </xsl:when>
9671
+ <xsl:otherwise>
9371
9672
 
9372
- <xsl:call-template name="setBlockSpanAll"/>
9673
+ <fo:block break-after="page"/>
9674
+ <fo:block id="{@id}">
9373
9675
 
9374
- <xsl:call-template name="refine_annex_style"/>
9676
+ <xsl:call-template name="setBlockSpanAll"/>
9375
9677
 
9376
- </fo:block>
9377
- <fo:block id="{@id}">
9378
- <xsl:apply-templates/>
9379
- </fo:block>
9678
+ <xsl:call-template name="refine_annex_style"/>
9679
+
9680
+ </fo:block>
9681
+
9682
+ <xsl:apply-templates select="*[local-name() = 'title'][@columns = 1]"/>
9683
+
9684
+ <fo:block>
9685
+ <xsl:apply-templates select="node()[not(local-name() = 'title' and @columns = 1)]"/>
9686
+ </fo:block>
9687
+ </xsl:otherwise>
9688
+ </xsl:choose>
9380
9689
  </xsl:template>
9381
9690
 
9382
9691
  <xsl:template name="refine_annex_style">
@@ -10070,8 +10379,12 @@
10070
10379
  </xsl:if>
10071
10380
  </xsl:if> -->
10072
10381
 
10073
- <fo:block id="{@id}" xsl:use-attribute-sets="references-non-normative-style">
10074
- <xsl:apply-templates/>
10382
+ <fo:block id="{@id}"/>
10383
+
10384
+ <xsl:apply-templates select="*[local-name() = 'title'][@columns = 1]"/>
10385
+
10386
+ <fo:block xsl:use-attribute-sets="references-non-normative-style">
10387
+ <xsl:apply-templates select="node()[not(local-name() = 'title' and @columns = 1)]"/>
10075
10388
 
10076
10389
  </fo:block>
10077
10390
 
@@ -10564,10 +10877,83 @@
10564
10877
  <!-- ===================================== -->
10565
10878
  <!-- Update xml -->
10566
10879
  <!-- ===================================== -->
10880
+
10881
+ <xsl:template name="updateXML">
10882
+ <xsl:if test="$debug = 'true'"><xsl:message>START updated_xml_step1</xsl:message></xsl:if>
10883
+ <xsl:variable name="startTime1" select="java:getTime(java:java.util.Date.new())"/>
10884
+
10885
+ <!-- STEP1: Re-order elements in 'preface', 'sections' based on @displayorder -->
10886
+ <xsl:variable name="updated_xml_step1">
10887
+ <xsl:if test="$table_if = 'false'">
10888
+ <xsl:apply-templates mode="update_xml_step1"/>
10889
+ </xsl:if>
10890
+ </xsl:variable>
10891
+
10892
+ <xsl:variable name="endTime1" select="java:getTime(java:java.util.Date.new())"/>
10893
+ <xsl:if test="$debug = 'true'">
10894
+ <xsl:message>DEBUG: processing time <xsl:value-of select="$endTime1 - $startTime1"/> msec.</xsl:message>
10895
+ <xsl:message>END updated_xml_step1</xsl:message>
10896
+ <!-- <redirect:write file="updated_xml_step1_{java:getTime(java:java.util.Date.new())}.xml">
10897
+ <xsl:copy-of select="$updated_xml_step1"/>
10898
+ </redirect:write> -->
10899
+ </xsl:if>
10900
+
10901
+ <xsl:if test="$debug = 'true'"><xsl:message>START updated_xml_step2</xsl:message></xsl:if>
10902
+ <xsl:variable name="startTime2" select="java:getTime(java:java.util.Date.new())"/>
10903
+
10904
+ <!-- STEP2: add 'fn' after 'eref' and 'origin', if referenced to bibitem with 'note' = Withdrawn.' or 'Cancelled and replaced...' -->
10905
+ <xsl:variable name="updated_xml_step2">
10906
+
10907
+ <xsl:if test="$table_if = 'false'">
10908
+ <xsl:copy-of select="$updated_xml_step1"/>
10909
+ </xsl:if>
10910
+
10911
+ </xsl:variable>
10912
+
10913
+ <xsl:variable name="endTime2" select="java:getTime(java:java.util.Date.new())"/>
10914
+ <xsl:if test="$debug = 'true'">
10915
+ <xsl:message>DEBUG: processing time <xsl:value-of select="$endTime2 - $startTime2"/> msec.</xsl:message>
10916
+ <xsl:message>END updated_xml_step2</xsl:message>
10917
+ <!-- <redirect:write file="updated_xml_step2_{java:getTime(java:java.util.Date.new())}.xml">
10918
+ <xsl:copy-of select="$updated_xml_step2"/>
10919
+ </redirect:write> -->
10920
+ </xsl:if>
10921
+
10922
+ <xsl:if test="$debug = 'true'"><xsl:message>START updated_xml_step3</xsl:message></xsl:if>
10923
+ <xsl:variable name="startTime3" select="java:getTime(java:java.util.Date.new())"/>
10924
+
10925
+ <xsl:variable name="updated_xml_step3">
10926
+ <xsl:choose>
10927
+ <xsl:when test="$table_if = 'false'">
10928
+ <xsl:apply-templates select="xalan:nodeset($updated_xml_step2)" mode="update_xml_enclose_keep-together_within-line"/>
10929
+ </xsl:when>
10930
+ <xsl:otherwise>
10931
+ <xsl:apply-templates select="." mode="update_xml_enclose_keep-together_within-line"/>
10932
+ </xsl:otherwise>
10933
+ </xsl:choose>
10934
+ </xsl:variable>
10935
+
10936
+ <xsl:variable name="endTime3" select="java:getTime(java:java.util.Date.new())"/>
10937
+ <xsl:if test="$debug = 'true'">
10938
+ <xsl:message>DEBUG: processing time <xsl:value-of select="$endTime3 - $startTime3"/> msec.</xsl:message>
10939
+ <xsl:message>END updated_xml_step3</xsl:message>
10940
+ <!-- <redirect:write file="updated_xml_step3_{java:getTime(java:java.util.Date.new())}.xml">
10941
+ <xsl:copy-of select="$updated_xml_step3"/>
10942
+ </redirect:write> -->
10943
+ </xsl:if>
10944
+
10945
+ <xsl:copy-of select="$updated_xml_step3"/>
10946
+
10947
+ </xsl:template>
10948
+
10567
10949
  <!-- =========================================================================== -->
10568
10950
  <!-- STEP1: -->
10569
10951
  <!-- - Re-order elements in 'preface', 'sections' based on @displayorder -->
10952
+ <!-- - Put Section title in the correct position -->
10570
10953
  <!-- - Ignore 'span' without style -->
10954
+ <!-- - Remove semantic xml part -->
10955
+ <!-- - Remove image/emf (EMF vector image for Word) -->
10956
+ <!-- - add @id, redundant for table auto-layout algorithm -->
10571
10957
  <!-- =========================================================================== -->
10572
10958
  <xsl:template match="@*|node()" mode="update_xml_step1">
10573
10959
  <xsl:copy>
@@ -10674,11 +11060,14 @@
10674
11060
  <!-- remove image/emf -->
10675
11061
  <xsl:template match="*[local-name() = 'image']/*[local-name() = 'emf']" mode="update_xml_step1"/>
10676
11062
 
10677
- <xsl:template match="*[local-name() = 'stem'] | *[local-name() = 'image']" mode="update_xml_step1">
11063
+ <!-- remove preprocess-xslt -->
11064
+ <xsl:template match="*[local-name() = 'preprocess-xslt']" mode="update_xml_step1"/>
11065
+
11066
+ <xsl:template match="*[local-name() = 'stem'] | *[local-name() = 'image'] | *[local-name() = 'sourcecode'] | *[local-name() = 'bibdata'] | *[local-name() = 'localized-strings']" mode="update_xml_step1">
10678
11067
  <xsl:copy-of select="."/>
10679
11068
  </xsl:template>
10680
11069
 
10681
- <!-- add @id, redundant for table auto-layout algorithm -->
11070
+ <!-- add @id, mandatory for table auto-layout algorithm -->
10682
11071
  <xsl:template match="*[local-name() = 'dl' or local-name() = 'table'][not(@id)]" mode="update_xml_step1">
10683
11072
  <xsl:copy>
10684
11073
  <xsl:copy-of select="@*"/>
@@ -10697,10 +11086,174 @@
10697
11086
  </xsl:if>
10698
11087
  </xsl:template>
10699
11088
 
11089
+ <!-- optimization: remove clause if table_only_with_id isn't empty and clause doesn't contain table or dl with table_only_with_id -->
11090
+ <xsl:template match="*[local-name() = 'clause' or local-name() = 'p' or local-name() = 'definitions' or local-name() = 'annex']" mode="update_xml_step1">
11091
+ <xsl:choose>
11092
+ <xsl:when test="($table_only_with_id != '' or $table_only_with_ids != '') and local-name() = 'p' and (ancestor::*[local-name() = 'table' or local-name() = 'dl' or local-name() = 'toc'])">
11093
+ <xsl:copy>
11094
+ <xsl:copy-of select="@*"/>
11095
+ <xsl:apply-templates mode="update_xml_step1"/>
11096
+ </xsl:copy>
11097
+ </xsl:when>
11098
+ <!-- for table auto-layout algorithm -->
11099
+ <xsl:when test="$table_only_with_id != '' and not(.//*[local-name() = 'table' or local-name() = 'dl'][@id = $table_only_with_id])">
11100
+ <xsl:copy>
11101
+ <xsl:copy-of select="@*"/>
11102
+ </xsl:copy>
11103
+ </xsl:when>
11104
+ <!-- for table auto-layout algorithm -->
11105
+ <xsl:when test="$table_only_with_ids != '' and not(.//*[local-name() = 'table' or local-name() = 'dl'][contains($table_only_with_ids, concat(@id, ' '))])">
11106
+ <xsl:copy>
11107
+ <xsl:copy-of select="@*"/>
11108
+ </xsl:copy>
11109
+ </xsl:when>
11110
+ <xsl:otherwise>
11111
+ <xsl:copy>
11112
+ <xsl:copy-of select="@*"/>
11113
+ <xsl:apply-templates mode="update_xml_step1"/>
11114
+ </xsl:copy>
11115
+ </xsl:otherwise>
11116
+ </xsl:choose>
11117
+ </xsl:template>
11118
+
10700
11119
  <!-- =========================================================================== -->
10701
11120
  <!-- END STEP1: Re-order elements in 'preface', 'sections' based on @displayorder -->
10702
11121
  <!-- =========================================================================== -->
10703
11122
 
11123
+ <!-- =========================================================================== -->
11124
+ <!-- STEP MOVE PAGEBREAK: move <pagebreak/> at top level under 'preface' and 'sections' -->
11125
+ <!-- =========================================================================== -->
11126
+ <xsl:template match="@*|node()" mode="update_xml_step_move_pagebreak">
11127
+ <xsl:copy>
11128
+ <xsl:apply-templates select="@*|node()" mode="update_xml_step_move_pagebreak"/>
11129
+ </xsl:copy>
11130
+ </xsl:template>
11131
+
11132
+ <!-- replace 'pagebreak' by closing tags + page_sequence and opening page_sequence + tags -->
11133
+ <xsl:template match="*[local-name() = 'pagebreak'][not(following-sibling::*[1][local-name() = 'pagebreak'])]" mode="update_xml_step_move_pagebreak">
11134
+
11135
+ <!-- <xsl:choose>
11136
+ <xsl:when test="ancestor::*[local-name() = 'sections']">
11137
+
11138
+ </xsl:when>
11139
+ <xsl:when test="ancestor::*[local-name() = 'annex']">
11140
+ </xsl:when>
11141
+ <xsl:otherwise>
11142
+ <xsl:copy-of select="."/>
11143
+ </xsl:otherwise>
11144
+ </xsl:choose> -->
11145
+
11146
+ <!-- determine pagebreak is last element before </fo:flow> or not -->
11147
+ <xsl:variable name="isLast">
11148
+ <xsl:for-each select="ancestor-or-self::*[ancestor::*[local-name() = 'preface'] or ancestor::*[local-name() = 'sections'] or ancestor-or-self::*[local-name() = 'annex']]">
11149
+ <xsl:if test="following-sibling::*">false</xsl:if>
11150
+ </xsl:for-each>
11151
+ </xsl:variable>
11152
+
11153
+ <xsl:if test="contains($isLast, 'false')">
11154
+
11155
+ <xsl:variable name="orientation" select="normalize-space(@orientation)"/>
11156
+
11157
+ <xsl:variable name="tree_">
11158
+ <xsl:call-template name="makeAncestorsElementsTree"/>
11159
+ </xsl:variable>
11160
+ <xsl:variable name="tree" select="xalan:nodeset($tree_)"/>
11161
+
11162
+ <!-- close fo:page-sequence (closing preceding fo elements) -->
11163
+ <xsl:call-template name="insertClosingElements">
11164
+ <xsl:with-param name="tree" select="$tree"/>
11165
+ </xsl:call-template>
11166
+
11167
+ <xsl:text disable-output-escaping="yes">&lt;/page_sequence&gt;</xsl:text>
11168
+
11169
+ <!-- create a new page_sequence (opening elements) -->
11170
+ <xsl:text disable-output-escaping="yes">&lt;page_sequence xmlns="</xsl:text><xsl:value-of select="$namespace_full"/>"<xsl:if test="$orientation != ''"> orientation="<xsl:value-of select="$orientation"/>"</xsl:if><xsl:text disable-output-escaping="yes">&gt;</xsl:text>
11171
+
11172
+ <xsl:call-template name="insertOpeningElements">
11173
+ <xsl:with-param name="tree" select="$tree"/>
11174
+ </xsl:call-template>
11175
+
11176
+ </xsl:if>
11177
+ </xsl:template>
11178
+
11179
+ <xsl:template name="makeAncestorsElementsTree">
11180
+ <xsl:for-each select="ancestor::*[ancestor::*[local-name() = 'preface'] or ancestor::*[local-name() = 'sections'] or ancestor-or-self::*[local-name() = 'annex']]">
11181
+ <element pos="{position()}">
11182
+ <xsl:copy-of select="@*[local-name() != 'id']"/>
11183
+ <xsl:value-of select="name()"/>
11184
+ </element>
11185
+ </xsl:for-each>
11186
+ </xsl:template>
11187
+
11188
+ <xsl:template name="insertClosingElements">
11189
+ <xsl:param name="tree"/>
11190
+ <xsl:for-each select="$tree//element">
11191
+ <xsl:sort data-type="number" order="descending" select="@pos"/>
11192
+ <xsl:text disable-output-escaping="yes">&lt;/</xsl:text>
11193
+ <xsl:value-of select="."/>
11194
+ <xsl:text disable-output-escaping="yes">&gt;</xsl:text>
11195
+ <xsl:if test="$debug = 'true'">
11196
+ <xsl:message>&lt;/<xsl:value-of select="."/>&gt;</xsl:message>
11197
+ </xsl:if>
11198
+ </xsl:for-each>
11199
+ </xsl:template>
11200
+
11201
+ <xsl:template name="insertOpeningElements">
11202
+ <xsl:param name="tree"/>
11203
+ <xsl:for-each select="$tree//element">
11204
+ <xsl:text disable-output-escaping="yes">&lt;</xsl:text>
11205
+ <xsl:value-of select="."/>
11206
+ <xsl:for-each select="@*[local-name() != 'pos']">
11207
+ <xsl:text> </xsl:text>
11208
+ <xsl:value-of select="local-name()"/>
11209
+ <xsl:text>="</xsl:text>
11210
+ <xsl:value-of select="."/>
11211
+ <xsl:text>"</xsl:text>
11212
+ </xsl:for-each>
11213
+ <xsl:if test="position() = 1"> continue="true"</xsl:if>
11214
+ <xsl:text disable-output-escaping="yes">&gt;</xsl:text>
11215
+ <xsl:if test="$debug = 'true'">
11216
+ <xsl:message>&lt;<xsl:value-of select="."/>&gt;</xsl:message>
11217
+ </xsl:if>
11218
+ </xsl:for-each>
11219
+ </xsl:template>
11220
+
11221
+ <!-- move full page width figures, tables at top level -->
11222
+ <xsl:template match="*[local-name() = 'figure' or local-name() = 'table'][normalize-space(@width) != 'text-width']" mode="update_xml_step_move_pagebreak">
11223
+ <xsl:choose>
11224
+ <xsl:when test="$layout_columns != 1">
11225
+
11226
+ <xsl:variable name="tree_">
11227
+ <xsl:call-template name="makeAncestorsElementsTree"/>
11228
+ </xsl:variable>
11229
+ <xsl:variable name="tree" select="xalan:nodeset($tree_)"/>
11230
+
11231
+ <xsl:call-template name="insertClosingElements">
11232
+ <xsl:with-param name="tree" select="$tree"/>
11233
+ </xsl:call-template>
11234
+
11235
+ <!-- <xsl:copy-of select="."/> -->
11236
+ <xsl:copy>
11237
+ <xsl:copy-of select="@*"/>
11238
+ <xsl:attribute name="top-level">true</xsl:attribute>
11239
+ <xsl:copy-of select="node()"/>
11240
+ </xsl:copy>
11241
+
11242
+ <xsl:call-template name="insertOpeningElements">
11243
+ <xsl:with-param name="tree" select="$tree"/>
11244
+ </xsl:call-template>
11245
+
11246
+ </xsl:when>
11247
+ <xsl:otherwise>
11248
+ <xsl:copy-of select="."/>
11249
+ </xsl:otherwise>
11250
+ </xsl:choose>
11251
+ </xsl:template>
11252
+
11253
+ <!-- =========================================================================== -->
11254
+ <!-- END STEP MOVE PAGEBREAK: move <pagebreak/> at top level under 'preface' and 'sections' -->
11255
+ <!-- =========================================================================== -->
11256
+
10704
11257
  <!-- =========================================================================== -->
10705
11258
  <!-- XML UPDATE STEP: enclose standard's name into tag 'keep-together_within-line' -->
10706
11259
  <!-- keep-together_within-line for: a/b, aaa/b, a/bbb, /b -->
@@ -10805,7 +11358,7 @@
10805
11358
  <xsl:value-of select="substring-before($text, $tag_open)"/>
10806
11359
  <xsl:variable name="text_after" select="substring-after($text, $tag_open)"/>
10807
11360
 
10808
- <xsl:element name="{substring-before(substring-after($tag_open, '###'),'###')}">
11361
+ <xsl:element name="{substring-before(substring-after($tag_open, '###'),'###')}" namespace="{$namespace_full}">
10809
11362
  <xsl:value-of select="substring-before($text_after, $tag_close)"/>
10810
11363
  </xsl:element>
10811
11364
 
@@ -10876,7 +11429,7 @@
10876
11429
  <xsl:apply-templates select="*[local-name() = 'term']" mode="linear_xml"/>
10877
11430
  </xsl:template>
10878
11431
 
10879
- <xsl:template match="*[local-name() = 'introduction']//*[local-name() = 'title'] | *[local-name() = 'foreword']//*[local-name() = 'title'] | *[local-name() = 'sections']//*[local-name() = 'title'] | *[local-name() = 'annex']//*[local-name() = 'title'] | *[local-name() = 'bibliography']/*[local-name() = 'clause']/*[local-name() = 'title'] | *[local-name() = 'references']/*[local-name() = 'title'] | *[local-name() = 'colophon']//*[local-name() = 'title']" mode="linear_xml" priority="2">
11432
+ <xsl:template match="*[local-name() = 'introduction']//*[local-name() = 'title'] | *[local-name() = 'foreword']//*[local-name() = 'title'] | *[local-name() = 'preface']//*[local-name() = 'title'] | *[local-name() = 'sections']//*[local-name() = 'title'] | *[local-name() = 'annex']//*[local-name() = 'title'] | *[local-name() = 'bibliography']/*[local-name() = 'clause']/*[local-name() = 'title'] | *[local-name() = 'references']/*[local-name() = 'title'] | *[local-name() = 'colophon']//*[local-name() = 'title']" mode="linear_xml" priority="2">
10880
11433
  <xsl:copy>
10881
11434
  <xsl:apply-templates select="@*" mode="linear_xml"/>
10882
11435
 
@@ -10895,7 +11448,7 @@
10895
11448
  <xsl:copy-of select="../@inline-header"/>
10896
11449
  </xsl:if>
10897
11450
 
10898
- <xsl:attribute name="ancestor">
11451
+ <xsl:variable name="ancestor">
10899
11452
  <xsl:choose>
10900
11453
  <xsl:when test="ancestor::*[local-name() = 'foreword']">foreword</xsl:when>
10901
11454
  <xsl:when test="ancestor::*[local-name() = 'introduction']">introduction</xsl:when>
@@ -10903,6 +11456,35 @@
10903
11456
  <xsl:when test="ancestor::*[local-name() = 'annex']">annex</xsl:when>
10904
11457
  <xsl:when test="ancestor::*[local-name() = 'bibliography']">bibliography</xsl:when>
10905
11458
  </xsl:choose>
11459
+ </xsl:variable>
11460
+ <xsl:attribute name="ancestor">
11461
+ <xsl:value-of select="$ancestor"/>
11462
+ </xsl:attribute>
11463
+
11464
+ <xsl:attribute name="parent">
11465
+ <xsl:choose>
11466
+ <xsl:when test="ancestor::*[local-name() = 'preface']">preface</xsl:when>
11467
+ <xsl:otherwise><xsl:value-of select="$ancestor"/></xsl:otherwise>
11468
+ </xsl:choose>
11469
+ </xsl:attribute>
11470
+
11471
+ <xsl:apply-templates mode="linear_xml"/>
11472
+ </xsl:copy>
11473
+ </xsl:template>
11474
+
11475
+ <xsl:template match="*[local-name() = 'li']" mode="linear_xml" priority="2">
11476
+ <xsl:copy>
11477
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
11478
+
11479
+ <xsl:variable name="ancestor">
11480
+ <xsl:choose>
11481
+ <xsl:when test="ancestor::*[local-name() = 'preface']">preface</xsl:when>
11482
+ <xsl:when test="ancestor::*[local-name() = 'sections']">sections</xsl:when>
11483
+ <xsl:when test="ancestor::*[local-name() = 'annex']">annex</xsl:when>
11484
+ </xsl:choose>
11485
+ </xsl:variable>
11486
+ <xsl:attribute name="ancestor">
11487
+ <xsl:value-of select="$ancestor"/>
10906
11488
  </xsl:attribute>
10907
11489
 
10908
11490
  <xsl:apply-templates mode="linear_xml"/>
@@ -11307,7 +11889,7 @@
11307
11889
  <xsl:value-of select="$depth"/>
11308
11890
  </xsl:when>
11309
11891
  <xsl:otherwise>
11310
- <xsl:variable name="level_total" select="count(ancestor::*)"/>
11892
+ <xsl:variable name="level_total" select="count(ancestor::*[local-name() != 'page_sequence'])"/>
11311
11893
  <xsl:variable name="level">
11312
11894
  <xsl:choose>
11313
11895
  <xsl:when test="parent::*[local-name() = 'preface']">
@@ -11598,7 +12180,10 @@
11598
12180
  <xsl:call-template name="setTextAlignment">
11599
12181
  <xsl:with-param name="default" select="$text_align_default"/>
11600
12182
  </xsl:call-template>
12183
+ <xsl:call-template name="setKeepAttributes"/>
12184
+ </xsl:template>
11601
12185
 
12186
+ <xsl:template name="setKeepAttributes">
11602
12187
  <!-- https://www.metanorma.org/author/topics/document-format/text/#avoiding-page-breaks -->
11603
12188
  <!-- Example: keep-lines-together="true" -->
11604
12189
  <xsl:if test="@keep-lines-together = 'true'">
@@ -11610,6 +12195,72 @@
11610
12195
  </xsl:if>
11611
12196
  </xsl:template>
11612
12197
 
12198
+ <!-- insert cover page image -->
12199
+ <!-- background cover image -->
12200
+ <xsl:template name="insertBackgroundPageImage">
12201
+ <xsl:param name="number">1</xsl:param>
12202
+ <xsl:param name="name">coverpage-image</xsl:param>
12203
+ <xsl:variable name="num" select="number($number)"/>
12204
+ <!-- background image -->
12205
+ <fo:block-container absolute-position="fixed" left="0mm" top="0mm" font-size="0" id="__internal_layout__coverpage_{$name}_{$number}_{generate-id()}">
12206
+ <fo:block>
12207
+ <xsl:for-each select="/*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'presentation-metadata'][*[local-name() = 'name'] = $name][1]/*[local-name() = 'value']/*[local-name() = 'image'][$num]">
12208
+ <xsl:choose>
12209
+ <xsl:when test="*[local-name() = 'svg'] or java:endsWith(java:java.lang.String.new(@src), '.svg')">
12210
+ <fo:instream-foreign-object fox:alt-text="Image Front">
12211
+ <xsl:attribute name="content-height"><xsl:value-of select="$pageHeight"/>mm</xsl:attribute>
12212
+ <xsl:call-template name="getSVG"/>
12213
+ </fo:instream-foreign-object>
12214
+ </xsl:when>
12215
+ <xsl:when test="starts-with(@src, 'data:application/pdf;base64')">
12216
+ <fo:external-graphic src="{@src}" fox:alt-text="Image Front"/>
12217
+ </xsl:when>
12218
+ <xsl:otherwise> <!-- bitmap image -->
12219
+ <xsl:variable name="coverimage_src" select="normalize-space(@src)"/>
12220
+ <xsl:if test="$coverimage_src != ''">
12221
+ <xsl:variable name="coverpage">
12222
+ <xsl:call-template name="getImageURL">
12223
+ <xsl:with-param name="src" select="$coverimage_src"/>
12224
+ </xsl:call-template>
12225
+ </xsl:variable>
12226
+ <!-- <xsl:variable name="coverpage" select="concat('url(file:',$basepath, 'coverpage1.png', ')')"/> --> <!-- for DEBUG -->
12227
+ <fo:external-graphic src="{$coverpage}" width="{$pageWidth}mm" content-height="scale-to-fit" scaling="uniform" fox:alt-text="Image Front"/>
12228
+ </xsl:if>
12229
+ </xsl:otherwise>
12230
+ </xsl:choose>
12231
+ </xsl:for-each>
12232
+ </fo:block>
12233
+ </fo:block-container>
12234
+ </xsl:template>
12235
+
12236
+ <xsl:template name="getImageURL">
12237
+ <xsl:param name="src"/>
12238
+ <xsl:choose>
12239
+ <xsl:when test="starts-with($src, 'data:image')">
12240
+ <xsl:value-of select="$src"/>
12241
+ </xsl:when>
12242
+ <xsl:otherwise>
12243
+ <xsl:value-of select="concat('url(file:///',$basepath, $src, ')')"/>
12244
+ </xsl:otherwise>
12245
+ </xsl:choose>
12246
+ </xsl:template>
12247
+
12248
+ <xsl:template name="getSVG">
12249
+ <xsl:choose>
12250
+ <xsl:when test="*[local-name() = 'svg']">
12251
+ <xsl:apply-templates select="*[local-name() = 'svg']" mode="svg_update"/>
12252
+ </xsl:when>
12253
+ <xsl:otherwise>
12254
+ <xsl:variable name="svg_content" select="document(@src)"/>
12255
+ <xsl:for-each select="xalan:nodeset($svg_content)/node()">
12256
+ <xsl:apply-templates select="." mode="svg_update"/>
12257
+ </xsl:for-each>
12258
+ </xsl:otherwise>
12259
+ </xsl:choose>
12260
+ </xsl:template>
12261
+
12262
+ <!-- END: insert cover page image -->
12263
+
11613
12264
  <xsl:template name="number-to-words">
11614
12265
  <xsl:param name="number"/>
11615
12266
  <xsl:param name="first"/>