metanorma-bipm 2.2.6 → 2.2.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -2363,11 +2363,17 @@
2363
2363
  <!-- ========================== -->
2364
2364
  <!-- Definition's list styles -->
2365
2365
  <!-- ========================== -->
2366
+
2367
+ <xsl:attribute-set name="dl-block-style">
2368
+
2369
+ </xsl:attribute-set>
2370
+
2366
2371
  <xsl:attribute-set name="dt-row-style">
2367
2372
 
2368
2373
  </xsl:attribute-set>
2369
2374
 
2370
2375
  <xsl:attribute-set name="dt-cell-style">
2376
+
2371
2377
  </xsl:attribute-set>
2372
2378
 
2373
2379
  <xsl:attribute-set name="dt-block-style">
@@ -2385,6 +2391,7 @@
2385
2391
 
2386
2392
  <xsl:attribute-set name="dd-cell-style">
2387
2393
  <xsl:attribute name="padding-left">2mm</xsl:attribute>
2394
+
2388
2395
  </xsl:attribute-set>
2389
2396
 
2390
2397
  <!-- ========================== -->
@@ -2504,6 +2511,7 @@
2504
2511
  <xsl:attribute-set name="term-name-style">
2505
2512
  <xsl:attribute name="keep-with-next">always</xsl:attribute>
2506
2513
  <xsl:attribute name="font-weight">bold</xsl:attribute>
2514
+
2507
2515
  </xsl:attribute-set>
2508
2516
 
2509
2517
  <xsl:attribute-set name="figure-block-style">
@@ -2526,6 +2534,10 @@
2526
2534
 
2527
2535
  </xsl:attribute-set>
2528
2536
 
2537
+ <xsl:attribute-set name="figure-source-style">
2538
+
2539
+ </xsl:attribute-set>
2540
+
2529
2541
  <!-- Formula's styles -->
2530
2542
  <xsl:attribute-set name="formula-style">
2531
2543
  <xsl:attribute name="margin-top">6pt</xsl:attribute>
@@ -3065,7 +3077,7 @@
3065
3077
 
3066
3078
  <xsl:template name="processTables_Contents">
3067
3079
  <tables>
3068
- <xsl:for-each select="//*[local-name() = 'table'][@id and *[local-name() = 'name'] and normalize-space(@id) != '']">
3080
+ <xsl:for-each select="//*[local-name() = 'table'][not(ancestor::*[local-name() = 'metanorma-extension'])][@id and *[local-name() = 'name'] and normalize-space(@id) != '']">
3069
3081
  <table id="{@id}" alt-text="{*[local-name() = 'name']}">
3070
3082
  <xsl:copy-of select="*[local-name() = 'name']"/>
3071
3083
  </table>
@@ -3409,7 +3421,7 @@
3409
3421
  </xsl:attribute>
3410
3422
  </xsl:for-each>
3411
3423
 
3412
- <xsl:variable name="isNoteOrFnExist" select="./*[local-name()='note'] or .//*[local-name()='fn'][local-name(..) != 'name']"/>
3424
+ <xsl:variable name="isNoteOrFnExist" select="./*[local-name()='note'] or .//*[local-name()='fn'][local-name(..) != 'name'] or ./*[local-name()='source']"/>
3413
3425
  <xsl:if test="$isNoteOrFnExist = 'true'">
3414
3426
  <xsl:attribute name="border-bottom">0pt solid black</xsl:attribute> <!-- set 0pt border, because there is a separete table below for footer -->
3415
3427
  </xsl:if>
@@ -3453,7 +3465,7 @@
3453
3465
  <xsl:apply-templates select="*[local-name()='thead']" mode="process_tbody"/>
3454
3466
  </xsl:when>
3455
3467
  <xsl:otherwise>
3456
- <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 -->
3468
+ <xsl:apply-templates select="node()[not(local-name() = 'name') and not(local-name() = 'note') and not(local-name() = 'dl') and not(local-name() = 'source') and not(local-name() = 'thead') and not(local-name() = 'tfoot')]"/> <!-- process all table' elements, except name, header, footer, note, source and dl which render separaterely -->
3457
3469
  </xsl:otherwise>
3458
3470
  </xsl:choose>
3459
3471
 
@@ -3559,6 +3571,11 @@
3559
3571
  </xsl:if>
3560
3572
  </xsl:template> <!-- table/name -->
3561
3573
 
3574
+ <!-- SOURCE: ... -->
3575
+ <xsl:template match="*[local-name()='table']/*[local-name() = 'source']" priority="2">
3576
+ <xsl:call-template name="termsource"/>
3577
+ </xsl:template>
3578
+
3562
3579
  <xsl:template name="calculate-columns-numbers">
3563
3580
  <xsl:param name="table-row"/>
3564
3581
  <xsl:variable name="columns-count" select="count($table-row/*)"/>
@@ -3919,7 +3936,7 @@
3919
3936
  </fo:table-header>
3920
3937
  </xsl:template> <!-- thead -->
3921
3938
 
3922
- <!-- template is using for iso, jcgm, bsi only -->
3939
+ <!-- template is using for iec, iso, jcgm, bsi only -->
3923
3940
  <xsl:template name="table-header-title">
3924
3941
  <xsl:param name="cols-count"/>
3925
3942
  <!-- row for title -->
@@ -3971,7 +3988,7 @@
3971
3988
  <xsl:param name="colwidths"/>
3972
3989
  <xsl:param name="colgroup"/>
3973
3990
 
3974
- <xsl:variable name="isNoteOrFnExist" select="../*[local-name()='note'] or ..//*[local-name()='fn'][local-name(..) != 'name']"/>
3991
+ <xsl:variable name="isNoteOrFnExist" select="../*[local-name()='note'] or ../*[local-name()='dl'] or ..//*[local-name()='fn'][local-name(..) != 'name'] or ../*[local-name()='source']"/>
3975
3992
 
3976
3993
  <xsl:variable name="isNoteOrFnExistShowAfterTable">
3977
3994
 
@@ -4039,7 +4056,9 @@
4039
4056
 
4040
4057
  <!-- except gb and bsi -->
4041
4058
 
4059
+ <xsl:apply-templates select="../*[local-name()='dl']"/>
4042
4060
  <xsl:apply-templates select="../*[local-name()='note']"/>
4061
+ <xsl:apply-templates select="../*[local-name()='source']"/>
4043
4062
 
4044
4063
  <xsl:variable name="isDisplayRowSeparator">
4045
4064
 
@@ -4205,7 +4224,7 @@
4205
4224
  <!-- ===================== -->
4206
4225
  <!-- Table's row processing -->
4207
4226
  <!-- ===================== -->
4208
- <!-- row in table header (thead) -->
4227
+ <!-- row in table header (thead) thead/tr -->
4209
4228
  <xsl:template match="*[local-name()='thead']/*[local-name()='tr']" priority="2">
4210
4229
  <fo:table-row xsl:use-attribute-sets="table-header-row-style">
4211
4230
 
@@ -4250,7 +4269,7 @@
4250
4269
  </xsl:choose>
4251
4270
  </xsl:template>
4252
4271
 
4253
- <!-- row in table footer (tfoot) -->
4272
+ <!-- row in table footer (tfoot), tfoot/tr -->
4254
4273
  <xsl:template match="*[local-name()='tfoot']/*[local-name()='tr']" priority="2">
4255
4274
  <fo:table-row xsl:use-attribute-sets="table-footer-row-style">
4256
4275
 
@@ -4736,12 +4755,26 @@
4736
4755
  <xsl:variable name="isAdded" select="@added"/>
4737
4756
  <xsl:variable name="isDeleted" select="@deleted"/>
4738
4757
  <!-- <dl><xsl:copy-of select="."/></dl> -->
4739
- <fo:block-container>
4758
+ <fo:block-container xsl:use-attribute-sets="dl-block-style">
4759
+
4760
+ <xsl:call-template name="setBlockSpanAll"/>
4740
4761
 
4741
4762
  <xsl:if test="not(ancestor::*[local-name() = 'quote'])">
4742
4763
  <xsl:attribute name="margin-left">0mm</xsl:attribute>
4743
4764
  </xsl:if>
4744
4765
 
4766
+ <xsl:if test="ancestor::*[local-name() = 'sourcecode']">
4767
+ <!-- set font-size as sourcecode font-size -->
4768
+ <xsl:variable name="sourcecode_attributes">
4769
+ <xsl:call-template name="get_sourcecode_attributes"/>
4770
+ </xsl:variable>
4771
+ <xsl:for-each select="xalan:nodeset($sourcecode_attributes)/sourcecode_attributes/@font-size">
4772
+ <xsl:attribute name="{local-name()}">
4773
+ <xsl:value-of select="."/>
4774
+ </xsl:attribute>
4775
+ </xsl:for-each>
4776
+ </xsl:if>
4777
+
4745
4778
  <xsl:if test="parent::*[local-name() = 'note']">
4746
4779
  <xsl:attribute name="margin-left">
4747
4780
  <xsl:choose>
@@ -5189,6 +5222,7 @@
5189
5222
  <xsl:param name="split_keep-within-line"/>
5190
5223
 
5191
5224
  <fo:table-row xsl:use-attribute-sets="dt-row-style">
5225
+
5192
5226
  <xsl:call-template name="insert_dt_cell">
5193
5227
  <xsl:with-param name="key_iso" select="$key_iso"/>
5194
5228
  <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
@@ -5210,6 +5244,7 @@
5210
5244
  <!-- border is mandatory, to calculate real width -->
5211
5245
  <xsl:attribute name="border">0.1pt solid black</xsl:attribute>
5212
5246
  <xsl:attribute name="text-align">left</xsl:attribute>
5247
+
5213
5248
  </xsl:if>
5214
5249
 
5215
5250
  <fo:block xsl:use-attribute-sets="dt-block-style">
@@ -5655,6 +5690,7 @@
5655
5690
  <fo:inline>
5656
5691
  <xsl:for-each select="$styles/style">
5657
5692
  <xsl:attribute name="{@name}"><xsl:value-of select="."/></xsl:attribute>
5693
+
5658
5694
  </xsl:for-each>
5659
5695
  <xsl:apply-templates/>
5660
5696
  </fo:inline>
@@ -6824,13 +6860,17 @@
6824
6860
  </xsl:template>
6825
6861
 
6826
6862
  <xsl:template match="*[local-name() = 'callout']">
6827
- <fo:basic-link internal-destination="{@target}" fox:alt-text="{@target}">&lt;<xsl:apply-templates/>&gt;</fo:basic-link>
6863
+ <xsl:choose>
6864
+ <xsl:when test="normalize-space(@target) = ''">&lt;<xsl:apply-templates/>&gt;</xsl:when>
6865
+ <xsl:otherwise><fo:basic-link internal-destination="{@target}" fox:alt-text="{@target}">&lt;<xsl:apply-templates/>&gt;</fo:basic-link></xsl:otherwise>
6866
+ </xsl:choose>
6828
6867
  </xsl:template>
6829
6868
 
6830
6869
  <xsl:template match="*[local-name() = 'annotation']">
6831
6870
  <xsl:variable name="annotation-id" select="@id"/>
6832
6871
  <xsl:variable name="callout" select="//*[@target = $annotation-id]/text()"/>
6833
6872
  <fo:block id="{$annotation-id}" white-space="nowrap">
6873
+
6834
6874
  <fo:inline>
6835
6875
  <xsl:apply-templates>
6836
6876
  <xsl:with-param name="callout" select="concat('&lt;', $callout, '&gt; ')"/>
@@ -6935,6 +6975,10 @@
6935
6975
  <!-- ====== -->
6936
6976
  <!-- ====== -->
6937
6977
 
6978
+ <xsl:template name="setBlockSpanAll">
6979
+ <xsl:if test="@columns = 1 or (local-name() = 'p' and *[@columns = 1])"><xsl:attribute name="span">all</xsl:attribute></xsl:if>
6980
+ </xsl:template>
6981
+
6938
6982
  <!-- ====== -->
6939
6983
  <!-- note -->
6940
6984
  <!-- termnote -->
@@ -6944,6 +6988,8 @@
6944
6988
 
6945
6989
  <fo:block-container id="{@id}" xsl:use-attribute-sets="note-style">
6946
6990
 
6991
+ <xsl:call-template name="setBlockSpanAll"/>
6992
+
6947
6993
  <fo:block-container margin-left="0mm" margin-right="0mm">
6948
6994
 
6949
6995
  <fo:block>
@@ -6994,6 +7040,8 @@
6994
7040
  <xsl:template match="*[local-name() = 'termnote']">
6995
7041
  <fo:block id="{@id}" xsl:use-attribute-sets="termnote-style">
6996
7042
 
7043
+ <xsl:call-template name="setBlockSpanAll"/>
7044
+
6997
7045
  <fo:inline xsl:use-attribute-sets="termnote-name-style">
6998
7046
 
6999
7047
  <xsl:if test="not(*[local-name() = 'name']/following-sibling::node()[1][self::text()][normalize-space()=''])">
@@ -7149,6 +7197,13 @@
7149
7197
  </fo:block>
7150
7198
  </xsl:template>
7151
7199
 
7200
+ <!-- SOURCE: ... -->
7201
+ <xsl:template match="*[local-name() = 'figure']/*[local-name() = 'source']" priority="2">
7202
+
7203
+ <xsl:call-template name="termsource"/>
7204
+
7205
+ </xsl:template>
7206
+
7152
7207
  <xsl:template match="*[local-name() = 'image']">
7153
7208
  <xsl:variable name="isAdded" select="../@added"/>
7154
7209
  <xsl:variable name="isDeleted" select="../@deleted"/>
@@ -8279,9 +8334,11 @@
8279
8334
  <xsl:attribute name="margin-bottom">0pt</xsl:attribute>
8280
8335
  </xsl:if>
8281
8336
 
8282
- <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
8337
+ <xsl:apply-templates select="node()[not(local-name() = 'name' or local-name() = 'dl')]"/>
8283
8338
  </fo:block>
8284
8339
 
8340
+ <xsl:apply-templates select="*[local-name() = 'dl']"/> <!-- Key table -->
8341
+
8285
8342
  <xsl:apply-templates select="*[local-name()='name']"/> <!-- show sourcecode's name AFTER content -->
8286
8343
 
8287
8344
  </fo:block-container>
@@ -8313,11 +8370,22 @@
8313
8370
  <!-- add sourcecode highlighting -->
8314
8371
  <xsl:template match="*[local-name()='sourcecode']//*[local-name()='span'][@class]" priority="2">
8315
8372
  <xsl:variable name="class" select="@class"/>
8373
+
8374
+ <!-- Example: <1> -->
8375
+ <xsl:variable name="is_callout">
8376
+ <xsl:if test="parent::*[local-name() = 'dt']">
8377
+ <xsl:variable name="dt_id" select="../@id"/>
8378
+ <xsl:if test="ancestor::*[local-name() = 'sourcecode']//*[local-name() = 'callout'][@target = $dt_id]">true</xsl:if>
8379
+ </xsl:if>
8380
+ </xsl:variable>
8381
+
8316
8382
  <xsl:choose>
8317
8383
  <xsl:when test="$sourcecode_css//class[@name = $class]">
8318
8384
  <fo:inline>
8319
8385
  <xsl:apply-templates select="$sourcecode_css//class[@name = $class]" mode="css"/>
8386
+ <xsl:if test="$is_callout = 'true'">&lt;</xsl:if>
8320
8387
  <xsl:apply-templates/>
8388
+ <xsl:if test="$is_callout = 'true'">&gt;</xsl:if>
8321
8389
  </fo:inline>
8322
8390
  </xsl:when>
8323
8391
  <xsl:otherwise>
@@ -8741,6 +8809,10 @@
8741
8809
  </fo:block>
8742
8810
  </xsl:template>
8743
8811
 
8812
+ <xsl:template match="*[local-name() = 'div']">
8813
+ <fo:block><xsl:apply-templates/></fo:block>
8814
+ </xsl:template>
8815
+
8744
8816
  <xsl:template match="*[local-name() = 'inherit'] | *[local-name() = 'component'][@class = 'inherit'] | *[local-name() = 'div'][@type = 'requirement-inherit'] | *[local-name() = 'div'][@type = 'recommendation-inherit'] | *[local-name() = 'div'][@type = 'permission-inherit']">
8745
8817
  <fo:block xsl:use-attribute-sets="inherit-style">
8746
8818
  <xsl:text>Dependency </xsl:text><xsl:apply-templates/>
@@ -8904,6 +8976,9 @@
8904
8976
  <!-- ====== -->
8905
8977
  <xsl:template match="*[local-name() = 'termexample']">
8906
8978
  <fo:block id="{@id}" xsl:use-attribute-sets="termexample-style">
8979
+
8980
+ <xsl:call-template name="setBlockSpanAll"/>
8981
+
8907
8982
  <xsl:apply-templates select="*[local-name()='name']"/>
8908
8983
  <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
8909
8984
  </fo:block>
@@ -8955,6 +9030,8 @@
8955
9030
 
8956
9031
  <fo:block-container id="{@id}" xsl:use-attribute-sets="example-style">
8957
9032
 
9033
+ <xsl:call-template name="setBlockSpanAll"/>
9034
+
8958
9035
  <xsl:variable name="fo_element">
8959
9036
  <xsl:if test=".//*[local-name() = 'table'] or .//*[local-name() = 'dl'] or *[not(local-name() = 'name')][1][local-name() = 'sourcecode']">block</xsl:if>
8960
9037
  inline
@@ -8982,6 +9059,35 @@
8982
9059
  </fo:block-container>
8983
9060
  </xsl:when> <!-- end block -->
8984
9061
 
9062
+ <xsl:when test="contains(normalize-space($fo_element), 'list')">
9063
+
9064
+ <xsl:variable name="provisional_distance_between_starts">
9065
+ 7
9066
+ </xsl:variable>
9067
+ <xsl:variable name="indent">
9068
+ 0
9069
+ </xsl:variable>
9070
+
9071
+ <fo:list-block provisional-distance-between-starts="{$provisional_distance_between_starts}mm">
9072
+ <fo:list-item>
9073
+ <fo:list-item-label start-indent="{$indent}mm" end-indent="label-end()">
9074
+ <fo:block>
9075
+ <xsl:apply-templates select="*[local-name()='name']">
9076
+ <xsl:with-param name="fo_element">block</xsl:with-param>
9077
+ </xsl:apply-templates>
9078
+ </fo:block>
9079
+ </fo:list-item-label>
9080
+ <fo:list-item-body start-indent="body-start()">
9081
+ <fo:block>
9082
+ <xsl:apply-templates select="node()[not(local-name() = 'name')]">
9083
+ <xsl:with-param name="fo_element" select="$fo_element"/>
9084
+ </xsl:apply-templates>
9085
+ </fo:block>
9086
+ </fo:list-item-body>
9087
+ </fo:list-item>
9088
+ </fo:list-block>
9089
+ </xsl:when> <!-- end list -->
9090
+
8985
9091
  <xsl:otherwise> <!-- inline -->
8986
9092
 
8987
9093
  <!-- display 'EXAMPLE' and first element in the same line -->
@@ -9062,6 +9168,11 @@
9062
9168
  </fo:block>
9063
9169
  </fo:block-container>
9064
9170
  </xsl:when>
9171
+ <xsl:when test="starts-with(normalize-space($element), 'list')">
9172
+ <fo:block xsl:use-attribute-sets="example-p-style">
9173
+ <xsl:apply-templates/>
9174
+ </fo:block>
9175
+ </xsl:when>
9065
9176
  <xsl:otherwise>
9066
9177
  <fo:inline xsl:use-attribute-sets="example-p-style">
9067
9178
  <xsl:apply-templates/>
@@ -9179,6 +9290,9 @@
9179
9290
  <!-- ====== -->
9180
9291
  <xsl:template match="*[local-name() = 'quote']">
9181
9292
  <fo:block-container margin-left="0mm">
9293
+
9294
+ <xsl:call-template name="setBlockSpanAll"/>
9295
+
9182
9296
  <xsl:if test="parent::*[local-name() = 'note']">
9183
9297
  <xsl:if test="not(ancestor::*[local-name() = 'table'])">
9184
9298
  <xsl:attribute name="margin-left">5mm</xsl:attribute>
@@ -9405,13 +9519,8 @@
9405
9519
  </xsl:template>
9406
9520
 
9407
9521
  <xsl:template match="*[local-name() = 'deprecates']">
9408
- <xsl:variable name="title-deprecated">
9409
- <xsl:call-template name="getLocalizedString">
9410
- <xsl:with-param name="key">deprecated</xsl:with-param>
9411
- </xsl:call-template>
9412
- </xsl:variable>
9413
9522
  <fo:block xsl:use-attribute-sets="deprecates-style">
9414
- <xsl:value-of select="$title-deprecated"/>: <xsl:apply-templates/>
9523
+ <xsl:apply-templates/>
9415
9524
  </fo:block>
9416
9525
  </xsl:template>
9417
9526
 
@@ -9476,6 +9585,8 @@
9476
9585
  <fo:block>
9477
9586
  <xsl:call-template name="setId"/>
9478
9587
 
9588
+ <xsl:call-template name="setBlockSpanAll"/>
9589
+
9479
9590
  <xsl:if test="@inline-header='true'">
9480
9591
  <xsl:attribute name="text-align">justify</xsl:attribute>
9481
9592
  </xsl:if>
@@ -9494,6 +9605,8 @@
9494
9605
  <fo:block break-after="page"/>
9495
9606
  <fo:block id="{@id}">
9496
9607
 
9608
+ <xsl:call-template name="setBlockSpanAll"/>
9609
+
9497
9610
  </fo:block>
9498
9611
  <xsl:apply-templates/>
9499
9612
  </xsl:template>
@@ -9532,6 +9645,8 @@
9532
9645
  <label level="2">−</label><!-- minus sign -->
9533
9646
  <label level="3" font-size="75%">o</label> <!-- white circle -->
9534
9647
 
9648
+ <label>-</label> <!-- full-width hyphen minus -->
9649
+
9535
9650
  </xsl:variable>
9536
9651
  <xsl:variable name="ul_labels" select="xalan:nodeset($ul_labels_)"/>
9537
9652
 
@@ -10450,6 +10565,8 @@
10450
10565
 
10451
10566
  <fo:block xsl:use-attribute-sets="admonition-style">
10452
10567
 
10568
+ <xsl:call-template name="setBlockSpanAll"/>
10569
+
10453
10570
  <xsl:if test="@type = 'editorial'">
10454
10571
  <xsl:attribute name="color">green</xsl:attribute>
10455
10572
  <xsl:attribute name="font-weight">normal</xsl:attribute>
@@ -10633,6 +10750,33 @@
10633
10750
  <xsl:apply-templates mode="update_xml_step1"/>
10634
10751
  </xsl:copy>
10635
10752
  </xsl:template>
10753
+
10754
+ <!-- remove semantic xml -->
10755
+ <xsl:template match="*[local-name() = 'metanorma-extension']/*[local-name() = 'metanorma']/*[local-name() = 'source']" mode="update_xml_step1"/>
10756
+
10757
+ <!-- remove image/emf -->
10758
+ <xsl:template match="*[local-name() = 'image']/*[local-name() = 'emf']" mode="update_xml_step1"/>
10759
+
10760
+ <xsl:template match="*[local-name() = 'stem'] | *[local-name() = 'image']" mode="update_xml_step1">
10761
+ <xsl:copy-of select="."/>
10762
+ </xsl:template>
10763
+
10764
+ <!-- add @id, redundant for table auto-layout algorithm -->
10765
+ <xsl:template match="*[local-name() = 'dl' or local-name() = 'table'][not(@id)]" mode="update_xml_step1">
10766
+ <xsl:copy>
10767
+ <xsl:copy-of select="@*"/>
10768
+ <xsl:call-template name="add_id"/>
10769
+ <xsl:apply-templates mode="update_xml_step1"/>
10770
+ </xsl:copy>
10771
+ </xsl:template>
10772
+
10773
+ <xsl:template name="add_id">
10774
+ <xsl:if test="not(@id)">
10775
+ <!-- add @id - first element with @id plus '_element_name' -->
10776
+ <xsl:attribute name="id"><xsl:value-of select="(.//*[@id])[1]/@id"/>_<xsl:value-of select="local-name()"/></xsl:attribute>
10777
+ </xsl:if>
10778
+ </xsl:template>
10779
+
10636
10780
  <!-- =========================================================================== -->
10637
10781
  <!-- END STEP1: Re-order elements in 'preface', 'sections' based on @displayorder -->
10638
10782
  <!-- =========================================================================== -->
@@ -10654,7 +10798,7 @@
10654
10798
 
10655
10799
  <xsl:variable name="element_name_keep-together_within-line">keep-together_within-line</xsl:variable>
10656
10800
 
10657
- <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">
10801
+ <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">
10658
10802
 
10659
10803
  <!-- enclose standard's number into tag 'keep-together_within-line' -->
10660
10804
  <xsl:variable name="tag_keep-together_within-line_open">###<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable>
@@ -10728,6 +10872,10 @@
10728
10872
 
10729
10873
  </xsl:template>
10730
10874
 
10875
+ <xsl:template match="*[local-name() = 'stem'] | *[local-name() = 'image']" mode="update_xml_enclose_keep-together_within-line">
10876
+ <xsl:copy-of select="."/>
10877
+ </xsl:template>
10878
+
10731
10879
  <xsl:template name="replace_text_tags">
10732
10880
  <xsl:param name="tag_open"/>
10733
10881
  <xsl:param name="tag_close"/>
@@ -10754,6 +10902,194 @@
10754
10902
  <!-- END XML UPDATE STEP: enclose standard's name into tag 'keep-together_within-line' -->
10755
10903
  <!-- ===================================== -->
10756
10904
 
10905
+ <!-- ===================================== -->
10906
+ <!-- ===================================== -->
10907
+ <!-- Make linear XML (need for landscape orientation) -->
10908
+ <!-- ===================================== -->
10909
+ <!-- ===================================== -->
10910
+ <xsl:template match="@*|node()" mode="linear_xml">
10911
+ <xsl:copy>
10912
+ <xsl:apply-templates select="@*|node()" mode="linear_xml"/>
10913
+ </xsl:copy>
10914
+ </xsl:template>
10915
+
10916
+ <xsl:template match="processing-instruction()" mode="linear_xml">
10917
+ <xsl:copy-of select="."/>
10918
+ </xsl:template>
10919
+
10920
+ <!-- From:
10921
+ <clause>
10922
+ <title>...</title>
10923
+ <p>...</p>
10924
+ </clause>
10925
+ To:
10926
+ <clause/>
10927
+ <title>...</title>
10928
+ <p>...</p>
10929
+ -->
10930
+ <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">
10931
+
10932
+ <xsl:copy>
10933
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
10934
+
10935
+ <xsl:attribute name="keep-with-next">always</xsl:attribute>
10936
+
10937
+ <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'">
10938
+ <xsl:attribute name="mainsection">true</xsl:attribute>
10939
+ </xsl:if>
10940
+ </xsl:copy>
10941
+
10942
+ <xsl:apply-templates mode="linear_xml"/>
10943
+ </xsl:template>
10944
+
10945
+ <xsl:template match="*[local-name() = 'term']" mode="linear_xml" priority="2">
10946
+ <xsl:copy>
10947
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
10948
+ <xsl:attribute name="keep-with-next">always</xsl:attribute>
10949
+ <xsl:variable name="level">
10950
+ <xsl:call-template name="getLevel"/>
10951
+ </xsl:variable>
10952
+ <xsl:attribute name="depth"><xsl:value-of select="$level"/></xsl:attribute>
10953
+ <xsl:attribute name="ancestor">sections</xsl:attribute>
10954
+ <xsl:apply-templates select="node()[not(local-name() = 'term')]" mode="linear_xml"/>
10955
+ </xsl:copy>
10956
+ <xsl:apply-templates select="*[local-name() = 'term']" mode="linear_xml"/>
10957
+ </xsl:template>
10958
+
10959
+ <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">
10960
+ <xsl:copy>
10961
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
10962
+
10963
+ <xsl:attribute name="keep-with-next">always</xsl:attribute>
10964
+
10965
+ <xsl:variable name="level">
10966
+ <xsl:call-template name="getLevel"/>
10967
+ </xsl:variable>
10968
+ <xsl:attribute name="depth"><xsl:value-of select="$level"/></xsl:attribute>
10969
+
10970
+ <xsl:if test="parent::*[local-name() = 'annex']">
10971
+ <xsl:attribute name="depth">1</xsl:attribute>
10972
+ </xsl:if>
10973
+
10974
+ <xsl:if test="../@inline-header = 'true' and following-sibling::*[1][local-name() = 'p']">
10975
+ <xsl:copy-of select="../@inline-header"/>
10976
+ </xsl:if>
10977
+
10978
+ <xsl:attribute name="ancestor">
10979
+ <xsl:choose>
10980
+ <xsl:when test="ancestor::*[local-name() = 'foreword']">foreword</xsl:when>
10981
+ <xsl:when test="ancestor::*[local-name() = 'introduction']">introduction</xsl:when>
10982
+ <xsl:when test="ancestor::*[local-name() = 'sections']">sections</xsl:when>
10983
+ <xsl:when test="ancestor::*[local-name() = 'annex']">annex</xsl:when>
10984
+ <xsl:when test="ancestor::*[local-name() = 'bibliography']">bibliography</xsl:when>
10985
+ </xsl:choose>
10986
+ </xsl:attribute>
10987
+
10988
+ <xsl:apply-templates mode="linear_xml"/>
10989
+ </xsl:copy>
10990
+ </xsl:template>
10991
+
10992
+ <!-- add @to = figure, table, clause -->
10993
+ <!-- add @depth = from -->
10994
+ <xsl:template match="*[local-name() = 'xref']" mode="linear_xml">
10995
+ <xsl:copy>
10996
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
10997
+ <xsl:variable name="target" select="@target"/>
10998
+ <xsl:attribute name="to">
10999
+ <xsl:value-of select="local-name(//*[@id = current()/@target][1])"/>
11000
+ </xsl:attribute>
11001
+ <xsl:attribute name="depth">
11002
+ <xsl:value-of select="//*[@id = current()/@target][1]/*[local-name() = 'title']/@depth"/>
11003
+ </xsl:attribute>
11004
+ <xsl:apply-templates select="node()" mode="linear_xml"/>
11005
+ </xsl:copy>
11006
+ </xsl:template>
11007
+
11008
+ <xsl:template match="*[not(ancestor::*[local-name() = 'sourcecode'])]/*[local-name() = 'p' or local-name() = 'strong' or local-name() = 'em']/text()" mode="linear_xml">
11009
+ <xsl:choose>
11010
+ <xsl:when test="contains(., $non_breaking_hyphen)">
11011
+ <xsl:call-template name="replaceChar">
11012
+ <xsl:with-param name="text" select="."/>
11013
+ <xsl:with-param name="replace" select="$non_breaking_hyphen"/>
11014
+ <xsl:with-param name="by" select="'-'"/>
11015
+ </xsl:call-template>
11016
+ </xsl:when>
11017
+ <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
11018
+ </xsl:choose>
11019
+ </xsl:template>
11020
+
11021
+ <xsl:template name="replaceChar">
11022
+ <xsl:param name="text"/>
11023
+ <xsl:param name="replace"/>
11024
+ <xsl:param name="by"/>
11025
+ <xsl:choose>
11026
+ <xsl:when test="$text = '' or $replace = '' or not($replace)">
11027
+ <xsl:value-of select="$text"/>
11028
+ </xsl:when>
11029
+ <xsl:when test="contains($text, $replace)">
11030
+ <xsl:value-of select="substring-before($text,$replace)"/>
11031
+ <xsl:element name="inlineChar" namespace="https://www.metanorma.org/ns/jis"><xsl:value-of select="$by"/></xsl:element>
11032
+ <xsl:call-template name="replaceChar">
11033
+ <xsl:with-param name="text" select="substring-after($text,$replace)"/>
11034
+ <xsl:with-param name="replace" select="$replace"/>
11035
+ <xsl:with-param name="by" select="$by"/>
11036
+ </xsl:call-template>
11037
+ </xsl:when>
11038
+ <xsl:otherwise>
11039
+ <xsl:value-of select="$text"/>
11040
+ </xsl:otherwise>
11041
+ </xsl:choose>
11042
+ </xsl:template>
11043
+
11044
+ <xsl:template match="*[local-name() = 'inlineChar']">
11045
+ <fo:inline><xsl:value-of select="."/></fo:inline>
11046
+ </xsl:template>
11047
+
11048
+ <!-- change @reference to actual value, and add skip_footnote_body="true" for repeatable (2nd, 3rd, ...) -->
11049
+ <!--
11050
+ <fn reference="1">
11051
+ <p id="_8e5cf917-f75a-4a49-b0aa-1714cb6cf954">Formerly denoted as 15 % (m/m).</p>
11052
+ </fn>
11053
+ -->
11054
+ <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">
11055
+ <xsl:variable name="p_fn_">
11056
+ <xsl:call-template name="get_fn_list"/>
11057
+ </xsl:variable>
11058
+ <xsl:variable name="p_fn" select="xalan:nodeset($p_fn_)"/>
11059
+ <xsl:variable name="gen_id" select="generate-id(.)"/>
11060
+ <xsl:variable name="lang" select="ancestor::*[contains(local-name(), '-standard')]/*[local-name()='bibdata']//*[local-name()='language'][@current = 'true']"/>
11061
+ <xsl:variable name="reference" select="@reference"/>
11062
+ <!-- fn sequence number in document -->
11063
+ <xsl:variable name="current_fn_number" select="count($p_fn//fn[@reference = $reference]/preceding-sibling::fn) + 1"/>
11064
+
11065
+ <xsl:copy>
11066
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
11067
+ <!-- put actual reference number -->
11068
+ <xsl:attribute name="current_fn_number">
11069
+ <xsl:value-of select="$current_fn_number"/>
11070
+ </xsl:attribute>
11071
+ <xsl:attribute name="skip_footnote_body"> <!-- false for repeatable footnote -->
11072
+ <xsl:value-of select="not($p_fn//fn[@gen_id = $gen_id] and (1 = 1))"/>
11073
+ </xsl:attribute>
11074
+ <xsl:apply-templates select="node()" mode="linear_xml"/>
11075
+ </xsl:copy>
11076
+ </xsl:template>
11077
+
11078
+ <xsl:template match="*[local-name() = 'p'][@type = 'section-title']" priority="3" mode="linear_xml">
11079
+ <xsl:copy>
11080
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
11081
+ <xsl:if test="@depth = '1'">
11082
+ <xsl:attribute name="mainsection">true</xsl:attribute>
11083
+ </xsl:if>
11084
+ <xsl:apply-templates select="node()" mode="linear_xml"/>
11085
+ </xsl:copy>
11086
+ </xsl:template>
11087
+ <!-- ===================================== -->
11088
+ <!-- ===================================== -->
11089
+ <!-- END: Make linear XML (need for landscape orientation) -->
11090
+ <!-- ===================================== -->
11091
+ <!-- ===================================== -->
11092
+
10757
11093
  <!-- for correct rendering combining chars -->
10758
11094
  <xsl:template match="*[local-name() = 'lang_none']">
10759
11095
  <fo:inline xml:lang="none"><xsl:value-of select="."/></fo:inline>