metanorma-ogc 2.0.7 → 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">
@@ -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>
@@ -4634,24 +4663,28 @@
4634
4663
  </xsl:template><xsl:template name="add-zero-spaces-equal">
4635
4664
  <xsl:param name="text" select="."/>
4636
4665
  <xsl:variable name="zero-space-after-equals">==========</xsl:variable>
4666
+ <xsl:variable name="regex_zero-space-after-equals">(==========)</xsl:variable>
4637
4667
  <xsl:variable name="zero-space-after-equal">=</xsl:variable>
4668
+ <xsl:variable name="regex_zero-space-after-equal">(=)</xsl:variable>
4638
4669
  <xsl:variable name="zero-space">​</xsl:variable>
4639
4670
  <xsl:choose>
4640
4671
  <xsl:when test="contains($text, $zero-space-after-equals)">
4641
- <xsl:value-of select="substring-before($text, $zero-space-after-equals)"/>
4672
+ <!-- <xsl:value-of select="substring-before($text, $zero-space-after-equals)"/>
4642
4673
  <xsl:value-of select="$zero-space-after-equals"/>
4643
4674
  <xsl:value-of select="$zero-space"/>
4644
4675
  <xsl:call-template name="add-zero-spaces-equal">
4645
4676
  <xsl:with-param name="text" select="substring-after($text, $zero-space-after-equals)"/>
4646
- </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))"/>
4647
4679
  </xsl:when>
4648
4680
  <xsl:when test="contains($text, $zero-space-after-equal)">
4649
- <xsl:value-of select="substring-before($text, $zero-space-after-equal)"/>
4681
+ <!-- <xsl:value-of select="substring-before($text, $zero-space-after-equal)"/>
4650
4682
  <xsl:value-of select="$zero-space-after-equal"/>
4651
4683
  <xsl:value-of select="$zero-space"/>
4652
4684
  <xsl:call-template name="add-zero-spaces-equal">
4653
4685
  <xsl:with-param name="text" select="substring-after($text, $zero-space-after-equal)"/>
4654
- </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))"/>
4655
4688
  </xsl:when>
4656
4689
  <xsl:otherwise>
4657
4690
  <xsl:value-of select="$text"/>
@@ -5131,7 +5164,12 @@
5131
5164
 
5132
5165
  <fo:inline xsl:use-attribute-sets="termnote-name-style">
5133
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
+
5134
5171
 
5172
+
5135
5173
 
5136
5174
  <!-- if 'p' contains all text in 'add' first and last elements in first p are 'add' -->
5137
5175
  <!-- <xsl:if test="*[not(local-name()='name')][1][node()[normalize-space() != ''][1][local-name() = 'add'] and node()[normalize-space() != ''][last()][local-name() = 'add']]"> -->
@@ -6140,17 +6178,15 @@
6140
6178
 
6141
6179
  <!-- split text by zero-width space -->
6142
6180
  <xsl:variable name="text_step4">
6143
- <xsl:call-template name="split">
6181
+ <xsl:call-template name="split_for_interspers">
6144
6182
  <xsl:with-param name="pText" select="$text_step3"/>
6145
6183
  <xsl:with-param name="sep" select="$zero_width_space"/>
6146
- <xsl:with-param name="normalize-space">false</xsl:with-param>
6147
- <xsl:with-param name="keep_sep">true</xsl:with-param>
6148
6184
  </xsl:call-template>
6149
6185
  </xsl:variable>
6150
6186
 
6151
- <xsl:for-each select="xalan:nodeset($text_step4)/item">
6187
+ <xsl:for-each select="xalan:nodeset($text_step4)/node()">
6152
6188
  <xsl:choose>
6153
- <xsl:when test="string-length() &gt; 30"> <!-- word with length more than 30 will be interspersed with zero-width space -->
6189
+ <xsl:when test="local-name() = 'interspers'"> <!-- word with length more than 30 will be interspersed with zero-width space -->
6154
6190
  <xsl:call-template name="interspers">
6155
6191
  <xsl:with-param name="str" select="."/>
6156
6192
  </xsl:call-template>
@@ -6161,6 +6197,30 @@
6161
6197
  </xsl:choose>
6162
6198
  </xsl:for-each>
6163
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>
6164
6224
  </xsl:template><xsl:template name="interspers">
6165
6225
  <xsl:param name="str"/>
6166
6226
  <xsl:param name="char" select="$zero_width_space"/>
@@ -6618,7 +6678,7 @@
6618
6678
  </xsl:otherwise>
6619
6679
  </xsl:choose> -->
6620
6680
  </fo:block>
6621
- </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">
6622
6682
  <xsl:text>[</xsl:text><xsl:value-of select="substring-after(., '[SOURCE: ')"/>
6623
6683
  </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()">
6624
6684
  <xsl:if test="normalize-space() != ''">
@@ -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">
@@ -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>
@@ -4634,24 +4663,28 @@
4634
4663
  </xsl:template><xsl:template name="add-zero-spaces-equal">
4635
4664
  <xsl:param name="text" select="."/>
4636
4665
  <xsl:variable name="zero-space-after-equals">==========</xsl:variable>
4666
+ <xsl:variable name="regex_zero-space-after-equals">(==========)</xsl:variable>
4637
4667
  <xsl:variable name="zero-space-after-equal">=</xsl:variable>
4668
+ <xsl:variable name="regex_zero-space-after-equal">(=)</xsl:variable>
4638
4669
  <xsl:variable name="zero-space">​</xsl:variable>
4639
4670
  <xsl:choose>
4640
4671
  <xsl:when test="contains($text, $zero-space-after-equals)">
4641
- <xsl:value-of select="substring-before($text, $zero-space-after-equals)"/>
4672
+ <!-- <xsl:value-of select="substring-before($text, $zero-space-after-equals)"/>
4642
4673
  <xsl:value-of select="$zero-space-after-equals"/>
4643
4674
  <xsl:value-of select="$zero-space"/>
4644
4675
  <xsl:call-template name="add-zero-spaces-equal">
4645
4676
  <xsl:with-param name="text" select="substring-after($text, $zero-space-after-equals)"/>
4646
- </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))"/>
4647
4679
  </xsl:when>
4648
4680
  <xsl:when test="contains($text, $zero-space-after-equal)">
4649
- <xsl:value-of select="substring-before($text, $zero-space-after-equal)"/>
4681
+ <!-- <xsl:value-of select="substring-before($text, $zero-space-after-equal)"/>
4650
4682
  <xsl:value-of select="$zero-space-after-equal"/>
4651
4683
  <xsl:value-of select="$zero-space"/>
4652
4684
  <xsl:call-template name="add-zero-spaces-equal">
4653
4685
  <xsl:with-param name="text" select="substring-after($text, $zero-space-after-equal)"/>
4654
- </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))"/>
4655
4688
  </xsl:when>
4656
4689
  <xsl:otherwise>
4657
4690
  <xsl:value-of select="$text"/>
@@ -5131,7 +5164,12 @@
5131
5164
 
5132
5165
  <fo:inline xsl:use-attribute-sets="termnote-name-style">
5133
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
+
5134
5171
 
5172
+
5135
5173
 
5136
5174
  <!-- if 'p' contains all text in 'add' first and last elements in first p are 'add' -->
5137
5175
  <!-- <xsl:if test="*[not(local-name()='name')][1][node()[normalize-space() != ''][1][local-name() = 'add'] and node()[normalize-space() != ''][last()][local-name() = 'add']]"> -->
@@ -6140,17 +6178,15 @@
6140
6178
 
6141
6179
  <!-- split text by zero-width space -->
6142
6180
  <xsl:variable name="text_step4">
6143
- <xsl:call-template name="split">
6181
+ <xsl:call-template name="split_for_interspers">
6144
6182
  <xsl:with-param name="pText" select="$text_step3"/>
6145
6183
  <xsl:with-param name="sep" select="$zero_width_space"/>
6146
- <xsl:with-param name="normalize-space">false</xsl:with-param>
6147
- <xsl:with-param name="keep_sep">true</xsl:with-param>
6148
6184
  </xsl:call-template>
6149
6185
  </xsl:variable>
6150
6186
 
6151
- <xsl:for-each select="xalan:nodeset($text_step4)/item">
6187
+ <xsl:for-each select="xalan:nodeset($text_step4)/node()">
6152
6188
  <xsl:choose>
6153
- <xsl:when test="string-length() &gt; 30"> <!-- word with length more than 30 will be interspersed with zero-width space -->
6189
+ <xsl:when test="local-name() = 'interspers'"> <!-- word with length more than 30 will be interspersed with zero-width space -->
6154
6190
  <xsl:call-template name="interspers">
6155
6191
  <xsl:with-param name="str" select="."/>
6156
6192
  </xsl:call-template>
@@ -6161,6 +6197,30 @@
6161
6197
  </xsl:choose>
6162
6198
  </xsl:for-each>
6163
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>
6164
6224
  </xsl:template><xsl:template name="interspers">
6165
6225
  <xsl:param name="str"/>
6166
6226
  <xsl:param name="char" select="$zero_width_space"/>
@@ -6618,7 +6678,7 @@
6618
6678
  </xsl:otherwise>
6619
6679
  </xsl:choose> -->
6620
6680
  </fo:block>
6621
- </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">
6622
6682
  <xsl:text>[</xsl:text><xsl:value-of select="substring-after(., '[SOURCE: ')"/>
6623
6683
  </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()">
6624
6684
  <xsl:if test="normalize-space() != ''">
@@ -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">
@@ -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>
@@ -4634,24 +4663,28 @@
4634
4663
  </xsl:template><xsl:template name="add-zero-spaces-equal">
4635
4664
  <xsl:param name="text" select="."/>
4636
4665
  <xsl:variable name="zero-space-after-equals">==========</xsl:variable>
4666
+ <xsl:variable name="regex_zero-space-after-equals">(==========)</xsl:variable>
4637
4667
  <xsl:variable name="zero-space-after-equal">=</xsl:variable>
4668
+ <xsl:variable name="regex_zero-space-after-equal">(=)</xsl:variable>
4638
4669
  <xsl:variable name="zero-space">​</xsl:variable>
4639
4670
  <xsl:choose>
4640
4671
  <xsl:when test="contains($text, $zero-space-after-equals)">
4641
- <xsl:value-of select="substring-before($text, $zero-space-after-equals)"/>
4672
+ <!-- <xsl:value-of select="substring-before($text, $zero-space-after-equals)"/>
4642
4673
  <xsl:value-of select="$zero-space-after-equals"/>
4643
4674
  <xsl:value-of select="$zero-space"/>
4644
4675
  <xsl:call-template name="add-zero-spaces-equal">
4645
4676
  <xsl:with-param name="text" select="substring-after($text, $zero-space-after-equals)"/>
4646
- </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))"/>
4647
4679
  </xsl:when>
4648
4680
  <xsl:when test="contains($text, $zero-space-after-equal)">
4649
- <xsl:value-of select="substring-before($text, $zero-space-after-equal)"/>
4681
+ <!-- <xsl:value-of select="substring-before($text, $zero-space-after-equal)"/>
4650
4682
  <xsl:value-of select="$zero-space-after-equal"/>
4651
4683
  <xsl:value-of select="$zero-space"/>
4652
4684
  <xsl:call-template name="add-zero-spaces-equal">
4653
4685
  <xsl:with-param name="text" select="substring-after($text, $zero-space-after-equal)"/>
4654
- </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))"/>
4655
4688
  </xsl:when>
4656
4689
  <xsl:otherwise>
4657
4690
  <xsl:value-of select="$text"/>
@@ -5131,7 +5164,12 @@
5131
5164
 
5132
5165
  <fo:inline xsl:use-attribute-sets="termnote-name-style">
5133
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
+
5134
5171
 
5172
+
5135
5173
 
5136
5174
  <!-- if 'p' contains all text in 'add' first and last elements in first p are 'add' -->
5137
5175
  <!-- <xsl:if test="*[not(local-name()='name')][1][node()[normalize-space() != ''][1][local-name() = 'add'] and node()[normalize-space() != ''][last()][local-name() = 'add']]"> -->
@@ -6140,17 +6178,15 @@
6140
6178
 
6141
6179
  <!-- split text by zero-width space -->
6142
6180
  <xsl:variable name="text_step4">
6143
- <xsl:call-template name="split">
6181
+ <xsl:call-template name="split_for_interspers">
6144
6182
  <xsl:with-param name="pText" select="$text_step3"/>
6145
6183
  <xsl:with-param name="sep" select="$zero_width_space"/>
6146
- <xsl:with-param name="normalize-space">false</xsl:with-param>
6147
- <xsl:with-param name="keep_sep">true</xsl:with-param>
6148
6184
  </xsl:call-template>
6149
6185
  </xsl:variable>
6150
6186
 
6151
- <xsl:for-each select="xalan:nodeset($text_step4)/item">
6187
+ <xsl:for-each select="xalan:nodeset($text_step4)/node()">
6152
6188
  <xsl:choose>
6153
- <xsl:when test="string-length() &gt; 30"> <!-- word with length more than 30 will be interspersed with zero-width space -->
6189
+ <xsl:when test="local-name() = 'interspers'"> <!-- word with length more than 30 will be interspersed with zero-width space -->
6154
6190
  <xsl:call-template name="interspers">
6155
6191
  <xsl:with-param name="str" select="."/>
6156
6192
  </xsl:call-template>
@@ -6161,6 +6197,30 @@
6161
6197
  </xsl:choose>
6162
6198
  </xsl:for-each>
6163
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>
6164
6224
  </xsl:template><xsl:template name="interspers">
6165
6225
  <xsl:param name="str"/>
6166
6226
  <xsl:param name="char" select="$zero_width_space"/>
@@ -6618,7 +6678,7 @@
6618
6678
  </xsl:otherwise>
6619
6679
  </xsl:choose> -->
6620
6680
  </fo:block>
6621
- </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">
6622
6682
  <xsl:text>[</xsl:text><xsl:value-of select="substring-after(., '[SOURCE: ')"/>
6623
6683
  </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()">
6624
6684
  <xsl:if test="normalize-space() != ''">