metanorma-ieee 1.0.6 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2742,10 +2742,6 @@
2742
2742
  </xsl:choose>
2743
2743
  </xsl:template>
2744
2744
 
2745
- <xsl:template match="*[local-name() = 'inlineChar']">
2746
- <fo:inline><xsl:value-of select="."/></fo:inline>
2747
- </xsl:template>
2748
-
2749
2745
  <!--
2750
2746
  <xsl:variable name="example_name_width">25</xsl:variable>
2751
2747
  <xsl:template match="ieee:termexample" priority="2">
@@ -3710,29 +3706,6 @@
3710
3706
  <!-- End Back Pages -->
3711
3707
  <!-- =============================== -->
3712
3708
 
3713
- <xsl:template name="replaceChar">
3714
- <xsl:param name="text"/>
3715
- <xsl:param name="replace"/>
3716
- <xsl:param name="by"/>
3717
- <xsl:choose>
3718
- <xsl:when test="$text = '' or $replace = '' or not($replace)">
3719
- <xsl:value-of select="$text"/>
3720
- </xsl:when>
3721
- <xsl:when test="contains($text, $replace)">
3722
- <xsl:value-of select="substring-before($text,$replace)"/>
3723
- <xsl:element name="inlineChar" namespace="https://www.metanorma.org/ns/ieee"><xsl:value-of select="$by"/></xsl:element>
3724
- <xsl:call-template name="replaceChar">
3725
- <xsl:with-param name="text" select="substring-after($text,$replace)"/>
3726
- <xsl:with-param name="replace" select="$replace"/>
3727
- <xsl:with-param name="by" select="$by"/>
3728
- </xsl:call-template>
3729
- </xsl:when>
3730
- <xsl:otherwise>
3731
- <xsl:value-of select="$text"/>
3732
- </xsl:otherwise>
3733
- </xsl:choose>
3734
- </xsl:template>
3735
-
3736
3709
  <xsl:strip-space elements="ieee:xref"/>
3737
3710
 
3738
3711
  <!-- external parameters -->
@@ -4327,7 +4300,6 @@
4327
4300
 
4328
4301
  <xsl:attribute-set name="table-header-cell-style">
4329
4302
  <xsl:attribute name="font-weight">bold</xsl:attribute>
4330
- <xsl:attribute name="border">solid black 1pt</xsl:attribute>
4331
4303
  <xsl:attribute name="padding-left">1mm</xsl:attribute>
4332
4304
  <xsl:attribute name="padding-right">1mm</xsl:attribute>
4333
4305
  <xsl:attribute name="display-align">center</xsl:attribute>
@@ -4339,7 +4311,6 @@
4339
4311
 
4340
4312
  <xsl:attribute-set name="table-cell-style">
4341
4313
  <xsl:attribute name="display-align">center</xsl:attribute>
4342
- <xsl:attribute name="border">solid black 1pt</xsl:attribute>
4343
4314
  <xsl:attribute name="padding-left">1mm</xsl:attribute>
4344
4315
  <xsl:attribute name="padding-right">1mm</xsl:attribute>
4345
4316
 
@@ -4546,6 +4517,7 @@
4546
4517
  <xsl:attribute-set name="term-name-style">
4547
4518
  <xsl:attribute name="keep-with-next">always</xsl:attribute>
4548
4519
  <xsl:attribute name="font-weight">bold</xsl:attribute>
4520
+
4549
4521
  </xsl:attribute-set>
4550
4522
 
4551
4523
  <xsl:attribute-set name="figure-block-style">
@@ -5084,7 +5056,7 @@
5084
5056
  <xsl:apply-templates select="." mode="contents"/>
5085
5057
  </xsl:for-each>
5086
5058
 
5087
- <xsl:for-each select="/*/*[local-name()='bibliography']/*[not(@normative='true') and not(*[local-name()='references'][@normative='true'])] | /*/*[local-name()='bibliography']/*[local-name()='clause'][*[local-name()='references'][not(@normative='true')]]">
5059
+ <xsl:for-each select="/*/*[local-name()='bibliography']/*[not(@normative='true') and not(*[local-name()='references'][@normative='true'])][count(.//*[local-name() = 'bibitem'][not(@hidden) = 'true']) &gt; 0] | /*/*[local-name()='bibliography']/*[local-name()='clause'][*[local-name()='references'][not(@normative='true')]][count(.//*[local-name() = 'bibitem'][not(@hidden) = 'true']) &gt; 0]">
5088
5060
  <xsl:sort select="@displayorder" data-type="number"/>
5089
5061
  <xsl:apply-templates select="." mode="contents"/>
5090
5062
  </xsl:for-each>
@@ -5511,7 +5483,7 @@
5511
5483
  <xsl:apply-templates select="*[local-name()='thead']" mode="process_tbody"/>
5512
5484
  </xsl:when>
5513
5485
  <xsl:otherwise>
5514
- <xsl:apply-templates select="node()[not(local-name() = 'name') and not(local-name() = 'note') and not(local-name() = 'thead') and not(local-name() = 'tfoot')]"/> <!-- process all table' elements, except name, header, footer and note that renders separaterely -->
5486
+ <xsl:apply-templates select="node()[not(local-name() = 'name') and not(local-name() = 'note') and not(local-name() = 'dl') and not(local-name() = 'thead') and not(local-name() = 'tfoot')]"/> <!-- process all table' elements, except name, header, footer, note and dl which render separaterely -->
5515
5487
  </xsl:otherwise>
5516
5488
  </xsl:choose>
5517
5489
 
@@ -6002,7 +5974,7 @@
6002
5974
  <xsl:param name="colwidths"/>
6003
5975
  <xsl:param name="colgroup"/>
6004
5976
 
6005
- <xsl:variable name="isNoteOrFnExist" select="../*[local-name()='note'] or ..//*[local-name()='fn'][local-name(..) != 'name']"/>
5977
+ <xsl:variable name="isNoteOrFnExist" select="../*[local-name()='note'] or ../*[local-name()='dl'] or ..//*[local-name()='fn'][local-name(..) != 'name']"/>
6006
5978
 
6007
5979
  <xsl:variable name="isNoteOrFnExistShowAfterTable">
6008
5980
 
@@ -6021,6 +5993,10 @@
6021
5993
  </xsl:choose>
6022
5994
  </xsl:variable>
6023
5995
 
5996
+ <xsl:variable name="table_fn_block">
5997
+ <xsl:call-template name="table_fn_display"/>
5998
+ </xsl:variable>
5999
+
6024
6000
  <xsl:variable name="tableWithNotesAndFootnotes">
6025
6001
 
6026
6002
  <fo:table keep-with-previous="always">
@@ -6066,9 +6042,23 @@
6066
6042
 
6067
6043
  <!-- except gb and bsi -->
6068
6044
 
6045
+ <xsl:apply-templates select="../*[local-name()='dl']"/>
6069
6046
  <xsl:apply-templates select="../*[local-name()='note']"/>
6070
6047
 
6048
+ <xsl:variable name="isDisplayRowSeparator">
6049
+
6050
+ </xsl:variable>
6051
+
6071
6052
  <!-- horizontal row separator -->
6053
+ <xsl:if test="normalize-space($isDisplayRowSeparator) = 'true'">
6054
+ <xsl:if test="../*[local-name()='note'] and normalize-space($table_fn_block) != ''">
6055
+ <fo:block-container border-top="0.5pt solid black" padding-left="1mm" padding-right="1mm">
6056
+
6057
+ <xsl:call-template name="setBordersTableArray"/>
6058
+ <fo:block font-size="1pt"> </fo:block>
6059
+ </fo:block-container>
6060
+ </xsl:if>
6061
+ </xsl:if>
6072
6062
 
6073
6063
  <!-- fn processing -->
6074
6064
  <fo:block/><!-- display fn after table -->
@@ -6086,7 +6076,8 @@
6086
6076
  <xsl:copy-of select="$tableWithNotesAndFootnotes"/>
6087
6077
  </xsl:if>
6088
6078
 
6089
- <xsl:call-template name="table_fn_display"/>
6079
+ <!-- <xsl:call-template name="table_fn_display" /> -->
6080
+ <xsl:copy-of select="$table_fn_block"/>
6090
6081
 
6091
6082
  </xsl:if>
6092
6083
  </xsl:template> <!-- insertTableFooterInSeparateTable -->
@@ -6219,7 +6210,7 @@
6219
6210
  <!-- ===================== -->
6220
6211
  <!-- Table's row processing -->
6221
6212
  <!-- ===================== -->
6222
- <!-- row in table header (thead) -->
6213
+ <!-- row in table header (thead) thead/tr -->
6223
6214
  <xsl:template match="*[local-name()='thead']/*[local-name()='tr']" priority="2">
6224
6215
  <fo:table-row xsl:use-attribute-sets="table-header-row-style">
6225
6216
 
@@ -6238,7 +6229,29 @@
6238
6229
  </fo:table-row>
6239
6230
  </xsl:template>
6240
6231
 
6241
- <!-- row in table footer (tfoot) -->
6232
+ <xsl:template name="setBorderUnderRow">
6233
+ <xsl:variable name="border_under_row_" select="normalize-space(ancestor::*[local-name() = 'table'][1]/@border-under-row)"/>
6234
+ <xsl:choose>
6235
+ <xsl:when test="$border_under_row_ != ''">
6236
+ <xsl:variable name="table_id" select="ancestor::*[local-name() = 'table'][1]/@id"/>
6237
+ <xsl:variable name="row_num_"><xsl:number level="any" count="*[local-name() = 'table'][@id = $table_id]//*[local-name() = 'tr']"/></xsl:variable>
6238
+ <xsl:variable name="row_num" select="number($row_num_) - 1"/> <!-- because values in border-under-row start with 0 -->
6239
+ <xsl:variable name="border_under_row">
6240
+ <xsl:call-template name="split">
6241
+ <xsl:with-param name="pText" select="$border_under_row_"/>
6242
+ </xsl:call-template>
6243
+ </xsl:variable>
6244
+ <xsl:if test="xalan:nodeset($border_under_row)/item[. = normalize-space($row_num)]">
6245
+ <xsl:attribute name="border-bottom"><xsl:value-of select="$table-border"/></xsl:attribute>
6246
+ </xsl:if>
6247
+ </xsl:when>
6248
+ <xsl:otherwise>
6249
+ <xsl:attribute name="border-bottom"><xsl:value-of select="$table-border"/></xsl:attribute>
6250
+ </xsl:otherwise>
6251
+ </xsl:choose>
6252
+ </xsl:template>
6253
+
6254
+ <!-- row in table footer (tfoot), tfoot/tr -->
6242
6255
  <xsl:template match="*[local-name()='tfoot']/*[local-name()='tr']" priority="2">
6243
6256
  <fo:table-row xsl:use-attribute-sets="table-footer-row-style">
6244
6257
 
@@ -6586,8 +6599,16 @@
6586
6599
  <!-- figure's footnotes rendering -->
6587
6600
  <xsl:template name="fn_display_figure">
6588
6601
 
6602
+ <!-- current figure id -->
6603
+ <xsl:variable name="figure_id_">
6604
+ <xsl:value-of select="@id"/>
6605
+ <xsl:if test="not(@id)"><xsl:value-of select="generate-id()"/></xsl:if>
6606
+ </xsl:variable>
6607
+ <xsl:variable name="figure_id" select="normalize-space($figure_id_)"/>
6608
+
6609
+ <!-- all footnotes relates to the current figure -->
6589
6610
  <xsl:variable name="references">
6590
- <xsl:for-each select=".//*[local-name()='fn'][not(parent::*[local-name()='name'])]">
6611
+ <xsl:for-each select=".//*[local-name()='fn'][not(parent::*[local-name()='name'])][ancestor::*[local-name() = 'figure'][1][@id = $figure_id]]">
6591
6612
  <fn reference="{@reference}" id="{@reference}_{ancestor::*[@id][1]/@id}">
6592
6613
  <xsl:apply-templates/>
6593
6614
  </fn>
@@ -6600,91 +6621,93 @@
6600
6621
 
6601
6622
  </xsl:variable>
6602
6623
 
6603
- <!-- current hierarchy is 'figure' element -->
6604
- <xsl:variable name="following_dl_colwidths">
6605
- <xsl:if test="*[local-name() = 'dl']"><!-- if there is a 'dl', then set the same columns width as for 'dl' -->
6606
- <xsl:variable name="simple-table">
6607
- <!-- <xsl:variable name="doc_ns">
6608
- <xsl:if test="$namespace = 'bipm'">bipm</xsl:if>
6624
+ <fo:block>
6625
+
6626
+ <!-- current hierarchy is 'figure' element -->
6627
+ <xsl:variable name="following_dl_colwidths">
6628
+ <xsl:if test="*[local-name() = 'dl']"><!-- if there is a 'dl', then set the same columns width as for 'dl' -->
6629
+ <xsl:variable name="simple-table">
6630
+ <!-- <xsl:variable name="doc_ns">
6631
+ <xsl:if test="$namespace = 'bipm'">bipm</xsl:if>
6632
+ </xsl:variable>
6633
+ <xsl:variable name="ns">
6634
+ <xsl:choose>
6635
+ <xsl:when test="normalize-space($doc_ns) != ''">
6636
+ <xsl:value-of select="normalize-space($doc_ns)"/>
6637
+ </xsl:when>
6638
+ <xsl:otherwise>
6639
+ <xsl:value-of select="substring-before(name(/*), '-')"/>
6640
+ </xsl:otherwise>
6641
+ </xsl:choose>
6642
+ </xsl:variable> -->
6643
+
6644
+ <xsl:for-each select="*[local-name() = 'dl'][1]">
6645
+ <tbody>
6646
+ <xsl:apply-templates mode="dl"/>
6647
+ </tbody>
6648
+ </xsl:for-each>
6649
+ </xsl:variable>
6650
+
6651
+ <xsl:call-template name="calculate-column-widths">
6652
+ <xsl:with-param name="cols-count" select="2"/>
6653
+ <xsl:with-param name="table" select="$simple-table"/>
6654
+ </xsl:call-template>
6655
+
6656
+ </xsl:if>
6657
+ </xsl:variable>
6658
+
6659
+ <xsl:variable name="maxlength_dt">
6660
+ <xsl:for-each select="*[local-name() = 'dl'][1]">
6661
+ <xsl:call-template name="getMaxLength_dt"/>
6662
+ </xsl:for-each>
6609
6663
  </xsl:variable>
6610
- <xsl:variable name="ns">
6664
+
6665
+ <fo:table width="95%" table-layout="fixed">
6666
+ <xsl:if test="normalize-space($key_iso) = 'true'">
6667
+ <xsl:attribute name="font-size">10pt</xsl:attribute>
6668
+
6669
+ </xsl:if>
6611
6670
  <xsl:choose>
6612
- <xsl:when test="normalize-space($doc_ns) != ''">
6613
- <xsl:value-of select="normalize-space($doc_ns)"/>
6671
+ <!-- if there 'dl', then set same columns width -->
6672
+ <xsl:when test="xalan:nodeset($following_dl_colwidths)//column">
6673
+ <xsl:call-template name="setColumnWidth_dl">
6674
+ <xsl:with-param name="colwidths" select="$following_dl_colwidths"/>
6675
+ <xsl:with-param name="maxlength_dt" select="$maxlength_dt"/>
6676
+ </xsl:call-template>
6614
6677
  </xsl:when>
6615
6678
  <xsl:otherwise>
6616
- <xsl:value-of select="substring-before(name(/*), '-')"/>
6679
+ <fo:table-column column-width="5%"/>
6680
+ <fo:table-column column-width="95%"/>
6617
6681
  </xsl:otherwise>
6618
6682
  </xsl:choose>
6619
- </xsl:variable> -->
6620
-
6621
- <xsl:for-each select="*[local-name() = 'dl'][1]">
6622
- <tbody>
6623
- <xsl:apply-templates mode="dl"/>
6624
- </tbody>
6625
- </xsl:for-each>
6626
- </xsl:variable>
6627
-
6628
- <xsl:call-template name="calculate-column-widths">
6629
- <xsl:with-param name="cols-count" select="2"/>
6630
- <xsl:with-param name="table" select="$simple-table"/>
6631
- </xsl:call-template>
6632
-
6633
- </xsl:if>
6634
- </xsl:variable>
6635
-
6636
- <xsl:variable name="maxlength_dt">
6637
- <xsl:for-each select="*[local-name() = 'dl'][1]">
6638
- <xsl:call-template name="getMaxLength_dt"/>
6639
- </xsl:for-each>
6640
- </xsl:variable>
6641
-
6642
- <fo:block>
6643
- <fo:table width="95%" table-layout="fixed">
6644
- <xsl:if test="normalize-space($key_iso) = 'true'">
6645
- <xsl:attribute name="font-size">10pt</xsl:attribute>
6683
+ <fo:table-body>
6684
+ <xsl:for-each select="xalan:nodeset($references)//fn">
6685
+ <xsl:variable name="reference" select="@reference"/>
6686
+ <xsl:if test="not(preceding-sibling::*[@reference = $reference])"> <!-- only unique reference puts in note-->
6687
+ <fo:table-row>
6688
+ <fo:table-cell>
6689
+ <fo:block>
6690
+ <fo:inline id="{@id}" xsl:use-attribute-sets="figure-fn-number-style">
6691
+ <xsl:value-of select="@reference"/>
6692
+ </fo:inline>
6693
+ </fo:block>
6694
+ </fo:table-cell>
6695
+ <fo:table-cell>
6696
+ <fo:block xsl:use-attribute-sets="figure-fn-body-style">
6697
+ <xsl:if test="normalize-space($key_iso) = 'true'">
6646
6698
 
6647
- </xsl:if>
6648
- <xsl:choose>
6649
- <!-- if there 'dl', then set same columns width -->
6650
- <xsl:when test="xalan:nodeset($following_dl_colwidths)//column">
6651
- <xsl:call-template name="setColumnWidth_dl">
6652
- <xsl:with-param name="colwidths" select="$following_dl_colwidths"/>
6653
- <xsl:with-param name="maxlength_dt" select="$maxlength_dt"/>
6654
- </xsl:call-template>
6655
- </xsl:when>
6656
- <xsl:otherwise>
6657
- <fo:table-column column-width="15%"/>
6658
- <fo:table-column column-width="85%"/>
6659
- </xsl:otherwise>
6660
- </xsl:choose>
6661
- <fo:table-body>
6662
- <xsl:for-each select="xalan:nodeset($references)//fn">
6663
- <xsl:variable name="reference" select="@reference"/>
6664
- <xsl:if test="not(preceding-sibling::*[@reference = $reference])"> <!-- only unique reference puts in note-->
6665
- <fo:table-row>
6666
- <fo:table-cell>
6667
- <fo:block>
6668
- <fo:inline id="{@id}" xsl:use-attribute-sets="figure-fn-number-style">
6669
- <xsl:value-of select="@reference"/>
6670
- </fo:inline>
6671
- </fo:block>
6672
- </fo:table-cell>
6673
- <fo:table-cell>
6674
- <fo:block xsl:use-attribute-sets="figure-fn-body-style">
6675
- <xsl:if test="normalize-space($key_iso) = 'true'">
6699
+ <xsl:attribute name="margin-bottom">0</xsl:attribute>
6676
6700
 
6677
- <xsl:attribute name="margin-bottom">0</xsl:attribute>
6701
+ </xsl:if>
6702
+ <xsl:copy-of select="./node()"/>
6703
+ </fo:block>
6704
+ </fo:table-cell>
6705
+ </fo:table-row>
6706
+ </xsl:if>
6707
+ </xsl:for-each>
6708
+ </fo:table-body>
6709
+ </fo:table>
6678
6710
 
6679
- </xsl:if>
6680
- <xsl:copy-of select="./node()"/>
6681
- </fo:block>
6682
- </fo:table-cell>
6683
- </fo:table-row>
6684
- </xsl:if>
6685
- </xsl:for-each>
6686
- </fo:table-body>
6687
- </fo:table>
6688
6711
  </fo:block>
6689
6712
  </xsl:if>
6690
6713
 
@@ -6724,6 +6747,8 @@
6724
6747
  <!-- <dl><xsl:copy-of select="."/></dl> -->
6725
6748
  <fo:block-container>
6726
6749
 
6750
+ <xsl:call-template name="setBlockSpanAll"/>
6751
+
6727
6752
  <xsl:if test="not(ancestor::*[local-name() = 'quote'])">
6728
6753
  <xsl:attribute name="margin-left">0mm</xsl:attribute>
6729
6754
  </xsl:if>
@@ -6760,12 +6785,14 @@
6760
6785
 
6761
6786
  <fo:block margin-bottom="12pt" text-align="left">
6762
6787
 
6763
- <xsl:variable name="title-where">
6788
+ <!-- <xsl:variable name="title-where">
6764
6789
  <xsl:call-template name="getLocalizedString">
6765
6790
  <xsl:with-param name="key">where</xsl:with-param>
6766
6791
  </xsl:call-template>
6767
6792
  </xsl:variable>
6768
- <xsl:value-of select="$title-where"/><xsl:text> </xsl:text>
6793
+ <xsl:value-of select="$title-where"/> -->
6794
+ <xsl:apply-templates select="preceding-sibling::*[1][local-name() = 'p' and @keep-with-next = 'true']/node()"/>
6795
+ <xsl:text> </xsl:text>
6769
6796
  <xsl:apply-templates select="*[local-name()='dt']/*"/>
6770
6797
  <xsl:text/>
6771
6798
  <xsl:apply-templates select="*[local-name()='dd']/*" mode="inline"/>
@@ -6775,12 +6802,14 @@
6775
6802
  <xsl:when test="$parent = 'formula'"> <!-- a few components -->
6776
6803
  <fo:block margin-bottom="12pt" text-align="left">
6777
6804
 
6778
- <xsl:variable name="title-where">
6805
+ <!-- <xsl:variable name="title-where">
6779
6806
  <xsl:call-template name="getLocalizedString">
6780
6807
  <xsl:with-param name="key">where</xsl:with-param>
6781
6808
  </xsl:call-template>
6782
6809
  </xsl:variable>
6783
- <xsl:value-of select="$title-where"/>
6810
+ <xsl:value-of select="$title-where"/><xsl:if test="$namespace = 'bsi' or $namespace = 'itu'">:</xsl:if> -->
6811
+ <!-- preceding 'p' with word 'where' -->
6812
+ <xsl:apply-templates select="preceding-sibling::*[1][local-name() = 'p' and @keep-with-next = 'true']/node()"/>
6784
6813
  </fo:block>
6785
6814
  </xsl:when> <!-- END: a few components -->
6786
6815
  <xsl:when test="$parent = 'figure' and (not(../@class) or ../@class !='pseudocode')"> <!-- definition list in a figure -->
@@ -6963,6 +6992,9 @@
6963
6992
 
6964
6993
  </xsl:template> <!-- END: dl -->
6965
6994
 
6995
+ <!-- ignore 'p' with 'where' in formula, before 'dl' -->
6996
+ <xsl:template match="*[local-name() = 'formula']/*[local-name() = 'p' and @keep-with-next = 'true' and following-sibling::*[1][local-name() = 'dl']]"/>
6997
+
6966
6998
  <xsl:template match="*[local-name() = 'dl']/*[local-name() = 'name']">
6967
6999
  <xsl:param name="process">false</xsl:param>
6968
7000
  <xsl:if test="$process = 'true'">
@@ -7790,8 +7822,8 @@
7790
7822
 
7791
7823
  <!-- add zero-width space (#x200B) after dot with next non-digit -->
7792
7824
  <xsl:variable name="text1" select="java:replaceAll(java:java.lang.String.new($text),'(\.)([^\d\s])','$1​$2')"/>
7793
- <!-- add zero-width space (#x200B) after characters: dash, equal, underscore, em dash, thin space, arrow right -->
7794
- <xsl:variable name="text2" select="java:replaceAll(java:java.lang.String.new($text1),'(-|=|_|—| |→)','$1​')"/>
7825
+ <!-- add zero-width space (#x200B) after characters: dash, equal, underscore, em dash, thin space, arrow right, ; -->
7826
+ <xsl:variable name="text2" select="java:replaceAll(java:java.lang.String.new($text1),'(-|=|_|—| |→|;)','$1​')"/>
7795
7827
  <!-- add zero-width space (#x200B) after characters: colon, if there aren't digits after -->
7796
7828
  <xsl:variable name="text3" select="java:replaceAll(java:java.lang.String.new($text2),'(:)(\D)','$1​$2')"/>
7797
7829
  <!-- add zero-width space (#x200B) after characters: 'great than' -->
@@ -7802,8 +7834,19 @@
7802
7834
  <xsl:variable name="text6" select="java:replaceAll(java:java.lang.String.new($text5), '(?&lt;!\W)(\{)', '​$1')"/> <!-- negative lookbehind: '{' not preceeded by 'punctuation char' -->
7803
7835
  <!-- add zero-width space (#x200B) after character: , -->
7804
7836
  <xsl:variable name="text7" select="java:replaceAll(java:java.lang.String.new($text6), '(\,)(?!\d)', '$1​')"/> <!-- negative lookahead: ',' not followed by digit -->
7837
+ <!-- add zero-width space (#x200B) after character: '/' -->
7838
+ <xsl:variable name="text8" select="java:replaceAll(java:java.lang.String.new($text7), '(\u002f)(?!\u002f)', '$1​')"/><!-- negative lookahead: '/' not followed by '/' -->
7805
7839
 
7806
- <xsl:value-of select="$text7"/>
7840
+ <xsl:variable name="text9">
7841
+ <xsl:choose>
7842
+ <xsl:when test="$isGenerateTableIF = 'true'">
7843
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new($text8), '([\u3000-\u9FFF])', '$1​')"/> <!-- 3000 - CJK Symbols and Punctuation ... 9FFF CJK Unified Ideographs-->
7844
+ </xsl:when>
7845
+ <xsl:otherwise><xsl:value-of select="$text8"/></xsl:otherwise>
7846
+ </xsl:choose>
7847
+ </xsl:variable>
7848
+
7849
+ <xsl:value-of select="$text9"/>
7807
7850
  </xsl:template>
7808
7851
 
7809
7852
  <xsl:template name="add-zero-spaces-link-java">
@@ -7811,8 +7854,8 @@
7811
7854
 
7812
7855
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new($text), $regex_url_start, '$1')"/> <!-- http://. https:// or www. -->
7813
7856
  <xsl:variable name="url_continue" select="java:replaceAll(java:java.lang.String.new($text), $regex_url_start, '$2')"/>
7814
- <!-- add zero-width space (#x200B) after characters: dash, dot, colon, equal, underscore, em dash, thin space -->
7815
- <xsl:variable name="url" select="java:replaceAll(java:java.lang.String.new($url_continue),'(-|\.|:|=|_|—| |,|/)','$1​')"/>
7857
+ <!-- add zero-width space (#x200B) after characters: dash, dot, colon, equal, underscore, em dash, thin space, comma, slash, @ -->
7858
+ <xsl:variable name="url" select="java:replaceAll(java:java.lang.String.new($url_continue),'(-|\.|:|=|_|—| |,|/|@)','$1​')"/>
7816
7859
  <!-- remove zero-width space at the end -->
7817
7860
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new($url), '​$', '')"/>
7818
7861
  </xsl:template>
@@ -8167,9 +8210,28 @@
8167
8210
  </xsl:variable>
8168
8211
  <xsl:copy-of select="$newRow"/>
8169
8212
 
8170
- <xsl:apply-templates select="following-sibling::tr[1]" mode="simple-table-rowspan">
8171
- <xsl:with-param name="previousRow" select="$newRow"/>
8172
- </xsl:apply-templates>
8213
+ <!-- optimize to prevent StackOverflowError, just copy next 'tr' -->
8214
+ <xsl:variable name="currrow_num" select="count(preceding-sibling::tr) + 1"/>
8215
+ <xsl:variable name="nextrow_without_rowspan_" select="count(following-sibling::tr[*[@rowspan and @rowspan != 1]][1]/preceding-sibling::tr) + 1"/>
8216
+ <xsl:variable name="nextrow_without_rowspan" select="$nextrow_without_rowspan_ - $currrow_num"/>
8217
+ <xsl:choose>
8218
+ <xsl:when test="not(xalan:nodeset($newRow)/*/*[@rowspan and @rowspan != 1]) and $nextrow_without_rowspan &lt;= 0">
8219
+ <xsl:copy-of select="following-sibling::tr"/>
8220
+ </xsl:when>
8221
+ <!-- <xsl:when test="xalan:nodeset($newRow)/*[not(@rowspan) or (@rowspan = 1)] and $nextrow_without_rowspan &gt; 0">
8222
+ <xsl:copy-of select="following-sibling::tr[position() &lt;= $nextrow_without_rowspan]"/>
8223
+
8224
+ <xsl:copy-of select="following-sibling::tr[$nextrow_without_rowspan + 1]"/>
8225
+ <xsl:apply-templates select="following-sibling::tr[$nextrow_without_rowspan + 2]" mode="simple-table-rowspan">
8226
+ <xsl:with-param name="previousRow" select="following-sibling::tr[$nextrow_without_rowspan + 1]"/>
8227
+ </xsl:apply-templates>
8228
+ </xsl:when> -->
8229
+ <xsl:otherwise>
8230
+ <xsl:apply-templates select="following-sibling::tr[1]" mode="simple-table-rowspan">
8231
+ <xsl:with-param name="previousRow" select="$newRow"/>
8232
+ </xsl:apply-templates>
8233
+ </xsl:otherwise>
8234
+ </xsl:choose>
8173
8235
  </xsl:template>
8174
8236
  <!-- End mode simple-table-rowspan -->
8175
8237
 
@@ -8332,6 +8394,27 @@
8332
8394
  </xsl:call-template>
8333
8395
  </xsl:template>
8334
8396
 
8397
+ <xsl:template match="*[local-name() = 'link'][normalize-space() = '']" mode="td_text_with_formatting">
8398
+ <xsl:variable name="link">
8399
+ <link_updated>
8400
+ <xsl:variable name="target_text">
8401
+ <xsl:choose>
8402
+ <xsl:when test="starts-with(normalize-space(@target), 'mailto:')">
8403
+ <xsl:value-of select="normalize-space(substring-after(@target, 'mailto:'))"/>
8404
+ </xsl:when>
8405
+ <xsl:otherwise>
8406
+ <xsl:value-of select="normalize-space(@target)"/>
8407
+ </xsl:otherwise>
8408
+ </xsl:choose>
8409
+ </xsl:variable>
8410
+ <xsl:value-of select="$target_text"/>
8411
+ </link_updated>
8412
+ </xsl:variable>
8413
+ <xsl:for-each select="xalan:nodeset($link)/*">
8414
+ <xsl:apply-templates mode="td_text_with_formatting"/>
8415
+ </xsl:for-each>
8416
+ </xsl:template>
8417
+
8335
8418
  <xsl:template name="getFormattingTags">
8336
8419
  <tags>
8337
8420
  <xsl:if test="ancestor::*[local-name() = 'strong']"><tag>strong</tag></xsl:if>
@@ -8675,7 +8758,7 @@
8675
8758
  </xsl:variable>
8676
8759
  <fo:inline xsl:use-attribute-sets="link-style">
8677
8760
 
8678
- <xsl:if test="starts-with(normalize-space(@target), 'mailto:')">
8761
+ <xsl:if test="starts-with(normalize-space(@target), 'mailto:') and not(ancestor::*[local-name() = 'td'])">
8679
8762
  <xsl:attribute name="keep-together.within-line">always</xsl:attribute>
8680
8763
  </xsl:if>
8681
8764
 
@@ -8742,13 +8825,17 @@
8742
8825
  </xsl:template>
8743
8826
 
8744
8827
  <xsl:template match="*[local-name() = 'callout']">
8745
- <fo:basic-link internal-destination="{@target}" fox:alt-text="{@target}">&lt;<xsl:apply-templates/>&gt;</fo:basic-link>
8828
+ <xsl:choose>
8829
+ <xsl:when test="normalize-space(@target) = ''">&lt;<xsl:apply-templates/>&gt;</xsl:when>
8830
+ <xsl:otherwise><fo:basic-link internal-destination="{@target}" fox:alt-text="{@target}">&lt;<xsl:apply-templates/>&gt;</fo:basic-link></xsl:otherwise>
8831
+ </xsl:choose>
8746
8832
  </xsl:template>
8747
8833
 
8748
8834
  <xsl:template match="*[local-name() = 'annotation']">
8749
8835
  <xsl:variable name="annotation-id" select="@id"/>
8750
8836
  <xsl:variable name="callout" select="//*[@target = $annotation-id]/text()"/>
8751
8837
  <fo:block id="{$annotation-id}" white-space="nowrap">
8838
+
8752
8839
  <fo:inline>
8753
8840
  <xsl:apply-templates>
8754
8841
  <xsl:with-param name="callout" select="concat('&lt;', $callout, '&gt; ')"/>
@@ -8853,6 +8940,10 @@
8853
8940
  <!-- ====== -->
8854
8941
  <!-- ====== -->
8855
8942
 
8943
+ <xsl:template name="setBlockSpanAll">
8944
+ <xsl:if test="@columns = 1 or (local-name() = 'p' and *[@columns = 1])"><xsl:attribute name="span">all</xsl:attribute></xsl:if>
8945
+ </xsl:template>
8946
+
8856
8947
  <!-- ====== -->
8857
8948
  <!-- note -->
8858
8949
  <!-- termnote -->
@@ -8862,6 +8953,8 @@
8862
8953
 
8863
8954
  <fo:block-container id="{@id}" xsl:use-attribute-sets="note-style">
8864
8955
 
8956
+ <xsl:call-template name="setBlockSpanAll"/>
8957
+
8865
8958
  <fo:block-container margin-left="0mm" margin-right="0mm">
8866
8959
 
8867
8960
  <fo:block>
@@ -8912,6 +9005,8 @@
8912
9005
  <xsl:template match="*[local-name() = 'termnote']">
8913
9006
  <fo:block id="{@id}" xsl:use-attribute-sets="termnote-style">
8914
9007
 
9008
+ <xsl:call-template name="setBlockSpanAll"/>
9009
+
8915
9010
  <fo:inline xsl:use-attribute-sets="termnote-name-style">
8916
9011
 
8917
9012
  <xsl:if test="not(*[local-name() = 'name']/following-sibling::node()[1][self::text()][normalize-space()=''])">
@@ -9048,10 +9143,10 @@
9048
9143
  <fo:block xsl:use-attribute-sets="figure-style">
9049
9144
  <xsl:apply-templates select="node()[not(local-name() = 'name') and not(local-name() = 'note' and @type = 'units')]"/>
9050
9145
  </fo:block>
9051
- <xsl:call-template name="fn_display_figure"/>
9052
9146
  <xsl:for-each select="*[local-name() = 'note'][not(@type = 'units')]">
9053
9147
  <xsl:call-template name="note"/>
9054
9148
  </xsl:for-each>
9149
+ <xsl:call-template name="fn_display_figure"/>
9055
9150
 
9056
9151
  <xsl:apply-templates select="*[local-name() = 'name']"/> <!-- show figure's name AFTER image -->
9057
9152
 
@@ -9114,7 +9209,13 @@
9114
9209
  </xsl:choose>
9115
9210
  </xsl:variable>
9116
9211
 
9117
- <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $width_effective, $height_effective)"/>
9212
+ <xsl:variable name="image_width_effective">
9213
+
9214
+ <xsl:value-of select="$width_effective"/>
9215
+
9216
+ </xsl:variable>
9217
+
9218
+ <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $image_width_effective, $height_effective)"/>
9118
9219
  <xsl:if test="number($scale) &lt; 100">
9119
9220
 
9120
9221
  <xsl:attribute name="content-width"><xsl:value-of select="$scale"/>%</xsl:attribute>
@@ -9701,6 +9802,13 @@
9701
9802
  <xsl:when test="$contents_nodes/doc">
9702
9803
  <xsl:choose>
9703
9804
  <xsl:when test="count($contents_nodes/doc) &gt; 1">
9805
+
9806
+ <xsl:if test="$contents_nodes/collection">
9807
+ <fo:bookmark internal-destination="{$contents/collection/@firstpage_id}">
9808
+ <fo:bookmark-title>collection.pdf</fo:bookmark-title>
9809
+ </fo:bookmark>
9810
+ </xsl:if>
9811
+
9704
9812
  <xsl:for-each select="$contents_nodes/doc">
9705
9813
  <fo:bookmark internal-destination="{contents/item[1]/@id}" starting-state="hide">
9706
9814
  <xsl:if test="@bundle = 'true'">
@@ -10817,6 +10925,9 @@
10817
10925
  <!-- ====== -->
10818
10926
  <xsl:template match="*[local-name() = 'termexample']">
10819
10927
  <fo:block id="{@id}" xsl:use-attribute-sets="termexample-style">
10928
+
10929
+ <xsl:call-template name="setBlockSpanAll"/>
10930
+
10820
10931
  <xsl:apply-templates select="*[local-name()='name']"/>
10821
10932
  <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
10822
10933
  </fo:block>
@@ -10872,6 +10983,8 @@
10872
10983
 
10873
10984
  <fo:block-container id="{@id}" xsl:use-attribute-sets="example-style">
10874
10985
 
10986
+ <xsl:call-template name="setBlockSpanAll"/>
10987
+
10875
10988
  <xsl:variable name="fo_element">
10876
10989
  <xsl:if test=".//*[local-name() = 'table'] or .//*[local-name() = 'dl'] or *[not(local-name() = 'name')][1][local-name() = 'sourcecode']">block</xsl:if>
10877
10990
  block
@@ -10899,6 +11012,35 @@
10899
11012
  </fo:block-container>
10900
11013
  </xsl:when> <!-- end block -->
10901
11014
 
11015
+ <xsl:when test="contains(normalize-space($fo_element), 'list')">
11016
+
11017
+ <xsl:variable name="provisional_distance_between_starts">
11018
+ 7
11019
+ </xsl:variable>
11020
+ <xsl:variable name="indent">
11021
+ 0
11022
+ </xsl:variable>
11023
+
11024
+ <fo:list-block provisional-distance-between-starts="{$provisional_distance_between_starts}mm">
11025
+ <fo:list-item>
11026
+ <fo:list-item-label start-indent="{$indent}mm" end-indent="label-end()">
11027
+ <fo:block>
11028
+ <xsl:apply-templates select="*[local-name()='name']">
11029
+ <xsl:with-param name="fo_element">block</xsl:with-param>
11030
+ </xsl:apply-templates>
11031
+ </fo:block>
11032
+ </fo:list-item-label>
11033
+ <fo:list-item-body start-indent="body-start()">
11034
+ <fo:block>
11035
+ <xsl:apply-templates select="node()[not(local-name() = 'name')]">
11036
+ <xsl:with-param name="fo_element" select="$fo_element"/>
11037
+ </xsl:apply-templates>
11038
+ </fo:block>
11039
+ </fo:list-item-body>
11040
+ </fo:list-item>
11041
+ </fo:list-block>
11042
+ </xsl:when> <!-- end list -->
11043
+
10902
11044
  <xsl:otherwise> <!-- inline -->
10903
11045
 
10904
11046
  <!-- display 'EXAMPLE' and first element in the same line -->
@@ -10978,6 +11120,11 @@
10978
11120
  </fo:block>
10979
11121
  </fo:block-container>
10980
11122
  </xsl:when>
11123
+ <xsl:when test="starts-with(normalize-space($element), 'list')">
11124
+ <fo:block xsl:use-attribute-sets="example-p-style">
11125
+ <xsl:apply-templates/>
11126
+ </fo:block>
11127
+ </xsl:when>
10981
11128
  <xsl:otherwise>
10982
11129
  <fo:inline xsl:use-attribute-sets="example-p-style">
10983
11130
  <xsl:apply-templates/>
@@ -11095,6 +11242,9 @@
11095
11242
  <!-- ====== -->
11096
11243
  <xsl:template match="*[local-name() = 'quote']">
11097
11244
  <fo:block-container margin-left="0mm">
11245
+
11246
+ <xsl:call-template name="setBlockSpanAll"/>
11247
+
11098
11248
  <xsl:if test="parent::*[local-name() = 'note']">
11099
11249
  <xsl:if test="not(ancestor::*[local-name() = 'table'])">
11100
11250
  <xsl:attribute name="margin-left">5mm</xsl:attribute>
@@ -11380,6 +11530,8 @@
11380
11530
  <fo:block>
11381
11531
  <xsl:call-template name="setId"/>
11382
11532
 
11533
+ <xsl:call-template name="setBlockSpanAll"/>
11534
+
11383
11535
  <xsl:apply-templates/>
11384
11536
  </fo:block>
11385
11537
  </xsl:template>
@@ -11394,6 +11546,8 @@
11394
11546
  <fo:block break-after="page"/>
11395
11547
  <fo:block id="{@id}">
11396
11548
 
11549
+ <xsl:call-template name="setBlockSpanAll"/>
11550
+
11397
11551
  </fo:block>
11398
11552
  <xsl:apply-templates/>
11399
11553
  </xsl:template>
@@ -11592,6 +11746,44 @@
11592
11746
 
11593
11747
  <fo:list-block xsl:use-attribute-sets="list-style">
11594
11748
 
11749
+ <xsl:variable name="provisional_distance_between_starts_">
11750
+ <attributes xsl:use-attribute-sets="list-style">
11751
+
11752
+ </attributes>
11753
+ </xsl:variable>
11754
+ <xsl:variable name="provisional_distance_between_starts" select="normalize-space(xalan:nodeset($provisional_distance_between_starts_)/attributes/@provisional-distance-between-starts)"/>
11755
+ <xsl:if test="$provisional_distance_between_starts != ''">
11756
+ <xsl:attribute name="provisional-distance-between-starts"><xsl:value-of select="$provisional_distance_between_starts"/></xsl:attribute>
11757
+ </xsl:if>
11758
+ <xsl:variable name="provisional_distance_between_starts_value" select="substring-before($provisional_distance_between_starts, 'mm')"/>
11759
+
11760
+ <!-- increase provisional-distance-between-starts for long lists -->
11761
+ <xsl:if test="local-name() = 'ol'">
11762
+ <!-- Examples: xiii), xviii), xxviii) -->
11763
+ <xsl:variable name="item_numbers">
11764
+ <xsl:for-each select="*[local-name() = 'li']">
11765
+ <item><xsl:call-template name="getListItemFormat"/></item>
11766
+ </xsl:for-each>
11767
+ </xsl:variable>
11768
+
11769
+ <xsl:variable name="max_length">
11770
+ <xsl:for-each select="xalan:nodeset($item_numbers)/item">
11771
+ <xsl:sort select="string-length(.)" data-type="number" order="descending"/>
11772
+ <xsl:if test="position() = 1"><xsl:value-of select="string-length(.)"/></xsl:if>
11773
+ </xsl:for-each>
11774
+ </xsl:variable>
11775
+
11776
+ <!-- base width (provisional-distance-between-starts) for 4 chars -->
11777
+ <xsl:variable name="addon" select="$max_length - 4"/>
11778
+ <xsl:if test="$addon &gt; 0">
11779
+ <xsl:attribute name="provisional-distance-between-starts"><xsl:value-of select="$provisional_distance_between_starts_value + $addon * 2"/>mm</xsl:attribute>
11780
+ </xsl:if>
11781
+ <!-- DEBUG -->
11782
+ <!-- <xsl:copy-of select="$item_numbers"/>
11783
+ <max_length><xsl:value-of select="$max_length"/></max_length>
11784
+ <addon><xsl:value-of select="$addon"/></addon> -->
11785
+ </xsl:if>
11786
+
11595
11787
  <xsl:if test="*[local-name() = 'name']">
11596
11788
  <xsl:attribute name="margin-top">0pt</xsl:attribute>
11597
11789
  </xsl:if>
@@ -12332,6 +12524,8 @@
12332
12524
  <!-- text in the box -->
12333
12525
  <fo:block-container id="{@id}" xsl:use-attribute-sets="admonition-style">
12334
12526
 
12527
+ <xsl:call-template name="setBlockSpanAll"/>
12528
+
12335
12529
  <xsl:if test="@type = 'editorial'">
12336
12530
  <xsl:attribute name="border">none</xsl:attribute>
12337
12531
  <!-- <xsl:attribute name="font-weight">bold</xsl:attribute>
@@ -12543,6 +12737,16 @@
12543
12737
  <xsl:apply-templates mode="update_xml_step1"/>
12544
12738
  </xsl:copy>
12545
12739
  </xsl:template>
12740
+
12741
+ <!-- remove semantic xml -->
12742
+ <xsl:template match="*[local-name() = 'metanorma-extension']/*[local-name() = 'metanorma']/*[local-name() = 'source']" mode="update_xml_step1"/>
12743
+
12744
+ <!-- remove image/emf -->
12745
+ <xsl:template match="*[local-name() = 'image']/*[local-name() = 'emf']" mode="update_xml_step1"/>
12746
+
12747
+ <xsl:template match="*[local-name() = 'stem'] | *[local-name() = 'image']" mode="update_xml_step1">
12748
+ <xsl:copy-of select="."/>
12749
+ </xsl:template>
12546
12750
  <!-- =========================================================================== -->
12547
12751
  <!-- END STEP1: Re-order elements in 'preface', 'sections' based on @displayorder -->
12548
12752
  <!-- =========================================================================== -->
@@ -12643,6 +12847,10 @@
12643
12847
  </xsl:call-template>
12644
12848
  </xsl:template>
12645
12849
 
12850
+ <xsl:template match="*[local-name() = 'stem'] | *[local-name() = 'image']" mode="update_xml_step2">
12851
+ <xsl:copy-of select="."/>
12852
+ </xsl:template>
12853
+
12646
12854
  <!-- =========================================================================== -->
12647
12855
  <!-- END STEP2: add 'fn' after 'eref' and 'origin', if referenced to bibitem with 'note' = Withdrawn.' or 'Cancelled and replaced...' -->
12648
12856
  <!-- =========================================================================== -->
@@ -12664,7 +12872,7 @@
12664
12872
 
12665
12873
  <xsl:variable name="element_name_keep-together_within-line">keep-together_within-line</xsl:variable>
12666
12874
 
12667
- <xsl:template match="text()[not(ancestor::*[local-name() = 'bibdata'] or ancestor::*[local-name() = 'link'][not(contains(.,' '))] or ancestor::*[local-name() = 'sourcecode'] or ancestor::*[local-name() = 'math'] or starts-with(., 'http://') or starts-with(., 'https://') or starts-with(., 'www.') )]" name="keep_together_standard_number" mode="update_xml_enclose_keep-together_within-line">
12875
+ <xsl:template match="text()[not(ancestor::*[local-name() = 'bibdata'] or ancestor::*[local-name() = 'link'][not(contains(.,' '))] or ancestor::*[local-name() = 'sourcecode'] or ancestor::*[local-name() = 'math'] or ancestor::*[local-name() = 'svg'] or starts-with(., 'http://') or starts-with(., 'https://') or starts-with(., 'www.') )]" name="keep_together_standard_number" mode="update_xml_enclose_keep-together_within-line">
12668
12876
 
12669
12877
  <!-- enclose standard's number into tag 'keep-together_within-line' -->
12670
12878
  <xsl:variable name="tag_keep-together_within-line_open">###<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable>
@@ -12694,7 +12902,7 @@
12694
12902
  <!-- \S matches any non-whitespace character (equivalent to [^\r\n\t\f\v ]) -->
12695
12903
  <!-- <xsl:variable name="regex_solidus_units">((\b((\S{1,3}\/\S+)|(\S+\/\S{1,3}))\b)|(\/\S{1,3})\b)</xsl:variable> -->
12696
12904
  <!-- add &lt; and &gt; to \S -->
12697
- <xsl:variable name="regex_S">[^\r\n\t\f\v \&lt;&gt;]</xsl:variable>
12905
+ <xsl:variable name="regex_S">[^\r\n\t\f\v \&lt;&gt;\u3000-\u9FFF]</xsl:variable>
12698
12906
  <xsl:variable name="regex_solidus_units">((\b((<xsl:value-of select="$regex_S"/>{1,3}\/<xsl:value-of select="$regex_S"/>+)|(<xsl:value-of select="$regex_S"/>+\/<xsl:value-of select="$regex_S"/>{1,3}))\b)|(\/<xsl:value-of select="$regex_S"/>{1,3})\b)</xsl:variable>
12699
12907
  <xsl:variable name="text3">
12700
12908
  <text><xsl:for-each select="xalan:nodeset($text2)/text/node()">
@@ -12716,7 +12924,8 @@
12716
12924
  <xsl:choose>
12717
12925
  <xsl:when test="ancestor::*[local-name() = 'td' or local-name() = 'th']">
12718
12926
  <!-- keep-together_within-line for: a.b, aaa.b, a.bbb, .b in table's cell ONLY -->
12719
- <xsl:variable name="regex_dots_units">((\b((\S{1,3}\.\S+)|(\S+\.\S{1,3}))\b)|(\.\S{1,3})\b)</xsl:variable>
12927
+ <xsl:variable name="non_white_space">[^\s\u3000-\u9FFF]</xsl:variable>
12928
+ <xsl:variable name="regex_dots_units">((\b((<xsl:value-of select="$non_white_space"/>{1,3}\.<xsl:value-of select="$non_white_space"/>+)|(<xsl:value-of select="$non_white_space"/>+\.<xsl:value-of select="$non_white_space"/>{1,3}))\b)|(\.<xsl:value-of select="$non_white_space"/>{1,3})\b)</xsl:variable>
12720
12929
  <xsl:for-each select="xalan:nodeset($text3)/text/node()">
12721
12930
  <xsl:choose>
12722
12931
  <xsl:when test="self::text()">
@@ -12737,6 +12946,10 @@
12737
12946
 
12738
12947
  </xsl:template>
12739
12948
 
12949
+ <xsl:template match="*[local-name() = 'stem'] | *[local-name() = 'image']" mode="update_xml_enclose_keep-together_within-line">
12950
+ <xsl:copy-of select="."/>
12951
+ </xsl:template>
12952
+
12740
12953
  <xsl:template name="replace_text_tags">
12741
12954
  <xsl:param name="tag_open"/>
12742
12955
  <xsl:param name="tag_close"/>
@@ -12763,6 +12976,194 @@
12763
12976
  <!-- END XML UPDATE STEP: enclose standard's name into tag 'keep-together_within-line' -->
12764
12977
  <!-- ===================================== -->
12765
12978
 
12979
+ <!-- ===================================== -->
12980
+ <!-- ===================================== -->
12981
+ <!-- Make linear XML (need for landscape orientation) -->
12982
+ <!-- ===================================== -->
12983
+ <!-- ===================================== -->
12984
+ <xsl:template match="@*|node()" mode="linear_xml">
12985
+ <xsl:copy>
12986
+ <xsl:apply-templates select="@*|node()" mode="linear_xml"/>
12987
+ </xsl:copy>
12988
+ </xsl:template>
12989
+
12990
+ <xsl:template match="processing-instruction()" mode="linear_xml">
12991
+ <xsl:copy-of select="."/>
12992
+ </xsl:template>
12993
+
12994
+ <!-- From:
12995
+ <clause>
12996
+ <title>...</title>
12997
+ <p>...</p>
12998
+ </clause>
12999
+ To:
13000
+ <clause/>
13001
+ <title>...</title>
13002
+ <p>...</p>
13003
+ -->
13004
+ <xsl:template match="*[local-name() = 'foreword'] | *[local-name() = 'foreword']//*[local-name() = 'clause'] | *[local-name() = 'preface']//*[local-name() = 'clause'][not(@type = 'corrigenda') and not(@type = 'policy') and not(@type = 'related-refs')] | *[local-name() = 'introduction'] | *[local-name() = 'introduction']//*[local-name() = 'clause'] | *[local-name() = 'sections']//*[local-name() = 'clause'] | *[local-name() = 'annex'] | *[local-name() = 'annex']//*[local-name() = 'clause'] | *[local-name() = 'references'][not(@hidden = 'true')] | *[local-name() = 'bibliography']/*[local-name() = 'clause'] | *[local-name() = 'colophon'] | *[local-name() = 'colophon']//*[local-name() = 'clause'] | *[local-name()='sections']//*[local-name()='terms'] | *[local-name()='sections']//*[local-name()='definitions'] | *[local-name()='annex']//*[local-name()='definitions']" mode="linear_xml" name="clause_linear">
13005
+
13006
+ <xsl:copy>
13007
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
13008
+
13009
+ <xsl:attribute name="keep-with-next">always</xsl:attribute>
13010
+
13011
+ <xsl:if test="local-name() = 'foreword' or local-name() = 'introduction' or local-name(..) = 'preface' or local-name(..) = 'sections' or (local-name() = 'references' and parent::*[local-name() = 'bibliography']) or (local-name() = 'clause' and parent::*[local-name() = 'bibliography']) or local-name() = 'annex' or local-name(..) = 'annex' or local-name(..) = 'colophon'">
13012
+ <xsl:attribute name="mainsection">true</xsl:attribute>
13013
+ </xsl:if>
13014
+ </xsl:copy>
13015
+
13016
+ <xsl:apply-templates mode="linear_xml"/>
13017
+ </xsl:template>
13018
+
13019
+ <xsl:template match="*[local-name() = 'term']" mode="linear_xml" priority="2">
13020
+ <xsl:copy>
13021
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
13022
+ <xsl:attribute name="keep-with-next">always</xsl:attribute>
13023
+ <xsl:variable name="level">
13024
+ <xsl:call-template name="getLevel"/>
13025
+ </xsl:variable>
13026
+ <xsl:attribute name="depth"><xsl:value-of select="$level"/></xsl:attribute>
13027
+ <xsl:attribute name="ancestor">sections</xsl:attribute>
13028
+ <xsl:apply-templates select="node()[not(local-name() = 'term')]" mode="linear_xml"/>
13029
+ </xsl:copy>
13030
+ <xsl:apply-templates select="*[local-name() = 'term']" mode="linear_xml"/>
13031
+ </xsl:template>
13032
+
13033
+ <xsl:template match="*[local-name() = 'introduction']//*[local-name() = 'title'] | *[local-name() = 'foreword']//*[local-name() = 'title'] | *[local-name() = 'sections']//*[local-name() = 'title'] | *[local-name() = 'annex']//*[local-name() = 'title'] | *[local-name() = 'bibliography']/*[local-name() = 'clause']/*[local-name() = 'title'] | *[local-name() = 'references']/*[local-name() = 'title'] | *[local-name() = 'colophon']//*[local-name() = 'title']" mode="linear_xml" priority="2">
13034
+ <xsl:copy>
13035
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
13036
+
13037
+ <xsl:attribute name="keep-with-next">always</xsl:attribute>
13038
+
13039
+ <xsl:variable name="level">
13040
+ <xsl:call-template name="getLevel"/>
13041
+ </xsl:variable>
13042
+ <xsl:attribute name="depth"><xsl:value-of select="$level"/></xsl:attribute>
13043
+
13044
+ <xsl:if test="parent::*[local-name() = 'annex']">
13045
+ <xsl:attribute name="depth">1</xsl:attribute>
13046
+ </xsl:if>
13047
+
13048
+ <xsl:if test="../@inline-header = 'true' and following-sibling::*[1][local-name() = 'p']">
13049
+ <xsl:copy-of select="../@inline-header"/>
13050
+ </xsl:if>
13051
+
13052
+ <xsl:attribute name="ancestor">
13053
+ <xsl:choose>
13054
+ <xsl:when test="ancestor::*[local-name() = 'foreword']">foreword</xsl:when>
13055
+ <xsl:when test="ancestor::*[local-name() = 'introduction']">introduction</xsl:when>
13056
+ <xsl:when test="ancestor::*[local-name() = 'sections']">sections</xsl:when>
13057
+ <xsl:when test="ancestor::*[local-name() = 'annex']">annex</xsl:when>
13058
+ <xsl:when test="ancestor::*[local-name() = 'bibliography']">bibliography</xsl:when>
13059
+ </xsl:choose>
13060
+ </xsl:attribute>
13061
+
13062
+ <xsl:apply-templates mode="linear_xml"/>
13063
+ </xsl:copy>
13064
+ </xsl:template>
13065
+
13066
+ <!-- add @to = figure, table, clause -->
13067
+ <!-- add @depth = from -->
13068
+ <xsl:template match="*[local-name() = 'xref']" mode="linear_xml">
13069
+ <xsl:copy>
13070
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
13071
+ <xsl:variable name="target" select="@target"/>
13072
+ <xsl:attribute name="to">
13073
+ <xsl:value-of select="local-name(//*[@id = current()/@target][1])"/>
13074
+ </xsl:attribute>
13075
+ <xsl:attribute name="depth">
13076
+ <xsl:value-of select="//*[@id = current()/@target][1]/*[local-name() = 'title']/@depth"/>
13077
+ </xsl:attribute>
13078
+ <xsl:apply-templates select="node()" mode="linear_xml"/>
13079
+ </xsl:copy>
13080
+ </xsl:template>
13081
+
13082
+ <xsl:template match="*[not(ancestor::*[local-name() = 'sourcecode'])]/*[local-name() = 'p' or local-name() = 'strong' or local-name() = 'em']/text()" mode="linear_xml">
13083
+ <xsl:choose>
13084
+ <xsl:when test="contains(., $non_breaking_hyphen)">
13085
+ <xsl:call-template name="replaceChar">
13086
+ <xsl:with-param name="text" select="."/>
13087
+ <xsl:with-param name="replace" select="$non_breaking_hyphen"/>
13088
+ <xsl:with-param name="by" select="'-'"/>
13089
+ </xsl:call-template>
13090
+ </xsl:when>
13091
+ <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
13092
+ </xsl:choose>
13093
+ </xsl:template>
13094
+
13095
+ <xsl:template name="replaceChar">
13096
+ <xsl:param name="text"/>
13097
+ <xsl:param name="replace"/>
13098
+ <xsl:param name="by"/>
13099
+ <xsl:choose>
13100
+ <xsl:when test="$text = '' or $replace = '' or not($replace)">
13101
+ <xsl:value-of select="$text"/>
13102
+ </xsl:when>
13103
+ <xsl:when test="contains($text, $replace)">
13104
+ <xsl:value-of select="substring-before($text,$replace)"/>
13105
+ <xsl:element name="inlineChar" namespace="https://www.metanorma.org/ns/jis"><xsl:value-of select="$by"/></xsl:element>
13106
+ <xsl:call-template name="replaceChar">
13107
+ <xsl:with-param name="text" select="substring-after($text,$replace)"/>
13108
+ <xsl:with-param name="replace" select="$replace"/>
13109
+ <xsl:with-param name="by" select="$by"/>
13110
+ </xsl:call-template>
13111
+ </xsl:when>
13112
+ <xsl:otherwise>
13113
+ <xsl:value-of select="$text"/>
13114
+ </xsl:otherwise>
13115
+ </xsl:choose>
13116
+ </xsl:template>
13117
+
13118
+ <xsl:template match="*[local-name() = 'inlineChar']">
13119
+ <fo:inline><xsl:value-of select="."/></fo:inline>
13120
+ </xsl:template>
13121
+
13122
+ <!-- change @reference to actual value, and add skip_footnote_body="true" for repeatable (2nd, 3rd, ...) -->
13123
+ <!--
13124
+ <fn reference="1">
13125
+ <p id="_8e5cf917-f75a-4a49-b0aa-1714cb6cf954">Formerly denoted as 15 % (m/m).</p>
13126
+ </fn>
13127
+ -->
13128
+ <xsl:template match="*[local-name() = 'fn'][not(ancestor::*[(local-name() = 'table' or local-name() = 'figure')] and not(ancestor::*[local-name() = 'name']))]" mode="linear_xml" name="linear_xml_fn">
13129
+ <xsl:variable name="p_fn_">
13130
+ <xsl:call-template name="get_fn_list"/>
13131
+ </xsl:variable>
13132
+ <xsl:variable name="p_fn" select="xalan:nodeset($p_fn_)"/>
13133
+ <xsl:variable name="gen_id" select="generate-id(.)"/>
13134
+ <xsl:variable name="lang" select="ancestor::*[contains(local-name(), '-standard')]/*[local-name()='bibdata']//*[local-name()='language'][@current = 'true']"/>
13135
+ <xsl:variable name="reference" select="@reference"/>
13136
+ <!-- fn sequence number in document -->
13137
+ <xsl:variable name="current_fn_number" select="count($p_fn//fn[@reference = $reference]/preceding-sibling::fn) + 1"/>
13138
+
13139
+ <xsl:copy>
13140
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
13141
+ <!-- put actual reference number -->
13142
+ <xsl:attribute name="current_fn_number">
13143
+ <xsl:value-of select="$current_fn_number"/>
13144
+ </xsl:attribute>
13145
+ <xsl:attribute name="skip_footnote_body"> <!-- false for repeatable footnote -->
13146
+ <xsl:value-of select="not($p_fn//fn[@gen_id = $gen_id] and (1 = 1))"/>
13147
+ </xsl:attribute>
13148
+ <xsl:apply-templates select="node()" mode="linear_xml"/>
13149
+ </xsl:copy>
13150
+ </xsl:template>
13151
+
13152
+ <xsl:template match="*[local-name() = 'p'][@type = 'section-title']" priority="3" mode="linear_xml">
13153
+ <xsl:copy>
13154
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
13155
+ <xsl:if test="@depth = '1'">
13156
+ <xsl:attribute name="mainsection">true</xsl:attribute>
13157
+ </xsl:if>
13158
+ <xsl:apply-templates select="node()" mode="linear_xml"/>
13159
+ </xsl:copy>
13160
+ </xsl:template>
13161
+ <!-- ===================================== -->
13162
+ <!-- ===================================== -->
13163
+ <!-- END: Make linear XML (need for landscape orientation) -->
13164
+ <!-- ===================================== -->
13165
+ <!-- ===================================== -->
13166
+
12766
13167
  <!-- for correct rendering combining chars -->
12767
13168
  <xsl:template match="*[local-name() = 'lang_none']">
12768
13169
  <fo:inline xml:lang="none"><xsl:value-of select="."/></fo:inline>
@@ -13317,6 +13718,23 @@
13317
13718
  </xsl:if>
13318
13719
  </xsl:template>
13319
13720
 
13721
+ <xsl:template name="setBlockAttributes">
13722
+ <xsl:param name="text_align_default">left</xsl:param>
13723
+ <xsl:call-template name="setTextAlignment">
13724
+ <xsl:with-param name="default" select="$text_align_default"/>
13725
+ </xsl:call-template>
13726
+
13727
+ <!-- https://www.metanorma.org/author/topics/document-format/text/#avoiding-page-breaks -->
13728
+ <!-- Example: keep-lines-together="true" -->
13729
+ <xsl:if test="@keep-lines-together = 'true'">
13730
+ <xsl:attribute name="keep-together.within-column">always</xsl:attribute>
13731
+ </xsl:if>
13732
+ <!-- Example: keep-with-next="true" -->
13733
+ <xsl:if test="@keep-with-next = 'true'">
13734
+ <xsl:attribute name="keep-with-next">always</xsl:attribute>
13735
+ </xsl:if>
13736
+ </xsl:template>
13737
+
13320
13738
  <xsl:template name="number-to-words">
13321
13739
  <xsl:param name="number"/>
13322
13740
  <xsl:param name="first"/>