metanorma-bipm 2.2.0 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,6 +6,7 @@
6
6
  <xsl:param name="doc_split_by_language"/>
7
7
 
8
8
  <xsl:param name="add_math_as_attachment">true</xsl:param>
9
+ <xsl:param name="final_transform">true</xsl:param>
9
10
 
10
11
  <xsl:key name="kfn" match="*[local-name() = 'fn'][not(ancestor::*[(local-name() = 'table' or local-name() = 'figure') and not(ancestor::*[local-name() = 'name'])])]" use="@reference"/>
11
12
 
@@ -82,63 +83,77 @@
82
83
  <xsl:when test="$doc_split_by_language = ''"><!-- all documents -->
83
84
  <xsl:for-each select="//bipm:bipm-standard">
84
85
 
85
- <xsl:variable name="current_document">
86
+ <!-- <xsl:variable name="current_document">
86
87
  <xsl:copy-of select="."/>
87
88
  </xsl:variable>
88
-
89
- <xsl:for-each select="xalan:nodeset($current_document)">
89
+
90
+ <xsl:for-each select="xalan:nodeset($current_document)"> -->
90
91
 
91
92
  <xsl:variable name="docid">
92
- <xsl:call-template name="getDocumentId"/>
93
+ <xsl:call-template name="getDocumentId_fromCurrentNode"/>
94
+ <!-- <xsl:call-template name="getDocumentId"/> -->
93
95
  </xsl:variable>
94
96
 
95
97
  <!-- add id to xref and split xref with @to into two xref -->
96
98
  <xsl:variable name="current_document_index_id">
97
- <xsl:apply-templates select=".//bipm:indexsect" mode="index_add_id"/>
99
+ <xsl:apply-templates select=".//bipm:indexsect" mode="index_add_id">
100
+ <xsl:with-param name="docid" select="$docid"/>
101
+ </xsl:apply-templates>
98
102
  </xsl:variable>
99
103
 
100
- <xsl:variable name="current_document_index">
104
+ <!-- <xsl:variable name="current_document_index">
101
105
  <xsl:apply-templates select="xalan:nodeset($current_document_index_id)" mode="index_update"/>
102
106
  </xsl:variable>
103
-
107
+
104
108
  <xsl:for-each select="xalan:nodeset($current_document_index)">
105
109
  <doc id="{$docid}">
106
110
  <xsl:copy-of select="."/>
107
111
  </doc>
108
- </xsl:for-each>
112
+ </xsl:for-each> -->
109
113
 
110
- </xsl:for-each>
114
+ <doc id="{$docid}">
115
+ <xsl:apply-templates select="xalan:nodeset($current_document_index_id)" mode="index_update"/>
116
+ </doc>
117
+
118
+ <!-- </xsl:for-each> -->
111
119
 
112
120
  </xsl:for-each>
113
121
  </xsl:when>
114
122
  <xsl:otherwise>
115
123
  <xsl:for-each select="(//bipm:bipm-standard)[*[local-name()='bibdata']/*[local-name()='language'][@current = 'true'] = $doc_split_by_language]">
116
124
 
117
- <xsl:variable name="current_document">
125
+ <!-- <xsl:variable name="current_document">
118
126
  <xsl:copy-of select="."/>
119
127
  </xsl:variable>
120
-
121
- <xsl:for-each select="xalan:nodeset($current_document)">
128
+
129
+ <xsl:for-each select="xalan:nodeset($current_document)"> -->
122
130
 
123
131
  <xsl:variable name="docid">
124
- <xsl:call-template name="getDocumentId"/>
132
+ <!-- <xsl:call-template name="getDocumentId"/> -->
133
+ <xsl:call-template name="getDocumentId_fromCurrentNode"/>
125
134
  </xsl:variable>
126
135
 
127
136
  <xsl:variable name="current_document_index_id">
128
- <xsl:apply-templates select=".//bipm:indexsect" mode="index_add_id"/>
137
+ <xsl:apply-templates select=".//bipm:indexsect" mode="index_add_id">
138
+ <xsl:with-param name="docid" select="$docid"/>
139
+ </xsl:apply-templates>
129
140
  </xsl:variable>
130
141
 
131
- <xsl:variable name="current_document_index">
142
+ <!-- <xsl:variable name="current_document_index">
132
143
  <xsl:apply-templates select="xalan:nodeset($current_document_index_id)" mode="index_update"/>
133
144
  </xsl:variable>
134
-
145
+
135
146
  <xsl:for-each select="xalan:nodeset($current_document_index)">
136
147
  <doc id="{$docid}">
137
148
  <xsl:copy-of select="."/>
138
149
  </doc>
139
- </xsl:for-each>
150
+ </xsl:for-each> -->
140
151
 
141
- </xsl:for-each>
152
+ <doc id="{$docid}">
153
+ <xsl:apply-templates select="xalan:nodeset($current_document_index_id)" mode="index_update"/>
154
+ </doc>
155
+
156
+ <!-- </xsl:for-each> -->
142
157
 
143
158
  </xsl:for-each>
144
159
  </xsl:otherwise>
@@ -179,7 +194,7 @@
179
194
  </xsl:template>
180
195
 
181
196
  <xsl:variable name="mathml_attachments">
182
- <xsl:if test="$add_math_as_attachment = 'true'">
197
+ <xsl:if test="$add_math_as_attachment = 'true' and $final_transform = 'true'">
183
198
  <xsl:for-each select="//mathml:math">
184
199
 
185
200
  <xsl:variable name="sequence_number"><xsl:number level="any" format="00001"/></xsl:variable>
@@ -353,18 +368,23 @@
353
368
  <fo:declarations>
354
369
  <xsl:call-template name="addPDFUAmeta"/>
355
370
 
356
- <xsl:if test="$add_math_as_attachment = 'true'">
371
+ <xsl:if test="$add_math_as_attachment = 'true' and $final_transform = 'true'">
357
372
  <!-- DEBUG: mathml_attachments=<xsl:copy-of select="$mathml_attachments"/> -->
358
373
  <xsl:for-each select="xalan:nodeset($mathml_attachments)//attachment">
359
374
 
360
375
  <xsl:variable name="mathml_filename" select="@filename"/>
361
376
  <xsl:variable name="mathml_content" select="."/>
362
377
 
363
- <xsl:variable name="basepath" select="java:org.metanorma.fop.Util.saveFileToDisk($mathml_filename,$mathml_content)"/>
378
+ <!-- <xsl:variable name="basepath" select="java:org.metanorma.fop.Util.saveFileToDisk($mathml_filename,$mathml_content)"/> -->
379
+
380
+ <!-- <xsl:variable name="url" select="concat('url(file:',$basepath, ')')"/> -->
364
381
 
365
- <xsl:variable name="url" select="concat('url(file:',$basepath, ')')"/>
382
+ <xsl:variable name="base64" select="java:org.metanorma.fop.Util.encodeBase64($mathml_content)"/>
366
383
 
367
- <xsl:if test="normalize-space($url) != ''">
384
+ <xsl:variable name="url" select="concat('data:application/xml;base64,',$base64)"/>
385
+
386
+ <!-- <xsl:if test="normalize-space($url) != ''"> -->
387
+ <xsl:if test="normalize-space($base64) != ''">
368
388
  <pdf:embedded-file src="{$url}" filename="{$mathml_filename}"/>
369
389
  </xsl:if>
370
390
  </xsl:for-each>
@@ -405,12 +425,13 @@
405
425
  <xsl:variable name="lang" select="*[local-name()='bibdata']//*[local-name()='language'][@current = 'true']"/>
406
426
  <xsl:variable name="num"><xsl:number level="any" count="bipm:bipm-standard"/></xsl:variable>
407
427
 
408
- <xsl:variable name="title_eref">
428
+ <!-- <xsl:variable name="title_eref">
409
429
  <xsl:apply-templates select="." mode="title_eref"/>
410
- </xsl:variable>
430
+ </xsl:variable> -->
411
431
 
412
432
  <xsl:variable name="flatxml_">
413
- <xsl:apply-templates select="xalan:nodeset($title_eref)" mode="flatxml"/>
433
+ <!-- <xsl:apply-templates select="xalan:nodeset($title_eref)" mode="flatxml"/> -->
434
+ <xsl:apply-templates select="." mode="flatxml"/>
414
435
  </xsl:variable>
415
436
 
416
437
  <xsl:variable name="flatxml">
@@ -430,12 +451,13 @@
430
451
  <xsl:variable name="lang" select="*[local-name()='bibdata']//*[local-name()='language'][@current = 'true']"/>
431
452
  <xsl:variable name="num"><xsl:number level="any" count="bipm:bipm-standard"/></xsl:variable>
432
453
 
433
- <xsl:variable name="title_eref">
454
+ <!-- <xsl:variable name="title_eref">
434
455
  <xsl:apply-templates select="." mode="title_eref"/>
435
- </xsl:variable>
456
+ </xsl:variable> -->
436
457
 
437
458
  <xsl:variable name="flatxml_">
438
- <xsl:apply-templates select="xalan:nodeset($title_eref)" mode="flatxml"/>
459
+ <!-- <xsl:apply-templates select="xalan:nodeset($title_eref)" mode="flatxml"/> -->
460
+ <xsl:apply-templates select="." mode="flatxml"/>
439
461
  </xsl:variable>
440
462
 
441
463
  <xsl:variable name="flatxml">
@@ -453,12 +475,13 @@
453
475
  </xsl:when>
454
476
  <xsl:otherwise>
455
477
 
456
- <xsl:variable name="title_eref">
478
+ <!-- <xsl:variable name="title_eref">
457
479
  <xsl:apply-templates mode="title_eref"/>
458
- </xsl:variable>
480
+ </xsl:variable> -->
459
481
 
460
482
  <xsl:variable name="flatxml_">
461
- <xsl:apply-templates select="xalan:nodeset($title_eref)" mode="flatxml"/>
483
+ <!-- <xsl:apply-templates select="xalan:nodeset($title_eref)" mode="flatxml"/> -->
484
+ <xsl:apply-templates select="." mode="flatxml"/>
462
485
  </xsl:variable>
463
486
 
464
487
  <xsl:variable name="flatxml">
@@ -3249,7 +3272,8 @@
3249
3272
  </xsl:call-template>
3250
3273
  <fo:block-container font-family="Arial" font-size="8pt" padding-top="12.5mm">
3251
3274
  <fo:block text-align="right">
3252
- <xsl:copy-of select="$header-title"/>
3275
+ <!-- <xsl:copy-of select="$header-title"/> -->
3276
+ <xsl:apply-templates select="xalan:nodeset($header-title)" mode="header_title_remove_link_embedded"/>
3253
3277
  <xsl:text>  </xsl:text>
3254
3278
  <fo:inline font-size="13pt" baseline-shift="-15%">•</fo:inline>
3255
3279
  <xsl:text>  </xsl:text>
@@ -3274,7 +3298,8 @@
3274
3298
  <xsl:text>  </xsl:text>
3275
3299
  <fo:inline font-size="13pt" baseline-shift="-15%">•</fo:inline>
3276
3300
  <xsl:text>  </xsl:text>
3277
- <xsl:copy-of select="$header-title"/>
3301
+ <!-- <xsl:copy-of select="$header-title"/> -->
3302
+ <xsl:apply-templates select="xalan:nodeset($header-title)" mode="header_title_remove_link_embedded"/>
3278
3303
  </fo:block>
3279
3304
  <fo:block-container font-size="1pt" border-top="0.5pt solid black" width="86.6mm">
3280
3305
  <fo:block> </fo:block>
@@ -3290,6 +3315,16 @@
3290
3315
  </fo:static-content>
3291
3316
  </xsl:template>
3292
3317
 
3318
+ <xsl:template match="@*|node()" mode="header_title_remove_link_embedded">
3319
+ <xsl:copy>
3320
+ <xsl:apply-templates select="@*|node()" mode="header_title_remove_link_embedded"/>
3321
+ </xsl:copy>
3322
+ </xsl:template>
3323
+
3324
+ <xsl:template match="fo:basic-link[contains(@external-destination,'embedded-file')]" mode="header_title_remove_link_embedded">
3325
+ <xsl:apply-templates mode="header_title_remove_link_embedded"/>
3326
+ </xsl:template>
3327
+
3293
3328
  <xsl:template name="insertDraftWatermark">
3294
3329
  <xsl:param name="isDraft"/>
3295
3330
  <xsl:param name="lang"/>
@@ -4592,6 +4627,10 @@
4592
4627
  <xsl:attribute name="font-weight">bold</xsl:attribute>
4593
4628
  </xsl:attribute-set>
4594
4629
 
4630
+ <xsl:attribute-set name="figure-block-style">
4631
+
4632
+ </xsl:attribute-set>
4633
+
4595
4634
  <xsl:attribute-set name="figure-style">
4596
4635
 
4597
4636
  </xsl:attribute-set>
@@ -6045,6 +6084,10 @@
6045
6084
  <xsl:with-param name="continued">true</xsl:with-param>
6046
6085
  </xsl:apply-templates>
6047
6086
 
6087
+ <xsl:if test="not(ancestor::*[local-name()='table']/*[local-name()='name'])"> <!-- to prevent empty fo:table-cell in case of missing table's name -->
6088
+ <fo:block/>
6089
+ </xsl:if>
6090
+
6048
6091
  </fo:table-cell>
6049
6092
  </fo:table-row>
6050
6093
  </xsl:template> <!-- table-header-title -->
@@ -6490,7 +6533,22 @@
6490
6533
 
6491
6534
  <xsl:variable name="ref_id" select="concat('footnote_', $lang, '_', $reference, '_', $current_fn_number)"/>
6492
6535
  <xsl:variable name="footnote_inline">
6493
- <fo:inline xsl:use-attribute-sets="fn-num-style">
6536
+ <fo:inline>
6537
+
6538
+ <xsl:variable name="fn_styles">
6539
+ <xsl:choose>
6540
+ <xsl:when test="ancestor::*[local-name() = 'bibitem']">
6541
+ <fn_styles xsl:use-attribute-sets="bibitem-note-fn-style"/>
6542
+ </xsl:when>
6543
+ <xsl:otherwise>
6544
+ <fn_styles xsl:use-attribute-sets="fn-num-style"/>
6545
+ </xsl:otherwise>
6546
+ </xsl:choose>
6547
+ </xsl:variable>
6548
+
6549
+ <xsl:for-each select="xalan:nodeset($fn_styles)/fn_styles/@*">
6550
+ <xsl:copy-of select="."/>
6551
+ </xsl:for-each>
6494
6552
 
6495
6553
  <xsl:if test="following-sibling::*[1][local-name() = 'fn']">
6496
6554
  <xsl:attribute name="padding-right">0.5mm</xsl:attribute>
@@ -6554,7 +6612,10 @@
6554
6612
  </xsl:for-each>
6555
6613
  <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']/*">
6556
6614
  <xsl:sort select="@displayorder" data-type="number"/>
6557
- <xsl:for-each select=".//*[local-name() = 'bibitem'][ancestor::*[local-name() = 'references']]/*[local-name() = 'note'] | .//*[local-name() = 'fn'][not(ancestor::*[(local-name() = 'table' or local-name() = 'figure') and not(ancestor::*[local-name() = 'name'])])][generate-id(.)=generate-id(key('kfn',@reference)[1])]">
6615
+ <!-- commented:
6616
+ .//*[local-name() = 'bibitem'][ancestor::*[local-name() = 'references']]/*[local-name() = 'note'] |
6617
+ because 'fn' there is in biblio-tag -->
6618
+ <xsl:for-each select=".//*[local-name() = 'fn'][not(ancestor::*[(local-name() = 'table' or local-name() = 'figure') and not(ancestor::*[local-name() = 'name'])])][generate-id(.)=generate-id(key('kfn',@reference)[1])]">
6558
6619
  <!-- copy unique fn -->
6559
6620
  <fn gen_id="{generate-id(.)}">
6560
6621
  <xsl:copy-of select="@*"/>
@@ -7412,7 +7473,7 @@
7412
7473
 
7413
7474
  <xsl:variable name="_font-size">
7414
7475
 
7415
- <!-- 10 -->
7476
+ <!-- inherit -->
7416
7477
 
7417
7478
  </xsl:variable>
7418
7479
  <xsl:variable name="font-size" select="normalize-space($_font-size)"/>
@@ -8380,6 +8441,33 @@
8380
8441
  </xsl:choose>
8381
8442
  </xsl:template>
8382
8443
 
8444
+ <xsl:template name="getLang_fromCurrentNode">
8445
+ <xsl:variable name="language_current" select="normalize-space(.//*[local-name()='bibdata']//*[local-name()='language'][@current = 'true'])"/>
8446
+ <xsl:variable name="language">
8447
+ <xsl:choose>
8448
+ <xsl:when test="$language_current != ''">
8449
+ <xsl:value-of select="$language_current"/>
8450
+ </xsl:when>
8451
+ <xsl:otherwise>
8452
+ <xsl:variable name="language_current_2" select="normalize-space(xalan:nodeset($bibdata)//*[local-name()='bibdata']//*[local-name()='language'][@current = 'true'])"/>
8453
+ <xsl:choose>
8454
+ <xsl:when test="$language_current_2 != ''">
8455
+ <xsl:value-of select="$language_current_2"/>
8456
+ </xsl:when>
8457
+ <xsl:otherwise>
8458
+ <xsl:value-of select=".//*[local-name()='bibdata']//*[local-name()='language']"/>
8459
+ </xsl:otherwise>
8460
+ </xsl:choose>
8461
+ </xsl:otherwise>
8462
+ </xsl:choose>
8463
+ </xsl:variable>
8464
+
8465
+ <xsl:choose>
8466
+ <xsl:when test="$language = 'English'">en</xsl:when>
8467
+ <xsl:otherwise><xsl:value-of select="$language"/></xsl:otherwise>
8468
+ </xsl:choose>
8469
+ </xsl:template>
8470
+
8383
8471
  <xsl:template name="capitalizeWords">
8384
8472
  <xsl:param name="str"/>
8385
8473
  <xsl:variable name="str2" select="translate($str, '-', ' ')"/>
@@ -9060,7 +9148,7 @@
9060
9148
  <xsl:template match="*[local-name() = 'figure']" name="figure">
9061
9149
  <xsl:variable name="isAdded" select="@added"/>
9062
9150
  <xsl:variable name="isDeleted" select="@deleted"/>
9063
- <fo:block-container id="{@id}">
9151
+ <fo:block-container id="{@id}" xsl:use-attribute-sets="figure-block-style">
9064
9152
 
9065
9153
  <xsl:if test="*[local-name() = 'name']">
9066
9154
  <xsl:attribute name="space-after">12pt</xsl:attribute>
@@ -10064,7 +10152,13 @@
10064
10152
  </xsl:template>
10065
10153
 
10066
10154
  <xsl:template match="text()" mode="contents_item">
10067
- <xsl:call-template name="keep_together_standard_number"/>
10155
+ <xsl:variable name="text">
10156
+ <!-- to split by '_' and other chars -->
10157
+ <text><xsl:call-template name="add-zero-spaces-java"/></text>
10158
+ </xsl:variable>
10159
+ <xsl:for-each select="xalan:nodeset($text)/text/text()">
10160
+ <xsl:call-template name="keep_together_standard_number"/>
10161
+ </xsl:for-each>
10068
10162
  </xsl:template>
10069
10163
 
10070
10164
  <!-- Note: to enable the addition of character span markup with semantic styling for DIS Word output -->
@@ -10075,34 +10169,52 @@
10075
10169
  <!-- =============== -->
10076
10170
  <!-- sourcecode -->
10077
10171
  <!-- =============== -->
10078
- <xsl:template match="*[local-name()='sourcecode']" name="sourcecode">
10079
10172
 
10080
- <xsl:variable name="sourcecode_attributes">
10081
- <xsl:element name="sourcecode_attributes" use-attribute-sets="sourcecode-style">
10082
- <xsl:variable name="_font-size">
10173
+ <xsl:variable name="source-highlighter-css_" select="//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'source-highlighter-css']"/>
10174
+ <xsl:variable name="sourcecode_css_" select="java:org.metanorma.fop.Util.parseCSS($source-highlighter-css_)"/>
10175
+ <xsl:variable name="sourcecode_css" select="xalan:nodeset($sourcecode_css_)"/>
10083
10176
 
10084
- <!-- 9 -->
10177
+ <xsl:template match="*[local-name() = 'property']" mode="css">
10178
+ <xsl:attribute name="{@name}">
10179
+ <xsl:value-of select="@value"/>
10180
+ </xsl:attribute>
10181
+ </xsl:template>
10085
10182
 
10086
- <!-- <xsl:if test="$namespace = 'ieee'">
10087
- <xsl:if test="$current_template = 'standard'">8</xsl:if>
10088
- </xsl:if> -->
10183
+ <xsl:template name="get_sourcecode_attributes">
10184
+ <xsl:element name="sourcecode_attributes" use-attribute-sets="sourcecode-style">
10185
+ <xsl:variable name="_font-size">
10089
10186
 
10090
- </xsl:variable>
10187
+ <!-- inherit -->
10091
10188
 
10092
- <xsl:variable name="font-size" select="normalize-space($_font-size)"/>
10093
- <xsl:if test="$font-size != ''">
10094
- <xsl:attribute name="font-size">
10095
- <xsl:choose>
10096
- <xsl:when test="$font-size = 'inherit'"><xsl:value-of select="$font-size"/></xsl:when>
10097
- <xsl:when test="contains($font-size, '%')"><xsl:value-of select="$font-size"/></xsl:when>
10098
- <xsl:when test="ancestor::*[local-name()='note']"><xsl:value-of select="$font-size * 0.91"/>pt</xsl:when>
10099
- <xsl:otherwise><xsl:value-of select="$font-size"/>pt</xsl:otherwise>
10100
- </xsl:choose>
10101
- </xsl:attribute>
10102
- </xsl:if>
10103
- </xsl:element>
10189
+ <!-- <xsl:if test="$namespace = 'ieee'">
10190
+ <xsl:if test="$current_template = 'standard'">8</xsl:if>
10191
+ </xsl:if> -->
10192
+
10193
+ </xsl:variable>
10194
+
10195
+ <xsl:variable name="font-size" select="normalize-space($_font-size)"/>
10196
+ <xsl:if test="$font-size != ''">
10197
+ <xsl:attribute name="font-size">
10198
+ <xsl:choose>
10199
+ <xsl:when test="$font-size = 'inherit'"><xsl:value-of select="$font-size"/></xsl:when>
10200
+ <xsl:when test="contains($font-size, '%')"><xsl:value-of select="$font-size"/></xsl:when>
10201
+ <xsl:when test="ancestor::*[local-name()='note']"><xsl:value-of select="$font-size * 0.91"/>pt</xsl:when>
10202
+ <xsl:otherwise><xsl:value-of select="$font-size"/>pt</xsl:otherwise>
10203
+ </xsl:choose>
10204
+ </xsl:attribute>
10205
+ </xsl:if>
10206
+ <xsl:apply-templates select="$sourcecode_css//class[@name = 'sourcecode']" mode="css"/>
10207
+ </xsl:element>
10208
+ </xsl:template>
10209
+
10210
+ <xsl:template match="*[local-name()='sourcecode']" name="sourcecode">
10211
+
10212
+ <xsl:variable name="sourcecode_attributes">
10213
+ <xsl:call-template name="get_sourcecode_attributes"/>
10104
10214
  </xsl:variable>
10105
10215
 
10216
+ <!-- <xsl:copy-of select="$sourcecode_css"/> -->
10217
+
10106
10218
  <xsl:choose>
10107
10219
  <xsl:when test="$isGenerateTableIF = 'true' and (ancestor::*[local-name() = 'td'] or ancestor::*[local-name() = 'th'])">
10108
10220
  <xsl:for-each select="xalan:nodeset($sourcecode_attributes)/sourcecode_attributes/@*">
@@ -10156,9 +10268,10 @@
10156
10268
  </xsl:choose>
10157
10269
  </xsl:template>
10158
10270
 
10159
- <xsl:template match="*[local-name()='sourcecode']/text()" priority="2">
10271
+ <xsl:template match="*[local-name()='sourcecode']/text() | *[local-name()='sourcecode']//*[local-name()='span']/text()" priority="2">
10160
10272
  <xsl:choose>
10161
- <xsl:when test="normalize-space($syntax-highlight) = 'true' and normalize-space(../@lang) != ''"> <!-- condition for turn on of highlighting -->
10273
+ <!-- disabled -->
10274
+ <xsl:when test="1 = 2 and normalize-space($syntax-highlight) = 'true' and normalize-space(../@lang) != ''"> <!-- condition for turn on of highlighting -->
10162
10275
  <xsl:variable name="syntax" select="java:org.metanorma.fop.Util.syntaxHighlight(., ../@lang)"/>
10163
10276
  <xsl:choose>
10164
10277
  <xsl:when test="normalize-space($syntax) != ''"><!-- if there is highlighted result -->
@@ -10173,8 +10286,75 @@
10173
10286
  <xsl:call-template name="add_spaces_to_sourcecode"/>
10174
10287
  </xsl:otherwise>
10175
10288
  </xsl:choose>
10289
+ </xsl:template>
10290
+
10291
+ <!-- add sourcecode highlighting -->
10292
+ <xsl:template match="*[local-name()='sourcecode']//*[local-name()='span'][@class]" priority="2">
10293
+ <xsl:variable name="class" select="@class"/>
10294
+ <xsl:choose>
10295
+ <xsl:when test="$sourcecode_css//class[@name = $class]">
10296
+ <fo:inline>
10297
+ <xsl:apply-templates select="$sourcecode_css//class[@name = $class]" mode="css"/>
10298
+ <xsl:apply-templates/>
10299
+ </fo:inline>
10300
+ </xsl:when>
10301
+ <xsl:otherwise>
10302
+ <xsl:apply-templates/>
10303
+ </xsl:otherwise>
10304
+ </xsl:choose>
10305
+ </xsl:template>
10306
+
10307
+ <!-- outer table with line numbers for sourcecode -->
10308
+ <xsl:template match="*[local-name()='table'][@type = 'sourcecode']" priority="2">
10309
+ <fo:block>
10310
+ <fo:table width="100%" table-layout="fixed">
10311
+ <xsl:copy-of select="@id"/>
10312
+ <fo:table-column column-width="8%"/>
10313
+ <fo:table-column column-width="92%"/>
10314
+ <fo:table-body>
10315
+ <xsl:apply-templates/>
10316
+ </fo:table-body>
10317
+ </fo:table>
10318
+ </fo:block>
10319
+ </xsl:template>
10320
+ <xsl:template match="*[local-name()='table'][@type = 'sourcecode']/*[local-name() = 'tbody']" priority="2">
10321
+ <xsl:apply-templates/>
10322
+ </xsl:template>
10323
+ <xsl:template match="*[local-name()='table'][@type = 'sourcecode']//*[local-name()='tr']" priority="2">
10324
+ <fo:table-row>
10325
+ <xsl:apply-templates/>
10326
+ </fo:table-row>
10327
+ </xsl:template>
10328
+ <!-- first td with line numbers -->
10329
+ <xsl:template match="*[local-name()='table'][@type = 'sourcecode']//*[local-name()='tr']/*[local-name()='td'][not(preceding-sibling::*)]" priority="2">
10330
+ <fo:table-cell>
10331
+ <fo:block>
10332
+
10333
+ <!-- set attibutes for line numbers - same as sourcecode -->
10334
+ <xsl:variable name="sourcecode_attributes">
10335
+ <xsl:for-each select="following-sibling::*[local-name() = 'td']/*[local-name() = 'sourcecode']">
10336
+ <xsl:call-template name="get_sourcecode_attributes"/>
10337
+ </xsl:for-each>
10338
+ </xsl:variable>
10339
+ <xsl:for-each select="xalan:nodeset($sourcecode_attributes)/sourcecode_attributes/@*[not(starts-with(local-name(), 'margin-') or starts-with(local-name(), 'space-'))]">
10340
+ <xsl:attribute name="{local-name()}">
10341
+ <xsl:value-of select="."/>
10342
+ </xsl:attribute>
10343
+ </xsl:for-each>
10176
10344
 
10345
+ <xsl:apply-templates/>
10346
+ </fo:block>
10347
+ </fo:table-cell>
10348
+ </xsl:template>
10349
+ <!-- second td with sourcecode -->
10350
+ <xsl:template match="*[local-name()='table'][@type = 'sourcecode']//*[local-name()='tr']/*[local-name()='td'][preceding-sibling::*]" priority="2">
10351
+ <fo:table-cell>
10352
+ <fo:block>
10353
+ <xsl:apply-templates/>
10354
+ </fo:block>
10355
+ </fo:table-cell>
10177
10356
  </xsl:template>
10357
+ <!-- END outer table with line numbers for sourcecode -->
10178
10358
 
10179
10359
  <xsl:template name="add_spaces_to_sourcecode">
10180
10360
  <xsl:variable name="text_step1">
@@ -11853,23 +12033,17 @@
11853
12033
  <fo:list-item-label end-indent="label-end()">
11854
12034
  <fo:block>
11855
12035
  <fo:inline>
11856
- <xsl:value-of select="bipm:docidentifier[@type='metanorma-ordinal']"/>
11857
- <xsl:if test="not(bipm:docidentifier[@type='metanorma-ordinal'])">
11858
- <xsl:choose>
11859
- <xsl:when test="bipm:docidentifier[@type='metanorma']">
11860
- <xsl:value-of select="bipm:docidentifier[@type='metanorma']"/>
11861
- </xsl:when>
11862
- <xsl:otherwise>
11863
- <xsl:number format="[1]" count="*[local-name()='bibitem'][not(@hidden = 'true')]"/>
11864
- </xsl:otherwise>
11865
- </xsl:choose>
11866
- </xsl:if>
12036
+ <xsl:apply-templates select="*[local-name() = 'biblio-tag']">
12037
+ <xsl:with-param name="biblio_tag_part">first</xsl:with-param>
12038
+ </xsl:apply-templates>
11867
12039
  </fo:inline>
11868
12040
  </fo:block>
11869
12041
  </fo:list-item-label>
11870
12042
  <fo:list-item-body start-indent="body-start()">
11871
12043
  <fo:block>
11872
- <xsl:call-template name="processBibitem"/>
12044
+ <xsl:call-template name="processBibitem">
12045
+ <xsl:with-param name="biblio_tag_part">last</xsl:with-param>
12046
+ </xsl:call-template>
11873
12047
  </fo:block>
11874
12048
  </fo:list-item-body>
11875
12049
  </fo:list-item>
@@ -11879,178 +12053,51 @@
11879
12053
  </xsl:template> <!-- references[not(@normative='true')]/bibitem -->
11880
12054
 
11881
12055
  <xsl:template name="processBibitem">
12056
+ <xsl:param name="biblio_tag_part">both</xsl:param>
11882
12057
 
11883
- <!-- start BIPM bibitem processing -->
11884
- <xsl:if test=".//bipm:fn">
12058
+ <!-- start bibitem processing -->
12059
+ <xsl:if test=".//*[local-name() = 'fn']">
11885
12060
  <xsl:attribute name="line-height-shift-adjustment">disregard-shifts</xsl:attribute>
11886
12061
  </xsl:if>
11887
12062
 
11888
- <xsl:variable name="docidentifier_" select="*[local-name() = 'docidentifier'][not(@type = 'URN' or @type = 'metanorma' or @type = 'metanorma-ordinal' or @type = 'BIPM' or @type = 'ISBN' or @type = 'ISSN')]"/>
11889
- <xsl:variable name="docidentifier_main" select="*[local-name() = 'docidentifier'][not(@type)]"/>
11890
- <xsl:variable name="docidentifier">
11891
- <xsl:choose>
11892
- <xsl:when test="$docidentifier_ = $docidentifier_main and @suppress_identifier = 'true'"><!-- suppress indentifier --></xsl:when>
11893
- <xsl:otherwise><xsl:value-of select="$docidentifier_"/></xsl:otherwise>
11894
- </xsl:choose>
11895
- </xsl:variable>
11896
- <xsl:value-of select="normalize-space($docidentifier)"/>
11897
-
11898
- <xsl:if test="normalize-space($docidentifier) != '' and *[local-name() = 'formattedref']">, </xsl:if>
12063
+ <xsl:apply-templates select="*[local-name() = 'biblio-tag']">
12064
+ <xsl:with-param name="biblio_tag_part" select="$biblio_tag_part"/>
12065
+ </xsl:apply-templates>
11899
12066
  <xsl:apply-templates select="*[local-name() = 'formattedref']"/>
11900
- <!-- end BIPM bibitem processing-->
12067
+ <!-- end bibitem processing -->
11901
12068
 
11902
12069
  </xsl:template> <!-- processBibitem (bibitem) -->
11903
12070
 
11904
- <xsl:template name="processBibitemDocId">
11905
- <xsl:variable name="_doc_ident" select="*[local-name() = 'docidentifier'][not(@type = 'DOI' or @type = 'metanorma' or @type = 'metanorma-ordinal' or @type = 'ISSN' or @type = 'ISBN' or @type = 'rfc-anchor')]"/>
11906
- <xsl:choose>
11907
- <xsl:when test="normalize-space($_doc_ident) != ''">
11908
- <!-- <xsl:variable name="type" select="*[local-name() = 'docidentifier'][not(@type = 'DOI' or @type = 'metanorma' or @type = 'ISSN' or @type = 'ISBN' or @type = 'rfc-anchor')]/@type"/>
11909
- <xsl:if test="$type != '' and not(contains($_doc_ident, $type))">
11910
- <xsl:value-of select="$type"/><xsl:text> </xsl:text>
11911
- </xsl:if> -->
11912
- <xsl:value-of select="$_doc_ident"/>
11913
- </xsl:when>
11914
- <xsl:otherwise>
11915
- <!-- <xsl:variable name="type" select="*[local-name() = 'docidentifier'][not(@type = 'metanorma')]/@type"/>
11916
- <xsl:if test="$type != ''">
11917
- <xsl:value-of select="$type"/><xsl:text> </xsl:text>
11918
- </xsl:if> -->
11919
- <xsl:value-of select="*[local-name() = 'docidentifier'][not(@type = 'metanorma') and not(@type = 'metanorma-ordinal')]"/>
11920
- </xsl:otherwise>
11921
- </xsl:choose>
11922
- </xsl:template> <!-- processBibitemDocId -->
12071
+ <xsl:template match="*[local-name() = 'title']" mode="title">
12072
+ <fo:inline><xsl:apply-templates/></fo:inline>
12073
+ </xsl:template>
12074
+
12075
+ <xsl:template match="*[local-name() = 'bibitem']/*[local-name() = 'docidentifier']"/>
12076
+
12077
+ <xsl:template match="*[local-name() = 'formattedref']">
12078
+ <!-- <xsl:if test="$namespace = 'unece' or $namespace = 'unece-rec'">
12079
+ <xsl:text>, </xsl:text>
12080
+ </xsl:if> -->
12081
+ <xsl:apply-templates/>
12082
+ </xsl:template>
11923
12083
 
11924
- <xsl:template name="processPersonalAuthor">
12084
+ <xsl:template match="*[local-name() = 'biblio-tag']">
12085
+ <xsl:param name="biblio_tag_part">both</xsl:param>
11925
12086
  <xsl:choose>
11926
- <xsl:when test="*[local-name() = 'name']/*[local-name() = 'completename']">
11927
- <author>
11928
- <xsl:apply-templates select="*[local-name() = 'name']/*[local-name() = 'completename']"/>
11929
- </author>
11930
- </xsl:when>
11931
- <xsl:when test="*[local-name() = 'name']/*[local-name() = 'surname'] and *[local-name() = 'name']/*[local-name() = 'initial']">
11932
- <author>
11933
- <xsl:apply-templates select="*[local-name() = 'name']/*[local-name() = 'surname']"/>
11934
- <xsl:text> </xsl:text>
11935
- <xsl:apply-templates select="*[local-name() = 'name']/*[local-name() = 'initial']" mode="strip"/>
11936
- </author>
12087
+ <xsl:when test="$biblio_tag_part = 'first' and *[local-name() = 'tab']">
12088
+ <xsl:apply-templates select="./*[local-name() = 'tab'][1]/preceding-sibling::node()"/>
11937
12089
  </xsl:when>
11938
- <xsl:when test="*[local-name() = 'name']/*[local-name() = 'surname'] and *[local-name() = 'name']/*[local-name() = 'forename']">
11939
- <author>
11940
- <xsl:apply-templates select="*[local-name() = 'name']/*[local-name() = 'surname']"/>
11941
- <xsl:text> </xsl:text>
11942
- <xsl:apply-templates select="*[local-name() = 'name']/*[local-name() = 'forename']" mode="strip"/>
11943
- </author>
12090
+ <xsl:when test="$biblio_tag_part = 'last'">
12091
+ <xsl:apply-templates select="./*[local-name() = 'tab'][1]/following-sibling::node()"/>
11944
12092
  </xsl:when>
11945
12093
  <xsl:otherwise>
11946
12094
  <xsl:apply-templates/>
11947
12095
  </xsl:otherwise>
11948
12096
  </xsl:choose>
11949
- </xsl:template> <!-- processPersonalAuthor -->
11950
-
11951
- <xsl:template name="renderDate">
11952
- <xsl:if test="normalize-space(*[local-name() = 'on']) != ''">
11953
- <xsl:value-of select="*[local-name() = 'on']"/>
11954
- </xsl:if>
11955
- <xsl:if test="normalize-space(*[local-name() = 'from']) != ''">
11956
- <xsl:value-of select="concat(*[local-name() = 'from'], '–', *[local-name() = 'to'])"/>
11957
- </xsl:if>
11958
- </xsl:template>
11959
-
11960
- <xsl:template match="*[local-name() = 'name']/*[local-name() = 'initial']/text()" mode="strip">
11961
- <xsl:value-of select="translate(.,'. ','')"/>
11962
- </xsl:template>
11963
-
11964
- <xsl:template match="*[local-name() = 'name']/*[local-name() = 'forename']/text()" mode="strip">
11965
- <xsl:value-of select="substring(.,1,1)"/>
11966
- </xsl:template>
11967
-
11968
- <xsl:template match="*[local-name() = 'title']" mode="title">
11969
- <fo:inline><xsl:apply-templates/></fo:inline>
11970
12097
  </xsl:template>
11971
12098
 
11972
- <xsl:template match="*[local-name() = 'bibitem']/*[local-name() = 'title']" priority="2">
11973
- <!-- <fo:inline><xsl:apply-templates /></fo:inline> -->
11974
- <fo:inline font-style="italic"> <!-- BIPM BSI CSD CSA GB IEC IHO ISO ITU JCGM -->
11975
- <xsl:apply-templates/>
11976
- </fo:inline>
11977
- </xsl:template>
11978
-
11979
- <!-- bibitem/note renders as footnote -->
11980
- <xsl:template match="*[local-name() = 'bibitem']/*[local-name() = 'note']" priority="2">
11981
-
11982
- <!-- list of footnotes to calculate actual footnotes number -->
11983
- <xsl:variable name="p_fn_">
11984
- <xsl:call-template name="get_fn_list"/>
11985
- </xsl:variable>
11986
- <xsl:variable name="p_fn" select="xalan:nodeset($p_fn_)"/>
11987
- <xsl:variable name="gen_id" select="generate-id(.)"/>
11988
- <xsl:variable name="lang" select="ancestor::*[contains(local-name(), '-standard')]/*[local-name()='bibdata']//*[local-name()='language'][@current = 'true']"/>
11989
- <!-- fn sequence number in document -->
11990
- <xsl:variable name="current_fn_number">
11991
- <xsl:choose>
11992
- <xsl:when test="@current_fn_number"><xsl:value-of select="@current_fn_number"/></xsl:when> <!-- for BSI -->
11993
- <xsl:otherwise>
11994
- <!-- <xsl:value-of select="count($p_fn//fn[@reference = $reference]/preceding-sibling::fn) + 1" /> -->
11995
- <xsl:value-of select="count($p_fn//fn[@gen_id = $gen_id]/preceding-sibling::fn) + 1"/>
11996
- </xsl:otherwise>
11997
- </xsl:choose>
11998
- </xsl:variable>
11999
- <fo:footnote>
12000
- <xsl:variable name="number">
12001
-
12002
- <xsl:choose>
12003
- <xsl:when test="ancestor::*[local-name() = 'references'][preceding-sibling::*[local-name() = 'references']]">
12004
- <xsl:number level="any" count="*[local-name() = 'references'][preceding-sibling::*[local-name() = 'references']]//*[local-name() = 'bibitem']/*[local-name() = 'note']"/>
12005
- </xsl:when>
12006
- <xsl:otherwise>
12007
- <xsl:value-of select="$current_fn_number"/>
12008
- </xsl:otherwise>
12009
- </xsl:choose>
12010
-
12011
- </xsl:variable>
12012
-
12013
- <xsl:variable name="current_fn_number_text">
12014
- <xsl:value-of select="$number"/>
12015
-
12016
- </xsl:variable>
12017
-
12018
- <fo:inline xsl:use-attribute-sets="bibitem-note-fn-style">
12019
- <fo:basic-link internal-destination="{$gen_id}" fox:alt-text="footnote {$number}">
12020
- <xsl:value-of select="$current_fn_number_text"/>
12021
- </fo:basic-link>
12022
- </fo:inline>
12023
- <fo:footnote-body>
12024
- <fo:block xsl:use-attribute-sets="bibitem-note-fn-body-style">
12025
- <fo:inline id="{$gen_id}" xsl:use-attribute-sets="bibitem-note-fn-number-style">
12026
- <xsl:value-of select="$current_fn_number_text"/>
12027
- </fo:inline>
12028
- <xsl:apply-templates/>
12029
- </fo:block>
12030
- </fo:footnote-body>
12031
- </fo:footnote>
12032
- </xsl:template>
12033
-
12034
- <xsl:template match="*[local-name() = 'bibitem']/*[local-name() = 'edition']"> <!-- for iho -->
12035
- <xsl:text> edition </xsl:text>
12036
- <xsl:value-of select="."/>
12037
- </xsl:template>
12038
-
12039
- <xsl:template match="*[local-name() = 'bibitem']/*[local-name() = 'uri']"> <!-- for iho -->
12040
- <xsl:text> (</xsl:text>
12041
- <fo:inline xsl:use-attribute-sets="link-style">
12042
- <fo:basic-link external-destination="." fox:alt-text=".">
12043
- <xsl:value-of select="."/>
12044
- </fo:basic-link>
12045
- </fo:inline>
12046
- <xsl:text>)</xsl:text>
12047
- </xsl:template>
12048
-
12049
- <xsl:template match="*[local-name() = 'bibitem']/*[local-name() = 'docidentifier']"/>
12050
-
12051
- <xsl:template match="*[local-name() = 'formattedref']">
12052
-
12053
- <xsl:apply-templates/>
12099
+ <xsl:template match="*[local-name() = 'biblio-tag']/*[local-name() = 'tab']" priority="2">
12100
+ <xsl:text> </xsl:text>
12054
12101
  </xsl:template>
12055
12102
 
12056
12103
  <!-- ======================= -->
@@ -12479,6 +12526,12 @@
12479
12526
  <xsl:template match="*[local-name() = 'span']" mode="update_xml_step1">
12480
12527
  <xsl:apply-templates mode="update_xml_step1"/>
12481
12528
  </xsl:template>
12529
+ <xsl:template match="*[local-name() = 'sourcecode']//*[local-name() = 'span'][@class]" mode="update_xml_step1" priority="2">
12530
+ <xsl:copy>
12531
+ <xsl:copy-of select="@*"/>
12532
+ <xsl:apply-templates mode="update_xml_step1"/>
12533
+ </xsl:copy>
12534
+ </xsl:template>
12482
12535
  <!-- =========================================================================== -->
12483
12536
  <!-- END STEP1: Re-order elements in 'preface', 'sections' based on @displayorder -->
12484
12537
  <!-- =========================================================================== -->
@@ -12959,6 +13012,10 @@
12959
13012
  <xsl:call-template name="getLang"/><xsl:value-of select="//*[local-name() = 'p'][1]/@id"/>
12960
13013
  </xsl:template>
12961
13014
 
13015
+ <xsl:template name="getDocumentId_fromCurrentNode">
13016
+ <xsl:call-template name="getLang_fromCurrentNode"/><xsl:value-of select=".//*[local-name() = 'p'][1]/@id"/>
13017
+ </xsl:template>
13018
+
12962
13019
  <xsl:template name="namespaceCheck">
12963
13020
  <xsl:variable name="documentNS" select="namespace-uri(/*)"/>
12964
13021
  <xsl:variable name="XSLNS">