metanorma-un 0.10.5 → 0.10.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1464,11 +1464,17 @@
1464
1464
  <!-- ========================== -->
1465
1465
  <!-- Definition's list styles -->
1466
1466
  <!-- ========================== -->
1467
+
1468
+ <xsl:attribute-set name="dl-block-style">
1469
+
1470
+ </xsl:attribute-set>
1471
+
1467
1472
  <xsl:attribute-set name="dt-row-style">
1468
1473
 
1469
1474
  </xsl:attribute-set>
1470
1475
 
1471
1476
  <xsl:attribute-set name="dt-cell-style">
1477
+
1472
1478
  </xsl:attribute-set>
1473
1479
 
1474
1480
  <xsl:attribute-set name="dt-block-style">
@@ -1486,6 +1492,7 @@
1486
1492
 
1487
1493
  <xsl:attribute-set name="dd-cell-style">
1488
1494
  <xsl:attribute name="padding-left">2mm</xsl:attribute>
1495
+
1489
1496
  </xsl:attribute-set>
1490
1497
 
1491
1498
  <!-- ========================== -->
@@ -1582,6 +1589,7 @@
1582
1589
  <xsl:attribute-set name="term-name-style">
1583
1590
  <xsl:attribute name="keep-with-next">always</xsl:attribute>
1584
1591
  <xsl:attribute name="font-weight">bold</xsl:attribute>
1592
+
1585
1593
  </xsl:attribute-set>
1586
1594
 
1587
1595
  <xsl:attribute-set name="figure-block-style">
@@ -1604,6 +1612,10 @@
1604
1612
 
1605
1613
  </xsl:attribute-set>
1606
1614
 
1615
+ <xsl:attribute-set name="figure-source-style">
1616
+
1617
+ </xsl:attribute-set>
1618
+
1607
1619
  <!-- Formula's styles -->
1608
1620
  <xsl:attribute-set name="formula-style">
1609
1621
  <xsl:attribute name="margin-top">6pt</xsl:attribute>
@@ -2139,7 +2151,7 @@
2139
2151
 
2140
2152
  <xsl:template name="processTables_Contents">
2141
2153
  <tables>
2142
- <xsl:for-each select="//*[local-name() = 'table'][@id and *[local-name() = 'name'] and normalize-space(@id) != '']">
2154
+ <xsl:for-each select="//*[local-name() = 'table'][not(ancestor::*[local-name() = 'metanorma-extension'])][@id and *[local-name() = 'name'] and normalize-space(@id) != '']">
2143
2155
  <table id="{@id}" alt-text="{*[local-name() = 'name']}">
2144
2156
  <xsl:copy-of select="*[local-name() = 'name']"/>
2145
2157
  </table>
@@ -2506,7 +2518,7 @@
2506
2518
  </xsl:attribute>
2507
2519
  </xsl:for-each>
2508
2520
 
2509
- <xsl:variable name="isNoteOrFnExist" select="./*[local-name()='note'] or .//*[local-name()='fn'][local-name(..) != 'name']"/>
2521
+ <xsl:variable name="isNoteOrFnExist" select="./*[local-name()='note'] or .//*[local-name()='fn'][local-name(..) != 'name'] or ./*[local-name()='source']"/>
2510
2522
  <xsl:if test="$isNoteOrFnExist = 'true'">
2511
2523
  <xsl:attribute name="border-bottom">0pt solid black</xsl:attribute> <!-- set 0pt border, because there is a separete table below for footer -->
2512
2524
  </xsl:if>
@@ -2550,7 +2562,7 @@
2550
2562
  <xsl:apply-templates select="*[local-name()='thead']" mode="process_tbody"/>
2551
2563
  </xsl:when>
2552
2564
  <xsl:otherwise>
2553
- <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 -->
2565
+ <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 -->
2554
2566
  </xsl:otherwise>
2555
2567
  </xsl:choose>
2556
2568
 
@@ -2651,6 +2663,11 @@
2651
2663
  </xsl:if>
2652
2664
  </xsl:template> <!-- table/name -->
2653
2665
 
2666
+ <!-- SOURCE: ... -->
2667
+ <xsl:template match="*[local-name()='table']/*[local-name() = 'source']" priority="2">
2668
+ <xsl:call-template name="termsource"/>
2669
+ </xsl:template>
2670
+
2654
2671
  <xsl:template name="calculate-columns-numbers">
2655
2672
  <xsl:param name="table-row"/>
2656
2673
  <xsl:variable name="columns-count" select="count($table-row/*)"/>
@@ -3007,7 +3024,7 @@
3007
3024
  </fo:table-header>
3008
3025
  </xsl:template> <!-- thead -->
3009
3026
 
3010
- <!-- template is using for iso, jcgm, bsi only -->
3027
+ <!-- template is using for iec, iso, jcgm, bsi only -->
3011
3028
  <xsl:template name="table-header-title">
3012
3029
  <xsl:param name="cols-count"/>
3013
3030
  <!-- row for title -->
@@ -3050,7 +3067,7 @@
3050
3067
  <xsl:param name="colwidths"/>
3051
3068
  <xsl:param name="colgroup"/>
3052
3069
 
3053
- <xsl:variable name="isNoteOrFnExist" select="../*[local-name()='note'] or ..//*[local-name()='fn'][local-name(..) != 'name']"/>
3070
+ <xsl:variable name="isNoteOrFnExist" select="../*[local-name()='note'] or ../*[local-name()='dl'] or ..//*[local-name()='fn'][local-name(..) != 'name'] or ../*[local-name()='source']"/>
3054
3071
 
3055
3072
  <xsl:variable name="isNoteOrFnExistShowAfterTable">
3056
3073
 
@@ -3118,7 +3135,9 @@
3118
3135
 
3119
3136
  <!-- except gb and bsi -->
3120
3137
 
3138
+ <xsl:apply-templates select="../*[local-name()='dl']"/>
3121
3139
  <xsl:apply-templates select="../*[local-name()='note']"/>
3140
+ <xsl:apply-templates select="../*[local-name()='source']"/>
3122
3141
 
3123
3142
  <xsl:variable name="isDisplayRowSeparator">
3124
3143
 
@@ -3243,7 +3262,7 @@
3243
3262
  <!-- ===================== -->
3244
3263
  <!-- Table's row processing -->
3245
3264
  <!-- ===================== -->
3246
- <!-- row in table header (thead) -->
3265
+ <!-- row in table header (thead) thead/tr -->
3247
3266
  <xsl:template match="*[local-name()='thead']/*[local-name()='tr']" priority="2">
3248
3267
  <fo:table-row xsl:use-attribute-sets="table-header-row-style">
3249
3268
 
@@ -3277,7 +3296,7 @@
3277
3296
  </xsl:choose>
3278
3297
  </xsl:template>
3279
3298
 
3280
- <!-- row in table footer (tfoot) -->
3299
+ <!-- row in table footer (tfoot), tfoot/tr -->
3281
3300
  <xsl:template match="*[local-name()='tfoot']/*[local-name()='tr']" priority="2">
3282
3301
  <fo:table-row xsl:use-attribute-sets="table-footer-row-style">
3283
3302
 
@@ -3775,12 +3794,26 @@
3775
3794
  <xsl:variable name="isAdded" select="@added"/>
3776
3795
  <xsl:variable name="isDeleted" select="@deleted"/>
3777
3796
  <!-- <dl><xsl:copy-of select="."/></dl> -->
3778
- <fo:block-container>
3797
+ <fo:block-container xsl:use-attribute-sets="dl-block-style">
3798
+
3799
+ <xsl:call-template name="setBlockSpanAll"/>
3779
3800
 
3780
3801
  <xsl:if test="not(ancestor::*[local-name() = 'quote'])">
3781
3802
  <xsl:attribute name="margin-left">0mm</xsl:attribute>
3782
3803
  </xsl:if>
3783
3804
 
3805
+ <xsl:if test="ancestor::*[local-name() = 'sourcecode']">
3806
+ <!-- set font-size as sourcecode font-size -->
3807
+ <xsl:variable name="sourcecode_attributes">
3808
+ <xsl:call-template name="get_sourcecode_attributes"/>
3809
+ </xsl:variable>
3810
+ <xsl:for-each select="xalan:nodeset($sourcecode_attributes)/sourcecode_attributes/@font-size">
3811
+ <xsl:attribute name="{local-name()}">
3812
+ <xsl:value-of select="."/>
3813
+ </xsl:attribute>
3814
+ </xsl:for-each>
3815
+ </xsl:if>
3816
+
3784
3817
  <xsl:if test="parent::*[local-name() = 'note']">
3785
3818
  <xsl:attribute name="margin-left">
3786
3819
  <xsl:choose>
@@ -4214,6 +4247,7 @@
4214
4247
  <xsl:param name="split_keep-within-line"/>
4215
4248
 
4216
4249
  <fo:table-row xsl:use-attribute-sets="dt-row-style">
4250
+
4217
4251
  <xsl:call-template name="insert_dt_cell">
4218
4252
  <xsl:with-param name="key_iso" select="$key_iso"/>
4219
4253
  <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
@@ -4235,6 +4269,7 @@
4235
4269
  <!-- border is mandatory, to calculate real width -->
4236
4270
  <xsl:attribute name="border">0.1pt solid black</xsl:attribute>
4237
4271
  <xsl:attribute name="text-align">left</xsl:attribute>
4272
+
4238
4273
  </xsl:if>
4239
4274
 
4240
4275
  <fo:block xsl:use-attribute-sets="dt-block-style">
@@ -4677,6 +4712,7 @@
4677
4712
  <fo:inline>
4678
4713
  <xsl:for-each select="$styles/style">
4679
4714
  <xsl:attribute name="{@name}"><xsl:value-of select="."/></xsl:attribute>
4715
+
4680
4716
  </xsl:for-each>
4681
4717
  <xsl:apply-templates/>
4682
4718
  </fo:inline>
@@ -5839,13 +5875,17 @@
5839
5875
  </xsl:template>
5840
5876
 
5841
5877
  <xsl:template match="*[local-name() = 'callout']">
5842
- <fo:basic-link internal-destination="{@target}" fox:alt-text="{@target}">&lt;<xsl:apply-templates/>&gt;</fo:basic-link>
5878
+ <xsl:choose>
5879
+ <xsl:when test="normalize-space(@target) = ''">&lt;<xsl:apply-templates/>&gt;</xsl:when>
5880
+ <xsl:otherwise><fo:basic-link internal-destination="{@target}" fox:alt-text="{@target}">&lt;<xsl:apply-templates/>&gt;</fo:basic-link></xsl:otherwise>
5881
+ </xsl:choose>
5843
5882
  </xsl:template>
5844
5883
 
5845
5884
  <xsl:template match="*[local-name() = 'annotation']">
5846
5885
  <xsl:variable name="annotation-id" select="@id"/>
5847
5886
  <xsl:variable name="callout" select="//*[@target = $annotation-id]/text()"/>
5848
5887
  <fo:block id="{$annotation-id}" white-space="nowrap">
5888
+
5849
5889
  <fo:inline>
5850
5890
  <xsl:apply-templates>
5851
5891
  <xsl:with-param name="callout" select="concat('&lt;', $callout, '&gt; ')"/>
@@ -5955,6 +5995,10 @@
5955
5995
  <!-- ====== -->
5956
5996
  <!-- ====== -->
5957
5997
 
5998
+ <xsl:template name="setBlockSpanAll">
5999
+ <xsl:if test="@columns = 1 or (local-name() = 'p' and *[@columns = 1])"><xsl:attribute name="span">all</xsl:attribute></xsl:if>
6000
+ </xsl:template>
6001
+
5958
6002
  <!-- ====== -->
5959
6003
  <!-- note -->
5960
6004
  <!-- termnote -->
@@ -5964,6 +6008,8 @@
5964
6008
 
5965
6009
  <fo:block-container id="{@id}" xsl:use-attribute-sets="note-style">
5966
6010
 
6011
+ <xsl:call-template name="setBlockSpanAll"/>
6012
+
5967
6013
  <xsl:if test="../@type = 'source' or ../@type = 'abbreviation'">
5968
6014
  <xsl:attribute name="border-top">0pt solid black</xsl:attribute>
5969
6015
  </xsl:if>
@@ -6027,6 +6073,8 @@
6027
6073
  <xsl:template match="*[local-name() = 'termnote']">
6028
6074
  <fo:block id="{@id}" xsl:use-attribute-sets="termnote-style">
6029
6075
 
6076
+ <xsl:call-template name="setBlockSpanAll"/>
6077
+
6030
6078
  <fo:inline xsl:use-attribute-sets="termnote-name-style">
6031
6079
 
6032
6080
  <xsl:if test="not(*[local-name() = 'name']/following-sibling::node()[1][self::text()][normalize-space()=''])">
@@ -6184,6 +6232,13 @@
6184
6232
  </fo:block>
6185
6233
  </xsl:template>
6186
6234
 
6235
+ <!-- SOURCE: ... -->
6236
+ <xsl:template match="*[local-name() = 'figure']/*[local-name() = 'source']" priority="2">
6237
+
6238
+ <xsl:call-template name="termsource"/>
6239
+
6240
+ </xsl:template>
6241
+
6187
6242
  <xsl:template match="*[local-name() = 'image']">
6188
6243
  <xsl:variable name="isAdded" select="../@added"/>
6189
6244
  <xsl:variable name="isDeleted" select="../@deleted"/>
@@ -7319,9 +7374,11 @@
7319
7374
  <xsl:attribute name="margin-bottom">0pt</xsl:attribute>
7320
7375
  </xsl:if>
7321
7376
 
7322
- <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
7377
+ <xsl:apply-templates select="node()[not(local-name() = 'name' or local-name() = 'dl')]"/>
7323
7378
  </fo:block>
7324
7379
 
7380
+ <xsl:apply-templates select="*[local-name() = 'dl']"/> <!-- Key table -->
7381
+
7325
7382
  <xsl:apply-templates select="*[local-name()='name']"/> <!-- show sourcecode's name AFTER content -->
7326
7383
 
7327
7384
  </fo:block-container>
@@ -7353,11 +7410,22 @@
7353
7410
  <!-- add sourcecode highlighting -->
7354
7411
  <xsl:template match="*[local-name()='sourcecode']//*[local-name()='span'][@class]" priority="2">
7355
7412
  <xsl:variable name="class" select="@class"/>
7413
+
7414
+ <!-- Example: <1> -->
7415
+ <xsl:variable name="is_callout">
7416
+ <xsl:if test="parent::*[local-name() = 'dt']">
7417
+ <xsl:variable name="dt_id" select="../@id"/>
7418
+ <xsl:if test="ancestor::*[local-name() = 'sourcecode']//*[local-name() = 'callout'][@target = $dt_id]">true</xsl:if>
7419
+ </xsl:if>
7420
+ </xsl:variable>
7421
+
7356
7422
  <xsl:choose>
7357
7423
  <xsl:when test="$sourcecode_css//class[@name = $class]">
7358
7424
  <fo:inline>
7359
7425
  <xsl:apply-templates select="$sourcecode_css//class[@name = $class]" mode="css"/>
7426
+ <xsl:if test="$is_callout = 'true'">&lt;</xsl:if>
7360
7427
  <xsl:apply-templates/>
7428
+ <xsl:if test="$is_callout = 'true'">&gt;</xsl:if>
7361
7429
  </fo:inline>
7362
7430
  </xsl:when>
7363
7431
  <xsl:otherwise>
@@ -7781,6 +7849,10 @@
7781
7849
  </fo:block>
7782
7850
  </xsl:template>
7783
7851
 
7852
+ <xsl:template match="*[local-name() = 'div']">
7853
+ <fo:block><xsl:apply-templates/></fo:block>
7854
+ </xsl:template>
7855
+
7784
7856
  <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']">
7785
7857
  <fo:block xsl:use-attribute-sets="inherit-style">
7786
7858
  <xsl:text>Dependency </xsl:text><xsl:apply-templates/>
@@ -7944,6 +8016,9 @@
7944
8016
  <!-- ====== -->
7945
8017
  <xsl:template match="*[local-name() = 'termexample']">
7946
8018
  <fo:block id="{@id}" xsl:use-attribute-sets="termexample-style">
8019
+
8020
+ <xsl:call-template name="setBlockSpanAll"/>
8021
+
7947
8022
  <xsl:apply-templates select="*[local-name()='name']"/>
7948
8023
  <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
7949
8024
  </fo:block>
@@ -7995,6 +8070,8 @@
7995
8070
 
7996
8071
  <fo:block-container id="{@id}" xsl:use-attribute-sets="example-style">
7997
8072
 
8073
+ <xsl:call-template name="setBlockSpanAll"/>
8074
+
7998
8075
  <xsl:variable name="fo_element">
7999
8076
  <xsl:if test=".//*[local-name() = 'table'] or .//*[local-name() = 'dl'] or *[not(local-name() = 'name')][1][local-name() = 'sourcecode']">block</xsl:if>
8000
8077
  block
@@ -8022,6 +8099,35 @@
8022
8099
  </fo:block-container>
8023
8100
  </xsl:when> <!-- end block -->
8024
8101
 
8102
+ <xsl:when test="contains(normalize-space($fo_element), 'list')">
8103
+
8104
+ <xsl:variable name="provisional_distance_between_starts">
8105
+ 7
8106
+ </xsl:variable>
8107
+ <xsl:variable name="indent">
8108
+ 0
8109
+ </xsl:variable>
8110
+
8111
+ <fo:list-block provisional-distance-between-starts="{$provisional_distance_between_starts}mm">
8112
+ <fo:list-item>
8113
+ <fo:list-item-label start-indent="{$indent}mm" end-indent="label-end()">
8114
+ <fo:block>
8115
+ <xsl:apply-templates select="*[local-name()='name']">
8116
+ <xsl:with-param name="fo_element">block</xsl:with-param>
8117
+ </xsl:apply-templates>
8118
+ </fo:block>
8119
+ </fo:list-item-label>
8120
+ <fo:list-item-body start-indent="body-start()">
8121
+ <fo:block>
8122
+ <xsl:apply-templates select="node()[not(local-name() = 'name')]">
8123
+ <xsl:with-param name="fo_element" select="$fo_element"/>
8124
+ </xsl:apply-templates>
8125
+ </fo:block>
8126
+ </fo:list-item-body>
8127
+ </fo:list-item>
8128
+ </fo:list-block>
8129
+ </xsl:when> <!-- end list -->
8130
+
8025
8131
  <xsl:otherwise> <!-- inline -->
8026
8132
 
8027
8133
  <!-- display 'EXAMPLE' and first element in the same line -->
@@ -8101,6 +8207,11 @@
8101
8207
  </fo:block>
8102
8208
  </fo:block-container>
8103
8209
  </xsl:when>
8210
+ <xsl:when test="starts-with(normalize-space($element), 'list')">
8211
+ <fo:block xsl:use-attribute-sets="example-p-style">
8212
+ <xsl:apply-templates/>
8213
+ </fo:block>
8214
+ </xsl:when>
8104
8215
  <xsl:otherwise>
8105
8216
  <fo:inline xsl:use-attribute-sets="example-p-style">
8106
8217
  <xsl:apply-templates/>
@@ -8218,6 +8329,9 @@
8218
8329
  <!-- ====== -->
8219
8330
  <xsl:template match="*[local-name() = 'quote']">
8220
8331
  <fo:block-container margin-left="0mm">
8332
+
8333
+ <xsl:call-template name="setBlockSpanAll"/>
8334
+
8221
8335
  <xsl:if test="parent::*[local-name() = 'note']">
8222
8336
  <xsl:if test="not(ancestor::*[local-name() = 'table'])">
8223
8337
  <xsl:attribute name="margin-left">5mm</xsl:attribute>
@@ -8434,13 +8548,8 @@
8434
8548
  </xsl:template>
8435
8549
 
8436
8550
  <xsl:template match="*[local-name() = 'deprecates']">
8437
- <xsl:variable name="title-deprecated">
8438
- <xsl:call-template name="getLocalizedString">
8439
- <xsl:with-param name="key">deprecated</xsl:with-param>
8440
- </xsl:call-template>
8441
- </xsl:variable>
8442
8551
  <fo:block xsl:use-attribute-sets="deprecates-style">
8443
- <xsl:value-of select="$title-deprecated"/>: <xsl:apply-templates/>
8552
+ <xsl:apply-templates/>
8444
8553
  </fo:block>
8445
8554
  </xsl:template>
8446
8555
 
@@ -8507,6 +8616,8 @@
8507
8616
  <fo:block>
8508
8617
  <xsl:call-template name="setId"/>
8509
8618
 
8619
+ <xsl:call-template name="setBlockSpanAll"/>
8620
+
8510
8621
  <xsl:apply-templates/>
8511
8622
  </fo:block>
8512
8623
  </xsl:template>
@@ -8521,6 +8632,8 @@
8521
8632
  <fo:block break-after="page"/>
8522
8633
  <fo:block id="{@id}">
8523
8634
 
8635
+ <xsl:call-template name="setBlockSpanAll"/>
8636
+
8524
8637
  <xsl:variable name="num"><xsl:number/></xsl:variable>
8525
8638
  <xsl:if test="$num = 1">
8526
8639
  <xsl:attribute name="margin-top">3pt</xsl:attribute>
@@ -9461,6 +9574,8 @@
9461
9574
  <!-- text in the box -->
9462
9575
  <fo:block-container id="{@id}" xsl:use-attribute-sets="admonition-style">
9463
9576
 
9577
+ <xsl:call-template name="setBlockSpanAll"/>
9578
+
9464
9579
  <fo:block xsl:use-attribute-sets="admonition-name-style">
9465
9580
  <xsl:call-template name="displayAdmonitionName"/>
9466
9581
  </fo:block>
@@ -9642,6 +9757,33 @@
9642
9757
  <xsl:apply-templates mode="update_xml_step1"/>
9643
9758
  </xsl:copy>
9644
9759
  </xsl:template>
9760
+
9761
+ <!-- remove semantic xml -->
9762
+ <xsl:template match="*[local-name() = 'metanorma-extension']/*[local-name() = 'metanorma']/*[local-name() = 'source']" mode="update_xml_step1"/>
9763
+
9764
+ <!-- remove image/emf -->
9765
+ <xsl:template match="*[local-name() = 'image']/*[local-name() = 'emf']" mode="update_xml_step1"/>
9766
+
9767
+ <xsl:template match="*[local-name() = 'stem'] | *[local-name() = 'image']" mode="update_xml_step1">
9768
+ <xsl:copy-of select="."/>
9769
+ </xsl:template>
9770
+
9771
+ <!-- add @id, redundant for table auto-layout algorithm -->
9772
+ <xsl:template match="*[local-name() = 'dl' or local-name() = 'table'][not(@id)]" mode="update_xml_step1">
9773
+ <xsl:copy>
9774
+ <xsl:copy-of select="@*"/>
9775
+ <xsl:call-template name="add_id"/>
9776
+ <xsl:apply-templates mode="update_xml_step1"/>
9777
+ </xsl:copy>
9778
+ </xsl:template>
9779
+
9780
+ <xsl:template name="add_id">
9781
+ <xsl:if test="not(@id)">
9782
+ <!-- add @id - first element with @id plus '_element_name' -->
9783
+ <xsl:attribute name="id"><xsl:value-of select="(.//*[@id])[1]/@id"/>_<xsl:value-of select="local-name()"/></xsl:attribute>
9784
+ </xsl:if>
9785
+ </xsl:template>
9786
+
9645
9787
  <!-- =========================================================================== -->
9646
9788
  <!-- END STEP1: Re-order elements in 'preface', 'sections' based on @displayorder -->
9647
9789
  <!-- =========================================================================== -->
@@ -9663,7 +9805,7 @@
9663
9805
 
9664
9806
  <xsl:variable name="element_name_keep-together_within-line">keep-together_within-line</xsl:variable>
9665
9807
 
9666
- <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">
9808
+ <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">
9667
9809
 
9668
9810
  <!-- enclose standard's number into tag 'keep-together_within-line' -->
9669
9811
  <xsl:variable name="tag_keep-together_within-line_open">###<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable>
@@ -9737,6 +9879,10 @@
9737
9879
 
9738
9880
  </xsl:template>
9739
9881
 
9882
+ <xsl:template match="*[local-name() = 'stem'] | *[local-name() = 'image']" mode="update_xml_enclose_keep-together_within-line">
9883
+ <xsl:copy-of select="."/>
9884
+ </xsl:template>
9885
+
9740
9886
  <xsl:template name="replace_text_tags">
9741
9887
  <xsl:param name="tag_open"/>
9742
9888
  <xsl:param name="tag_close"/>
@@ -9763,6 +9909,194 @@
9763
9909
  <!-- END XML UPDATE STEP: enclose standard's name into tag 'keep-together_within-line' -->
9764
9910
  <!-- ===================================== -->
9765
9911
 
9912
+ <!-- ===================================== -->
9913
+ <!-- ===================================== -->
9914
+ <!-- Make linear XML (need for landscape orientation) -->
9915
+ <!-- ===================================== -->
9916
+ <!-- ===================================== -->
9917
+ <xsl:template match="@*|node()" mode="linear_xml">
9918
+ <xsl:copy>
9919
+ <xsl:apply-templates select="@*|node()" mode="linear_xml"/>
9920
+ </xsl:copy>
9921
+ </xsl:template>
9922
+
9923
+ <xsl:template match="processing-instruction()" mode="linear_xml">
9924
+ <xsl:copy-of select="."/>
9925
+ </xsl:template>
9926
+
9927
+ <!-- From:
9928
+ <clause>
9929
+ <title>...</title>
9930
+ <p>...</p>
9931
+ </clause>
9932
+ To:
9933
+ <clause/>
9934
+ <title>...</title>
9935
+ <p>...</p>
9936
+ -->
9937
+ <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">
9938
+
9939
+ <xsl:copy>
9940
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
9941
+
9942
+ <xsl:attribute name="keep-with-next">always</xsl:attribute>
9943
+
9944
+ <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'">
9945
+ <xsl:attribute name="mainsection">true</xsl:attribute>
9946
+ </xsl:if>
9947
+ </xsl:copy>
9948
+
9949
+ <xsl:apply-templates mode="linear_xml"/>
9950
+ </xsl:template>
9951
+
9952
+ <xsl:template match="*[local-name() = 'term']" mode="linear_xml" priority="2">
9953
+ <xsl:copy>
9954
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
9955
+ <xsl:attribute name="keep-with-next">always</xsl:attribute>
9956
+ <xsl:variable name="level">
9957
+ <xsl:call-template name="getLevel"/>
9958
+ </xsl:variable>
9959
+ <xsl:attribute name="depth"><xsl:value-of select="$level"/></xsl:attribute>
9960
+ <xsl:attribute name="ancestor">sections</xsl:attribute>
9961
+ <xsl:apply-templates select="node()[not(local-name() = 'term')]" mode="linear_xml"/>
9962
+ </xsl:copy>
9963
+ <xsl:apply-templates select="*[local-name() = 'term']" mode="linear_xml"/>
9964
+ </xsl:template>
9965
+
9966
+ <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">
9967
+ <xsl:copy>
9968
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
9969
+
9970
+ <xsl:attribute name="keep-with-next">always</xsl:attribute>
9971
+
9972
+ <xsl:variable name="level">
9973
+ <xsl:call-template name="getLevel"/>
9974
+ </xsl:variable>
9975
+ <xsl:attribute name="depth"><xsl:value-of select="$level"/></xsl:attribute>
9976
+
9977
+ <xsl:if test="parent::*[local-name() = 'annex']">
9978
+ <xsl:attribute name="depth">1</xsl:attribute>
9979
+ </xsl:if>
9980
+
9981
+ <xsl:if test="../@inline-header = 'true' and following-sibling::*[1][local-name() = 'p']">
9982
+ <xsl:copy-of select="../@inline-header"/>
9983
+ </xsl:if>
9984
+
9985
+ <xsl:attribute name="ancestor">
9986
+ <xsl:choose>
9987
+ <xsl:when test="ancestor::*[local-name() = 'foreword']">foreword</xsl:when>
9988
+ <xsl:when test="ancestor::*[local-name() = 'introduction']">introduction</xsl:when>
9989
+ <xsl:when test="ancestor::*[local-name() = 'sections']">sections</xsl:when>
9990
+ <xsl:when test="ancestor::*[local-name() = 'annex']">annex</xsl:when>
9991
+ <xsl:when test="ancestor::*[local-name() = 'bibliography']">bibliography</xsl:when>
9992
+ </xsl:choose>
9993
+ </xsl:attribute>
9994
+
9995
+ <xsl:apply-templates mode="linear_xml"/>
9996
+ </xsl:copy>
9997
+ </xsl:template>
9998
+
9999
+ <!-- add @to = figure, table, clause -->
10000
+ <!-- add @depth = from -->
10001
+ <xsl:template match="*[local-name() = 'xref']" mode="linear_xml">
10002
+ <xsl:copy>
10003
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
10004
+ <xsl:variable name="target" select="@target"/>
10005
+ <xsl:attribute name="to">
10006
+ <xsl:value-of select="local-name(//*[@id = current()/@target][1])"/>
10007
+ </xsl:attribute>
10008
+ <xsl:attribute name="depth">
10009
+ <xsl:value-of select="//*[@id = current()/@target][1]/*[local-name() = 'title']/@depth"/>
10010
+ </xsl:attribute>
10011
+ <xsl:apply-templates select="node()" mode="linear_xml"/>
10012
+ </xsl:copy>
10013
+ </xsl:template>
10014
+
10015
+ <xsl:template match="*[not(ancestor::*[local-name() = 'sourcecode'])]/*[local-name() = 'p' or local-name() = 'strong' or local-name() = 'em']/text()" mode="linear_xml">
10016
+ <xsl:choose>
10017
+ <xsl:when test="contains(., $non_breaking_hyphen)">
10018
+ <xsl:call-template name="replaceChar">
10019
+ <xsl:with-param name="text" select="."/>
10020
+ <xsl:with-param name="replace" select="$non_breaking_hyphen"/>
10021
+ <xsl:with-param name="by" select="'-'"/>
10022
+ </xsl:call-template>
10023
+ </xsl:when>
10024
+ <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
10025
+ </xsl:choose>
10026
+ </xsl:template>
10027
+
10028
+ <xsl:template name="replaceChar">
10029
+ <xsl:param name="text"/>
10030
+ <xsl:param name="replace"/>
10031
+ <xsl:param name="by"/>
10032
+ <xsl:choose>
10033
+ <xsl:when test="$text = '' or $replace = '' or not($replace)">
10034
+ <xsl:value-of select="$text"/>
10035
+ </xsl:when>
10036
+ <xsl:when test="contains($text, $replace)">
10037
+ <xsl:value-of select="substring-before($text,$replace)"/>
10038
+ <xsl:element name="inlineChar" namespace="https://www.metanorma.org/ns/jis"><xsl:value-of select="$by"/></xsl:element>
10039
+ <xsl:call-template name="replaceChar">
10040
+ <xsl:with-param name="text" select="substring-after($text,$replace)"/>
10041
+ <xsl:with-param name="replace" select="$replace"/>
10042
+ <xsl:with-param name="by" select="$by"/>
10043
+ </xsl:call-template>
10044
+ </xsl:when>
10045
+ <xsl:otherwise>
10046
+ <xsl:value-of select="$text"/>
10047
+ </xsl:otherwise>
10048
+ </xsl:choose>
10049
+ </xsl:template>
10050
+
10051
+ <xsl:template match="*[local-name() = 'inlineChar']">
10052
+ <fo:inline><xsl:value-of select="."/></fo:inline>
10053
+ </xsl:template>
10054
+
10055
+ <!-- change @reference to actual value, and add skip_footnote_body="true" for repeatable (2nd, 3rd, ...) -->
10056
+ <!--
10057
+ <fn reference="1">
10058
+ <p id="_8e5cf917-f75a-4a49-b0aa-1714cb6cf954">Formerly denoted as 15 % (m/m).</p>
10059
+ </fn>
10060
+ -->
10061
+ <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">
10062
+ <xsl:variable name="p_fn_">
10063
+ <xsl:call-template name="get_fn_list"/>
10064
+ </xsl:variable>
10065
+ <xsl:variable name="p_fn" select="xalan:nodeset($p_fn_)"/>
10066
+ <xsl:variable name="gen_id" select="generate-id(.)"/>
10067
+ <xsl:variable name="lang" select="ancestor::*[contains(local-name(), '-standard')]/*[local-name()='bibdata']//*[local-name()='language'][@current = 'true']"/>
10068
+ <xsl:variable name="reference" select="@reference"/>
10069
+ <!-- fn sequence number in document -->
10070
+ <xsl:variable name="current_fn_number" select="count($p_fn//fn[@reference = $reference]/preceding-sibling::fn) + 1"/>
10071
+
10072
+ <xsl:copy>
10073
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
10074
+ <!-- put actual reference number -->
10075
+ <xsl:attribute name="current_fn_number">
10076
+ <xsl:value-of select="$current_fn_number"/>
10077
+ </xsl:attribute>
10078
+ <xsl:attribute name="skip_footnote_body"> <!-- false for repeatable footnote -->
10079
+ <xsl:value-of select="not($p_fn//fn[@gen_id = $gen_id] and (1 = 1))"/>
10080
+ </xsl:attribute>
10081
+ <xsl:apply-templates select="node()" mode="linear_xml"/>
10082
+ </xsl:copy>
10083
+ </xsl:template>
10084
+
10085
+ <xsl:template match="*[local-name() = 'p'][@type = 'section-title']" priority="3" mode="linear_xml">
10086
+ <xsl:copy>
10087
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
10088
+ <xsl:if test="@depth = '1'">
10089
+ <xsl:attribute name="mainsection">true</xsl:attribute>
10090
+ </xsl:if>
10091
+ <xsl:apply-templates select="node()" mode="linear_xml"/>
10092
+ </xsl:copy>
10093
+ </xsl:template>
10094
+ <!-- ===================================== -->
10095
+ <!-- ===================================== -->
10096
+ <!-- END: Make linear XML (need for landscape orientation) -->
10097
+ <!-- ===================================== -->
10098
+ <!-- ===================================== -->
10099
+
9766
10100
  <!-- for correct rendering combining chars -->
9767
10101
  <xsl:template match="*[local-name() = 'lang_none']">
9768
10102
  <fo:inline xml:lang="none"><xsl:value-of select="."/></fo:inline>