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.
@@ -1398,11 +1398,17 @@
1398
1398
  <!-- ========================== -->
1399
1399
  <!-- Definition's list styles -->
1400
1400
  <!-- ========================== -->
1401
+
1402
+ <xsl:attribute-set name="dl-block-style">
1403
+
1404
+ </xsl:attribute-set>
1405
+
1401
1406
  <xsl:attribute-set name="dt-row-style">
1402
1407
 
1403
1408
  </xsl:attribute-set>
1404
1409
 
1405
1410
  <xsl:attribute-set name="dt-cell-style">
1411
+
1406
1412
  </xsl:attribute-set>
1407
1413
 
1408
1414
  <xsl:attribute-set name="dt-block-style">
@@ -1420,6 +1426,7 @@
1420
1426
 
1421
1427
  <xsl:attribute-set name="dd-cell-style">
1422
1428
  <xsl:attribute name="padding-left">2mm</xsl:attribute>
1429
+
1423
1430
  </xsl:attribute-set>
1424
1431
 
1425
1432
  <!-- ========================== -->
@@ -1515,6 +1522,7 @@
1515
1522
  <xsl:attribute-set name="term-name-style">
1516
1523
  <xsl:attribute name="keep-with-next">always</xsl:attribute>
1517
1524
  <xsl:attribute name="font-weight">bold</xsl:attribute>
1525
+
1518
1526
  </xsl:attribute-set>
1519
1527
 
1520
1528
  <xsl:attribute-set name="figure-block-style">
@@ -1535,6 +1543,10 @@
1535
1543
 
1536
1544
  </xsl:attribute-set>
1537
1545
 
1546
+ <xsl:attribute-set name="figure-source-style">
1547
+
1548
+ </xsl:attribute-set>
1549
+
1538
1550
  <!-- Formula's styles -->
1539
1551
  <xsl:attribute-set name="formula-style">
1540
1552
  <xsl:attribute name="margin-top">6pt</xsl:attribute>
@@ -2069,7 +2081,7 @@
2069
2081
 
2070
2082
  <xsl:template name="processTables_Contents">
2071
2083
  <tables>
2072
- <xsl:for-each select="//*[local-name() = 'table'][@id and *[local-name() = 'name'] and normalize-space(@id) != '']">
2084
+ <xsl:for-each select="//*[local-name() = 'table'][not(ancestor::*[local-name() = 'metanorma-extension'])][@id and *[local-name() = 'name'] and normalize-space(@id) != '']">
2073
2085
  <table id="{@id}" alt-text="{*[local-name() = 'name']}">
2074
2086
  <xsl:copy-of select="*[local-name() = 'name']"/>
2075
2087
  </table>
@@ -2427,7 +2439,7 @@
2427
2439
  </xsl:attribute>
2428
2440
  </xsl:for-each>
2429
2441
 
2430
- <xsl:variable name="isNoteOrFnExist" select="./*[local-name()='note'] or .//*[local-name()='fn'][local-name(..) != 'name']"/>
2442
+ <xsl:variable name="isNoteOrFnExist" select="./*[local-name()='note'] or .//*[local-name()='fn'][local-name(..) != 'name'] or ./*[local-name()='source']"/>
2431
2443
  <xsl:if test="$isNoteOrFnExist = 'true'">
2432
2444
  <xsl:attribute name="border-bottom">0pt solid black</xsl:attribute> <!-- set 0pt border, because there is a separete table below for footer -->
2433
2445
  </xsl:if>
@@ -2471,7 +2483,7 @@
2471
2483
  <xsl:apply-templates select="*[local-name()='thead']" mode="process_tbody"/>
2472
2484
  </xsl:when>
2473
2485
  <xsl:otherwise>
2474
- <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 -->
2486
+ <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 -->
2475
2487
  </xsl:otherwise>
2476
2488
  </xsl:choose>
2477
2489
 
@@ -2572,6 +2584,11 @@
2572
2584
  </xsl:if>
2573
2585
  </xsl:template> <!-- table/name -->
2574
2586
 
2587
+ <!-- SOURCE: ... -->
2588
+ <xsl:template match="*[local-name()='table']/*[local-name() = 'source']" priority="2">
2589
+ <xsl:call-template name="termsource"/>
2590
+ </xsl:template>
2591
+
2575
2592
  <xsl:template name="calculate-columns-numbers">
2576
2593
  <xsl:param name="table-row"/>
2577
2594
  <xsl:variable name="columns-count" select="count($table-row/*)"/>
@@ -2928,7 +2945,7 @@
2928
2945
  </fo:table-header>
2929
2946
  </xsl:template> <!-- thead -->
2930
2947
 
2931
- <!-- template is using for iso, jcgm, bsi only -->
2948
+ <!-- template is using for iec, iso, jcgm, bsi only -->
2932
2949
  <xsl:template name="table-header-title">
2933
2950
  <xsl:param name="cols-count"/>
2934
2951
  <!-- row for title -->
@@ -2971,7 +2988,7 @@
2971
2988
  <xsl:param name="colwidths"/>
2972
2989
  <xsl:param name="colgroup"/>
2973
2990
 
2974
- <xsl:variable name="isNoteOrFnExist" select="../*[local-name()='note'] or ..//*[local-name()='fn'][local-name(..) != 'name']"/>
2991
+ <xsl:variable name="isNoteOrFnExist" select="../*[local-name()='note'] or ../*[local-name()='dl'] or ..//*[local-name()='fn'][local-name(..) != 'name'] or ../*[local-name()='source']"/>
2975
2992
 
2976
2993
  <xsl:variable name="isNoteOrFnExistShowAfterTable">
2977
2994
 
@@ -3039,7 +3056,9 @@
3039
3056
 
3040
3057
  <!-- except gb and bsi -->
3041
3058
 
3059
+ <xsl:apply-templates select="../*[local-name()='dl']"/>
3042
3060
  <xsl:apply-templates select="../*[local-name()='note']"/>
3061
+ <xsl:apply-templates select="../*[local-name()='source']"/>
3043
3062
 
3044
3063
  <xsl:variable name="isDisplayRowSeparator">
3045
3064
 
@@ -3164,7 +3183,7 @@
3164
3183
  <!-- ===================== -->
3165
3184
  <!-- Table's row processing -->
3166
3185
  <!-- ===================== -->
3167
- <!-- row in table header (thead) -->
3186
+ <!-- row in table header (thead) thead/tr -->
3168
3187
  <xsl:template match="*[local-name()='thead']/*[local-name()='tr']" priority="2">
3169
3188
  <fo:table-row xsl:use-attribute-sets="table-header-row-style">
3170
3189
 
@@ -3198,7 +3217,7 @@
3198
3217
  </xsl:choose>
3199
3218
  </xsl:template>
3200
3219
 
3201
- <!-- row in table footer (tfoot) -->
3220
+ <!-- row in table footer (tfoot), tfoot/tr -->
3202
3221
  <xsl:template match="*[local-name()='tfoot']/*[local-name()='tr']" priority="2">
3203
3222
  <fo:table-row xsl:use-attribute-sets="table-footer-row-style">
3204
3223
 
@@ -3680,12 +3699,26 @@
3680
3699
  <xsl:variable name="isAdded" select="@added"/>
3681
3700
  <xsl:variable name="isDeleted" select="@deleted"/>
3682
3701
  <!-- <dl><xsl:copy-of select="."/></dl> -->
3683
- <fo:block-container>
3702
+ <fo:block-container xsl:use-attribute-sets="dl-block-style">
3703
+
3704
+ <xsl:call-template name="setBlockSpanAll"/>
3684
3705
 
3685
3706
  <xsl:if test="not(ancestor::*[local-name() = 'quote'])">
3686
3707
  <xsl:attribute name="margin-left">0mm</xsl:attribute>
3687
3708
  </xsl:if>
3688
3709
 
3710
+ <xsl:if test="ancestor::*[local-name() = 'sourcecode']">
3711
+ <!-- set font-size as sourcecode font-size -->
3712
+ <xsl:variable name="sourcecode_attributes">
3713
+ <xsl:call-template name="get_sourcecode_attributes"/>
3714
+ </xsl:variable>
3715
+ <xsl:for-each select="xalan:nodeset($sourcecode_attributes)/sourcecode_attributes/@font-size">
3716
+ <xsl:attribute name="{local-name()}">
3717
+ <xsl:value-of select="."/>
3718
+ </xsl:attribute>
3719
+ </xsl:for-each>
3720
+ </xsl:if>
3721
+
3689
3722
  <xsl:if test="parent::*[local-name() = 'note']">
3690
3723
  <xsl:attribute name="margin-left">
3691
3724
  <xsl:choose>
@@ -4119,6 +4152,7 @@
4119
4152
  <xsl:param name="split_keep-within-line"/>
4120
4153
 
4121
4154
  <fo:table-row xsl:use-attribute-sets="dt-row-style">
4155
+
4122
4156
  <xsl:call-template name="insert_dt_cell">
4123
4157
  <xsl:with-param name="key_iso" select="$key_iso"/>
4124
4158
  <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
@@ -4140,6 +4174,7 @@
4140
4174
  <!-- border is mandatory, to calculate real width -->
4141
4175
  <xsl:attribute name="border">0.1pt solid black</xsl:attribute>
4142
4176
  <xsl:attribute name="text-align">left</xsl:attribute>
4177
+
4143
4178
  </xsl:if>
4144
4179
 
4145
4180
  <fo:block xsl:use-attribute-sets="dt-block-style">
@@ -4582,6 +4617,7 @@
4582
4617
  <fo:inline>
4583
4618
  <xsl:for-each select="$styles/style">
4584
4619
  <xsl:attribute name="{@name}"><xsl:value-of select="."/></xsl:attribute>
4620
+
4585
4621
  </xsl:for-each>
4586
4622
  <xsl:apply-templates/>
4587
4623
  </fo:inline>
@@ -5744,13 +5780,17 @@
5744
5780
  </xsl:template>
5745
5781
 
5746
5782
  <xsl:template match="*[local-name() = 'callout']">
5747
- <fo:basic-link internal-destination="{@target}" fox:alt-text="{@target}">&lt;<xsl:apply-templates/>&gt;</fo:basic-link>
5783
+ <xsl:choose>
5784
+ <xsl:when test="normalize-space(@target) = ''">&lt;<xsl:apply-templates/>&gt;</xsl:when>
5785
+ <xsl:otherwise><fo:basic-link internal-destination="{@target}" fox:alt-text="{@target}">&lt;<xsl:apply-templates/>&gt;</fo:basic-link></xsl:otherwise>
5786
+ </xsl:choose>
5748
5787
  </xsl:template>
5749
5788
 
5750
5789
  <xsl:template match="*[local-name() = 'annotation']">
5751
5790
  <xsl:variable name="annotation-id" select="@id"/>
5752
5791
  <xsl:variable name="callout" select="//*[@target = $annotation-id]/text()"/>
5753
5792
  <fo:block id="{$annotation-id}" white-space="nowrap">
5793
+
5754
5794
  <fo:inline>
5755
5795
  <xsl:apply-templates>
5756
5796
  <xsl:with-param name="callout" select="concat('&lt;', $callout, '&gt; ')"/>
@@ -5860,6 +5900,10 @@
5860
5900
  <!-- ====== -->
5861
5901
  <!-- ====== -->
5862
5902
 
5903
+ <xsl:template name="setBlockSpanAll">
5904
+ <xsl:if test="@columns = 1 or (local-name() = 'p' and *[@columns = 1])"><xsl:attribute name="span">all</xsl:attribute></xsl:if>
5905
+ </xsl:template>
5906
+
5863
5907
  <!-- ====== -->
5864
5908
  <!-- note -->
5865
5909
  <!-- termnote -->
@@ -5869,6 +5913,8 @@
5869
5913
 
5870
5914
  <fo:block-container id="{@id}" xsl:use-attribute-sets="note-style">
5871
5915
 
5916
+ <xsl:call-template name="setBlockSpanAll"/>
5917
+
5872
5918
  <fo:block-container margin-left="0mm" margin-right="0mm">
5873
5919
 
5874
5920
  <fo:block>
@@ -5928,6 +5974,8 @@
5928
5974
  <xsl:template match="*[local-name() = 'termnote']">
5929
5975
  <fo:block id="{@id}" xsl:use-attribute-sets="termnote-style">
5930
5976
 
5977
+ <xsl:call-template name="setBlockSpanAll"/>
5978
+
5931
5979
  <fo:inline xsl:use-attribute-sets="termnote-name-style">
5932
5980
 
5933
5981
  <xsl:if test="not(*[local-name() = 'name']/following-sibling::node()[1][self::text()][normalize-space()=''])">
@@ -6085,6 +6133,13 @@
6085
6133
  </fo:block>
6086
6134
  </xsl:template>
6087
6135
 
6136
+ <!-- SOURCE: ... -->
6137
+ <xsl:template match="*[local-name() = 'figure']/*[local-name() = 'source']" priority="2">
6138
+
6139
+ <xsl:call-template name="termsource"/>
6140
+
6141
+ </xsl:template>
6142
+
6088
6143
  <xsl:template match="*[local-name() = 'image']">
6089
6144
  <xsl:variable name="isAdded" select="../@added"/>
6090
6145
  <xsl:variable name="isDeleted" select="../@deleted"/>
@@ -7215,9 +7270,11 @@
7215
7270
  <xsl:attribute name="margin-bottom">0pt</xsl:attribute>
7216
7271
  </xsl:if>
7217
7272
 
7218
- <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
7273
+ <xsl:apply-templates select="node()[not(local-name() = 'name' or local-name() = 'dl')]"/>
7219
7274
  </fo:block>
7220
7275
 
7276
+ <xsl:apply-templates select="*[local-name() = 'dl']"/> <!-- Key table -->
7277
+
7221
7278
  <xsl:apply-templates select="*[local-name()='name']"/> <!-- show sourcecode's name AFTER content -->
7222
7279
 
7223
7280
  </fo:block-container>
@@ -7249,11 +7306,22 @@
7249
7306
  <!-- add sourcecode highlighting -->
7250
7307
  <xsl:template match="*[local-name()='sourcecode']//*[local-name()='span'][@class]" priority="2">
7251
7308
  <xsl:variable name="class" select="@class"/>
7309
+
7310
+ <!-- Example: <1> -->
7311
+ <xsl:variable name="is_callout">
7312
+ <xsl:if test="parent::*[local-name() = 'dt']">
7313
+ <xsl:variable name="dt_id" select="../@id"/>
7314
+ <xsl:if test="ancestor::*[local-name() = 'sourcecode']//*[local-name() = 'callout'][@target = $dt_id]">true</xsl:if>
7315
+ </xsl:if>
7316
+ </xsl:variable>
7317
+
7252
7318
  <xsl:choose>
7253
7319
  <xsl:when test="$sourcecode_css//class[@name = $class]">
7254
7320
  <fo:inline>
7255
7321
  <xsl:apply-templates select="$sourcecode_css//class[@name = $class]" mode="css"/>
7322
+ <xsl:if test="$is_callout = 'true'">&lt;</xsl:if>
7256
7323
  <xsl:apply-templates/>
7324
+ <xsl:if test="$is_callout = 'true'">&gt;</xsl:if>
7257
7325
  </fo:inline>
7258
7326
  </xsl:when>
7259
7327
  <xsl:otherwise>
@@ -7677,6 +7745,10 @@
7677
7745
  </fo:block>
7678
7746
  </xsl:template>
7679
7747
 
7748
+ <xsl:template match="*[local-name() = 'div']">
7749
+ <fo:block><xsl:apply-templates/></fo:block>
7750
+ </xsl:template>
7751
+
7680
7752
  <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']">
7681
7753
  <fo:block xsl:use-attribute-sets="inherit-style">
7682
7754
  <xsl:text>Dependency </xsl:text><xsl:apply-templates/>
@@ -7840,6 +7912,9 @@
7840
7912
  <!-- ====== -->
7841
7913
  <xsl:template match="*[local-name() = 'termexample']">
7842
7914
  <fo:block id="{@id}" xsl:use-attribute-sets="termexample-style">
7915
+
7916
+ <xsl:call-template name="setBlockSpanAll"/>
7917
+
7843
7918
  <xsl:apply-templates select="*[local-name()='name']"/>
7844
7919
  <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
7845
7920
  </fo:block>
@@ -7891,6 +7966,8 @@
7891
7966
 
7892
7967
  <fo:block-container id="{@id}" xsl:use-attribute-sets="example-style">
7893
7968
 
7969
+ <xsl:call-template name="setBlockSpanAll"/>
7970
+
7894
7971
  <xsl:variable name="fo_element">
7895
7972
  <xsl:if test=".//*[local-name() = 'table'] or .//*[local-name() = 'dl'] or *[not(local-name() = 'name')][1][local-name() = 'sourcecode']">block</xsl:if>
7896
7973
  block
@@ -7918,6 +7995,35 @@
7918
7995
  </fo:block-container>
7919
7996
  </xsl:when> <!-- end block -->
7920
7997
 
7998
+ <xsl:when test="contains(normalize-space($fo_element), 'list')">
7999
+
8000
+ <xsl:variable name="provisional_distance_between_starts">
8001
+ 7
8002
+ </xsl:variable>
8003
+ <xsl:variable name="indent">
8004
+ 0
8005
+ </xsl:variable>
8006
+
8007
+ <fo:list-block provisional-distance-between-starts="{$provisional_distance_between_starts}mm">
8008
+ <fo:list-item>
8009
+ <fo:list-item-label start-indent="{$indent}mm" end-indent="label-end()">
8010
+ <fo:block>
8011
+ <xsl:apply-templates select="*[local-name()='name']">
8012
+ <xsl:with-param name="fo_element">block</xsl:with-param>
8013
+ </xsl:apply-templates>
8014
+ </fo:block>
8015
+ </fo:list-item-label>
8016
+ <fo:list-item-body start-indent="body-start()">
8017
+ <fo:block>
8018
+ <xsl:apply-templates select="node()[not(local-name() = 'name')]">
8019
+ <xsl:with-param name="fo_element" select="$fo_element"/>
8020
+ </xsl:apply-templates>
8021
+ </fo:block>
8022
+ </fo:list-item-body>
8023
+ </fo:list-item>
8024
+ </fo:list-block>
8025
+ </xsl:when> <!-- end list -->
8026
+
7921
8027
  <xsl:otherwise> <!-- inline -->
7922
8028
 
7923
8029
  <!-- display 'EXAMPLE' and first element in the same line -->
@@ -7997,6 +8103,11 @@
7997
8103
  </fo:block>
7998
8104
  </fo:block-container>
7999
8105
  </xsl:when>
8106
+ <xsl:when test="starts-with(normalize-space($element), 'list')">
8107
+ <fo:block xsl:use-attribute-sets="example-p-style">
8108
+ <xsl:apply-templates/>
8109
+ </fo:block>
8110
+ </xsl:when>
8000
8111
  <xsl:otherwise>
8001
8112
  <fo:inline xsl:use-attribute-sets="example-p-style">
8002
8113
  <xsl:apply-templates/>
@@ -8114,6 +8225,9 @@
8114
8225
  <!-- ====== -->
8115
8226
  <xsl:template match="*[local-name() = 'quote']">
8116
8227
  <fo:block-container margin-left="0mm">
8228
+
8229
+ <xsl:call-template name="setBlockSpanAll"/>
8230
+
8117
8231
  <xsl:if test="parent::*[local-name() = 'note']">
8118
8232
  <xsl:if test="not(ancestor::*[local-name() = 'table'])">
8119
8233
  <xsl:attribute name="margin-left">5mm</xsl:attribute>
@@ -8332,13 +8446,8 @@
8332
8446
  </xsl:template>
8333
8447
 
8334
8448
  <xsl:template match="*[local-name() = 'deprecates']">
8335
- <xsl:variable name="title-deprecated">
8336
- <xsl:call-template name="getLocalizedString">
8337
- <xsl:with-param name="key">deprecated</xsl:with-param>
8338
- </xsl:call-template>
8339
- </xsl:variable>
8340
8449
  <fo:block xsl:use-attribute-sets="deprecates-style">
8341
- <xsl:value-of select="$title-deprecated"/>: <xsl:apply-templates/>
8450
+ <xsl:apply-templates/>
8342
8451
  </fo:block>
8343
8452
  </xsl:template>
8344
8453
 
@@ -8403,6 +8512,8 @@
8403
8512
  <fo:block>
8404
8513
  <xsl:call-template name="setId"/>
8405
8514
 
8515
+ <xsl:call-template name="setBlockSpanAll"/>
8516
+
8406
8517
  <xsl:apply-templates/>
8407
8518
  </fo:block>
8408
8519
  </xsl:template>
@@ -8417,6 +8528,8 @@
8417
8528
  <fo:block break-after="page"/>
8418
8529
  <fo:block id="{@id}">
8419
8530
 
8531
+ <xsl:call-template name="setBlockSpanAll"/>
8532
+
8420
8533
  <xsl:variable name="num"><xsl:number/></xsl:variable>
8421
8534
  <xsl:if test="$num = 1">
8422
8535
  <xsl:attribute name="margin-top">3pt</xsl:attribute>
@@ -9360,6 +9473,8 @@
9360
9473
  <!-- text in the box -->
9361
9474
  <fo:block-container id="{@id}" xsl:use-attribute-sets="admonition-style">
9362
9475
 
9476
+ <xsl:call-template name="setBlockSpanAll"/>
9477
+
9363
9478
  <fo:block-container xsl:use-attribute-sets="admonition-container-style">
9364
9479
 
9365
9480
  <fo:block-container margin-left="0mm" margin-right="0mm">
@@ -9537,6 +9652,33 @@
9537
9652
  <xsl:apply-templates mode="update_xml_step1"/>
9538
9653
  </xsl:copy>
9539
9654
  </xsl:template>
9655
+
9656
+ <!-- remove semantic xml -->
9657
+ <xsl:template match="*[local-name() = 'metanorma-extension']/*[local-name() = 'metanorma']/*[local-name() = 'source']" mode="update_xml_step1"/>
9658
+
9659
+ <!-- remove image/emf -->
9660
+ <xsl:template match="*[local-name() = 'image']/*[local-name() = 'emf']" mode="update_xml_step1"/>
9661
+
9662
+ <xsl:template match="*[local-name() = 'stem'] | *[local-name() = 'image']" mode="update_xml_step1">
9663
+ <xsl:copy-of select="."/>
9664
+ </xsl:template>
9665
+
9666
+ <!-- add @id, redundant for table auto-layout algorithm -->
9667
+ <xsl:template match="*[local-name() = 'dl' or local-name() = 'table'][not(@id)]" mode="update_xml_step1">
9668
+ <xsl:copy>
9669
+ <xsl:copy-of select="@*"/>
9670
+ <xsl:call-template name="add_id"/>
9671
+ <xsl:apply-templates mode="update_xml_step1"/>
9672
+ </xsl:copy>
9673
+ </xsl:template>
9674
+
9675
+ <xsl:template name="add_id">
9676
+ <xsl:if test="not(@id)">
9677
+ <!-- add @id - first element with @id plus '_element_name' -->
9678
+ <xsl:attribute name="id"><xsl:value-of select="(.//*[@id])[1]/@id"/>_<xsl:value-of select="local-name()"/></xsl:attribute>
9679
+ </xsl:if>
9680
+ </xsl:template>
9681
+
9540
9682
  <!-- =========================================================================== -->
9541
9683
  <!-- END STEP1: Re-order elements in 'preface', 'sections' based on @displayorder -->
9542
9684
  <!-- =========================================================================== -->
@@ -9558,7 +9700,7 @@
9558
9700
 
9559
9701
  <xsl:variable name="element_name_keep-together_within-line">keep-together_within-line</xsl:variable>
9560
9702
 
9561
- <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">
9703
+ <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">
9562
9704
 
9563
9705
  <!-- enclose standard's number into tag 'keep-together_within-line' -->
9564
9706
  <xsl:variable name="tag_keep-together_within-line_open">###<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable>
@@ -9632,6 +9774,10 @@
9632
9774
 
9633
9775
  </xsl:template>
9634
9776
 
9777
+ <xsl:template match="*[local-name() = 'stem'] | *[local-name() = 'image']" mode="update_xml_enclose_keep-together_within-line">
9778
+ <xsl:copy-of select="."/>
9779
+ </xsl:template>
9780
+
9635
9781
  <xsl:template name="replace_text_tags">
9636
9782
  <xsl:param name="tag_open"/>
9637
9783
  <xsl:param name="tag_close"/>
@@ -9658,6 +9804,194 @@
9658
9804
  <!-- END XML UPDATE STEP: enclose standard's name into tag 'keep-together_within-line' -->
9659
9805
  <!-- ===================================== -->
9660
9806
 
9807
+ <!-- ===================================== -->
9808
+ <!-- ===================================== -->
9809
+ <!-- Make linear XML (need for landscape orientation) -->
9810
+ <!-- ===================================== -->
9811
+ <!-- ===================================== -->
9812
+ <xsl:template match="@*|node()" mode="linear_xml">
9813
+ <xsl:copy>
9814
+ <xsl:apply-templates select="@*|node()" mode="linear_xml"/>
9815
+ </xsl:copy>
9816
+ </xsl:template>
9817
+
9818
+ <xsl:template match="processing-instruction()" mode="linear_xml">
9819
+ <xsl:copy-of select="."/>
9820
+ </xsl:template>
9821
+
9822
+ <!-- From:
9823
+ <clause>
9824
+ <title>...</title>
9825
+ <p>...</p>
9826
+ </clause>
9827
+ To:
9828
+ <clause/>
9829
+ <title>...</title>
9830
+ <p>...</p>
9831
+ -->
9832
+ <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">
9833
+
9834
+ <xsl:copy>
9835
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
9836
+
9837
+ <xsl:attribute name="keep-with-next">always</xsl:attribute>
9838
+
9839
+ <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'">
9840
+ <xsl:attribute name="mainsection">true</xsl:attribute>
9841
+ </xsl:if>
9842
+ </xsl:copy>
9843
+
9844
+ <xsl:apply-templates mode="linear_xml"/>
9845
+ </xsl:template>
9846
+
9847
+ <xsl:template match="*[local-name() = 'term']" mode="linear_xml" priority="2">
9848
+ <xsl:copy>
9849
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
9850
+ <xsl:attribute name="keep-with-next">always</xsl:attribute>
9851
+ <xsl:variable name="level">
9852
+ <xsl:call-template name="getLevel"/>
9853
+ </xsl:variable>
9854
+ <xsl:attribute name="depth"><xsl:value-of select="$level"/></xsl:attribute>
9855
+ <xsl:attribute name="ancestor">sections</xsl:attribute>
9856
+ <xsl:apply-templates select="node()[not(local-name() = 'term')]" mode="linear_xml"/>
9857
+ </xsl:copy>
9858
+ <xsl:apply-templates select="*[local-name() = 'term']" mode="linear_xml"/>
9859
+ </xsl:template>
9860
+
9861
+ <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">
9862
+ <xsl:copy>
9863
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
9864
+
9865
+ <xsl:attribute name="keep-with-next">always</xsl:attribute>
9866
+
9867
+ <xsl:variable name="level">
9868
+ <xsl:call-template name="getLevel"/>
9869
+ </xsl:variable>
9870
+ <xsl:attribute name="depth"><xsl:value-of select="$level"/></xsl:attribute>
9871
+
9872
+ <xsl:if test="parent::*[local-name() = 'annex']">
9873
+ <xsl:attribute name="depth">1</xsl:attribute>
9874
+ </xsl:if>
9875
+
9876
+ <xsl:if test="../@inline-header = 'true' and following-sibling::*[1][local-name() = 'p']">
9877
+ <xsl:copy-of select="../@inline-header"/>
9878
+ </xsl:if>
9879
+
9880
+ <xsl:attribute name="ancestor">
9881
+ <xsl:choose>
9882
+ <xsl:when test="ancestor::*[local-name() = 'foreword']">foreword</xsl:when>
9883
+ <xsl:when test="ancestor::*[local-name() = 'introduction']">introduction</xsl:when>
9884
+ <xsl:when test="ancestor::*[local-name() = 'sections']">sections</xsl:when>
9885
+ <xsl:when test="ancestor::*[local-name() = 'annex']">annex</xsl:when>
9886
+ <xsl:when test="ancestor::*[local-name() = 'bibliography']">bibliography</xsl:when>
9887
+ </xsl:choose>
9888
+ </xsl:attribute>
9889
+
9890
+ <xsl:apply-templates mode="linear_xml"/>
9891
+ </xsl:copy>
9892
+ </xsl:template>
9893
+
9894
+ <!-- add @to = figure, table, clause -->
9895
+ <!-- add @depth = from -->
9896
+ <xsl:template match="*[local-name() = 'xref']" mode="linear_xml">
9897
+ <xsl:copy>
9898
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
9899
+ <xsl:variable name="target" select="@target"/>
9900
+ <xsl:attribute name="to">
9901
+ <xsl:value-of select="local-name(//*[@id = current()/@target][1])"/>
9902
+ </xsl:attribute>
9903
+ <xsl:attribute name="depth">
9904
+ <xsl:value-of select="//*[@id = current()/@target][1]/*[local-name() = 'title']/@depth"/>
9905
+ </xsl:attribute>
9906
+ <xsl:apply-templates select="node()" mode="linear_xml"/>
9907
+ </xsl:copy>
9908
+ </xsl:template>
9909
+
9910
+ <xsl:template match="*[not(ancestor::*[local-name() = 'sourcecode'])]/*[local-name() = 'p' or local-name() = 'strong' or local-name() = 'em']/text()" mode="linear_xml">
9911
+ <xsl:choose>
9912
+ <xsl:when test="contains(., $non_breaking_hyphen)">
9913
+ <xsl:call-template name="replaceChar">
9914
+ <xsl:with-param name="text" select="."/>
9915
+ <xsl:with-param name="replace" select="$non_breaking_hyphen"/>
9916
+ <xsl:with-param name="by" select="'-'"/>
9917
+ </xsl:call-template>
9918
+ </xsl:when>
9919
+ <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
9920
+ </xsl:choose>
9921
+ </xsl:template>
9922
+
9923
+ <xsl:template name="replaceChar">
9924
+ <xsl:param name="text"/>
9925
+ <xsl:param name="replace"/>
9926
+ <xsl:param name="by"/>
9927
+ <xsl:choose>
9928
+ <xsl:when test="$text = '' or $replace = '' or not($replace)">
9929
+ <xsl:value-of select="$text"/>
9930
+ </xsl:when>
9931
+ <xsl:when test="contains($text, $replace)">
9932
+ <xsl:value-of select="substring-before($text,$replace)"/>
9933
+ <xsl:element name="inlineChar" namespace="https://www.metanorma.org/ns/jis"><xsl:value-of select="$by"/></xsl:element>
9934
+ <xsl:call-template name="replaceChar">
9935
+ <xsl:with-param name="text" select="substring-after($text,$replace)"/>
9936
+ <xsl:with-param name="replace" select="$replace"/>
9937
+ <xsl:with-param name="by" select="$by"/>
9938
+ </xsl:call-template>
9939
+ </xsl:when>
9940
+ <xsl:otherwise>
9941
+ <xsl:value-of select="$text"/>
9942
+ </xsl:otherwise>
9943
+ </xsl:choose>
9944
+ </xsl:template>
9945
+
9946
+ <xsl:template match="*[local-name() = 'inlineChar']">
9947
+ <fo:inline><xsl:value-of select="."/></fo:inline>
9948
+ </xsl:template>
9949
+
9950
+ <!-- change @reference to actual value, and add skip_footnote_body="true" for repeatable (2nd, 3rd, ...) -->
9951
+ <!--
9952
+ <fn reference="1">
9953
+ <p id="_8e5cf917-f75a-4a49-b0aa-1714cb6cf954">Formerly denoted as 15 % (m/m).</p>
9954
+ </fn>
9955
+ -->
9956
+ <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">
9957
+ <xsl:variable name="p_fn_">
9958
+ <xsl:call-template name="get_fn_list"/>
9959
+ </xsl:variable>
9960
+ <xsl:variable name="p_fn" select="xalan:nodeset($p_fn_)"/>
9961
+ <xsl:variable name="gen_id" select="generate-id(.)"/>
9962
+ <xsl:variable name="lang" select="ancestor::*[contains(local-name(), '-standard')]/*[local-name()='bibdata']//*[local-name()='language'][@current = 'true']"/>
9963
+ <xsl:variable name="reference" select="@reference"/>
9964
+ <!-- fn sequence number in document -->
9965
+ <xsl:variable name="current_fn_number" select="count($p_fn//fn[@reference = $reference]/preceding-sibling::fn) + 1"/>
9966
+
9967
+ <xsl:copy>
9968
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
9969
+ <!-- put actual reference number -->
9970
+ <xsl:attribute name="current_fn_number">
9971
+ <xsl:value-of select="$current_fn_number"/>
9972
+ </xsl:attribute>
9973
+ <xsl:attribute name="skip_footnote_body"> <!-- false for repeatable footnote -->
9974
+ <xsl:value-of select="not($p_fn//fn[@gen_id = $gen_id] and (1 = 1))"/>
9975
+ </xsl:attribute>
9976
+ <xsl:apply-templates select="node()" mode="linear_xml"/>
9977
+ </xsl:copy>
9978
+ </xsl:template>
9979
+
9980
+ <xsl:template match="*[local-name() = 'p'][@type = 'section-title']" priority="3" mode="linear_xml">
9981
+ <xsl:copy>
9982
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
9983
+ <xsl:if test="@depth = '1'">
9984
+ <xsl:attribute name="mainsection">true</xsl:attribute>
9985
+ </xsl:if>
9986
+ <xsl:apply-templates select="node()" mode="linear_xml"/>
9987
+ </xsl:copy>
9988
+ </xsl:template>
9989
+ <!-- ===================================== -->
9990
+ <!-- ===================================== -->
9991
+ <!-- END: Make linear XML (need for landscape orientation) -->
9992
+ <!-- ===================================== -->
9993
+ <!-- ===================================== -->
9994
+
9661
9995
  <!-- for correct rendering combining chars -->
9662
9996
  <xsl:template match="*[local-name() = 'lang_none']">
9663
9997
  <fo:inline xml:lang="none"><xsl:value-of select="."/></fo:inline>