metanorma-iec 2.0.8 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -936,14 +936,16 @@
936
936
  <fo:inline keep-together.within-line="always" font-size="25pt" font-weight="bold" color="{$color_gray}" border-bottom="0.5pt solid {$color_gray}" padding-bottom="3.5mm" baseline-shift="5.5mm"><fo:leader leader-pattern="space"/><xsl:value-of select="//iec:iec-standard/iec:bibdata/iec:docidentifier[@type = 'iso' or @type = 'ISO']"/></fo:inline>
937
937
  </fo:block>
938
938
  <fo:block font-size="10.5pt" text-align="right" margin-top="0.5mm">
939
- <xsl:variable name="title-edition">
940
- <xsl:call-template name="getTitle">
941
- <xsl:with-param name="name" select="'title-edition'"/>
942
- </xsl:call-template>
943
- </xsl:variable>
944
- <xsl:value-of select="$title-edition"/>
939
+ <xsl:call-template name="capitalize">
940
+ <xsl:with-param name="str">
941
+ <xsl:call-template name="getLocalizedString">
942
+ <xsl:with-param name="key">edition</xsl:with-param>
943
+ </xsl:call-template>
944
+ </xsl:with-param>
945
+ </xsl:call-template>
946
+ <xsl:text> </xsl:text>
945
947
  <fo:inline>
946
- <xsl:variable name="edition" select="//iec:iec-standard/iec:bibdata/iec:edition"/>
948
+ <xsl:variable name="edition" select="//iec:iec-standard/iec:bibdata/iec:edition[normalize-space(@language) = '']"/>
947
949
  <xsl:value-of select="$edition"/>
948
950
  <xsl:if test="not(contains($edition, '.'))">.0</xsl:if>
949
951
  </fo:inline>
@@ -1928,7 +1930,7 @@
1928
1930
  </xsl:copy>
1929
1931
  </xsl:template> -->
1930
1932
 
1931
- <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">
1933
+ <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:param name="add_math_as_text">true</xsl:param><xsl:variable name="lang">
1932
1934
  <xsl:call-template name="getLang"/>
1933
1935
  </xsl:variable><xsl:variable name="pageWidth_">
1934
1936
  210
@@ -1943,20 +1945,7 @@
1943
1945
  </xsl:variable><xsl:variable name="marginTop" select="normalize-space($marginTop_)"/><xsl:variable name="marginBottom_">
1944
1946
  15
1945
1947
  </xsl:variable><xsl:variable name="marginBottom" select="normalize-space($marginBottom_)"/><xsl:variable name="titles_">
1946
-
1947
- <title-edition lang="en">
1948
-
1949
- <xsl:text>Edition </xsl:text>
1950
-
1951
- </title-edition>
1952
-
1953
- <title-edition lang="fr">
1954
- <xsl:text>Édition </xsl:text>
1955
- </title-edition>
1956
1948
 
1957
- <title-edition lang="ru">
1958
- <xsl:text>Издание </xsl:text>
1959
- </title-edition>
1960
1949
 
1961
1950
  <!-- These titles of Table of contents renders different than determined in localized-strings -->
1962
1951
  <title-toc lang="en">
@@ -2041,7 +2030,7 @@
2041
2030
  </xsl:variable><xsl:variable name="bibdata">
2042
2031
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']"/>
2043
2032
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'localized-strings']"/>
2044
- </xsl:variable><xsl:variable name="linebreak">&#8232;</xsl:variable><xsl:variable name="tab_zh"> </xsl:variable><xsl:variable name="non_breaking_hyphen">‑</xsl:variable><xsl:variable name="thin_space"> </xsl:variable><xsl:variable name="zero_width_space">​</xsl:variable><xsl:variable name="en_dash">–</xsl:variable><xsl:template name="getTitle">
2033
+ </xsl:variable><xsl:variable name="linebreak">&#8232;</xsl:variable><xsl:variable name="tab_zh"> </xsl:variable><xsl:variable name="non_breaking_hyphen">‑</xsl:variable><xsl:variable name="thin_space"> </xsl:variable><xsl:variable name="zero_width_space">​</xsl:variable><xsl:variable name="hair_space"> </xsl:variable><xsl:variable name="en_dash">–</xsl:variable><xsl:template name="getTitle">
2045
2034
  <xsl:param name="name"/>
2046
2035
  <xsl:param name="lang"/>
2047
2036
  <xsl:variable name="lang_">
@@ -2089,7 +2078,7 @@
2089
2078
  <xsl:variable name="root-style_" select="xalan:nodeset($root-style)"/>
2090
2079
 
2091
2080
  <xsl:variable name="additional_fonts_">
2092
- <xsl:for-each select="//*[local-name() = 'misc-container'][1]/*[local-name() = 'presentation-metadata'][*[local-name() = 'name'] = 'fonts']/*[local-name() = 'value']">
2081
+ <xsl:for-each select="//*[contains(local-name(), '-standard')][1]/*[local-name() = 'misc-container']/*[local-name() = 'presentation-metadata'][*[local-name() = 'name'] = 'fonts']/*[local-name() = 'value'] | //*[contains(local-name(), '-standard')][1]/*[local-name() = 'presentation-metadata'][*[local-name() = 'name'] = 'fonts']/*[local-name() = 'value']">
2093
2082
  <xsl:value-of select="."/><xsl:if test="position() != last()">, </xsl:if>
2094
2083
  </xsl:for-each>
2095
2084
  </xsl:variable>
@@ -2165,7 +2154,6 @@
2165
2154
 
2166
2155
 
2167
2156
  </xsl:attribute-set><xsl:attribute-set name="sourcecode-container-style">
2168
- <xsl:attribute name="margin-left">0mm</xsl:attribute>
2169
2157
 
2170
2158
  </xsl:attribute-set><xsl:attribute-set name="sourcecode-style">
2171
2159
  <xsl:attribute name="white-space">pre</xsl:attribute>
@@ -2253,6 +2241,7 @@
2253
2241
  <xsl:attribute name="margin-left">10mm</xsl:attribute>
2254
2242
 
2255
2243
 
2244
+
2256
2245
  </xsl:attribute-set><xsl:attribute-set name="example-name-style">
2257
2246
 
2258
2247
 
@@ -3372,22 +3361,32 @@
3372
3361
  <xsl:sort select="@displayorder" data-type="number"/>
3373
3362
  <xsl:apply-templates select="."/>
3374
3363
  </xsl:for-each>
3375
- </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">
3376
- <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
3377
- <xsl:variable name="text" select="java:replaceAll(java:java.lang.String.new(.),$regex_standard_reference,concat($tag_open,'$1',$tag_close))"/>
3378
- <xsl:call-template name="replace_fo_inline">
3379
- <xsl:with-param name="text" select="$text"/>
3380
- </xsl:call-template>
3381
- </xsl:template><xsl:template name="replace_fo_inline">
3364
+ </xsl:template><xsl:variable name="tag_fo_inline_keep-together_within-line_open">###fo:inline keep-together_within-line###</xsl:variable><xsl:variable name="tag_fo_inline_keep-together_within-line_close">###/fo:inline keep-together_within-line###</xsl:variable><xsl:template match="text()" name="text">
3365
+
3366
+ <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
3367
+ <xsl:variable name="text" select="java:replaceAll(java:java.lang.String.new(.),$regex_standard_reference,concat($tag_fo_inline_keep-together_within-line_open,'$1',$tag_fo_inline_keep-together_within-line_close))"/>
3368
+ <xsl:call-template name="replace_fo_inline_tags">
3369
+ <xsl:with-param name="tag_open" select="$tag_fo_inline_keep-together_within-line_open"/>
3370
+ <xsl:with-param name="tag_close" select="$tag_fo_inline_keep-together_within-line_close"/>
3371
+ <xsl:with-param name="text" select="$text"/>
3372
+ </xsl:call-template>
3373
+
3374
+ </xsl:template><xsl:template name="replace_fo_inline_tags">
3375
+ <xsl:param name="tag_open"/>
3376
+ <xsl:param name="tag_close"/>
3382
3377
  <xsl:param name="text"/>
3383
3378
  <xsl:choose>
3384
3379
  <xsl:when test="contains($text, $tag_open)">
3385
3380
  <xsl:value-of select="substring-before($text, $tag_open)"/>
3386
- <xsl:text disable-output-escaping="yes">&lt;fo:inline keep-together.within-line="always"&gt;</xsl:text>
3381
+ <!-- <xsl:text disable-output-escaping="yes">&lt;fo:inline keep-together.within-line="always"&gt;</xsl:text> -->
3387
3382
  <xsl:variable name="text_after" select="substring-after($text, $tag_open)"/>
3388
- <xsl:value-of select="substring-before($text_after, $tag_close)"/>
3389
- <xsl:text disable-output-escaping="yes">&lt;/fo:inline&gt;</xsl:text>
3390
- <xsl:call-template name="replace_fo_inline">
3383
+ <fo:inline keep-together.within-line="always">
3384
+ <xsl:value-of select="substring-before($text_after, $tag_close)"/>
3385
+ </fo:inline>
3386
+ <!-- <xsl:text disable-output-escaping="yes">&lt;/fo:inline&gt;</xsl:text> -->
3387
+ <xsl:call-template name="replace_fo_inline_tags">
3388
+ <xsl:with-param name="tag_open" select="$tag_open"/>
3389
+ <xsl:with-param name="tag_close" select="$tag_close"/>
3391
3390
  <xsl:with-param name="text" select="substring-after($text_after, $tag_close)"/>
3392
3391
  </xsl:call-template>
3393
3392
  </xsl:when>
@@ -3395,6 +3394,8 @@
3395
3394
  </xsl:choose>
3396
3395
  </xsl:template><xsl:template match="*[local-name()='br']">
3397
3396
  <xsl:value-of select="$linebreak"/>
3397
+ </xsl:template><xsl:template match="*[local-name() = 'keep-together_within-line']">
3398
+ <fo:inline keep-together.within-line="always"><xsl:apply-templates/></fo:inline>
3398
3399
  </xsl:template><xsl:template match="*[local-name()='copyright-statement']">
3399
3400
  <fo:block xsl:use-attribute-sets="copyright-statement-style">
3400
3401
  <xsl:apply-templates/>
@@ -3463,8 +3464,23 @@
3463
3464
  </fo:block>
3464
3465
 
3465
3466
  </xsl:template><xsl:template match="*[local-name()='td']//text() | *[local-name()='th']//text() | *[local-name()='dt']//text() | *[local-name()='dd']//text()" priority="1">
3466
- <!-- <xsl:call-template name="add-zero-spaces"/> -->
3467
- <xsl:call-template name="add-zero-spaces-java"/>
3467
+ <xsl:choose>
3468
+ <xsl:when test="parent::*[local-name() = 'keep-together_within-line']">
3469
+ <xsl:value-of select="."/>
3470
+ </xsl:when>
3471
+ <xsl:otherwise>
3472
+ <xsl:call-template name="addZeroWidthSpacesToTextNodes"/>
3473
+ </xsl:otherwise>
3474
+ </xsl:choose>
3475
+ </xsl:template><xsl:template name="addZeroWidthSpacesToTextNodes">
3476
+ <xsl:variable name="text"><text><xsl:call-template name="text"/></text></xsl:variable>
3477
+ <!-- <xsl:copy-of select="$text"/> -->
3478
+ <xsl:for-each select="xalan:nodeset($text)/text/node()">
3479
+ <xsl:choose>
3480
+ <xsl:when test="self::text()"><xsl:call-template name="add-zero-spaces-java"/></xsl:when>
3481
+ <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... -->
3482
+ </xsl:choose>
3483
+ </xsl:for-each>
3468
3484
  </xsl:template><xsl:template match="*[local-name()='table']" name="table">
3469
3485
 
3470
3486
  <xsl:variable name="table-preamble">
@@ -3592,16 +3608,9 @@
3592
3608
  </xsl:for-each>
3593
3609
  </xsl:when>
3594
3610
  <xsl:otherwise>
3595
- <xsl:for-each select="xalan:nodeset($colwidths)//column">
3596
- <xsl:choose>
3597
- <xsl:when test=". = 1 or . = 0">
3598
- <fo:table-column column-width="proportional-column-width(2)"/>
3599
- </xsl:when>
3600
- <xsl:otherwise>
3601
- <fo:table-column column-width="proportional-column-width({.})"/>
3602
- </xsl:otherwise>
3603
- </xsl:choose>
3604
- </xsl:for-each>
3611
+ <xsl:call-template name="insertTableColumnWidth">
3612
+ <xsl:with-param name="colwidths" select="$colwidths"/>
3613
+ </xsl:call-template>
3605
3614
  </xsl:otherwise>
3606
3615
  </xsl:choose>
3607
3616
 
@@ -3765,6 +3774,7 @@
3765
3774
  <xsl:with-param name="text" select="$td_text"/>
3766
3775
  </xsl:call-template>
3767
3776
  </xsl:variable>
3777
+ <!-- <xsl:message>string_with_added_zerospaces=<xsl:value-of select="$string_with_added_zerospaces"/></xsl:message> -->
3768
3778
  <xsl:call-template name="tokenize">
3769
3779
  <!-- <xsl:with-param name="text" select="translate(td[$curr-col],'- —:', ' ')"/> -->
3770
3780
  <!-- 2009 thinspace -->
@@ -3777,6 +3787,7 @@
3777
3787
  <xsl:with-param name="words" select="xalan:nodeset($words)"/>
3778
3788
  </xsl:call-template>
3779
3789
  </xsl:variable>
3790
+ <!-- <xsl:message>max_length=<xsl:value-of select="$max_length"/></xsl:message> -->
3780
3791
  <width>
3781
3792
  <xsl:variable name="divider">
3782
3793
  <xsl:choose>
@@ -3809,6 +3820,10 @@
3809
3820
  <xsl:with-param name="table" select="$table"/>
3810
3821
  </xsl:call-template>
3811
3822
  </xsl:if>
3823
+ </xsl:template><xsl:template match="*[@keep-together.within-line]/text()" priority="2" mode="td_text">
3824
+ <!-- <xsl:message>DEBUG t1=<xsl:value-of select="."/></xsl:message>
3825
+ <xsl:message>DEBUG t2=<xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'.','X')"/></xsl:message> -->
3826
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'.','X')"/>
3812
3827
  </xsl:template><xsl:template match="text()" mode="td_text">
3813
3828
  <xsl:value-of select="translate(., $zero_width_space, ' ')"/><xsl:text> </xsl:text>
3814
3829
  </xsl:template><xsl:template match="*[local-name()='termsource']" mode="td_text">
@@ -3910,16 +3925,9 @@
3910
3925
  </xsl:for-each>
3911
3926
  </xsl:when>
3912
3927
  <xsl:otherwise>
3913
- <xsl:for-each select="xalan:nodeset($colwidths)//column">
3914
- <xsl:choose>
3915
- <xsl:when test=". = 1 or . = 0">
3916
- <fo:table-column column-width="proportional-column-width(2)"/>
3917
- </xsl:when>
3918
- <xsl:otherwise>
3919
- <fo:table-column column-width="proportional-column-width({.})"/>
3920
- </xsl:otherwise>
3921
- </xsl:choose>
3922
- </xsl:for-each>
3928
+ <xsl:call-template name="insertTableColumnWidth">
3929
+ <xsl:with-param name="colwidths" select="$colwidths"/>
3930
+ </xsl:call-template>
3923
3931
  </xsl:otherwise>
3924
3932
  </xsl:choose>
3925
3933
 
@@ -4486,8 +4494,10 @@
4486
4494
  <!-- and (not(../@class) or ../@class !='pseudocode') -->
4487
4495
  </xsl:variable>
4488
4496
 
4497
+ <xsl:variable name="onlyOneComponent" select="normalize-space($parent = 'formula' and count(*[local-name()='dt']) = 1)"/>
4498
+
4489
4499
  <xsl:choose>
4490
- <xsl:when test="$parent = 'formula' and count(*[local-name()='dt']) = 1"> <!-- only one component -->
4500
+ <xsl:when test="$onlyOneComponent = 'true'"> <!-- only one component -->
4491
4501
 
4492
4502
  <fo:block text-align="left">
4493
4503
 
@@ -4509,7 +4519,7 @@
4509
4519
  <xsl:apply-templates select="*[local-name()='dd']/*" mode="inline"/>
4510
4520
  </fo:block>
4511
4521
 
4512
- </xsl:when>
4522
+ </xsl:when> <!-- END: only one component -->
4513
4523
  <xsl:when test="$parent = 'formula'"> <!-- a few components -->
4514
4524
  <fo:block margin-bottom="12pt" text-align="left">
4515
4525
 
@@ -4525,8 +4535,8 @@
4525
4535
  </xsl:variable>
4526
4536
  <xsl:value-of select="$title-where"/>
4527
4537
  </fo:block>
4528
- </xsl:when>
4529
- <xsl:when test="$parent = 'figure' and (not(../@class) or ../@class !='pseudocode')">
4538
+ </xsl:when> <!-- END: a few components -->
4539
+ <xsl:when test="$parent = 'figure' and (not(../@class) or ../@class !='pseudocode')"> <!-- definition list in a figure -->
4530
4540
  <fo:block font-weight="bold" text-align="left" margin-bottom="12pt" keep-with-next="always">
4531
4541
 
4532
4542
 
@@ -4542,11 +4552,11 @@
4542
4552
  </xsl:variable>
4543
4553
  <xsl:value-of select="$title-key"/>
4544
4554
  </fo:block>
4545
- </xsl:when>
4555
+ </xsl:when> <!-- END: definition list in a figure -->
4546
4556
  </xsl:choose>
4547
4557
 
4548
4558
  <!-- a few components -->
4549
- <xsl:if test="not($parent = 'formula' and count(*[local-name()='dt']) = 1)">
4559
+ <xsl:if test="$onlyOneComponent = 'false'">
4550
4560
  <fo:block>
4551
4561
 
4552
4562
 
@@ -4587,21 +4597,28 @@
4587
4597
  <xsl:apply-templates mode="dl"/>
4588
4598
  </tbody>
4589
4599
  </xsl:variable>
4590
- <!-- html-table<xsl:copy-of select="$html-table"/> -->
4600
+ <!-- DEBUG: html-table<xsl:copy-of select="$html-table"/> -->
4591
4601
  <xsl:variable name="colwidths">
4592
4602
  <xsl:call-template name="calculate-column-widths">
4593
4603
  <xsl:with-param name="cols-count" select="2"/>
4594
4604
  <xsl:with-param name="table" select="$html-table"/>
4595
4605
  </xsl:call-template>
4596
4606
  </xsl:variable>
4597
- <!-- colwidths=<xsl:copy-of select="$colwidths"/> -->
4607
+ <!-- DEBUG: colwidths=<xsl:copy-of select="$colwidths"/> -->
4598
4608
  <xsl:variable name="maxlength_dt">
4599
4609
  <xsl:call-template name="getMaxLength_dt"/>
4600
4610
  </xsl:variable>
4611
+ <xsl:variable name="isContainsKeepTogetherTag_">
4612
+ false
4613
+ </xsl:variable>
4614
+ <xsl:variable name="isContainsKeepTogetherTag" select="normalize-space($isContainsKeepTogetherTag_)"/>
4615
+ <!-- isContainsExpressReference=<xsl:value-of select="$isContainsExpressReference"/> -->
4601
4616
  <xsl:call-template name="setColumnWidth_dl">
4602
4617
  <xsl:with-param name="colwidths" select="$colwidths"/>
4603
4618
  <xsl:with-param name="maxlength_dt" select="$maxlength_dt"/>
4619
+ <xsl:with-param name="isContainsKeepTogetherTag" select="$isContainsKeepTogetherTag"/>
4604
4620
  </xsl:call-template>
4621
+
4605
4622
  <fo:table-body>
4606
4623
  <xsl:apply-templates>
4607
4624
  <xsl:with-param name="key_iso" select="normalize-space($key_iso)"/>
@@ -4610,12 +4627,13 @@
4610
4627
  </fo:table>
4611
4628
  </fo:block>
4612
4629
  </fo:block>
4613
- </xsl:if>
4630
+ </xsl:if> <!-- END: a few components -->
4614
4631
  </fo:block-container>
4615
4632
  </fo:block-container>
4616
4633
  </xsl:template><xsl:template name="setColumnWidth_dl">
4617
4634
  <xsl:param name="colwidths"/>
4618
4635
  <xsl:param name="maxlength_dt"/>
4636
+ <xsl:param name="isContainsKeepTogetherTag"/>
4619
4637
  <xsl:choose>
4620
4638
  <xsl:when test="ancestor::*[local-name()='dl']"><!-- second level, i.e. inlined table -->
4621
4639
  <fo:table-column column-width="50%"/>
@@ -4623,6 +4641,11 @@
4623
4641
  </xsl:when>
4624
4642
  <xsl:otherwise>
4625
4643
  <xsl:choose>
4644
+ <xsl:when test="$isContainsKeepTogetherTag">
4645
+ <xsl:call-template name="insertTableColumnWidth">
4646
+ <xsl:with-param name="colwidths" select="$colwidths"/>
4647
+ </xsl:call-template>
4648
+ </xsl:when>
4626
4649
  <!-- to set width check most wide chars like `W` -->
4627
4650
  <xsl:when test="normalize-space($maxlength_dt) != '' and number($maxlength_dt) &lt;= 2"> <!-- if dt contains short text like t90, a, etc -->
4628
4651
  <fo:table-column column-width="7%"/>
@@ -4653,20 +4676,25 @@
4653
4676
  <fo:table-column column-width="60%"/>
4654
4677
  </xsl:when>
4655
4678
  <xsl:otherwise>
4656
- <xsl:for-each select="xalan:nodeset($colwidths)//column">
4657
- <xsl:choose>
4658
- <xsl:when test=". = 1 or . = 0">
4659
- <fo:table-column column-width="proportional-column-width(2)"/>
4660
- </xsl:when>
4661
- <xsl:otherwise>
4662
- <fo:table-column column-width="proportional-column-width({.})"/>
4663
- </xsl:otherwise>
4664
- </xsl:choose>
4665
- </xsl:for-each>
4679
+ <xsl:call-template name="insertTableColumnWidth">
4680
+ <xsl:with-param name="colwidths" select="$colwidths"/>
4681
+ </xsl:call-template>
4666
4682
  </xsl:otherwise>
4667
4683
  </xsl:choose>
4668
4684
  </xsl:otherwise>
4669
4685
  </xsl:choose>
4686
+ </xsl:template><xsl:template name="insertTableColumnWidth">
4687
+ <xsl:param name="colwidths"/>
4688
+ <xsl:for-each select="xalan:nodeset($colwidths)//column">
4689
+ <xsl:choose>
4690
+ <xsl:when test=". = 1 or . = 0">
4691
+ <fo:table-column column-width="proportional-column-width(2)"/>
4692
+ </xsl:when>
4693
+ <xsl:otherwise>
4694
+ <fo:table-column column-width="proportional-column-width({.})"/>
4695
+ </xsl:otherwise>
4696
+ </xsl:choose>
4697
+ </xsl:for-each>
4670
4698
  </xsl:template><xsl:template name="getMaxLength_dt">
4671
4699
  <xsl:variable name="lengths">
4672
4700
  <xsl:for-each select="*[local-name()='dt']">
@@ -4690,7 +4718,6 @@
4690
4718
  <xsl:value-of select="$maxLength"/>
4691
4719
  </xsl:template><xsl:template match="*[local-name()='dl']/*[local-name()='note']" priority="2">
4692
4720
  <xsl:param name="key_iso"/>
4693
-
4694
4721
  <!-- <tr>
4695
4722
  <td>NOTE</td>
4696
4723
  <td>
@@ -4698,18 +4725,30 @@
4698
4725
  </td>
4699
4726
  </tr>
4700
4727
  -->
4701
- <fo:table-row>
4728
+ <!-- OLD Variant -->
4729
+ <!-- <fo:table-row>
4702
4730
  <fo:table-cell>
4703
4731
  <fo:block margin-top="6pt">
4704
4732
  <xsl:if test="normalize-space($key_iso) = 'true'">
4705
4733
  <xsl:attribute name="margin-top">0</xsl:attribute>
4706
4734
  </xsl:if>
4707
- <xsl:apply-templates select="*[local-name() = 'name']"/>
4735
+ <xsl:apply-templates select="*[local-name() = 'name']" />
4708
4736
  </fo:block>
4709
4737
  </fo:table-cell>
4710
4738
  <fo:table-cell>
4711
4739
  <fo:block>
4712
- <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
4740
+ <xsl:apply-templates select="node()[not(local-name() = 'name')]" />
4741
+ </fo:block>
4742
+ </fo:table-cell>
4743
+ </fo:table-row> -->
4744
+ <!-- <tr>
4745
+ <td number-columns-spanned="2">NOTE <xsl:apply-templates /> </td>
4746
+ </tr>
4747
+ -->
4748
+ <fo:table-row>
4749
+ <fo:table-cell number-columns-spanned="2">
4750
+ <fo:block>
4751
+ <xsl:call-template name="note"/>
4713
4752
  </fo:block>
4714
4753
  </fo:table-cell>
4715
4754
  </fo:table-row>
@@ -4811,13 +4850,15 @@
4811
4850
  <xsl:choose>
4812
4851
  <xsl:when test="$font-size = 'inherit'"><xsl:value-of select="$font-size"/></xsl:when>
4813
4852
  <xsl:when test="contains($font-size, '%')"><xsl:value-of select="$font-size"/></xsl:when>
4814
- <xsl:when test="ancestor::*[local-name()='note']"><xsl:value-of select="$font-size * 0.91"/>pt</xsl:when>
4853
+ <xsl:when test="ancestor::*[local-name()='note'] or ancestor::*[local-name()='example']"><xsl:value-of select="$font-size * 0.91"/>pt</xsl:when>
4815
4854
  <xsl:otherwise><xsl:value-of select="$font-size"/>pt</xsl:otherwise>
4816
4855
  </xsl:choose>
4817
4856
  </xsl:attribute>
4818
4857
  </xsl:if>
4819
4858
  <xsl:apply-templates/>
4820
4859
  </fo:inline>
4860
+ </xsl:template><xsl:template match="*[local-name()='tt']/text()" priority="2">
4861
+ <xsl:call-template name="add_spaces_to_sourcecode"/>
4821
4862
  </xsl:template><xsl:template match="*[local-name()='underline']">
4822
4863
  <fo:inline text-decoration="underline">
4823
4864
  <xsl:apply-templates/>
@@ -4965,41 +5006,50 @@
4965
5006
  <fo:block break-after="page"/>
4966
5007
  <fo:block> </fo:block>
4967
5008
  <fo:block break-after="page"/>
5009
+ </xsl:template><xsl:template match="*[local-name() = 'span']">
5010
+ <xsl:apply-templates/>
4968
5011
  </xsl:template><xsl:template name="tokenize">
4969
5012
  <xsl:param name="text"/>
4970
5013
  <xsl:param name="separator" select="' '"/>
4971
5014
  <xsl:choose>
4972
5015
  <xsl:when test="not(contains($text, $separator))">
4973
5016
  <word>
4974
- <xsl:variable name="str_no_en_chars" select="normalize-space(translate($text, $en_chars, ''))"/>
4975
- <xsl:variable name="len_str_no_en_chars" select="string-length($str_no_en_chars)"/>
4976
5017
  <xsl:variable name="len_str_tmp" select="string-length(normalize-space($text))"/>
4977
- <xsl:variable name="len_str">
4978
- <xsl:choose>
4979
- <xsl:when test="normalize-space(translate($text, $upper, '')) = ''"> <!-- english word in CAPITAL letters -->
4980
- <xsl:value-of select="$len_str_tmp * 1.5"/>
4981
- </xsl:when>
4982
- <xsl:otherwise>
4983
- <xsl:value-of select="$len_str_tmp"/>
4984
- </xsl:otherwise>
4985
- </xsl:choose>
4986
- </xsl:variable>
4987
-
4988
- <!-- <xsl:if test="$len_str_no_en_chars div $len_str &gt; 0.8">
4989
- <xsl:message>
4990
- div=<xsl:value-of select="$len_str_no_en_chars div $len_str"/>
4991
- len_str=<xsl:value-of select="$len_str"/>
4992
- len_str_no_en_chars=<xsl:value-of select="$len_str_no_en_chars"/>
4993
- </xsl:message>
4994
- </xsl:if> -->
4995
- <!-- <len_str_no_en_chars><xsl:value-of select="$len_str_no_en_chars"/></len_str_no_en_chars>
4996
- <len_str><xsl:value-of select="$len_str"/></len_str> -->
4997
5018
  <xsl:choose>
4998
- <xsl:when test="$len_str_no_en_chars div $len_str &gt; 0.8"> <!-- means non-english string -->
4999
- <xsl:value-of select="$len_str - $len_str_no_en_chars"/>
5019
+ <xsl:when test="normalize-space(translate($text, 'X', '')) = ''"> <!-- special case for keep-together.within-line -->
5020
+ <xsl:value-of select="$len_str_tmp"/>
5000
5021
  </xsl:when>
5001
5022
  <xsl:otherwise>
5002
- <xsl:value-of select="$len_str"/>
5023
+ <xsl:variable name="str_no_en_chars" select="normalize-space(translate($text, $en_chars, ''))"/>
5024
+ <xsl:variable name="len_str_no_en_chars" select="string-length($str_no_en_chars)"/>
5025
+ <xsl:variable name="len_str">
5026
+ <xsl:choose>
5027
+ <xsl:when test="normalize-space(translate($text, $upper, '')) = ''"> <!-- english word in CAPITAL letters -->
5028
+ <xsl:value-of select="$len_str_tmp * 1.5"/>
5029
+ </xsl:when>
5030
+ <xsl:otherwise>
5031
+ <xsl:value-of select="$len_str_tmp"/>
5032
+ </xsl:otherwise>
5033
+ </xsl:choose>
5034
+ </xsl:variable>
5035
+
5036
+ <!-- <xsl:if test="$len_str_no_en_chars div $len_str &gt; 0.8">
5037
+ <xsl:message>
5038
+ div=<xsl:value-of select="$len_str_no_en_chars div $len_str"/>
5039
+ len_str=<xsl:value-of select="$len_str"/>
5040
+ len_str_no_en_chars=<xsl:value-of select="$len_str_no_en_chars"/>
5041
+ </xsl:message>
5042
+ </xsl:if> -->
5043
+ <!-- <len_str_no_en_chars><xsl:value-of select="$len_str_no_en_chars"/></len_str_no_en_chars>
5044
+ <len_str><xsl:value-of select="$len_str"/></len_str> -->
5045
+ <xsl:choose>
5046
+ <xsl:when test="$len_str_no_en_chars div $len_str &gt; 0.8"> <!-- means non-english string -->
5047
+ <xsl:value-of select="$len_str - $len_str_no_en_chars"/>
5048
+ </xsl:when>
5049
+ <xsl:otherwise>
5050
+ <xsl:value-of select="$len_str"/>
5051
+ </xsl:otherwise>
5052
+ </xsl:choose>
5003
5053
  </xsl:otherwise>
5004
5054
  </xsl:choose>
5005
5055
  </word>
@@ -5274,6 +5324,9 @@
5274
5324
  <xsl:variable name="isDeleted" select="@deleted"/>
5275
5325
 
5276
5326
  <fo:inline xsl:use-attribute-sets="mathml-style">
5327
+
5328
+
5329
+
5277
5330
 
5278
5331
 
5279
5332
  <xsl:call-template name="setTrackChangesStyles">
@@ -5281,48 +5334,80 @@
5281
5334
  <xsl:with-param name="isDeleted" select="$isDeleted"/>
5282
5335
  </xsl:call-template>
5283
5336
 
5337
+ <xsl:if test="$add_math_as_text = 'true'">
5338
+ <!-- insert helper tag -->
5339
+ <!-- set unique font-size (fiction) -->
5340
+ <xsl:variable name="font-size_sfx"><xsl:number level="any"/></xsl:variable>
5341
+ <fo:inline color="white" font-size="1.{$font-size_sfx}pt" font-style="normal" font-weight="normal"><xsl:value-of select="$zero_width_space"/></fo:inline> <!-- zero width space -->
5342
+ </xsl:if>
5284
5343
 
5285
-
5286
- <xsl:variable name="mathml">
5287
- <xsl:apply-templates select="." mode="mathml"/>
5344
+ <xsl:variable name="mathml_content">
5345
+ <xsl:apply-templates select="." mode="mathml_actual_text"/>
5288
5346
  </xsl:variable>
5289
- <fo:instream-foreign-object fox:alt-text="Math">
5290
5347
 
5348
+
5349
+ <xsl:call-template name="mathml_instream_object">
5350
+ <xsl:with-param name="mathml_content" select="$mathml_content"/>
5351
+ </xsl:call-template>
5291
5352
 
5292
-
5293
- <xsl:variable name="comment_text_following" select="following-sibling::node()[1][self::comment()]"/>
5294
- <xsl:variable name="comment_text_">
5295
- <xsl:choose>
5296
- <xsl:when test="normalize-space($comment_text_following) != ''">
5297
- <xsl:value-of select="$comment_text_following"/>
5298
- </xsl:when>
5299
- <xsl:otherwise>
5300
- <xsl:value-of select="normalize-space(translate(.,' ⁢',' '))"/>
5301
- </xsl:otherwise>
5302
- </xsl:choose>
5303
- </xsl:variable>
5304
- <xsl:variable name="comment_text" select="java:org.metanorma.fop.Util.unescape($comment_text_)"/>
5305
-
5306
- <xsl:if test="normalize-space($comment_text) != ''">
5307
- <!-- put Mathin Alternate Text -->
5308
- <xsl:attribute name="fox:alt-text">
5309
- <xsl:value-of select="java:org.metanorma.fop.Util.unescape($comment_text)"/>
5310
- </xsl:attribute>
5311
- </xsl:if>
5312
-
5313
- <xsl:variable name="mathml_content">
5314
- <xsl:apply-templates select="." mode="mathml_actual_text"/>
5315
- </xsl:variable>
5316
- <!-- put MathML in Actual Text -->
5317
- <xsl:attribute name="fox:actual-text">
5318
- <xsl:value-of select="$mathml_content"/>
5319
- </xsl:attribute>
5320
-
5321
-
5322
-
5323
- <xsl:copy-of select="xalan:nodeset($mathml)"/>
5324
- </fo:instream-foreign-object>
5353
+
5325
5354
  </fo:inline>
5355
+ </xsl:template><xsl:template name="getMathml_comment_text">
5356
+ <xsl:variable name="comment_text_following" select="following-sibling::node()[1][self::comment()]"/>
5357
+ <xsl:variable name="comment_text_">
5358
+ <xsl:choose>
5359
+ <xsl:when test="normalize-space($comment_text_following) != ''">
5360
+ <xsl:value-of select="$comment_text_following"/>
5361
+ </xsl:when>
5362
+ <xsl:otherwise>
5363
+ <xsl:value-of select="normalize-space(translate(.,' ⁢',' '))"/>
5364
+ </xsl:otherwise>
5365
+ </xsl:choose>
5366
+ </xsl:variable>
5367
+ <xsl:variable name="comment_text_2" select="java:org.metanorma.fop.Util.unescape($comment_text_)"/>
5368
+ <xsl:variable name="comment_text" select="java:trim(java:java.lang.String.new($comment_text_2))"/>
5369
+ <xsl:value-of select="$comment_text"/>
5370
+ </xsl:template><xsl:template name="mathml_instream_object">
5371
+ <xsl:param name="comment_text"/>
5372
+ <xsl:param name="mathml_content"/>
5373
+
5374
+ <xsl:variable name="comment_text_">
5375
+ <xsl:choose>
5376
+ <xsl:when test="normalize-space($comment_text) != ''"><xsl:value-of select="$comment_text"/></xsl:when>
5377
+ <xsl:otherwise><xsl:call-template name="getMathml_comment_text"/></xsl:otherwise>
5378
+ </xsl:choose>
5379
+ </xsl:variable>
5380
+
5381
+ <xsl:variable name="mathml">
5382
+ <xsl:apply-templates select="." mode="mathml"/>
5383
+ </xsl:variable>
5384
+
5385
+ <fo:instream-foreign-object fox:alt-text="Math">
5386
+
5387
+
5388
+
5389
+
5390
+
5391
+
5392
+
5393
+ <!-- put MathML in Actual Text -->
5394
+ <!-- DEBUG: mathml_content=<xsl:value-of select="$mathml_content"/> -->
5395
+ <xsl:attribute name="fox:actual-text">
5396
+ <xsl:value-of select="$mathml_content"/>
5397
+ </xsl:attribute>
5398
+
5399
+ <!-- <xsl:if test="$add_math_as_text = 'true'"> -->
5400
+ <xsl:if test="normalize-space($comment_text_) != ''">
5401
+ <!-- put Mathin Alternate Text -->
5402
+ <xsl:attribute name="fox:alt-text">
5403
+ <xsl:value-of select="$comment_text_"/>
5404
+ </xsl:attribute>
5405
+ </xsl:if>
5406
+ <!-- </xsl:if> -->
5407
+
5408
+ <xsl:copy-of select="xalan:nodeset($mathml)"/>
5409
+
5410
+ </fo:instream-foreign-object>
5326
5411
  </xsl:template><xsl:template match="mathml:*" mode="mathml_actual_text">
5327
5412
  <!-- <xsl:text>a+b</xsl:text> -->
5328
5413
  <xsl:text>&lt;</xsl:text>
@@ -5353,7 +5438,9 @@
5353
5438
  <!-- replace start and end spaces to non-break space -->
5354
5439
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'(^ )|( $)',' ')"/>
5355
5440
  </xsl:copy>
5356
- </xsl:template><xsl:template match="mathml:math/*[local-name()='unit']" mode="mathml"/><xsl:template match="mathml:math/*[local-name()='prefix']" mode="mathml"/><xsl:template match="mathml:math/*[local-name()='dimension']" mode="mathml"/><xsl:template match="mathml:math/*[local-name()='quantity']" mode="mathml"/><xsl:template match="*[local-name()='localityStack']"/><xsl:template match="*[local-name()='link']" name="link">
5441
+ </xsl:template><xsl:template match="mathml:math/*[local-name()='unit']" mode="mathml"/><xsl:template match="mathml:math/*[local-name()='prefix']" mode="mathml"/><xsl:template match="mathml:math/*[local-name()='dimension']" mode="mathml"/><xsl:template match="mathml:math/*[local-name()='quantity']" mode="mathml"/><xsl:template match="mathml:mtd/mathml:mo/text()[. = '/']" mode="mathml">
5442
+ <xsl:value-of select="."/><xsl:value-of select="$zero_width_space"/>
5443
+ </xsl:template><xsl:template match="*[local-name()='localityStack']"/><xsl:template match="*[local-name()='link']" name="link">
5357
5444
  <xsl:variable name="target">
5358
5445
  <xsl:choose>
5359
5446
  <xsl:when test="@updatetype = 'true'">
@@ -5950,18 +6037,33 @@
5950
6037
  </xsl:template><xsl:template match="*[local-name() = 'svg'][not(@width and @height)]" mode="svg_update">
5951
6038
  <xsl:copy>
5952
6039
  <xsl:apply-templates select="@*" mode="svg_update"/>
5953
- <xsl:variable name="viewbox">
6040
+ <xsl:variable name="viewbox_">
5954
6041
  <xsl:call-template name="split">
5955
6042
  <xsl:with-param name="pText" select="@viewBox"/>
5956
6043
  <xsl:with-param name="sep" select="' '"/>
5957
6044
  </xsl:call-template>
5958
6045
  </xsl:variable>
6046
+ <xsl:variable name="viewbox" select="xalan:nodeset($viewbox_)"/>
6047
+ <xsl:variable name="width" select="normalize-space($viewbox//item[3])"/>
6048
+ <xsl:variable name="height" select="normalize-space($viewbox//item[4])"/>
6049
+
5959
6050
  <xsl:attribute name="width">
5960
- <xsl:value-of select="round(xalan:nodeset($viewbox)//item[3])"/>
6051
+ <xsl:choose>
6052
+ <xsl:when test="$width != ''">
6053
+ <xsl:value-of select="round($width)"/>
6054
+ </xsl:when>
6055
+ <xsl:otherwise>400</xsl:otherwise> <!-- default width -->
6056
+ </xsl:choose>
5961
6057
  </xsl:attribute>
5962
6058
  <xsl:attribute name="height">
5963
- <xsl:value-of select="round(xalan:nodeset($viewbox)//item[4])"/>
6059
+ <xsl:choose>
6060
+ <xsl:when test="$height != ''">
6061
+ <xsl:value-of select="round($height)"/>
6062
+ </xsl:when>
6063
+ <xsl:otherwise>400</xsl:otherwise> <!-- default height -->
6064
+ </xsl:choose>
5964
6065
  </xsl:attribute>
6066
+
5965
6067
  <xsl:apply-templates mode="svg_update"/>
5966
6068
  </xsl:copy>
5967
6069
  </xsl:template><xsl:template match="*[local-name() = 'figure']/*[local-name() = 'image'][*[local-name() = 'svg']]" priority="3">
@@ -6156,7 +6258,11 @@
6156
6258
  <xsl:apply-templates mode="bookmarks"/>
6157
6259
  </xsl:template><xsl:template match="*[local-name() = 'title' or local-name() = 'name']//*[local-name() = 'stem']" mode="contents">
6158
6260
  <xsl:apply-templates select="."/>
6159
- </xsl:template><xsl:template match="*[local-name() = 'references'][@hidden='true']" mode="contents" priority="3"/><xsl:template match="*[local-name() = 'references']/*[local-name() = 'bibitem']" mode="contents"/><xsl:template match="*[local-name() = 'stem']" mode="bookmarks">
6261
+ </xsl:template><xsl:template match="*[local-name() = 'references'][@hidden='true']" mode="contents" priority="3"/><xsl:template match="*[local-name() = 'references']/*[local-name() = 'bibitem']" mode="contents"/><xsl:template match="*[local-name() = 'span']" mode="contents">
6262
+ <xsl:apply-templates mode="contents"/>
6263
+ </xsl:template><xsl:template match="*[local-name() = 'stem']" mode="bookmarks">
6264
+ <xsl:apply-templates mode="bookmarks"/>
6265
+ </xsl:template><xsl:template match="*[local-name() = 'span']" mode="bookmarks">
6160
6266
  <xsl:apply-templates mode="bookmarks"/>
6161
6267
  </xsl:template><xsl:template name="addBookmarks">
6162
6268
  <xsl:param name="contents"/>
@@ -6447,7 +6553,9 @@
6447
6553
  <xsl:apply-templates/>
6448
6554
  </xsl:otherwise>
6449
6555
  </xsl:choose>
6450
- </xsl:template><xsl:template match="*[local-name() = 'fn']" mode="contents"/><xsl:template match="*[local-name() = 'fn']" mode="bookmarks"/><xsl:template match="*[local-name() = 'fn']" mode="contents_item"/><xsl:template match="*[local-name() = 'tab']" mode="contents_item">
6556
+ </xsl:template><xsl:template match="*[local-name() = 'fn']" mode="contents"/><xsl:template match="*[local-name() = 'fn']" mode="bookmarks"/><xsl:template match="*[local-name() = 'fn']" mode="contents_item"/><xsl:template match="*[local-name() = 'xref']" mode="contents">
6557
+ <xsl:value-of select="."/>
6558
+ </xsl:template><xsl:template match="*[local-name() = 'tab']" mode="contents_item">
6451
6559
  <xsl:text> </xsl:text>
6452
6560
  </xsl:template><xsl:template match="*[local-name() = 'strong']" mode="contents_item">
6453
6561
  <xsl:copy>
@@ -6478,9 +6586,22 @@
6478
6586
  </xsl:when>
6479
6587
  <xsl:otherwise><xsl:apply-templates mode="contents_item"/></xsl:otherwise>
6480
6588
  </xsl:choose>
6589
+ </xsl:template><xsl:template match="text()" mode="contents_item">
6590
+ <xsl:call-template name="keep_together_standard_number"/>
6591
+ </xsl:template><xsl:template match="*[local-name() = 'span']" mode="contents_item">
6592
+ <xsl:apply-templates mode="contents_item"/>
6481
6593
  </xsl:template><xsl:template match="*[local-name()='sourcecode']" name="sourcecode">
6482
6594
 
6483
6595
  <fo:block-container xsl:use-attribute-sets="sourcecode-container-style">
6596
+
6597
+ <xsl:if test="not(ancestor::*[local-name() = 'li']) or ancestor::*[local-name() = 'example']">
6598
+ <xsl:attribute name="margin-left">0mm</xsl:attribute>
6599
+ </xsl:if>
6600
+
6601
+ <xsl:if test="ancestor::*[local-name() = 'example']">
6602
+ <xsl:attribute name="margin-right">0mm</xsl:attribute>
6603
+ </xsl:if>
6604
+
6484
6605
  <xsl:copy-of select="@id"/>
6485
6606
 
6486
6607
  <xsl:if test="parent::*[local-name() = 'note']">
@@ -6958,11 +7079,13 @@
6958
7079
  </xsl:otherwise>
6959
7080
  </xsl:choose>
6960
7081
  </xsl:template><xsl:template match="*[local-name() = 'example']">
6961
- <fo:block id="{@id}" xsl:use-attribute-sets="example-style">
6962
-
7082
+
7083
+ <fo:block-container id="{@id}" xsl:use-attribute-sets="example-style">
7084
+
6963
7085
 
7086
+
6964
7087
  <xsl:variable name="fo_element">
6965
- <xsl:if test=".//*[local-name() = 'table'] or .//*[local-name() = 'dl']">block</xsl:if>
7088
+ <xsl:if test=".//*[local-name() = 'table'] or .//*[local-name() = 'dl'] or *[not(local-name() = 'name')][1][local-name() = 'sourcecode']">block</xsl:if>
6966
7089
 
6967
7090
  <xsl:choose>
6968
7091
  <!-- if example contains only one (except 'name') element (paragraph for example), then display it on the same line as EXAMPLE title -->
@@ -6972,31 +7095,57 @@
6972
7095
 
6973
7096
  </xsl:variable>
6974
7097
 
6975
- <!-- display 'EXAMPLE' -->
6976
- <xsl:apply-templates select="*[local-name()='name']">
6977
- <xsl:with-param name="fo_element" select="$fo_element"/>
6978
- </xsl:apply-templates>
7098
+ <fo:block-container margin-left="0mm">
6979
7099
 
6980
- <xsl:choose>
6981
- <xsl:when test="contains(normalize-space($fo_element), 'block')">
6982
- <fo:block-container xsl:use-attribute-sets="example-body-style">
6983
- <fo:block-container margin-left="0mm" margin-right="0mm">
6984
- <xsl:apply-templates select="node()[not(local-name() = 'name')]">
7100
+ <xsl:choose>
7101
+
7102
+ <xsl:when test="contains(normalize-space($fo_element), 'block')">
7103
+
7104
+ <!-- display name 'EXAMPLE' in a separate block -->
7105
+ <fo:block>
7106
+ <xsl:apply-templates select="*[local-name()='name']">
6985
7107
  <xsl:with-param name="fo_element" select="$fo_element"/>
6986
7108
  </xsl:apply-templates>
7109
+ </fo:block>
7110
+
7111
+ <fo:block-container xsl:use-attribute-sets="example-body-style">
7112
+ <fo:block-container margin-left="0mm" margin-right="0mm">
7113
+ <xsl:apply-templates select="node()[not(local-name() = 'name')]">
7114
+ <xsl:with-param name="fo_element" select="$fo_element"/>
7115
+ </xsl:apply-templates>
7116
+ </fo:block-container>
6987
7117
  </fo:block-container>
6988
- </fo:block-container>
6989
- </xsl:when>
6990
- <xsl:otherwise>
6991
- <fo:inline>
6992
- <xsl:apply-templates select="node()[not(local-name() = 'name')]">
6993
- <xsl:with-param name="fo_element" select="$fo_element"/>
6994
- </xsl:apply-templates>
6995
- </fo:inline>
6996
- </xsl:otherwise>
6997
- </xsl:choose>
6998
-
6999
- </fo:block>
7118
+ </xsl:when> <!-- end block -->
7119
+
7120
+ <xsl:otherwise> <!-- inline -->
7121
+
7122
+ <!-- display 'EXAMPLE' and first element in the same line -->
7123
+ <fo:block>
7124
+ <xsl:apply-templates select="*[local-name()='name']">
7125
+ <xsl:with-param name="fo_element" select="$fo_element"/>
7126
+ </xsl:apply-templates>
7127
+ <fo:inline>
7128
+ <xsl:apply-templates select="*[not(local-name() = 'name')][1]">
7129
+ <xsl:with-param name="fo_element" select="$fo_element"/>
7130
+ </xsl:apply-templates>
7131
+ </fo:inline>
7132
+ </fo:block>
7133
+
7134
+ <xsl:if test="*[not(local-name() = 'name')][position() &gt; 1]">
7135
+ <!-- display further elements in blocks -->
7136
+ <fo:block-container xsl:use-attribute-sets="example-body-style">
7137
+ <fo:block-container margin-left="0mm" margin-right="0mm">
7138
+ <xsl:apply-templates select="*[not(local-name() = 'name')][position() &gt; 1]">
7139
+ <xsl:with-param name="fo_element" select="'block'"/>
7140
+ </xsl:apply-templates>
7141
+ </fo:block-container>
7142
+ </fo:block-container>
7143
+ </xsl:if>
7144
+ </xsl:otherwise> <!-- end inline -->
7145
+
7146
+ </xsl:choose>
7147
+ </fo:block-container>
7148
+ </fo:block-container>
7000
7149
  </xsl:template><xsl:template match="*[local-name() = 'example']/*[local-name() = 'name']">
7001
7150
  <xsl:param name="fo_element">block</xsl:param>
7002
7151
 
@@ -7028,10 +7177,16 @@
7028
7177
  </xsl:variable>
7029
7178
  <xsl:choose>
7030
7179
  <xsl:when test="starts-with(normalize-space($element), 'block')">
7031
- <fo:block xsl:use-attribute-sets="example-p-style">
7032
-
7033
- <xsl:apply-templates/>
7034
- </fo:block>
7180
+ <fo:block-container>
7181
+ <xsl:if test="ancestor::*[local-name() = 'li'] and contains(normalize-space($fo_element), 'block')">
7182
+ <xsl:attribute name="margin-left">0mm</xsl:attribute>
7183
+ <xsl:attribute name="margin-right">0mm</xsl:attribute>
7184
+ </xsl:if>
7185
+ <fo:block xsl:use-attribute-sets="example-p-style">
7186
+
7187
+ <xsl:apply-templates/>
7188
+ </fo:block>
7189
+ </fo:block-container>
7035
7190
  </xsl:when>
7036
7191
  <xsl:otherwise>
7037
7192
  <fo:inline xsl:use-attribute-sets="example-p-style">
@@ -7210,7 +7365,16 @@
7210
7365
  </fo:inline>
7211
7366
  </xsl:when>
7212
7367
  <xsl:otherwise> <!-- if there is key('bibitems_hidden', $current_bibitemid) -->
7213
- <fo:inline><xsl:apply-templates/></fo:inline>
7368
+
7369
+ <!-- if in bibitem[@hidden='true'] there is url[@type='src'], then create hyperlink -->
7370
+ <xsl:variable name="uri_src" select="normalize-space($bibitems_hidden/*[local-name() ='bibitem'][@id = $current_bibitemid]/*[local-name() = 'uri'][@type = 'src'])"/>
7371
+ <xsl:choose>
7372
+ <xsl:when test="$uri_src != ''">
7373
+ <fo:basic-link external-destination="{$uri_src}" fox:alt-text="{$uri_src}"><xsl:apply-templates/></fo:basic-link>
7374
+ </xsl:when>
7375
+ <xsl:otherwise><fo:inline><xsl:apply-templates/></fo:inline></xsl:otherwise>
7376
+ </xsl:choose>
7377
+
7214
7378
  </xsl:otherwise>
7215
7379
  </xsl:choose>
7216
7380
  </xsl:template><xsl:template match="*[local-name() = 'tab']">
@@ -7387,10 +7551,24 @@
7387
7551
 
7388
7552
  </fo:block>
7389
7553
  <xsl:apply-templates/>
7390
- </xsl:template><xsl:template match="*[local-name() = 'review']">
7554
+ </xsl:template><xsl:template match="*[local-name() = 'review']"> <!-- 'review' will be processed in mn2pdf/review.xsl -->
7391
7555
  <!-- comment 2019-11-29 -->
7392
7556
  <!-- <fo:block font-weight="bold">Review:</fo:block>
7393
7557
  <xsl:apply-templates /> -->
7558
+
7559
+ <xsl:variable name="id_from" select="normalize-space(current()/@from)"/>
7560
+
7561
+ <xsl:choose>
7562
+ <!-- if there isn't the attribute '@from', then -->
7563
+ <xsl:when test="$id_from = ''">
7564
+ <fo:block id="{@id}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block>
7565
+ </xsl:when>
7566
+ <!-- if there isn't element with id 'from', then create 'bookmark' here -->
7567
+ <xsl:when test="not(ancestor::*[contains(local-name(), '-standard')]//*[@id = $id_from])">
7568
+ <fo:block id="{@from}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block>
7569
+ </xsl:when>
7570
+ </xsl:choose>
7571
+
7394
7572
  </xsl:template><xsl:template match="*[local-name() = 'name']/text()">
7395
7573
  <!-- 0xA0 to space replacement -->
7396
7574
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),' ',' ')"/>
@@ -7756,7 +7934,10 @@
7756
7934
  <!-- to split by '_' and other chars -->
7757
7935
  <xsl:call-template name="add-zero-spaces-java"/>
7758
7936
  </xsl:template><xsl:template match="*[local-name() = 'bookmark']" name="bookmark">
7759
- <fo:inline id="{@id}" font-size="1pt"/>
7937
+ <!-- <fo:inline id="{@id}" font-size="1pt"/> -->
7938
+ <fo:inline id="{@id}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:inline>
7939
+ <!-- we need to add zero-width space, otherwise this fo:inline is missing in IF xml -->
7940
+ <xsl:if test="not(following-sibling::node()[normalize-space() != ''])"> </xsl:if>
7760
7941
  </xsl:template><xsl:template match="*[local-name() = 'errata']">
7761
7942
  <!-- <row>
7762
7943
  <date>05-07-2013</date>
@@ -8302,6 +8483,120 @@
8302
8483
  <xsl:apply-templates select="." mode="update_xml_step1"/>
8303
8484
  </xsl:for-each>
8304
8485
  </xsl:copy>
8486
+ </xsl:template><xsl:template match="*[local-name() = 'span']" mode="update_xml_step1">
8487
+ <xsl:apply-templates mode="update_xml_step1"/>
8488
+ </xsl:template><xsl:template match="@*|node()" mode="update_xml_enclose_keep-together_within-line">
8489
+ <xsl:copy>
8490
+ <xsl:apply-templates select="@*|node()" mode="update_xml_enclose_keep-together_within-line"/>
8491
+ </xsl:copy>
8492
+ </xsl:template><xsl:variable name="express_reference_separators">_.\</xsl:variable><xsl:variable name="express_reference_characters" select="concat($upper,$lower,'1234567890',$express_reference_separators)"/><xsl:variable name="element_name_keep-together_within-line">keep-together_within-line</xsl:variable><xsl:template match="text()[not(ancestor::*[local-name() = 'bibdata'] or ancestor::*[local-name() = 'sourcecode'] or ancestor::*[local-name() = 'math'])]" name="keep_together_standard_number" mode="update_xml_enclose_keep-together_within-line">
8493
+
8494
+ <!-- enclose standard's number into tag 'keep-together_within-line' -->
8495
+ <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
8496
+ <xsl:variable name="tag_keep-together_within-line_open">###<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable>
8497
+ <xsl:variable name="tag_keep-together_within-line_close">###/<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable>
8498
+ <xsl:variable name="text_" select="java:replaceAll(java:java.lang.String.new(.),$regex_standard_reference,concat($tag_keep-together_within-line_open,'$1',$tag_keep-together_within-line_close))"/>
8499
+ <xsl:variable name="text"><text><xsl:call-template name="replace_text_tags">
8500
+ <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
8501
+ <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
8502
+ <xsl:with-param name="text" select="$text_"/>
8503
+ </xsl:call-template></text></xsl:variable>
8504
+
8505
+ <xsl:variable name="parent" select="local-name(..)"/>
8506
+
8507
+ <xsl:variable name="text2">
8508
+ <text><xsl:for-each select="xalan:nodeset($text)/text/node()">
8509
+ <xsl:copy-of select="."/>
8510
+ </xsl:for-each></text>
8511
+ </xsl:variable>
8512
+
8513
+ <!-- keep-together_within-line for: a/b, aaa/b, a/bbb, /b -->
8514
+ <xsl:variable name="regex_solidus_units">((\b((\S{1,3}\/\S+)|(\S+\/\S{1,3}))\b)|(\/\S{1,3})\b)</xsl:variable>
8515
+ <xsl:variable name="text3">
8516
+ <text><xsl:for-each select="xalan:nodeset($text2)/text/node()">
8517
+ <xsl:choose>
8518
+ <xsl:when test="self::text()">
8519
+ <xsl:variable name="text_units_" select="java:replaceAll(java:java.lang.String.new(.),$regex_solidus_units,concat($tag_keep-together_within-line_open,'$1',$tag_keep-together_within-line_close))"/>
8520
+ <xsl:variable name="text_units"><text><xsl:call-template name="replace_text_tags">
8521
+ <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
8522
+ <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
8523
+ <xsl:with-param name="text" select="$text_units_"/>
8524
+ </xsl:call-template></text></xsl:variable>
8525
+ <xsl:copy-of select="xalan:nodeset($text_units)/text/node()"/>
8526
+ </xsl:when>
8527
+ <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... -->
8528
+ </xsl:choose>
8529
+ </xsl:for-each></text>
8530
+ </xsl:variable>
8531
+
8532
+ <xsl:choose>
8533
+ <xsl:when test="ancestor::*[local-name() = 'td' or local-name() = 'th']">
8534
+ <!-- keep-together_within-line for: a.b, aaa.b, a.bbb, .b in table's cell ONLY -->
8535
+ <xsl:variable name="regex_dots_units">((\b((\S{1,3}\.\S+)|(\S+\.\S{1,3}))\b)|(\.\S{1,3})\b)</xsl:variable>
8536
+ <xsl:for-each select="xalan:nodeset($text3)/text/node()">
8537
+ <xsl:choose>
8538
+ <xsl:when test="self::text()">
8539
+ <xsl:variable name="text_dots_" select="java:replaceAll(java:java.lang.String.new(.),$regex_dots_units,concat($tag_keep-together_within-line_open,'$1',$tag_keep-together_within-line_close))"/>
8540
+ <xsl:variable name="text_dots"><text><xsl:call-template name="replace_text_tags">
8541
+ <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
8542
+ <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
8543
+ <xsl:with-param name="text" select="$text_dots_"/>
8544
+ </xsl:call-template></text></xsl:variable>
8545
+ <xsl:copy-of select="xalan:nodeset($text_dots)/text/node()"/>
8546
+ </xsl:when>
8547
+ <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... -->
8548
+ </xsl:choose>
8549
+ </xsl:for-each>
8550
+ </xsl:when>
8551
+ <xsl:otherwise><xsl:copy-of select="xalan:nodeset($text3)/text/node()"/></xsl:otherwise>
8552
+ </xsl:choose>
8553
+
8554
+ </xsl:template><xsl:template name="replace_text_tags">
8555
+ <xsl:param name="tag_open"/>
8556
+ <xsl:param name="tag_close"/>
8557
+ <xsl:param name="text"/>
8558
+ <xsl:choose>
8559
+ <xsl:when test="contains($text, $tag_open)">
8560
+ <xsl:value-of select="substring-before($text, $tag_open)"/>
8561
+ <xsl:variable name="text_after" select="substring-after($text, $tag_open)"/>
8562
+
8563
+ <xsl:element name="{substring-before(substring-after($tag_open, '###'),'###')}">
8564
+ <xsl:value-of select="substring-before($text_after, $tag_close)"/>
8565
+ </xsl:element>
8566
+
8567
+ <xsl:call-template name="replace_text_tags">
8568
+ <xsl:with-param name="tag_open" select="$tag_open"/>
8569
+ <xsl:with-param name="tag_close" select="$tag_close"/>
8570
+ <xsl:with-param name="text" select="substring-after($text_after, $tag_close)"/>
8571
+ </xsl:call-template>
8572
+ </xsl:when>
8573
+ <xsl:otherwise><xsl:value-of select="$text"/></xsl:otherwise>
8574
+ </xsl:choose>
8575
+ </xsl:template><xsl:template name="printEdition">
8576
+ <xsl:variable name="edition_i18n" select="normalize-space((//*[contains(local-name(), '-standard')])[1]/*[local-name() = 'bibdata']/*[local-name() = 'edition'][normalize-space(@language) != ''])"/>
8577
+ <xsl:text> </xsl:text>
8578
+ <xsl:choose>
8579
+ <xsl:when test="$edition_i18n != ''">
8580
+ <!-- Example: <edition language="fr">deuxième édition</edition> -->
8581
+ <xsl:call-template name="capitalize">
8582
+ <xsl:with-param name="str" select="$edition_i18n"/>
8583
+ </xsl:call-template>
8584
+ </xsl:when>
8585
+ <xsl:otherwise>
8586
+ <xsl:variable name="edition" select="normalize-space((//*[contains(local-name(), '-standard')])[1]/*[local-name() = 'bibdata']/*[local-name() = 'edition'])"/>
8587
+ <xsl:if test="$edition != ''"> <!-- Example: 1.3 -->
8588
+ <xsl:call-template name="capitalize">
8589
+ <xsl:with-param name="str">
8590
+ <xsl:call-template name="getLocalizedString">
8591
+ <xsl:with-param name="key">edition</xsl:with-param>
8592
+ </xsl:call-template>
8593
+ </xsl:with-param>
8594
+ </xsl:call-template>
8595
+ <xsl:text> </xsl:text>
8596
+ <xsl:value-of select="$edition"/>
8597
+ </xsl:if>
8598
+ </xsl:otherwise>
8599
+ </xsl:choose>
8305
8600
  </xsl:template><xsl:template name="convertDate">
8306
8601
  <xsl:param name="date"/>
8307
8602
  <xsl:param name="format" select="'short'"/>