metanorma-ogc 2.0.5 → 2.0.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -130,7 +130,13 @@
130
130
 
131
131
  <xsl:template match="/">
132
132
  <xsl:call-template name="namespaceCheck"/>
133
- <fo:root xsl:use-attribute-sets="root-style" xml:lang="{$lang}">
133
+ <fo:root xml:lang="{$lang}">
134
+ <xsl:variable name="root-style">
135
+ <root-style xsl:use-attribute-sets="root-style"/>
136
+ </xsl:variable>
137
+ <xsl:call-template name="insertRootStyle">
138
+ <xsl:with-param name="root-style" select="$root-style"/>
139
+ </xsl:call-template>
134
140
  <fo:layout-master-set>
135
141
  <!-- Cover page -->
136
142
  <fo:simple-page-master master-name="cover-page" page-width="{$pageWidth}mm" page-height="{$pageHeight}mm">
@@ -1451,7 +1457,7 @@
1451
1457
  </fo:static-content>
1452
1458
  </xsl:template>
1453
1459
 
1454
- <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">
1460
+ <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">
1455
1461
  <xsl:call-template name="getLang"/>
1456
1462
  </xsl:variable><xsl:variable name="pageWidth_">
1457
1463
  215.9
@@ -1604,7 +1610,30 @@
1604
1610
 
1605
1611
 
1606
1612
 
1607
- </xsl:attribute-set><xsl:attribute-set name="copyright-statement-style">
1613
+ </xsl:attribute-set><xsl:template name="insertRootStyle">
1614
+ <xsl:param name="root-style"/>
1615
+ <xsl:variable name="root-style_" select="xalan:nodeset($root-style)"/>
1616
+
1617
+ <xsl:variable name="additional_fonts_">
1618
+ <xsl:for-each select="//*[local-name() = 'misc-container'][1]/*[local-name() = 'presentation-metadata'][*[local-name() = 'name'] = 'fonts']/*[local-name() = 'value']">
1619
+ <xsl:value-of select="."/><xsl:if test="position() != last()">, </xsl:if>
1620
+ </xsl:for-each>
1621
+ </xsl:variable>
1622
+ <xsl:variable name="additional_fonts" select="normalize-space($additional_fonts_)"/>
1623
+
1624
+ <xsl:for-each select="$root-style_/root-style/@*">
1625
+ <xsl:choose>
1626
+ <xsl:when test="local-name() = 'font-family' and $additional_fonts != ''">
1627
+ <xsl:attribute name="{local-name()}">
1628
+ <xsl:value-of select="."/>, <xsl:value-of select="$additional_fonts"/>
1629
+ </xsl:attribute>
1630
+ </xsl:when>
1631
+ <xsl:otherwise>
1632
+ <xsl:copy-of select="."/>
1633
+ </xsl:otherwise>
1634
+ </xsl:choose>
1635
+ </xsl:for-each>
1636
+ </xsl:template><xsl:attribute-set name="copyright-statement-style">
1608
1637
 
1609
1638
  <xsl:attribute name="font-size">8pt</xsl:attribute>
1610
1639
  <xsl:attribute name="line-height">125%</xsl:attribute>
@@ -2195,7 +2224,7 @@
2195
2224
  <xsl:attribute name="margin-bottom">12pt</xsl:attribute>
2196
2225
 
2197
2226
 
2198
- </xsl:attribute-set><xsl:attribute-set name="termnote-name-style">
2227
+ </xsl:attribute-set><xsl:attribute-set name="termnote-name-style">
2199
2228
 
2200
2229
 
2201
2230
  <xsl:attribute name="font-weight">bold</xsl:attribute>
@@ -2930,8 +2959,27 @@
2930
2959
  <xsl:sort select="@displayorder" data-type="number"/>
2931
2960
  <xsl:apply-templates select="."/>
2932
2961
  </xsl:for-each>
2933
- </xsl:template><xsl:template match="text()">
2934
- <xsl:value-of select="."/>
2962
+ </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">
2963
+ <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
2964
+ <xsl:variable name="text" select="java:replaceAll(java:java.lang.String.new(.),$regex_standard_reference,concat($tag_open,'$1',$tag_close))"/>
2965
+ <xsl:call-template name="replace_fo_inline">
2966
+ <xsl:with-param name="text" select="$text"/>
2967
+ </xsl:call-template>
2968
+ </xsl:template><xsl:template name="replace_fo_inline">
2969
+ <xsl:param name="text"/>
2970
+ <xsl:choose>
2971
+ <xsl:when test="contains($text, $tag_open)">
2972
+ <xsl:value-of select="substring-before($text, $tag_open)"/>
2973
+ <xsl:text disable-output-escaping="yes">&lt;fo:inline keep-together.within-line="always"&gt;</xsl:text>
2974
+ <xsl:variable name="text_after" select="substring-after($text, $tag_open)"/>
2975
+ <xsl:value-of select="substring-before($text_after, $tag_close)"/>
2976
+ <xsl:text disable-output-escaping="yes">&lt;/fo:inline&gt;</xsl:text>
2977
+ <xsl:call-template name="replace_fo_inline">
2978
+ <xsl:with-param name="text" select="substring-after($text_after, $tag_close)"/>
2979
+ </xsl:call-template>
2980
+ </xsl:when>
2981
+ <xsl:otherwise><xsl:value-of select="$text"/></xsl:otherwise>
2982
+ </xsl:choose>
2935
2983
  </xsl:template><xsl:template match="*[local-name()='br']">
2936
2984
  <xsl:value-of select="$linebreak"/>
2937
2985
  </xsl:template><xsl:template match="*[local-name()='copyright-statement']">
@@ -4615,24 +4663,28 @@
4615
4663
  </xsl:template><xsl:template name="add-zero-spaces-equal">
4616
4664
  <xsl:param name="text" select="."/>
4617
4665
  <xsl:variable name="zero-space-after-equals">==========</xsl:variable>
4666
+ <xsl:variable name="regex_zero-space-after-equals">(==========)</xsl:variable>
4618
4667
  <xsl:variable name="zero-space-after-equal">=</xsl:variable>
4668
+ <xsl:variable name="regex_zero-space-after-equal">(=)</xsl:variable>
4619
4669
  <xsl:variable name="zero-space">​</xsl:variable>
4620
4670
  <xsl:choose>
4621
4671
  <xsl:when test="contains($text, $zero-space-after-equals)">
4622
- <xsl:value-of select="substring-before($text, $zero-space-after-equals)"/>
4672
+ <!-- <xsl:value-of select="substring-before($text, $zero-space-after-equals)"/>
4623
4673
  <xsl:value-of select="$zero-space-after-equals"/>
4624
4674
  <xsl:value-of select="$zero-space"/>
4625
4675
  <xsl:call-template name="add-zero-spaces-equal">
4626
4676
  <xsl:with-param name="text" select="substring-after($text, $zero-space-after-equals)"/>
4627
- </xsl:call-template>
4677
+ </xsl:call-template> -->
4678
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),$regex_zero-space-after-equals,concat('$1',$zero_width_space))"/>
4628
4679
  </xsl:when>
4629
4680
  <xsl:when test="contains($text, $zero-space-after-equal)">
4630
- <xsl:value-of select="substring-before($text, $zero-space-after-equal)"/>
4681
+ <!-- <xsl:value-of select="substring-before($text, $zero-space-after-equal)"/>
4631
4682
  <xsl:value-of select="$zero-space-after-equal"/>
4632
4683
  <xsl:value-of select="$zero-space"/>
4633
4684
  <xsl:call-template name="add-zero-spaces-equal">
4634
4685
  <xsl:with-param name="text" select="substring-after($text, $zero-space-after-equal)"/>
4635
- </xsl:call-template>
4686
+ </xsl:call-template> -->
4687
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),$regex_zero-space-after-equal,concat('$1',$zero_width_space))"/>
4636
4688
  </xsl:when>
4637
4689
  <xsl:otherwise>
4638
4690
  <xsl:value-of select="$text"/>
@@ -5112,7 +5164,12 @@
5112
5164
 
5113
5165
  <fo:inline xsl:use-attribute-sets="termnote-name-style">
5114
5166
 
5167
+ <xsl:if test="not(*[local-name() = 'name']/following-sibling::node()[1][self::text()][normalize-space()=''])">
5168
+ <xsl:attribute name="padding-right">1mm</xsl:attribute>
5169
+ </xsl:if>
5170
+
5115
5171
 
5172
+
5116
5173
 
5117
5174
  <!-- if 'p' contains all text in 'add' first and last elements in first p are 'add' -->
5118
5175
  <!-- <xsl:if test="*[not(local-name()='name')][1][node()[normalize-space() != ''][1][local-name() = 'add'] and node()[normalize-space() != ''][last()][local-name() = 'add']]"> -->
@@ -6113,7 +6170,73 @@
6113
6170
  <xsl:with-param name="text" select="$text_step1"/>
6114
6171
  </xsl:call-template>
6115
6172
  </xsl:variable>
6116
- <xsl:value-of select="$text_step2"/>
6173
+
6174
+ <!-- <xsl:value-of select="$text_step2"/> -->
6175
+
6176
+ <!-- add zero-width space after space -->
6177
+ <xsl:variable name="text_step3" select="java:replaceAll(java:java.lang.String.new($text_step2),' ',' ​')"/>
6178
+
6179
+ <!-- split text by zero-width space -->
6180
+ <xsl:variable name="text_step4">
6181
+ <xsl:call-template name="split_for_interspers">
6182
+ <xsl:with-param name="pText" select="$text_step3"/>
6183
+ <xsl:with-param name="sep" select="$zero_width_space"/>
6184
+ </xsl:call-template>
6185
+ </xsl:variable>
6186
+
6187
+ <xsl:for-each select="xalan:nodeset($text_step4)/node()">
6188
+ <xsl:choose>
6189
+ <xsl:when test="local-name() = 'interspers'"> <!-- word with length more than 30 will be interspersed with zero-width space -->
6190
+ <xsl:call-template name="interspers">
6191
+ <xsl:with-param name="str" select="."/>
6192
+ </xsl:call-template>
6193
+ </xsl:when>
6194
+ <xsl:otherwise>
6195
+ <xsl:value-of select="."/>
6196
+ </xsl:otherwise>
6197
+ </xsl:choose>
6198
+ </xsl:for-each>
6199
+
6200
+ </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">
6201
+ <xsl:param name="pText" select="."/>
6202
+ <xsl:param name="sep" select="','"/>
6203
+ <!-- word with length more than 30 will be interspersed with zero-width space -->
6204
+ <xsl:variable name="regex" select="concat('([^', $zero_width_space, ']{31,})')"/> <!-- sequence of characters (more 31), that doesn't contains zero-width space -->
6205
+ <xsl:variable name="text" select="java:replaceAll(java:java.lang.String.new($pText),$regex,concat($interspers_tag_open,'$1',$interspers_tag_close))"/>
6206
+ <xsl:call-template name="replace_tag_interspers">
6207
+ <xsl:with-param name="text" select="$text"/>
6208
+ </xsl:call-template>
6209
+ </xsl:template><xsl:template name="replace_tag_interspers">
6210
+ <xsl:param name="text"/>
6211
+ <xsl:choose>
6212
+ <xsl:when test="contains($text, $interspers_tag_open)">
6213
+ <xsl:value-of select="substring-before($text, $interspers_tag_open)"/>
6214
+ <xsl:variable name="text_after" select="substring-after($text, $interspers_tag_open)"/>
6215
+ <interspers>
6216
+ <xsl:value-of select="substring-before($text_after, $interspers_tag_close)"/>
6217
+ </interspers>
6218
+ <xsl:call-template name="replace_tag_interspers">
6219
+ <xsl:with-param name="text" select="substring-after($text_after, $interspers_tag_close)"/>
6220
+ </xsl:call-template>
6221
+ </xsl:when>
6222
+ <xsl:otherwise><xsl:value-of select="$text"/></xsl:otherwise>
6223
+ </xsl:choose>
6224
+ </xsl:template><xsl:template name="interspers">
6225
+ <xsl:param name="str"/>
6226
+ <xsl:param name="char" select="$zero_width_space"/>
6227
+ <xsl:if test="$str != ''">
6228
+ <xsl:value-of select="substring($str, 1, 1)"/>
6229
+
6230
+ <xsl:variable name="next_char" select="substring($str, 2, 1)"/>
6231
+ <xsl:if test="not(contains(concat(' -.:=_— ', $char), $next_char))">
6232
+ <xsl:value-of select="$char"/>
6233
+ </xsl:if>
6234
+
6235
+ <xsl:call-template name="interspers">
6236
+ <xsl:with-param name="str" select="substring($str, 2)"/>
6237
+ <xsl:with-param name="char" select="$char"/>
6238
+ </xsl:call-template>
6239
+ </xsl:if>
6117
6240
  </xsl:template><xsl:template match="*" mode="syntax_highlight">
6118
6241
  <xsl:apply-templates mode="syntax_highlight"/>
6119
6242
  </xsl:template><xsl:variable name="syntax_highlight_styles_">
@@ -6555,7 +6678,7 @@
6555
6678
  </xsl:otherwise>
6556
6679
  </xsl:choose> -->
6557
6680
  </fo:block>
6558
- </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()[starts-with(., '[SOURCE: Adapted from: ')]" priority="2">
6681
+ </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">
6559
6682
  <xsl:text>[</xsl:text><xsl:value-of select="substring-after(., '[SOURCE: ')"/>
6560
6683
  </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()">
6561
6684
  <xsl:if test="normalize-space() != ''">
@@ -6591,7 +6714,8 @@
6591
6714
  <fo:inline><xsl:apply-templates/></fo:inline>
6592
6715
  </xsl:template><xsl:template match="*[local-name() = 'modification']/text()">
6593
6716
  <xsl:if test="normalize-space() != ''">
6594
- <xsl:value-of select="."/>
6717
+ <!-- <xsl:value-of select="."/> -->
6718
+ <xsl:call-template name="text"/>
6595
6719
  </xsl:if>
6596
6720
  </xsl:template><xsl:template match="*[local-name() = 'quote']">
6597
6721
  <fo:block-container margin-left="0mm">
@@ -6631,11 +6755,24 @@
6631
6755
  </xsl:template><xsl:template match="*[local-name() = 'author']">
6632
6756
  <xsl:text>— </xsl:text>
6633
6757
  <xsl:apply-templates/>
6634
- </xsl:template><xsl:template match="*[local-name() = 'eref']">
6758
+ </xsl:template><xsl:variable name="bibitems_">
6759
+ <xsl:for-each select="//*[local-name() = 'bibitem']">
6760
+ <xsl:copy-of select="."/>
6761
+ </xsl:for-each>
6762
+ </xsl:variable><xsl:variable name="bibitems" select="xalan:nodeset($bibitems_)"/><xsl:variable name="bibitems_hidden_">
6763
+ <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden='true']">
6764
+ <xsl:copy-of select="."/>
6765
+ </xsl:for-each>
6766
+ <xsl:for-each select="//*[local-name() = 'references'][@hidden='true']//*[local-name() = 'bibitem']">
6767
+ <xsl:copy-of select="."/>
6768
+ </xsl:for-each>
6769
+ </xsl:variable><xsl:variable name="bibitems_hidden" select="xalan:nodeset($bibitems_hidden_)"/><xsl:template match="*[local-name() = 'eref']">
6635
6770
  <xsl:variable name="current_bibitemid" select="@bibitemid"/>
6636
- <xsl:variable name="external-destination" select="normalize-space(key('bibitems', $current_bibitemid)/*[local-name() = 'uri'][@type = 'citation'])"/>
6771
+ <!-- <xsl:variable name="external-destination" select="normalize-space(key('bibitems', $current_bibitemid)/*[local-name() = 'uri'][@type = 'citation'])"/> -->
6772
+ <xsl:variable name="external-destination" select="normalize-space($bibitems/*[local-name() ='bibitem'][@id = $current_bibitemid]/*[local-name() = 'uri'][@type = 'citation'])"/>
6637
6773
  <xsl:choose>
6638
- <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) -->
6774
+ <!-- <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) -->
6775
+ <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) -->
6639
6776
  <fo:inline xsl:use-attribute-sets="eref-style">
6640
6777
  <xsl:if test="@type = 'footnote'">
6641
6778
  <xsl:attribute name="keep-together.within-line">always</xsl:attribute>
@@ -7881,7 +8018,7 @@
7881
8018
  <xsl:copy>
7882
8019
  <xsl:copy-of select="@*"/>
7883
8020
  <!-- copy all elements from bibliography except 'Normative references' (moved to 'sections') -->
7884
- <xsl:for-each select="*[not(@normative='true') and not(*[*[@normative='true']])]">
8021
+ <xsl:for-each select="*[not(@normative='true') and not(*[@normative='true'])]">
7885
8022
  <xsl:sort select="@displayorder" data-type="number"/>
7886
8023
  <xsl:apply-templates select="." mode="update_xml_step1"/>
7887
8024
  </xsl:for-each>
@@ -8130,22 +8267,25 @@
8130
8267
  <xsl:param name="pText" select="."/>
8131
8268
  <xsl:param name="sep" select="','"/>
8132
8269
  <xsl:param name="normalize-space" select="'true'"/>
8270
+ <xsl:param name="keep_sep" select="'false'"/>
8133
8271
  <xsl:if test="string-length($pText) &gt;0">
8134
- <item>
8135
- <xsl:choose>
8136
- <xsl:when test="$normalize-space = 'true'">
8137
- <xsl:value-of select="normalize-space(substring-before(concat($pText, $sep), $sep))"/>
8138
- </xsl:when>
8139
- <xsl:otherwise>
8140
- <xsl:value-of select="substring-before(concat($pText, $sep), $sep)"/>
8141
- </xsl:otherwise>
8142
- </xsl:choose>
8143
- </item>
8144
- <xsl:call-template name="split">
8145
- <xsl:with-param name="pText" select="substring-after($pText, $sep)"/>
8146
- <xsl:with-param name="sep" select="$sep"/>
8147
- <xsl:with-param name="normalize-space" select="$normalize-space"/>
8148
- </xsl:call-template>
8272
+ <item>
8273
+ <xsl:choose>
8274
+ <xsl:when test="$normalize-space = 'true'">
8275
+ <xsl:value-of select="normalize-space(substring-before(concat($pText, $sep), $sep))"/>
8276
+ </xsl:when>
8277
+ <xsl:otherwise>
8278
+ <xsl:value-of select="substring-before(concat($pText, $sep), $sep)"/>
8279
+ </xsl:otherwise>
8280
+ </xsl:choose>
8281
+ </item>
8282
+ <xsl:if test="$keep_sep = 'true' and contains($pText, $sep)"><item><xsl:value-of select="$sep"/></item></xsl:if>
8283
+ <xsl:call-template name="split">
8284
+ <xsl:with-param name="pText" select="substring-after($pText, $sep)"/>
8285
+ <xsl:with-param name="sep" select="$sep"/>
8286
+ <xsl:with-param name="normalize-space" select="$normalize-space"/>
8287
+ <xsl:with-param name="keep_sep" select="$keep_sep"/>
8288
+ </xsl:call-template>
8149
8289
  </xsl:if>
8150
8290
  </xsl:template><xsl:template name="getDocumentId">
8151
8291
  <xsl:call-template name="getLang"/><xsl:value-of select="//*[local-name() = 'p'][1]/@id"/>
@@ -87,7 +87,13 @@
87
87
 
88
88
  <xsl:template match="/">
89
89
  <xsl:call-template name="namespaceCheck"/>
90
- <fo:root xsl:use-attribute-sets="root-style" xml:lang="{$lang}">
90
+ <fo:root xml:lang="{$lang}">
91
+ <xsl:variable name="root-style">
92
+ <root-style xsl:use-attribute-sets="root-style"/>
93
+ </xsl:variable>
94
+ <xsl:call-template name="insertRootStyle">
95
+ <xsl:with-param name="root-style" select="$root-style"/>
96
+ </xsl:call-template>
91
97
  <fo:layout-master-set>
92
98
 
93
99
  <!-- Document pages -->
@@ -632,7 +638,7 @@
632
638
  </xsl:choose>
633
639
  </xsl:template>
634
640
 
635
- <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">
641
+ <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">
636
642
  <xsl:call-template name="getLang"/>
637
643
  </xsl:variable><xsl:variable name="pageWidth_">
638
644
  215.9
@@ -784,7 +790,30 @@
784
790
 
785
791
 
786
792
 
787
- </xsl:attribute-set><xsl:attribute-set name="copyright-statement-style">
793
+ </xsl:attribute-set><xsl:template name="insertRootStyle">
794
+ <xsl:param name="root-style"/>
795
+ <xsl:variable name="root-style_" select="xalan:nodeset($root-style)"/>
796
+
797
+ <xsl:variable name="additional_fonts_">
798
+ <xsl:for-each select="//*[local-name() = 'misc-container'][1]/*[local-name() = 'presentation-metadata'][*[local-name() = 'name'] = 'fonts']/*[local-name() = 'value']">
799
+ <xsl:value-of select="."/><xsl:if test="position() != last()">, </xsl:if>
800
+ </xsl:for-each>
801
+ </xsl:variable>
802
+ <xsl:variable name="additional_fonts" select="normalize-space($additional_fonts_)"/>
803
+
804
+ <xsl:for-each select="$root-style_/root-style/@*">
805
+ <xsl:choose>
806
+ <xsl:when test="local-name() = 'font-family' and $additional_fonts != ''">
807
+ <xsl:attribute name="{local-name()}">
808
+ <xsl:value-of select="."/>, <xsl:value-of select="$additional_fonts"/>
809
+ </xsl:attribute>
810
+ </xsl:when>
811
+ <xsl:otherwise>
812
+ <xsl:copy-of select="."/>
813
+ </xsl:otherwise>
814
+ </xsl:choose>
815
+ </xsl:for-each>
816
+ </xsl:template><xsl:attribute-set name="copyright-statement-style">
788
817
 
789
818
  </xsl:attribute-set><xsl:attribute-set name="copyright-statement-title-style">
790
819
 
@@ -1384,7 +1413,7 @@
1384
1413
 
1385
1414
 
1386
1415
 
1387
- </xsl:attribute-set><xsl:attribute-set name="termnote-name-style">
1416
+ </xsl:attribute-set><xsl:attribute-set name="termnote-name-style">
1388
1417
 
1389
1418
 
1390
1419
 
@@ -2119,8 +2148,27 @@
2119
2148
  <xsl:sort select="@displayorder" data-type="number"/>
2120
2149
  <xsl:apply-templates select="."/>
2121
2150
  </xsl:for-each>
2122
- </xsl:template><xsl:template match="text()">
2123
- <xsl:value-of select="."/>
2151
+ </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">
2152
+ <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
2153
+ <xsl:variable name="text" select="java:replaceAll(java:java.lang.String.new(.),$regex_standard_reference,concat($tag_open,'$1',$tag_close))"/>
2154
+ <xsl:call-template name="replace_fo_inline">
2155
+ <xsl:with-param name="text" select="$text"/>
2156
+ </xsl:call-template>
2157
+ </xsl:template><xsl:template name="replace_fo_inline">
2158
+ <xsl:param name="text"/>
2159
+ <xsl:choose>
2160
+ <xsl:when test="contains($text, $tag_open)">
2161
+ <xsl:value-of select="substring-before($text, $tag_open)"/>
2162
+ <xsl:text disable-output-escaping="yes">&lt;fo:inline keep-together.within-line="always"&gt;</xsl:text>
2163
+ <xsl:variable name="text_after" select="substring-after($text, $tag_open)"/>
2164
+ <xsl:value-of select="substring-before($text_after, $tag_close)"/>
2165
+ <xsl:text disable-output-escaping="yes">&lt;/fo:inline&gt;</xsl:text>
2166
+ <xsl:call-template name="replace_fo_inline">
2167
+ <xsl:with-param name="text" select="substring-after($text_after, $tag_close)"/>
2168
+ </xsl:call-template>
2169
+ </xsl:when>
2170
+ <xsl:otherwise><xsl:value-of select="$text"/></xsl:otherwise>
2171
+ </xsl:choose>
2124
2172
  </xsl:template><xsl:template match="*[local-name()='br']">
2125
2173
  <xsl:value-of select="$linebreak"/>
2126
2174
  </xsl:template><xsl:template match="*[local-name()='copyright-statement']">
@@ -3816,24 +3864,28 @@
3816
3864
  </xsl:template><xsl:template name="add-zero-spaces-equal">
3817
3865
  <xsl:param name="text" select="."/>
3818
3866
  <xsl:variable name="zero-space-after-equals">==========</xsl:variable>
3867
+ <xsl:variable name="regex_zero-space-after-equals">(==========)</xsl:variable>
3819
3868
  <xsl:variable name="zero-space-after-equal">=</xsl:variable>
3869
+ <xsl:variable name="regex_zero-space-after-equal">(=)</xsl:variable>
3820
3870
  <xsl:variable name="zero-space">​</xsl:variable>
3821
3871
  <xsl:choose>
3822
3872
  <xsl:when test="contains($text, $zero-space-after-equals)">
3823
- <xsl:value-of select="substring-before($text, $zero-space-after-equals)"/>
3873
+ <!-- <xsl:value-of select="substring-before($text, $zero-space-after-equals)"/>
3824
3874
  <xsl:value-of select="$zero-space-after-equals"/>
3825
3875
  <xsl:value-of select="$zero-space"/>
3826
3876
  <xsl:call-template name="add-zero-spaces-equal">
3827
3877
  <xsl:with-param name="text" select="substring-after($text, $zero-space-after-equals)"/>
3828
- </xsl:call-template>
3878
+ </xsl:call-template> -->
3879
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),$regex_zero-space-after-equals,concat('$1',$zero_width_space))"/>
3829
3880
  </xsl:when>
3830
3881
  <xsl:when test="contains($text, $zero-space-after-equal)">
3831
- <xsl:value-of select="substring-before($text, $zero-space-after-equal)"/>
3882
+ <!-- <xsl:value-of select="substring-before($text, $zero-space-after-equal)"/>
3832
3883
  <xsl:value-of select="$zero-space-after-equal"/>
3833
3884
  <xsl:value-of select="$zero-space"/>
3834
3885
  <xsl:call-template name="add-zero-spaces-equal">
3835
3886
  <xsl:with-param name="text" select="substring-after($text, $zero-space-after-equal)"/>
3836
- </xsl:call-template>
3887
+ </xsl:call-template> -->
3888
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),$regex_zero-space-after-equal,concat('$1',$zero_width_space))"/>
3837
3889
  </xsl:when>
3838
3890
  <xsl:otherwise>
3839
3891
  <xsl:value-of select="$text"/>
@@ -4313,7 +4365,12 @@
4313
4365
 
4314
4366
  <fo:inline xsl:use-attribute-sets="termnote-name-style">
4315
4367
 
4368
+ <xsl:if test="not(*[local-name() = 'name']/following-sibling::node()[1][self::text()][normalize-space()=''])">
4369
+ <xsl:attribute name="padding-right">1mm</xsl:attribute>
4370
+ </xsl:if>
4371
+
4316
4372
 
4373
+
4317
4374
 
4318
4375
  <!-- if 'p' contains all text in 'add' first and last elements in first p are 'add' -->
4319
4376
  <!-- <xsl:if test="*[not(local-name()='name')][1][node()[normalize-space() != ''][1][local-name() = 'add'] and node()[normalize-space() != ''][last()][local-name() = 'add']]"> -->
@@ -5274,7 +5331,73 @@
5274
5331
  <xsl:with-param name="text" select="$text_step1"/>
5275
5332
  </xsl:call-template>
5276
5333
  </xsl:variable>
5277
- <xsl:value-of select="$text_step2"/>
5334
+
5335
+ <!-- <xsl:value-of select="$text_step2"/> -->
5336
+
5337
+ <!-- add zero-width space after space -->
5338
+ <xsl:variable name="text_step3" select="java:replaceAll(java:java.lang.String.new($text_step2),' ',' ​')"/>
5339
+
5340
+ <!-- split text by zero-width space -->
5341
+ <xsl:variable name="text_step4">
5342
+ <xsl:call-template name="split_for_interspers">
5343
+ <xsl:with-param name="pText" select="$text_step3"/>
5344
+ <xsl:with-param name="sep" select="$zero_width_space"/>
5345
+ </xsl:call-template>
5346
+ </xsl:variable>
5347
+
5348
+ <xsl:for-each select="xalan:nodeset($text_step4)/node()">
5349
+ <xsl:choose>
5350
+ <xsl:when test="local-name() = 'interspers'"> <!-- word with length more than 30 will be interspersed with zero-width space -->
5351
+ <xsl:call-template name="interspers">
5352
+ <xsl:with-param name="str" select="."/>
5353
+ </xsl:call-template>
5354
+ </xsl:when>
5355
+ <xsl:otherwise>
5356
+ <xsl:value-of select="."/>
5357
+ </xsl:otherwise>
5358
+ </xsl:choose>
5359
+ </xsl:for-each>
5360
+
5361
+ </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">
5362
+ <xsl:param name="pText" select="."/>
5363
+ <xsl:param name="sep" select="','"/>
5364
+ <!-- word with length more than 30 will be interspersed with zero-width space -->
5365
+ <xsl:variable name="regex" select="concat('([^', $zero_width_space, ']{31,})')"/> <!-- sequence of characters (more 31), that doesn't contains zero-width space -->
5366
+ <xsl:variable name="text" select="java:replaceAll(java:java.lang.String.new($pText),$regex,concat($interspers_tag_open,'$1',$interspers_tag_close))"/>
5367
+ <xsl:call-template name="replace_tag_interspers">
5368
+ <xsl:with-param name="text" select="$text"/>
5369
+ </xsl:call-template>
5370
+ </xsl:template><xsl:template name="replace_tag_interspers">
5371
+ <xsl:param name="text"/>
5372
+ <xsl:choose>
5373
+ <xsl:when test="contains($text, $interspers_tag_open)">
5374
+ <xsl:value-of select="substring-before($text, $interspers_tag_open)"/>
5375
+ <xsl:variable name="text_after" select="substring-after($text, $interspers_tag_open)"/>
5376
+ <interspers>
5377
+ <xsl:value-of select="substring-before($text_after, $interspers_tag_close)"/>
5378
+ </interspers>
5379
+ <xsl:call-template name="replace_tag_interspers">
5380
+ <xsl:with-param name="text" select="substring-after($text_after, $interspers_tag_close)"/>
5381
+ </xsl:call-template>
5382
+ </xsl:when>
5383
+ <xsl:otherwise><xsl:value-of select="$text"/></xsl:otherwise>
5384
+ </xsl:choose>
5385
+ </xsl:template><xsl:template name="interspers">
5386
+ <xsl:param name="str"/>
5387
+ <xsl:param name="char" select="$zero_width_space"/>
5388
+ <xsl:if test="$str != ''">
5389
+ <xsl:value-of select="substring($str, 1, 1)"/>
5390
+
5391
+ <xsl:variable name="next_char" select="substring($str, 2, 1)"/>
5392
+ <xsl:if test="not(contains(concat(' -.:=_— ', $char), $next_char))">
5393
+ <xsl:value-of select="$char"/>
5394
+ </xsl:if>
5395
+
5396
+ <xsl:call-template name="interspers">
5397
+ <xsl:with-param name="str" select="substring($str, 2)"/>
5398
+ <xsl:with-param name="char" select="$char"/>
5399
+ </xsl:call-template>
5400
+ </xsl:if>
5278
5401
  </xsl:template><xsl:template match="*" mode="syntax_highlight">
5279
5402
  <xsl:apply-templates mode="syntax_highlight"/>
5280
5403
  </xsl:template><xsl:variable name="syntax_highlight_styles_">
@@ -5716,7 +5839,7 @@
5716
5839
  </xsl:otherwise>
5717
5840
  </xsl:choose> -->
5718
5841
  </fo:block>
5719
- </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()[starts-with(., '[SOURCE: Adapted from: ')]" priority="2">
5842
+ </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">
5720
5843
  <xsl:text>[</xsl:text><xsl:value-of select="substring-after(., '[SOURCE: ')"/>
5721
5844
  </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()">
5722
5845
  <xsl:if test="normalize-space() != ''">
@@ -5752,7 +5875,8 @@
5752
5875
  <fo:inline><xsl:apply-templates/></fo:inline>
5753
5876
  </xsl:template><xsl:template match="*[local-name() = 'modification']/text()">
5754
5877
  <xsl:if test="normalize-space() != ''">
5755
- <xsl:value-of select="."/>
5878
+ <!-- <xsl:value-of select="."/> -->
5879
+ <xsl:call-template name="text"/>
5756
5880
  </xsl:if>
5757
5881
  </xsl:template><xsl:template match="*[local-name() = 'quote']">
5758
5882
  <fo:block-container margin-left="0mm">
@@ -5792,11 +5916,24 @@
5792
5916
  </xsl:template><xsl:template match="*[local-name() = 'author']">
5793
5917
  <xsl:text>— </xsl:text>
5794
5918
  <xsl:apply-templates/>
5795
- </xsl:template><xsl:template match="*[local-name() = 'eref']">
5919
+ </xsl:template><xsl:variable name="bibitems_">
5920
+ <xsl:for-each select="//*[local-name() = 'bibitem']">
5921
+ <xsl:copy-of select="."/>
5922
+ </xsl:for-each>
5923
+ </xsl:variable><xsl:variable name="bibitems" select="xalan:nodeset($bibitems_)"/><xsl:variable name="bibitems_hidden_">
5924
+ <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden='true']">
5925
+ <xsl:copy-of select="."/>
5926
+ </xsl:for-each>
5927
+ <xsl:for-each select="//*[local-name() = 'references'][@hidden='true']//*[local-name() = 'bibitem']">
5928
+ <xsl:copy-of select="."/>
5929
+ </xsl:for-each>
5930
+ </xsl:variable><xsl:variable name="bibitems_hidden" select="xalan:nodeset($bibitems_hidden_)"/><xsl:template match="*[local-name() = 'eref']">
5796
5931
  <xsl:variable name="current_bibitemid" select="@bibitemid"/>
5797
- <xsl:variable name="external-destination" select="normalize-space(key('bibitems', $current_bibitemid)/*[local-name() = 'uri'][@type = 'citation'])"/>
5932
+ <!-- <xsl:variable name="external-destination" select="normalize-space(key('bibitems', $current_bibitemid)/*[local-name() = 'uri'][@type = 'citation'])"/> -->
5933
+ <xsl:variable name="external-destination" select="normalize-space($bibitems/*[local-name() ='bibitem'][@id = $current_bibitemid]/*[local-name() = 'uri'][@type = 'citation'])"/>
5798
5934
  <xsl:choose>
5799
- <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) -->
5935
+ <!-- <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) -->
5936
+ <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) -->
5800
5937
  <fo:inline xsl:use-attribute-sets="eref-style">
5801
5938
  <xsl:if test="@type = 'footnote'">
5802
5939
  <xsl:attribute name="keep-together.within-line">always</xsl:attribute>
@@ -7047,7 +7184,7 @@
7047
7184
  <xsl:copy>
7048
7185
  <xsl:copy-of select="@*"/>
7049
7186
  <!-- copy all elements from bibliography except 'Normative references' (moved to 'sections') -->
7050
- <xsl:for-each select="*[not(@normative='true') and not(*[*[@normative='true']])]">
7187
+ <xsl:for-each select="*[not(@normative='true') and not(*[@normative='true'])]">
7051
7188
  <xsl:sort select="@displayorder" data-type="number"/>
7052
7189
  <xsl:apply-templates select="." mode="update_xml_step1"/>
7053
7190
  </xsl:for-each>
@@ -7296,22 +7433,25 @@
7296
7433
  <xsl:param name="pText" select="."/>
7297
7434
  <xsl:param name="sep" select="','"/>
7298
7435
  <xsl:param name="normalize-space" select="'true'"/>
7436
+ <xsl:param name="keep_sep" select="'false'"/>
7299
7437
  <xsl:if test="string-length($pText) &gt;0">
7300
- <item>
7301
- <xsl:choose>
7302
- <xsl:when test="$normalize-space = 'true'">
7303
- <xsl:value-of select="normalize-space(substring-before(concat($pText, $sep), $sep))"/>
7304
- </xsl:when>
7305
- <xsl:otherwise>
7306
- <xsl:value-of select="substring-before(concat($pText, $sep), $sep)"/>
7307
- </xsl:otherwise>
7308
- </xsl:choose>
7309
- </item>
7310
- <xsl:call-template name="split">
7311
- <xsl:with-param name="pText" select="substring-after($pText, $sep)"/>
7312
- <xsl:with-param name="sep" select="$sep"/>
7313
- <xsl:with-param name="normalize-space" select="$normalize-space"/>
7314
- </xsl:call-template>
7438
+ <item>
7439
+ <xsl:choose>
7440
+ <xsl:when test="$normalize-space = 'true'">
7441
+ <xsl:value-of select="normalize-space(substring-before(concat($pText, $sep), $sep))"/>
7442
+ </xsl:when>
7443
+ <xsl:otherwise>
7444
+ <xsl:value-of select="substring-before(concat($pText, $sep), $sep)"/>
7445
+ </xsl:otherwise>
7446
+ </xsl:choose>
7447
+ </item>
7448
+ <xsl:if test="$keep_sep = 'true' and contains($pText, $sep)"><item><xsl:value-of select="$sep"/></item></xsl:if>
7449
+ <xsl:call-template name="split">
7450
+ <xsl:with-param name="pText" select="substring-after($pText, $sep)"/>
7451
+ <xsl:with-param name="sep" select="$sep"/>
7452
+ <xsl:with-param name="normalize-space" select="$normalize-space"/>
7453
+ <xsl:with-param name="keep_sep" select="$keep_sep"/>
7454
+ </xsl:call-template>
7315
7455
  </xsl:if>
7316
7456
  </xsl:template><xsl:template name="getDocumentId">
7317
7457
  <xsl:call-template name="getLang"/><xsl:value-of select="//*[local-name() = 'p'][1]/@id"/>
@@ -226,7 +226,8 @@ module IsoDoc
226
226
 
227
227
  def bibliography_bibitem_number_skip(bibitem)
228
228
  @xrefs.klass.implicit_reference(bibitem) ||
229
- bibitem.at(ns(".//docidentifier[@type = 'metanorma-ordinal']"))
229
+ bibitem.at(ns(".//docidentifier[@type = 'metanorma-ordinal']")) ||
230
+ bibitem["hidden"] == "true" || bibitem.parent["hidden"] == "true"
230
231
  end
231
232
 
232
233
  include Init