metanorma-bipm 2.0.5 → 2.0.8

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9b206ced2e07cad956cc85b8bc7d8b762db76ffc0985ec98281349ca63751e4f
4
- data.tar.gz: fe16b2306394e683cc6de883b00ea32f7b04dfbfaf1b03842c03dcf180748def
3
+ metadata.gz: 33196837871392a573466c7460c01dd6d1609fc0680c7f281f86f7f32ffb140a
4
+ data.tar.gz: e220e419305c88f6bd3a8bd90ae12896f551faf2fb105fa6549e2510a22ef56a
5
5
  SHA512:
6
- metadata.gz: 878e61ad2e63ca173e915142c1df409b9b20417bcb1c6ea404ea7224c675b13449ab991f45ee5559632efdab53677d6b5b4d45ab687a40e89afcd594d1a898cb
7
- data.tar.gz: cd239bf349dbd8074e61a0337160595b3c63df97b282d9590ec146e78e15ce3a6d4e1a7beeb38962e102d112074ce56e880a5b556c5a3105aaf4961746e6ce2a
6
+ metadata.gz: 9f57935c7da50a72a2ab1b6a26d32cb51c80f0024a308a579e0832274f7dd205a07f1d2322886250d41e9a859c8d43bf42ada50f3127576484a4267bc089c62b
7
+ data.tar.gz: 3a8d5a538ca694c173af2d40bfb1722fc7626f5c6d169542b02287c8ea213e46abcf5e6ba1b12bc12c171beee463c5ee0ffd3f70879d2e133b7670721a14affc
@@ -220,7 +220,13 @@
220
220
 
221
221
 
222
222
  <xsl:template match="/">
223
- <fo:root xsl:use-attribute-sets="root-style" xml:lang="{$lang}">
223
+ <fo:root xml:lang="{$lang}">
224
+ <xsl:variable name="root-style">
225
+ <root-style xsl:use-attribute-sets="root-style"/>
226
+ </xsl:variable>
227
+ <xsl:call-template name="insertRootStyle">
228
+ <xsl:with-param name="root-style" select="$root-style"/>
229
+ </xsl:call-template>
224
230
  <fo:layout-master-set>
225
231
 
226
232
  <!-- blank page -->
@@ -3916,7 +3922,7 @@
3916
3922
  </xsl:template>
3917
3923
 
3918
3924
 
3919
- <xsl:param name="svg_images"/><xsl:variable name="images" select="document($svg_images)"/><xsl:param name="basepath"/><xsl:param name="external_index"/><xsl:param name="syntax-highlight">false</xsl:param><xsl:key name="bibitems" match="*[local-name() = 'bibitem']" use="@id"/><xsl:key name="bibitems_hidden" match="*[local-name() = 'bibitem'][@hidden='true'] | *[local-name() = 'references'][@hidden='true']//*[local-name() = 'bibitem']" use="@id"/><xsl:variable name="lang">
3925
+ <xsl:param name="svg_images"/><xsl:variable name="images" select="document($svg_images)"/><xsl:param name="basepath"/><xsl:param name="external_index"/><xsl:param name="syntax-highlight">false</xsl:param><xsl:variable name="lang">
3920
3926
  <xsl:call-template name="getLang"/>
3921
3927
  </xsl:variable><xsl:variable name="pageWidth_">
3922
3928
  210
@@ -4070,7 +4076,30 @@
4070
4076
 
4071
4077
 
4072
4078
 
4073
- </xsl:attribute-set><xsl:attribute-set name="copyright-statement-style">
4079
+ </xsl:attribute-set><xsl:template name="insertRootStyle">
4080
+ <xsl:param name="root-style"/>
4081
+ <xsl:variable name="root-style_" select="xalan:nodeset($root-style)"/>
4082
+
4083
+ <xsl:variable name="additional_fonts_">
4084
+ <xsl:for-each select="//*[local-name() = 'misc-container'][1]/*[local-name() = 'presentation-metadata'][*[local-name() = 'name'] = 'fonts']/*[local-name() = 'value']">
4085
+ <xsl:value-of select="."/><xsl:if test="position() != last()">, </xsl:if>
4086
+ </xsl:for-each>
4087
+ </xsl:variable>
4088
+ <xsl:variable name="additional_fonts" select="normalize-space($additional_fonts_)"/>
4089
+
4090
+ <xsl:for-each select="$root-style_/root-style/@*">
4091
+ <xsl:choose>
4092
+ <xsl:when test="local-name() = 'font-family' and $additional_fonts != ''">
4093
+ <xsl:attribute name="{local-name()}">
4094
+ <xsl:value-of select="."/>, <xsl:value-of select="$additional_fonts"/>
4095
+ </xsl:attribute>
4096
+ </xsl:when>
4097
+ <xsl:otherwise>
4098
+ <xsl:copy-of select="."/>
4099
+ </xsl:otherwise>
4100
+ </xsl:choose>
4101
+ </xsl:for-each>
4102
+ </xsl:template><xsl:attribute-set name="copyright-statement-style">
4074
4103
 
4075
4104
  </xsl:attribute-set><xsl:attribute-set name="copyright-statement-title-style">
4076
4105
 
@@ -4589,7 +4618,7 @@
4589
4618
 
4590
4619
 
4591
4620
 
4592
- </xsl:attribute-set><xsl:attribute-set name="termnote-name-style">
4621
+ </xsl:attribute-set><xsl:attribute-set name="termnote-name-style">
4593
4622
 
4594
4623
 
4595
4624
 
@@ -5302,8 +5331,27 @@
5302
5331
  <xsl:sort select="@displayorder" data-type="number"/>
5303
5332
  <xsl:apply-templates select="."/>
5304
5333
  </xsl:for-each>
5305
- </xsl:template><xsl:template match="text()">
5306
- <xsl:value-of select="."/>
5334
+ </xsl:template><xsl:variable name="tag_open">###fo:inline###</xsl:variable><xsl:variable name="tag_close">###/fo:inline###</xsl:variable><xsl:template match="text()" name="text">
5335
+ <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
5336
+ <xsl:variable name="text" select="java:replaceAll(java:java.lang.String.new(.),$regex_standard_reference,concat($tag_open,'$1',$tag_close))"/>
5337
+ <xsl:call-template name="replace_fo_inline">
5338
+ <xsl:with-param name="text" select="$text"/>
5339
+ </xsl:call-template>
5340
+ </xsl:template><xsl:template name="replace_fo_inline">
5341
+ <xsl:param name="text"/>
5342
+ <xsl:choose>
5343
+ <xsl:when test="contains($text, $tag_open)">
5344
+ <xsl:value-of select="substring-before($text, $tag_open)"/>
5345
+ <xsl:text disable-output-escaping="yes">&lt;fo:inline keep-together.within-line="always"&gt;</xsl:text>
5346
+ <xsl:variable name="text_after" select="substring-after($text, $tag_open)"/>
5347
+ <xsl:value-of select="substring-before($text_after, $tag_close)"/>
5348
+ <xsl:text disable-output-escaping="yes">&lt;/fo:inline&gt;</xsl:text>
5349
+ <xsl:call-template name="replace_fo_inline">
5350
+ <xsl:with-param name="text" select="substring-after($text_after, $tag_close)"/>
5351
+ </xsl:call-template>
5352
+ </xsl:when>
5353
+ <xsl:otherwise><xsl:value-of select="$text"/></xsl:otherwise>
5354
+ </xsl:choose>
5307
5355
  </xsl:template><xsl:template match="*[local-name()='br']">
5308
5356
  <xsl:value-of select="$linebreak"/>
5309
5357
  </xsl:template><xsl:template match="*[local-name()='copyright-statement']">
@@ -7045,24 +7093,28 @@
7045
7093
  </xsl:template><xsl:template name="add-zero-spaces-equal">
7046
7094
  <xsl:param name="text" select="."/>
7047
7095
  <xsl:variable name="zero-space-after-equals">==========</xsl:variable>
7096
+ <xsl:variable name="regex_zero-space-after-equals">(==========)</xsl:variable>
7048
7097
  <xsl:variable name="zero-space-after-equal">=</xsl:variable>
7098
+ <xsl:variable name="regex_zero-space-after-equal">(=)</xsl:variable>
7049
7099
  <xsl:variable name="zero-space">​</xsl:variable>
7050
7100
  <xsl:choose>
7051
7101
  <xsl:when test="contains($text, $zero-space-after-equals)">
7052
- <xsl:value-of select="substring-before($text, $zero-space-after-equals)"/>
7102
+ <!-- <xsl:value-of select="substring-before($text, $zero-space-after-equals)"/>
7053
7103
  <xsl:value-of select="$zero-space-after-equals"/>
7054
7104
  <xsl:value-of select="$zero-space"/>
7055
7105
  <xsl:call-template name="add-zero-spaces-equal">
7056
7106
  <xsl:with-param name="text" select="substring-after($text, $zero-space-after-equals)"/>
7057
- </xsl:call-template>
7107
+ </xsl:call-template> -->
7108
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),$regex_zero-space-after-equals,concat('$1',$zero_width_space))"/>
7058
7109
  </xsl:when>
7059
7110
  <xsl:when test="contains($text, $zero-space-after-equal)">
7060
- <xsl:value-of select="substring-before($text, $zero-space-after-equal)"/>
7111
+ <!-- <xsl:value-of select="substring-before($text, $zero-space-after-equal)"/>
7061
7112
  <xsl:value-of select="$zero-space-after-equal"/>
7062
7113
  <xsl:value-of select="$zero-space"/>
7063
7114
  <xsl:call-template name="add-zero-spaces-equal">
7064
7115
  <xsl:with-param name="text" select="substring-after($text, $zero-space-after-equal)"/>
7065
- </xsl:call-template>
7116
+ </xsl:call-template> -->
7117
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),$regex_zero-space-after-equal,concat('$1',$zero_width_space))"/>
7066
7118
  </xsl:when>
7067
7119
  <xsl:otherwise>
7068
7120
  <xsl:value-of select="$text"/>
@@ -7576,7 +7628,12 @@
7576
7628
 
7577
7629
  <fo:inline xsl:use-attribute-sets="termnote-name-style">
7578
7630
 
7631
+ <xsl:if test="not(*[local-name() = 'name']/following-sibling::node()[1][self::text()][normalize-space()=''])">
7632
+ <xsl:attribute name="padding-right">1mm</xsl:attribute>
7633
+ </xsl:if>
7634
+
7579
7635
 
7636
+
7580
7637
 
7581
7638
  <!-- if 'p' contains all text in 'add' first and last elements in first p are 'add' -->
7582
7639
  <!-- <xsl:if test="*[not(local-name()='name')][1][node()[normalize-space() != ''][1][local-name() = 'add'] and node()[normalize-space() != ''][last()][local-name() = 'add']]"> -->
@@ -8568,7 +8625,73 @@
8568
8625
  <xsl:with-param name="text" select="$text_step1"/>
8569
8626
  </xsl:call-template>
8570
8627
  </xsl:variable>
8571
- <xsl:value-of select="$text_step2"/>
8628
+
8629
+ <!-- <xsl:value-of select="$text_step2"/> -->
8630
+
8631
+ <!-- add zero-width space after space -->
8632
+ <xsl:variable name="text_step3" select="java:replaceAll(java:java.lang.String.new($text_step2),' ',' ​')"/>
8633
+
8634
+ <!-- split text by zero-width space -->
8635
+ <xsl:variable name="text_step4">
8636
+ <xsl:call-template name="split_for_interspers">
8637
+ <xsl:with-param name="pText" select="$text_step3"/>
8638
+ <xsl:with-param name="sep" select="$zero_width_space"/>
8639
+ </xsl:call-template>
8640
+ </xsl:variable>
8641
+
8642
+ <xsl:for-each select="xalan:nodeset($text_step4)/node()">
8643
+ <xsl:choose>
8644
+ <xsl:when test="local-name() = 'interspers'"> <!-- word with length more than 30 will be interspersed with zero-width space -->
8645
+ <xsl:call-template name="interspers">
8646
+ <xsl:with-param name="str" select="."/>
8647
+ </xsl:call-template>
8648
+ </xsl:when>
8649
+ <xsl:otherwise>
8650
+ <xsl:value-of select="."/>
8651
+ </xsl:otherwise>
8652
+ </xsl:choose>
8653
+ </xsl:for-each>
8654
+
8655
+ </xsl:template><xsl:variable name="interspers_tag_open">###interspers123###</xsl:variable><xsl:variable name="interspers_tag_close">###/interspers123###</xsl:variable><xsl:template name="split_for_interspers">
8656
+ <xsl:param name="pText" select="."/>
8657
+ <xsl:param name="sep" select="','"/>
8658
+ <!-- word with length more than 30 will be interspersed with zero-width space -->
8659
+ <xsl:variable name="regex" select="concat('([^', $zero_width_space, ']{31,})')"/> <!-- sequence of characters (more 31), that doesn't contains zero-width space -->
8660
+ <xsl:variable name="text" select="java:replaceAll(java:java.lang.String.new($pText),$regex,concat($interspers_tag_open,'$1',$interspers_tag_close))"/>
8661
+ <xsl:call-template name="replace_tag_interspers">
8662
+ <xsl:with-param name="text" select="$text"/>
8663
+ </xsl:call-template>
8664
+ </xsl:template><xsl:template name="replace_tag_interspers">
8665
+ <xsl:param name="text"/>
8666
+ <xsl:choose>
8667
+ <xsl:when test="contains($text, $interspers_tag_open)">
8668
+ <xsl:value-of select="substring-before($text, $interspers_tag_open)"/>
8669
+ <xsl:variable name="text_after" select="substring-after($text, $interspers_tag_open)"/>
8670
+ <interspers>
8671
+ <xsl:value-of select="substring-before($text_after, $interspers_tag_close)"/>
8672
+ </interspers>
8673
+ <xsl:call-template name="replace_tag_interspers">
8674
+ <xsl:with-param name="text" select="substring-after($text_after, $interspers_tag_close)"/>
8675
+ </xsl:call-template>
8676
+ </xsl:when>
8677
+ <xsl:otherwise><xsl:value-of select="$text"/></xsl:otherwise>
8678
+ </xsl:choose>
8679
+ </xsl:template><xsl:template name="interspers">
8680
+ <xsl:param name="str"/>
8681
+ <xsl:param name="char" select="$zero_width_space"/>
8682
+ <xsl:if test="$str != ''">
8683
+ <xsl:value-of select="substring($str, 1, 1)"/>
8684
+
8685
+ <xsl:variable name="next_char" select="substring($str, 2, 1)"/>
8686
+ <xsl:if test="not(contains(concat(' -.:=_— ', $char), $next_char))">
8687
+ <xsl:value-of select="$char"/>
8688
+ </xsl:if>
8689
+
8690
+ <xsl:call-template name="interspers">
8691
+ <xsl:with-param name="str" select="substring($str, 2)"/>
8692
+ <xsl:with-param name="char" select="$char"/>
8693
+ </xsl:call-template>
8694
+ </xsl:if>
8572
8695
  </xsl:template><xsl:template match="*" mode="syntax_highlight">
8573
8696
  <xsl:apply-templates mode="syntax_highlight"/>
8574
8697
  </xsl:template><xsl:variable name="syntax_highlight_styles_">
@@ -9000,7 +9123,7 @@
9000
9123
  </xsl:otherwise>
9001
9124
  </xsl:choose> -->
9002
9125
  </fo:block>
9003
- </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()[starts-with(., '[SOURCE: Adapted from: ')]" priority="2">
9126
+ </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()[starts-with(., '[SOURCE: Adapted from: ') or starts-with(., '[SOURCE: Quoted from: ') or starts-with(., '[SOURCE: Modified from: ')]" priority="2">
9004
9127
  <xsl:text>[</xsl:text><xsl:value-of select="substring-after(., '[SOURCE: ')"/>
9005
9128
  </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()">
9006
9129
  <xsl:if test="normalize-space() != ''">
@@ -9036,7 +9159,8 @@
9036
9159
  <fo:inline><xsl:apply-templates/></fo:inline>
9037
9160
  </xsl:template><xsl:template match="*[local-name() = 'modification']/text()">
9038
9161
  <xsl:if test="normalize-space() != ''">
9039
- <xsl:value-of select="."/>
9162
+ <!-- <xsl:value-of select="."/> -->
9163
+ <xsl:call-template name="text"/>
9040
9164
  </xsl:if>
9041
9165
  </xsl:template><xsl:template match="*[local-name() = 'quote']">
9042
9166
  <fo:block-container margin-left="0mm">
@@ -9076,11 +9200,24 @@
9076
9200
  </xsl:template><xsl:template match="*[local-name() = 'author']">
9077
9201
  <xsl:text>— </xsl:text>
9078
9202
  <xsl:apply-templates/>
9079
- </xsl:template><xsl:template match="*[local-name() = 'eref']">
9203
+ </xsl:template><xsl:variable name="bibitems_">
9204
+ <xsl:for-each select="//*[local-name() = 'bibitem']">
9205
+ <xsl:copy-of select="."/>
9206
+ </xsl:for-each>
9207
+ </xsl:variable><xsl:variable name="bibitems" select="xalan:nodeset($bibitems_)"/><xsl:variable name="bibitems_hidden_">
9208
+ <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden='true']">
9209
+ <xsl:copy-of select="."/>
9210
+ </xsl:for-each>
9211
+ <xsl:for-each select="//*[local-name() = 'references'][@hidden='true']//*[local-name() = 'bibitem']">
9212
+ <xsl:copy-of select="."/>
9213
+ </xsl:for-each>
9214
+ </xsl:variable><xsl:variable name="bibitems_hidden" select="xalan:nodeset($bibitems_hidden_)"/><xsl:template match="*[local-name() = 'eref']">
9080
9215
  <xsl:variable name="current_bibitemid" select="@bibitemid"/>
9081
- <xsl:variable name="external-destination" select="normalize-space(key('bibitems', $current_bibitemid)/*[local-name() = 'uri'][@type = 'citation'])"/>
9216
+ <!-- <xsl:variable name="external-destination" select="normalize-space(key('bibitems', $current_bibitemid)/*[local-name() = 'uri'][@type = 'citation'])"/> -->
9217
+ <xsl:variable name="external-destination" select="normalize-space($bibitems/*[local-name() ='bibitem'][@id = $current_bibitemid]/*[local-name() = 'uri'][@type = 'citation'])"/>
9082
9218
  <xsl:choose>
9083
- <xsl:when test="$external-destination != '' or not(key('bibitems_hidden', $current_bibitemid))"> <!-- if in the bibliography there is the item with @bibitemid (and not hidden), then create link (internal to the bibitem or external) -->
9219
+ <!-- <xsl:when test="$external-destination != '' or not(key('bibitems_hidden', $current_bibitemid))"> --> <!-- if in the bibliography there is the item with @bibitemid (and not hidden), then create link (internal to the bibitem or external) -->
9220
+ <xsl:when test="$external-destination != '' or not($bibitems_hidden/*[local-name() ='bibitem'][@id = $current_bibitemid])"> <!-- if in the bibliography there is the item with @bibitemid (and not hidden), then create link (internal to the bibitem or external) -->
9084
9221
  <fo:inline xsl:use-attribute-sets="eref-style">
9085
9222
  <xsl:if test="@type = 'footnote'">
9086
9223
  <xsl:attribute name="keep-together.within-line">always</xsl:attribute>
@@ -10221,7 +10358,7 @@
10221
10358
  <xsl:copy>
10222
10359
  <xsl:copy-of select="@*"/>
10223
10360
  <!-- copy all elements from bibliography except 'Normative references' (moved to 'sections') -->
10224
- <xsl:for-each select="*[not(@normative='true') and not(*[*[@normative='true']])]">
10361
+ <xsl:for-each select="*[not(@normative='true') and not(*[@normative='true'])]">
10225
10362
  <xsl:sort select="@displayorder" data-type="number"/>
10226
10363
  <xsl:apply-templates select="." mode="update_xml_step1"/>
10227
10364
  </xsl:for-each>
@@ -10470,22 +10607,25 @@
10470
10607
  <xsl:param name="pText" select="."/>
10471
10608
  <xsl:param name="sep" select="','"/>
10472
10609
  <xsl:param name="normalize-space" select="'true'"/>
10610
+ <xsl:param name="keep_sep" select="'false'"/>
10473
10611
  <xsl:if test="string-length($pText) &gt;0">
10474
- <item>
10475
- <xsl:choose>
10476
- <xsl:when test="$normalize-space = 'true'">
10477
- <xsl:value-of select="normalize-space(substring-before(concat($pText, $sep), $sep))"/>
10478
- </xsl:when>
10479
- <xsl:otherwise>
10480
- <xsl:value-of select="substring-before(concat($pText, $sep), $sep)"/>
10481
- </xsl:otherwise>
10482
- </xsl:choose>
10483
- </item>
10484
- <xsl:call-template name="split">
10485
- <xsl:with-param name="pText" select="substring-after($pText, $sep)"/>
10486
- <xsl:with-param name="sep" select="$sep"/>
10487
- <xsl:with-param name="normalize-space" select="$normalize-space"/>
10488
- </xsl:call-template>
10612
+ <item>
10613
+ <xsl:choose>
10614
+ <xsl:when test="$normalize-space = 'true'">
10615
+ <xsl:value-of select="normalize-space(substring-before(concat($pText, $sep), $sep))"/>
10616
+ </xsl:when>
10617
+ <xsl:otherwise>
10618
+ <xsl:value-of select="substring-before(concat($pText, $sep), $sep)"/>
10619
+ </xsl:otherwise>
10620
+ </xsl:choose>
10621
+ </item>
10622
+ <xsl:if test="$keep_sep = 'true' and contains($pText, $sep)"><item><xsl:value-of select="$sep"/></item></xsl:if>
10623
+ <xsl:call-template name="split">
10624
+ <xsl:with-param name="pText" select="substring-after($pText, $sep)"/>
10625
+ <xsl:with-param name="sep" select="$sep"/>
10626
+ <xsl:with-param name="normalize-space" select="$normalize-space"/>
10627
+ <xsl:with-param name="keep_sep" select="$keep_sep"/>
10628
+ </xsl:call-template>
10489
10629
  </xsl:if>
10490
10630
  </xsl:template><xsl:template name="getDocumentId">
10491
10631
  <xsl:call-template name="getLang"/><xsl:value-of select="//*[local-name() = 'p'][1]/@id"/>
@@ -220,7 +220,13 @@
220
220
 
221
221
 
222
222
  <xsl:template match="/">
223
- <fo:root xsl:use-attribute-sets="root-style" xml:lang="{$lang}">
223
+ <fo:root xml:lang="{$lang}">
224
+ <xsl:variable name="root-style">
225
+ <root-style xsl:use-attribute-sets="root-style"/>
226
+ </xsl:variable>
227
+ <xsl:call-template name="insertRootStyle">
228
+ <xsl:with-param name="root-style" select="$root-style"/>
229
+ </xsl:call-template>
224
230
  <fo:layout-master-set>
225
231
 
226
232
  <!-- blank page -->
@@ -3916,7 +3922,7 @@
3916
3922
  </xsl:template>
3917
3923
 
3918
3924
 
3919
- <xsl:param name="svg_images"/><xsl:variable name="images" select="document($svg_images)"/><xsl:param name="basepath"/><xsl:param name="external_index"/><xsl:param name="syntax-highlight">false</xsl:param><xsl:key name="bibitems" match="*[local-name() = 'bibitem']" use="@id"/><xsl:key name="bibitems_hidden" match="*[local-name() = 'bibitem'][@hidden='true'] | *[local-name() = 'references'][@hidden='true']//*[local-name() = 'bibitem']" use="@id"/><xsl:variable name="lang">
3925
+ <xsl:param name="svg_images"/><xsl:variable name="images" select="document($svg_images)"/><xsl:param name="basepath"/><xsl:param name="external_index"/><xsl:param name="syntax-highlight">false</xsl:param><xsl:variable name="lang">
3920
3926
  <xsl:call-template name="getLang"/>
3921
3927
  </xsl:variable><xsl:variable name="pageWidth_">
3922
3928
  210
@@ -4070,7 +4076,30 @@
4070
4076
 
4071
4077
 
4072
4078
 
4073
- </xsl:attribute-set><xsl:attribute-set name="copyright-statement-style">
4079
+ </xsl:attribute-set><xsl:template name="insertRootStyle">
4080
+ <xsl:param name="root-style"/>
4081
+ <xsl:variable name="root-style_" select="xalan:nodeset($root-style)"/>
4082
+
4083
+ <xsl:variable name="additional_fonts_">
4084
+ <xsl:for-each select="//*[local-name() = 'misc-container'][1]/*[local-name() = 'presentation-metadata'][*[local-name() = 'name'] = 'fonts']/*[local-name() = 'value']">
4085
+ <xsl:value-of select="."/><xsl:if test="position() != last()">, </xsl:if>
4086
+ </xsl:for-each>
4087
+ </xsl:variable>
4088
+ <xsl:variable name="additional_fonts" select="normalize-space($additional_fonts_)"/>
4089
+
4090
+ <xsl:for-each select="$root-style_/root-style/@*">
4091
+ <xsl:choose>
4092
+ <xsl:when test="local-name() = 'font-family' and $additional_fonts != ''">
4093
+ <xsl:attribute name="{local-name()}">
4094
+ <xsl:value-of select="."/>, <xsl:value-of select="$additional_fonts"/>
4095
+ </xsl:attribute>
4096
+ </xsl:when>
4097
+ <xsl:otherwise>
4098
+ <xsl:copy-of select="."/>
4099
+ </xsl:otherwise>
4100
+ </xsl:choose>
4101
+ </xsl:for-each>
4102
+ </xsl:template><xsl:attribute-set name="copyright-statement-style">
4074
4103
 
4075
4104
  </xsl:attribute-set><xsl:attribute-set name="copyright-statement-title-style">
4076
4105
 
@@ -4589,7 +4618,7 @@
4589
4618
 
4590
4619
 
4591
4620
 
4592
- </xsl:attribute-set><xsl:attribute-set name="termnote-name-style">
4621
+ </xsl:attribute-set><xsl:attribute-set name="termnote-name-style">
4593
4622
 
4594
4623
 
4595
4624
 
@@ -5302,8 +5331,27 @@
5302
5331
  <xsl:sort select="@displayorder" data-type="number"/>
5303
5332
  <xsl:apply-templates select="."/>
5304
5333
  </xsl:for-each>
5305
- </xsl:template><xsl:template match="text()">
5306
- <xsl:value-of select="."/>
5334
+ </xsl:template><xsl:variable name="tag_open">###fo:inline###</xsl:variable><xsl:variable name="tag_close">###/fo:inline###</xsl:variable><xsl:template match="text()" name="text">
5335
+ <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
5336
+ <xsl:variable name="text" select="java:replaceAll(java:java.lang.String.new(.),$regex_standard_reference,concat($tag_open,'$1',$tag_close))"/>
5337
+ <xsl:call-template name="replace_fo_inline">
5338
+ <xsl:with-param name="text" select="$text"/>
5339
+ </xsl:call-template>
5340
+ </xsl:template><xsl:template name="replace_fo_inline">
5341
+ <xsl:param name="text"/>
5342
+ <xsl:choose>
5343
+ <xsl:when test="contains($text, $tag_open)">
5344
+ <xsl:value-of select="substring-before($text, $tag_open)"/>
5345
+ <xsl:text disable-output-escaping="yes">&lt;fo:inline keep-together.within-line="always"&gt;</xsl:text>
5346
+ <xsl:variable name="text_after" select="substring-after($text, $tag_open)"/>
5347
+ <xsl:value-of select="substring-before($text_after, $tag_close)"/>
5348
+ <xsl:text disable-output-escaping="yes">&lt;/fo:inline&gt;</xsl:text>
5349
+ <xsl:call-template name="replace_fo_inline">
5350
+ <xsl:with-param name="text" select="substring-after($text_after, $tag_close)"/>
5351
+ </xsl:call-template>
5352
+ </xsl:when>
5353
+ <xsl:otherwise><xsl:value-of select="$text"/></xsl:otherwise>
5354
+ </xsl:choose>
5307
5355
  </xsl:template><xsl:template match="*[local-name()='br']">
5308
5356
  <xsl:value-of select="$linebreak"/>
5309
5357
  </xsl:template><xsl:template match="*[local-name()='copyright-statement']">
@@ -7045,24 +7093,28 @@
7045
7093
  </xsl:template><xsl:template name="add-zero-spaces-equal">
7046
7094
  <xsl:param name="text" select="."/>
7047
7095
  <xsl:variable name="zero-space-after-equals">==========</xsl:variable>
7096
+ <xsl:variable name="regex_zero-space-after-equals">(==========)</xsl:variable>
7048
7097
  <xsl:variable name="zero-space-after-equal">=</xsl:variable>
7098
+ <xsl:variable name="regex_zero-space-after-equal">(=)</xsl:variable>
7049
7099
  <xsl:variable name="zero-space">​</xsl:variable>
7050
7100
  <xsl:choose>
7051
7101
  <xsl:when test="contains($text, $zero-space-after-equals)">
7052
- <xsl:value-of select="substring-before($text, $zero-space-after-equals)"/>
7102
+ <!-- <xsl:value-of select="substring-before($text, $zero-space-after-equals)"/>
7053
7103
  <xsl:value-of select="$zero-space-after-equals"/>
7054
7104
  <xsl:value-of select="$zero-space"/>
7055
7105
  <xsl:call-template name="add-zero-spaces-equal">
7056
7106
  <xsl:with-param name="text" select="substring-after($text, $zero-space-after-equals)"/>
7057
- </xsl:call-template>
7107
+ </xsl:call-template> -->
7108
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),$regex_zero-space-after-equals,concat('$1',$zero_width_space))"/>
7058
7109
  </xsl:when>
7059
7110
  <xsl:when test="contains($text, $zero-space-after-equal)">
7060
- <xsl:value-of select="substring-before($text, $zero-space-after-equal)"/>
7111
+ <!-- <xsl:value-of select="substring-before($text, $zero-space-after-equal)"/>
7061
7112
  <xsl:value-of select="$zero-space-after-equal"/>
7062
7113
  <xsl:value-of select="$zero-space"/>
7063
7114
  <xsl:call-template name="add-zero-spaces-equal">
7064
7115
  <xsl:with-param name="text" select="substring-after($text, $zero-space-after-equal)"/>
7065
- </xsl:call-template>
7116
+ </xsl:call-template> -->
7117
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),$regex_zero-space-after-equal,concat('$1',$zero_width_space))"/>
7066
7118
  </xsl:when>
7067
7119
  <xsl:otherwise>
7068
7120
  <xsl:value-of select="$text"/>
@@ -7576,7 +7628,12 @@
7576
7628
 
7577
7629
  <fo:inline xsl:use-attribute-sets="termnote-name-style">
7578
7630
 
7631
+ <xsl:if test="not(*[local-name() = 'name']/following-sibling::node()[1][self::text()][normalize-space()=''])">
7632
+ <xsl:attribute name="padding-right">1mm</xsl:attribute>
7633
+ </xsl:if>
7634
+
7579
7635
 
7636
+
7580
7637
 
7581
7638
  <!-- if 'p' contains all text in 'add' first and last elements in first p are 'add' -->
7582
7639
  <!-- <xsl:if test="*[not(local-name()='name')][1][node()[normalize-space() != ''][1][local-name() = 'add'] and node()[normalize-space() != ''][last()][local-name() = 'add']]"> -->
@@ -8568,7 +8625,73 @@
8568
8625
  <xsl:with-param name="text" select="$text_step1"/>
8569
8626
  </xsl:call-template>
8570
8627
  </xsl:variable>
8571
- <xsl:value-of select="$text_step2"/>
8628
+
8629
+ <!-- <xsl:value-of select="$text_step2"/> -->
8630
+
8631
+ <!-- add zero-width space after space -->
8632
+ <xsl:variable name="text_step3" select="java:replaceAll(java:java.lang.String.new($text_step2),' ',' ​')"/>
8633
+
8634
+ <!-- split text by zero-width space -->
8635
+ <xsl:variable name="text_step4">
8636
+ <xsl:call-template name="split_for_interspers">
8637
+ <xsl:with-param name="pText" select="$text_step3"/>
8638
+ <xsl:with-param name="sep" select="$zero_width_space"/>
8639
+ </xsl:call-template>
8640
+ </xsl:variable>
8641
+
8642
+ <xsl:for-each select="xalan:nodeset($text_step4)/node()">
8643
+ <xsl:choose>
8644
+ <xsl:when test="local-name() = 'interspers'"> <!-- word with length more than 30 will be interspersed with zero-width space -->
8645
+ <xsl:call-template name="interspers">
8646
+ <xsl:with-param name="str" select="."/>
8647
+ </xsl:call-template>
8648
+ </xsl:when>
8649
+ <xsl:otherwise>
8650
+ <xsl:value-of select="."/>
8651
+ </xsl:otherwise>
8652
+ </xsl:choose>
8653
+ </xsl:for-each>
8654
+
8655
+ </xsl:template><xsl:variable name="interspers_tag_open">###interspers123###</xsl:variable><xsl:variable name="interspers_tag_close">###/interspers123###</xsl:variable><xsl:template name="split_for_interspers">
8656
+ <xsl:param name="pText" select="."/>
8657
+ <xsl:param name="sep" select="','"/>
8658
+ <!-- word with length more than 30 will be interspersed with zero-width space -->
8659
+ <xsl:variable name="regex" select="concat('([^', $zero_width_space, ']{31,})')"/> <!-- sequence of characters (more 31), that doesn't contains zero-width space -->
8660
+ <xsl:variable name="text" select="java:replaceAll(java:java.lang.String.new($pText),$regex,concat($interspers_tag_open,'$1',$interspers_tag_close))"/>
8661
+ <xsl:call-template name="replace_tag_interspers">
8662
+ <xsl:with-param name="text" select="$text"/>
8663
+ </xsl:call-template>
8664
+ </xsl:template><xsl:template name="replace_tag_interspers">
8665
+ <xsl:param name="text"/>
8666
+ <xsl:choose>
8667
+ <xsl:when test="contains($text, $interspers_tag_open)">
8668
+ <xsl:value-of select="substring-before($text, $interspers_tag_open)"/>
8669
+ <xsl:variable name="text_after" select="substring-after($text, $interspers_tag_open)"/>
8670
+ <interspers>
8671
+ <xsl:value-of select="substring-before($text_after, $interspers_tag_close)"/>
8672
+ </interspers>
8673
+ <xsl:call-template name="replace_tag_interspers">
8674
+ <xsl:with-param name="text" select="substring-after($text_after, $interspers_tag_close)"/>
8675
+ </xsl:call-template>
8676
+ </xsl:when>
8677
+ <xsl:otherwise><xsl:value-of select="$text"/></xsl:otherwise>
8678
+ </xsl:choose>
8679
+ </xsl:template><xsl:template name="interspers">
8680
+ <xsl:param name="str"/>
8681
+ <xsl:param name="char" select="$zero_width_space"/>
8682
+ <xsl:if test="$str != ''">
8683
+ <xsl:value-of select="substring($str, 1, 1)"/>
8684
+
8685
+ <xsl:variable name="next_char" select="substring($str, 2, 1)"/>
8686
+ <xsl:if test="not(contains(concat(' -.:=_— ', $char), $next_char))">
8687
+ <xsl:value-of select="$char"/>
8688
+ </xsl:if>
8689
+
8690
+ <xsl:call-template name="interspers">
8691
+ <xsl:with-param name="str" select="substring($str, 2)"/>
8692
+ <xsl:with-param name="char" select="$char"/>
8693
+ </xsl:call-template>
8694
+ </xsl:if>
8572
8695
  </xsl:template><xsl:template match="*" mode="syntax_highlight">
8573
8696
  <xsl:apply-templates mode="syntax_highlight"/>
8574
8697
  </xsl:template><xsl:variable name="syntax_highlight_styles_">
@@ -9000,7 +9123,7 @@
9000
9123
  </xsl:otherwise>
9001
9124
  </xsl:choose> -->
9002
9125
  </fo:block>
9003
- </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()[starts-with(., '[SOURCE: Adapted from: ')]" priority="2">
9126
+ </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()[starts-with(., '[SOURCE: Adapted from: ') or starts-with(., '[SOURCE: Quoted from: ') or starts-with(., '[SOURCE: Modified from: ')]" priority="2">
9004
9127
  <xsl:text>[</xsl:text><xsl:value-of select="substring-after(., '[SOURCE: ')"/>
9005
9128
  </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()">
9006
9129
  <xsl:if test="normalize-space() != ''">
@@ -9036,7 +9159,8 @@
9036
9159
  <fo:inline><xsl:apply-templates/></fo:inline>
9037
9160
  </xsl:template><xsl:template match="*[local-name() = 'modification']/text()">
9038
9161
  <xsl:if test="normalize-space() != ''">
9039
- <xsl:value-of select="."/>
9162
+ <!-- <xsl:value-of select="."/> -->
9163
+ <xsl:call-template name="text"/>
9040
9164
  </xsl:if>
9041
9165
  </xsl:template><xsl:template match="*[local-name() = 'quote']">
9042
9166
  <fo:block-container margin-left="0mm">
@@ -9076,11 +9200,24 @@
9076
9200
  </xsl:template><xsl:template match="*[local-name() = 'author']">
9077
9201
  <xsl:text>— </xsl:text>
9078
9202
  <xsl:apply-templates/>
9079
- </xsl:template><xsl:template match="*[local-name() = 'eref']">
9203
+ </xsl:template><xsl:variable name="bibitems_">
9204
+ <xsl:for-each select="//*[local-name() = 'bibitem']">
9205
+ <xsl:copy-of select="."/>
9206
+ </xsl:for-each>
9207
+ </xsl:variable><xsl:variable name="bibitems" select="xalan:nodeset($bibitems_)"/><xsl:variable name="bibitems_hidden_">
9208
+ <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden='true']">
9209
+ <xsl:copy-of select="."/>
9210
+ </xsl:for-each>
9211
+ <xsl:for-each select="//*[local-name() = 'references'][@hidden='true']//*[local-name() = 'bibitem']">
9212
+ <xsl:copy-of select="."/>
9213
+ </xsl:for-each>
9214
+ </xsl:variable><xsl:variable name="bibitems_hidden" select="xalan:nodeset($bibitems_hidden_)"/><xsl:template match="*[local-name() = 'eref']">
9080
9215
  <xsl:variable name="current_bibitemid" select="@bibitemid"/>
9081
- <xsl:variable name="external-destination" select="normalize-space(key('bibitems', $current_bibitemid)/*[local-name() = 'uri'][@type = 'citation'])"/>
9216
+ <!-- <xsl:variable name="external-destination" select="normalize-space(key('bibitems', $current_bibitemid)/*[local-name() = 'uri'][@type = 'citation'])"/> -->
9217
+ <xsl:variable name="external-destination" select="normalize-space($bibitems/*[local-name() ='bibitem'][@id = $current_bibitemid]/*[local-name() = 'uri'][@type = 'citation'])"/>
9082
9218
  <xsl:choose>
9083
- <xsl:when test="$external-destination != '' or not(key('bibitems_hidden', $current_bibitemid))"> <!-- if in the bibliography there is the item with @bibitemid (and not hidden), then create link (internal to the bibitem or external) -->
9219
+ <!-- <xsl:when test="$external-destination != '' or not(key('bibitems_hidden', $current_bibitemid))"> --> <!-- if in the bibliography there is the item with @bibitemid (and not hidden), then create link (internal to the bibitem or external) -->
9220
+ <xsl:when test="$external-destination != '' or not($bibitems_hidden/*[local-name() ='bibitem'][@id = $current_bibitemid])"> <!-- if in the bibliography there is the item with @bibitemid (and not hidden), then create link (internal to the bibitem or external) -->
9084
9221
  <fo:inline xsl:use-attribute-sets="eref-style">
9085
9222
  <xsl:if test="@type = 'footnote'">
9086
9223
  <xsl:attribute name="keep-together.within-line">always</xsl:attribute>
@@ -10221,7 +10358,7 @@
10221
10358
  <xsl:copy>
10222
10359
  <xsl:copy-of select="@*"/>
10223
10360
  <!-- copy all elements from bibliography except 'Normative references' (moved to 'sections') -->
10224
- <xsl:for-each select="*[not(@normative='true') and not(*[*[@normative='true']])]">
10361
+ <xsl:for-each select="*[not(@normative='true') and not(*[@normative='true'])]">
10225
10362
  <xsl:sort select="@displayorder" data-type="number"/>
10226
10363
  <xsl:apply-templates select="." mode="update_xml_step1"/>
10227
10364
  </xsl:for-each>
@@ -10470,22 +10607,25 @@
10470
10607
  <xsl:param name="pText" select="."/>
10471
10608
  <xsl:param name="sep" select="','"/>
10472
10609
  <xsl:param name="normalize-space" select="'true'"/>
10610
+ <xsl:param name="keep_sep" select="'false'"/>
10473
10611
  <xsl:if test="string-length($pText) &gt;0">
10474
- <item>
10475
- <xsl:choose>
10476
- <xsl:when test="$normalize-space = 'true'">
10477
- <xsl:value-of select="normalize-space(substring-before(concat($pText, $sep), $sep))"/>
10478
- </xsl:when>
10479
- <xsl:otherwise>
10480
- <xsl:value-of select="substring-before(concat($pText, $sep), $sep)"/>
10481
- </xsl:otherwise>
10482
- </xsl:choose>
10483
- </item>
10484
- <xsl:call-template name="split">
10485
- <xsl:with-param name="pText" select="substring-after($pText, $sep)"/>
10486
- <xsl:with-param name="sep" select="$sep"/>
10487
- <xsl:with-param name="normalize-space" select="$normalize-space"/>
10488
- </xsl:call-template>
10612
+ <item>
10613
+ <xsl:choose>
10614
+ <xsl:when test="$normalize-space = 'true'">
10615
+ <xsl:value-of select="normalize-space(substring-before(concat($pText, $sep), $sep))"/>
10616
+ </xsl:when>
10617
+ <xsl:otherwise>
10618
+ <xsl:value-of select="substring-before(concat($pText, $sep), $sep)"/>
10619
+ </xsl:otherwise>
10620
+ </xsl:choose>
10621
+ </item>
10622
+ <xsl:if test="$keep_sep = 'true' and contains($pText, $sep)"><item><xsl:value-of select="$sep"/></item></xsl:if>
10623
+ <xsl:call-template name="split">
10624
+ <xsl:with-param name="pText" select="substring-after($pText, $sep)"/>
10625
+ <xsl:with-param name="sep" select="$sep"/>
10626
+ <xsl:with-param name="normalize-space" select="$normalize-space"/>
10627
+ <xsl:with-param name="keep_sep" select="$keep_sep"/>
10628
+ </xsl:call-template>
10489
10629
  </xsl:if>
10490
10630
  </xsl:template><xsl:template name="getDocumentId">
10491
10631
  <xsl:call-template name="getLang"/><xsl:value-of select="//*[local-name() = 'p'][1]/@id"/>