metanorma-itu 2.0.5 → 2.0.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -114,21 +114,29 @@
114
114
 
115
115
  <xsl:template match="/">
116
116
  <xsl:call-template name="namespaceCheck"/>
117
- <fo:root xsl:use-attribute-sets="root-style" xml:lang="{$lang}">
118
- <!-- <xsl:if test="$lang != 'ar'">
119
- <xsl:attribute name="xml:lang"><xsl:value-of select="$lang"/></xsl:attribute>
120
- </xsl:if> -->
121
- <xsl:if test="$doctype = 'resolution'">
122
- <xsl:attribute name="font-size">11pt</xsl:attribute>
123
- </xsl:if>
124
- <xsl:if test="$doctype = 'service-publication'">
125
- <xsl:attribute name="font-size">11pt</xsl:attribute>
126
- <xsl:attribute name="font-family">Arial, STIX Two Math</xsl:attribute>
127
- </xsl:if>
128
- <xsl:call-template name="setWritingMode"/>
129
- <xsl:if test="$lang = 'ar'">
130
- <xsl:attribute name="font-family">Traditional Arabic, Times New Roman, STIX Two Math</xsl:attribute>
131
- </xsl:if>
117
+ <fo:root xml:lang="{$lang}">
118
+ <xsl:variable name="root-style">
119
+ <root-style xsl:use-attribute-sets="root-style">
120
+ <!-- <xsl:if test="$lang != 'ar'">
121
+ <xsl:attribute name="xml:lang"><xsl:value-of select="$lang"/></xsl:attribute>
122
+ </xsl:if> -->
123
+ <xsl:if test="$doctype = 'resolution'">
124
+ <xsl:attribute name="font-size">11pt</xsl:attribute>
125
+ </xsl:if>
126
+ <xsl:if test="$doctype = 'service-publication'">
127
+ <xsl:attribute name="font-size">11pt</xsl:attribute>
128
+ <xsl:attribute name="font-family">Arial, STIX Two Math</xsl:attribute>
129
+ </xsl:if>
130
+ <xsl:call-template name="setWritingMode"/>
131
+ <xsl:if test="$lang = 'ar'">
132
+ <xsl:attribute name="font-family">Traditional Arabic, Times New Roman, STIX Two Math</xsl:attribute>
133
+ </xsl:if>
134
+ </root-style>
135
+ </xsl:variable>
136
+ <xsl:call-template name="insertRootStyle">
137
+ <xsl:with-param name="root-style" select="$root-style"/>
138
+ </xsl:call-template>
139
+
132
140
  <fo:layout-master-set>
133
141
 
134
142
  <!-- Technical Report first page -->
@@ -2060,7 +2068,7 @@
2060
2068
  </xsl:if>
2061
2069
  </xsl:template>
2062
2070
 
2063
- <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">
2071
+ <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">
2064
2072
  <xsl:call-template name="getLang"/>
2065
2073
  </xsl:variable><xsl:variable name="pageWidth_">
2066
2074
  210
@@ -2210,7 +2218,30 @@
2210
2218
 
2211
2219
 
2212
2220
 
2213
- </xsl:attribute-set><xsl:attribute-set name="copyright-statement-style">
2221
+ </xsl:attribute-set><xsl:template name="insertRootStyle">
2222
+ <xsl:param name="root-style"/>
2223
+ <xsl:variable name="root-style_" select="xalan:nodeset($root-style)"/>
2224
+
2225
+ <xsl:variable name="additional_fonts_">
2226
+ <xsl:for-each select="//*[local-name() = 'misc-container'][1]/*[local-name() = 'presentation-metadata'][*[local-name() = 'name'] = 'fonts']/*[local-name() = 'value']">
2227
+ <xsl:value-of select="."/><xsl:if test="position() != last()">, </xsl:if>
2228
+ </xsl:for-each>
2229
+ </xsl:variable>
2230
+ <xsl:variable name="additional_fonts" select="normalize-space($additional_fonts_)"/>
2231
+
2232
+ <xsl:for-each select="$root-style_/root-style/@*">
2233
+ <xsl:choose>
2234
+ <xsl:when test="local-name() = 'font-family' and $additional_fonts != ''">
2235
+ <xsl:attribute name="{local-name()}">
2236
+ <xsl:value-of select="."/>, <xsl:value-of select="$additional_fonts"/>
2237
+ </xsl:attribute>
2238
+ </xsl:when>
2239
+ <xsl:otherwise>
2240
+ <xsl:copy-of select="."/>
2241
+ </xsl:otherwise>
2242
+ </xsl:choose>
2243
+ </xsl:for-each>
2244
+ </xsl:template><xsl:attribute-set name="copyright-statement-style">
2214
2245
 
2215
2246
  </xsl:attribute-set><xsl:attribute-set name="copyright-statement-title-style">
2216
2247
 
@@ -2720,7 +2751,7 @@
2720
2751
 
2721
2752
 
2722
2753
 
2723
- </xsl:attribute-set><xsl:attribute-set name="termnote-name-style">
2754
+ </xsl:attribute-set><xsl:attribute-set name="termnote-name-style">
2724
2755
 
2725
2756
 
2726
2757
 
@@ -3423,8 +3454,27 @@
3423
3454
  <xsl:sort select="@displayorder" data-type="number"/>
3424
3455
  <xsl:apply-templates select="."/>
3425
3456
  </xsl:for-each>
3426
- </xsl:template><xsl:template match="text()">
3427
- <xsl:value-of select="."/>
3457
+ </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">
3458
+ <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
3459
+ <xsl:variable name="text" select="java:replaceAll(java:java.lang.String.new(.),$regex_standard_reference,concat($tag_open,'$1',$tag_close))"/>
3460
+ <xsl:call-template name="replace_fo_inline">
3461
+ <xsl:with-param name="text" select="$text"/>
3462
+ </xsl:call-template>
3463
+ </xsl:template><xsl:template name="replace_fo_inline">
3464
+ <xsl:param name="text"/>
3465
+ <xsl:choose>
3466
+ <xsl:when test="contains($text, $tag_open)">
3467
+ <xsl:value-of select="substring-before($text, $tag_open)"/>
3468
+ <xsl:text disable-output-escaping="yes">&lt;fo:inline keep-together.within-line="always"&gt;</xsl:text>
3469
+ <xsl:variable name="text_after" select="substring-after($text, $tag_open)"/>
3470
+ <xsl:value-of select="substring-before($text_after, $tag_close)"/>
3471
+ <xsl:text disable-output-escaping="yes">&lt;/fo:inline&gt;</xsl:text>
3472
+ <xsl:call-template name="replace_fo_inline">
3473
+ <xsl:with-param name="text" select="substring-after($text_after, $tag_close)"/>
3474
+ </xsl:call-template>
3475
+ </xsl:when>
3476
+ <xsl:otherwise><xsl:value-of select="$text"/></xsl:otherwise>
3477
+ </xsl:choose>
3428
3478
  </xsl:template><xsl:template match="*[local-name()='br']">
3429
3479
  <xsl:value-of select="$linebreak"/>
3430
3480
  </xsl:template><xsl:template match="*[local-name()='copyright-statement']">
@@ -5157,24 +5207,28 @@
5157
5207
  </xsl:template><xsl:template name="add-zero-spaces-equal">
5158
5208
  <xsl:param name="text" select="."/>
5159
5209
  <xsl:variable name="zero-space-after-equals">==========</xsl:variable>
5210
+ <xsl:variable name="regex_zero-space-after-equals">(==========)</xsl:variable>
5160
5211
  <xsl:variable name="zero-space-after-equal">=</xsl:variable>
5212
+ <xsl:variable name="regex_zero-space-after-equal">(=)</xsl:variable>
5161
5213
  <xsl:variable name="zero-space">​</xsl:variable>
5162
5214
  <xsl:choose>
5163
5215
  <xsl:when test="contains($text, $zero-space-after-equals)">
5164
- <xsl:value-of select="substring-before($text, $zero-space-after-equals)"/>
5216
+ <!-- <xsl:value-of select="substring-before($text, $zero-space-after-equals)"/>
5165
5217
  <xsl:value-of select="$zero-space-after-equals"/>
5166
5218
  <xsl:value-of select="$zero-space"/>
5167
5219
  <xsl:call-template name="add-zero-spaces-equal">
5168
5220
  <xsl:with-param name="text" select="substring-after($text, $zero-space-after-equals)"/>
5169
- </xsl:call-template>
5221
+ </xsl:call-template> -->
5222
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),$regex_zero-space-after-equals,concat('$1',$zero_width_space))"/>
5170
5223
  </xsl:when>
5171
5224
  <xsl:when test="contains($text, $zero-space-after-equal)">
5172
- <xsl:value-of select="substring-before($text, $zero-space-after-equal)"/>
5225
+ <!-- <xsl:value-of select="substring-before($text, $zero-space-after-equal)"/>
5173
5226
  <xsl:value-of select="$zero-space-after-equal"/>
5174
5227
  <xsl:value-of select="$zero-space"/>
5175
5228
  <xsl:call-template name="add-zero-spaces-equal">
5176
5229
  <xsl:with-param name="text" select="substring-after($text, $zero-space-after-equal)"/>
5177
- </xsl:call-template>
5230
+ </xsl:call-template> -->
5231
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),$regex_zero-space-after-equal,concat('$1',$zero_width_space))"/>
5178
5232
  </xsl:when>
5179
5233
  <xsl:otherwise>
5180
5234
  <xsl:value-of select="$text"/>
@@ -5654,7 +5708,12 @@
5654
5708
 
5655
5709
  <fo:inline xsl:use-attribute-sets="termnote-name-style">
5656
5710
 
5711
+ <xsl:if test="not(*[local-name() = 'name']/following-sibling::node()[1][self::text()][normalize-space()=''])">
5712
+ <xsl:attribute name="padding-right">1mm</xsl:attribute>
5713
+ </xsl:if>
5714
+
5657
5715
 
5716
+
5658
5717
 
5659
5718
  <!-- if 'p' contains all text in 'add' first and last elements in first p are 'add' -->
5660
5719
  <!-- <xsl:if test="*[not(local-name()='name')][1][node()[normalize-space() != ''][1][local-name() = 'add'] and node()[normalize-space() != ''][last()][local-name() = 'add']]"> -->
@@ -6628,7 +6687,73 @@
6628
6687
  <xsl:with-param name="text" select="$text_step1"/>
6629
6688
  </xsl:call-template>
6630
6689
  </xsl:variable>
6631
- <xsl:value-of select="$text_step2"/>
6690
+
6691
+ <!-- <xsl:value-of select="$text_step2"/> -->
6692
+
6693
+ <!-- add zero-width space after space -->
6694
+ <xsl:variable name="text_step3" select="java:replaceAll(java:java.lang.String.new($text_step2),' ',' ​')"/>
6695
+
6696
+ <!-- split text by zero-width space -->
6697
+ <xsl:variable name="text_step4">
6698
+ <xsl:call-template name="split_for_interspers">
6699
+ <xsl:with-param name="pText" select="$text_step3"/>
6700
+ <xsl:with-param name="sep" select="$zero_width_space"/>
6701
+ </xsl:call-template>
6702
+ </xsl:variable>
6703
+
6704
+ <xsl:for-each select="xalan:nodeset($text_step4)/node()">
6705
+ <xsl:choose>
6706
+ <xsl:when test="local-name() = 'interspers'"> <!-- word with length more than 30 will be interspersed with zero-width space -->
6707
+ <xsl:call-template name="interspers">
6708
+ <xsl:with-param name="str" select="."/>
6709
+ </xsl:call-template>
6710
+ </xsl:when>
6711
+ <xsl:otherwise>
6712
+ <xsl:value-of select="."/>
6713
+ </xsl:otherwise>
6714
+ </xsl:choose>
6715
+ </xsl:for-each>
6716
+
6717
+ </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">
6718
+ <xsl:param name="pText" select="."/>
6719
+ <xsl:param name="sep" select="','"/>
6720
+ <!-- word with length more than 30 will be interspersed with zero-width space -->
6721
+ <xsl:variable name="regex" select="concat('([^', $zero_width_space, ']{31,})')"/> <!-- sequence of characters (more 31), that doesn't contains zero-width space -->
6722
+ <xsl:variable name="text" select="java:replaceAll(java:java.lang.String.new($pText),$regex,concat($interspers_tag_open,'$1',$interspers_tag_close))"/>
6723
+ <xsl:call-template name="replace_tag_interspers">
6724
+ <xsl:with-param name="text" select="$text"/>
6725
+ </xsl:call-template>
6726
+ </xsl:template><xsl:template name="replace_tag_interspers">
6727
+ <xsl:param name="text"/>
6728
+ <xsl:choose>
6729
+ <xsl:when test="contains($text, $interspers_tag_open)">
6730
+ <xsl:value-of select="substring-before($text, $interspers_tag_open)"/>
6731
+ <xsl:variable name="text_after" select="substring-after($text, $interspers_tag_open)"/>
6732
+ <interspers>
6733
+ <xsl:value-of select="substring-before($text_after, $interspers_tag_close)"/>
6734
+ </interspers>
6735
+ <xsl:call-template name="replace_tag_interspers">
6736
+ <xsl:with-param name="text" select="substring-after($text_after, $interspers_tag_close)"/>
6737
+ </xsl:call-template>
6738
+ </xsl:when>
6739
+ <xsl:otherwise><xsl:value-of select="$text"/></xsl:otherwise>
6740
+ </xsl:choose>
6741
+ </xsl:template><xsl:template name="interspers">
6742
+ <xsl:param name="str"/>
6743
+ <xsl:param name="char" select="$zero_width_space"/>
6744
+ <xsl:if test="$str != ''">
6745
+ <xsl:value-of select="substring($str, 1, 1)"/>
6746
+
6747
+ <xsl:variable name="next_char" select="substring($str, 2, 1)"/>
6748
+ <xsl:if test="not(contains(concat(' -.:=_— ', $char), $next_char))">
6749
+ <xsl:value-of select="$char"/>
6750
+ </xsl:if>
6751
+
6752
+ <xsl:call-template name="interspers">
6753
+ <xsl:with-param name="str" select="substring($str, 2)"/>
6754
+ <xsl:with-param name="char" select="$char"/>
6755
+ </xsl:call-template>
6756
+ </xsl:if>
6632
6757
  </xsl:template><xsl:template match="*" mode="syntax_highlight">
6633
6758
  <xsl:apply-templates mode="syntax_highlight"/>
6634
6759
  </xsl:template><xsl:variable name="syntax_highlight_styles_">
@@ -7060,7 +7185,7 @@
7060
7185
  </xsl:otherwise>
7061
7186
  </xsl:choose> -->
7062
7187
  </fo:block>
7063
- </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()[starts-with(., '[SOURCE: Adapted from: ')]" priority="2">
7188
+ </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">
7064
7189
  <xsl:text>[</xsl:text><xsl:value-of select="substring-after(., '[SOURCE: ')"/>
7065
7190
  </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()">
7066
7191
  <xsl:if test="normalize-space() != ''">
@@ -7096,7 +7221,8 @@
7096
7221
  <fo:inline><xsl:apply-templates/></fo:inline>
7097
7222
  </xsl:template><xsl:template match="*[local-name() = 'modification']/text()">
7098
7223
  <xsl:if test="normalize-space() != ''">
7099
- <xsl:value-of select="."/>
7224
+ <!-- <xsl:value-of select="."/> -->
7225
+ <xsl:call-template name="text"/>
7100
7226
  </xsl:if>
7101
7227
  </xsl:template><xsl:template match="*[local-name() = 'quote']">
7102
7228
  <fo:block-container margin-left="0mm">
@@ -7136,11 +7262,24 @@
7136
7262
  </xsl:template><xsl:template match="*[local-name() = 'author']">
7137
7263
  <xsl:text>— </xsl:text>
7138
7264
  <xsl:apply-templates/>
7139
- </xsl:template><xsl:template match="*[local-name() = 'eref']">
7265
+ </xsl:template><xsl:variable name="bibitems_">
7266
+ <xsl:for-each select="//*[local-name() = 'bibitem']">
7267
+ <xsl:copy-of select="."/>
7268
+ </xsl:for-each>
7269
+ </xsl:variable><xsl:variable name="bibitems" select="xalan:nodeset($bibitems_)"/><xsl:variable name="bibitems_hidden_">
7270
+ <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden='true']">
7271
+ <xsl:copy-of select="."/>
7272
+ </xsl:for-each>
7273
+ <xsl:for-each select="//*[local-name() = 'references'][@hidden='true']//*[local-name() = 'bibitem']">
7274
+ <xsl:copy-of select="."/>
7275
+ </xsl:for-each>
7276
+ </xsl:variable><xsl:variable name="bibitems_hidden" select="xalan:nodeset($bibitems_hidden_)"/><xsl:template match="*[local-name() = 'eref']">
7140
7277
  <xsl:variable name="current_bibitemid" select="@bibitemid"/>
7141
- <xsl:variable name="external-destination" select="normalize-space(key('bibitems', $current_bibitemid)/*[local-name() = 'uri'][@type = 'citation'])"/>
7278
+ <!-- <xsl:variable name="external-destination" select="normalize-space(key('bibitems', $current_bibitemid)/*[local-name() = 'uri'][@type = 'citation'])"/> -->
7279
+ <xsl:variable name="external-destination" select="normalize-space($bibitems/*[local-name() ='bibitem'][@id = $current_bibitemid]/*[local-name() = 'uri'][@type = 'citation'])"/>
7142
7280
  <xsl:choose>
7143
- <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) -->
7281
+ <!-- <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) -->
7282
+ <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) -->
7144
7283
  <fo:inline xsl:use-attribute-sets="eref-style">
7145
7284
  <xsl:if test="@type = 'footnote'">
7146
7285
  <xsl:attribute name="keep-together.within-line">always</xsl:attribute>
@@ -8291,7 +8430,7 @@
8291
8430
  <xsl:copy>
8292
8431
  <xsl:copy-of select="@*"/>
8293
8432
  <!-- copy all elements from bibliography except 'Normative references' (moved to 'sections') -->
8294
- <xsl:for-each select="*[not(@normative='true') and not(*[*[@normative='true']])]">
8433
+ <xsl:for-each select="*[not(@normative='true') and not(*[@normative='true'])]">
8295
8434
  <xsl:sort select="@displayorder" data-type="number"/>
8296
8435
  <xsl:apply-templates select="." mode="update_xml_step1"/>
8297
8436
  </xsl:for-each>
@@ -8540,22 +8679,25 @@
8540
8679
  <xsl:param name="pText" select="."/>
8541
8680
  <xsl:param name="sep" select="','"/>
8542
8681
  <xsl:param name="normalize-space" select="'true'"/>
8682
+ <xsl:param name="keep_sep" select="'false'"/>
8543
8683
  <xsl:if test="string-length($pText) &gt;0">
8544
- <item>
8545
- <xsl:choose>
8546
- <xsl:when test="$normalize-space = 'true'">
8547
- <xsl:value-of select="normalize-space(substring-before(concat($pText, $sep), $sep))"/>
8548
- </xsl:when>
8549
- <xsl:otherwise>
8550
- <xsl:value-of select="substring-before(concat($pText, $sep), $sep)"/>
8551
- </xsl:otherwise>
8552
- </xsl:choose>
8553
- </item>
8554
- <xsl:call-template name="split">
8555
- <xsl:with-param name="pText" select="substring-after($pText, $sep)"/>
8556
- <xsl:with-param name="sep" select="$sep"/>
8557
- <xsl:with-param name="normalize-space" select="$normalize-space"/>
8558
- </xsl:call-template>
8684
+ <item>
8685
+ <xsl:choose>
8686
+ <xsl:when test="$normalize-space = 'true'">
8687
+ <xsl:value-of select="normalize-space(substring-before(concat($pText, $sep), $sep))"/>
8688
+ </xsl:when>
8689
+ <xsl:otherwise>
8690
+ <xsl:value-of select="substring-before(concat($pText, $sep), $sep)"/>
8691
+ </xsl:otherwise>
8692
+ </xsl:choose>
8693
+ </item>
8694
+ <xsl:if test="$keep_sep = 'true' and contains($pText, $sep)"><item><xsl:value-of select="$sep"/></item></xsl:if>
8695
+ <xsl:call-template name="split">
8696
+ <xsl:with-param name="pText" select="substring-after($pText, $sep)"/>
8697
+ <xsl:with-param name="sep" select="$sep"/>
8698
+ <xsl:with-param name="normalize-space" select="$normalize-space"/>
8699
+ <xsl:with-param name="keep_sep" select="$keep_sep"/>
8700
+ </xsl:call-template>
8559
8701
  </xsl:if>
8560
8702
  </xsl:template><xsl:template name="getDocumentId">
8561
8703
  <xsl:call-template name="getLang"/><xsl:value-of select="//*[local-name() = 'p'][1]/@id"/>