metanorma-ieee 1.0.7 → 1.0.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -2742,10 +2742,6 @@
2742
2742
  </xsl:choose>
2743
2743
  </xsl:template>
2744
2744
 
2745
- <xsl:template match="*[local-name() = 'inlineChar']">
2746
- <fo:inline><xsl:value-of select="."/></fo:inline>
2747
- </xsl:template>
2748
-
2749
2745
  <!--
2750
2746
  <xsl:variable name="example_name_width">25</xsl:variable>
2751
2747
  <xsl:template match="ieee:termexample" priority="2">
@@ -3710,29 +3706,6 @@
3710
3706
  <!-- End Back Pages -->
3711
3707
  <!-- =============================== -->
3712
3708
 
3713
- <xsl:template name="replaceChar">
3714
- <xsl:param name="text"/>
3715
- <xsl:param name="replace"/>
3716
- <xsl:param name="by"/>
3717
- <xsl:choose>
3718
- <xsl:when test="$text = '' or $replace = '' or not($replace)">
3719
- <xsl:value-of select="$text"/>
3720
- </xsl:when>
3721
- <xsl:when test="contains($text, $replace)">
3722
- <xsl:value-of select="substring-before($text,$replace)"/>
3723
- <xsl:element name="inlineChar" namespace="https://www.metanorma.org/ns/ieee"><xsl:value-of select="$by"/></xsl:element>
3724
- <xsl:call-template name="replaceChar">
3725
- <xsl:with-param name="text" select="substring-after($text,$replace)"/>
3726
- <xsl:with-param name="replace" select="$replace"/>
3727
- <xsl:with-param name="by" select="$by"/>
3728
- </xsl:call-template>
3729
- </xsl:when>
3730
- <xsl:otherwise>
3731
- <xsl:value-of select="$text"/>
3732
- </xsl:otherwise>
3733
- </xsl:choose>
3734
- </xsl:template>
3735
-
3736
3709
  <xsl:strip-space elements="ieee:xref"/>
3737
3710
 
3738
3711
  <!-- external parameters -->
@@ -4416,11 +4389,17 @@
4416
4389
  <!-- ========================== -->
4417
4390
  <!-- Definition's list styles -->
4418
4391
  <!-- ========================== -->
4392
+
4393
+ <xsl:attribute-set name="dl-block-style">
4394
+
4395
+ </xsl:attribute-set>
4396
+
4419
4397
  <xsl:attribute-set name="dt-row-style">
4420
4398
 
4421
4399
  </xsl:attribute-set>
4422
4400
 
4423
4401
  <xsl:attribute-set name="dt-cell-style">
4402
+
4424
4403
  </xsl:attribute-set>
4425
4404
 
4426
4405
  <xsl:attribute-set name="dt-block-style">
@@ -4442,6 +4421,7 @@
4442
4421
 
4443
4422
  <xsl:attribute-set name="dd-cell-style">
4444
4423
  <xsl:attribute name="padding-left">2mm</xsl:attribute>
4424
+
4445
4425
  </xsl:attribute-set>
4446
4426
 
4447
4427
  <!-- ========================== -->
@@ -4544,6 +4524,7 @@
4544
4524
  <xsl:attribute-set name="term-name-style">
4545
4525
  <xsl:attribute name="keep-with-next">always</xsl:attribute>
4546
4526
  <xsl:attribute name="font-weight">bold</xsl:attribute>
4527
+
4547
4528
  </xsl:attribute-set>
4548
4529
 
4549
4530
  <xsl:attribute-set name="figure-block-style">
@@ -4567,6 +4548,10 @@
4567
4548
 
4568
4549
  </xsl:attribute-set>
4569
4550
 
4551
+ <xsl:attribute-set name="figure-source-style">
4552
+
4553
+ </xsl:attribute-set>
4554
+
4570
4555
  <!-- Formula's styles -->
4571
4556
  <xsl:attribute-set name="formula-style">
4572
4557
  <xsl:attribute name="margin-top">6pt</xsl:attribute>
@@ -5100,7 +5085,7 @@
5100
5085
 
5101
5086
  <xsl:template name="processTables_Contents">
5102
5087
  <tables>
5103
- <xsl:for-each select="//*[local-name() = 'table'][@id and *[local-name() = 'name'] and normalize-space(@id) != '']">
5088
+ <xsl:for-each select="//*[local-name() = 'table'][not(ancestor::*[local-name() = 'metanorma-extension'])][@id and *[local-name() = 'name'] and normalize-space(@id) != '']">
5104
5089
  <table id="{@id}" alt-text="{*[local-name() = 'name']}">
5105
5090
  <xsl:copy-of select="*[local-name() = 'name']"/>
5106
5091
  </table>
@@ -5465,7 +5450,7 @@
5465
5450
  </xsl:attribute>
5466
5451
  </xsl:for-each>
5467
5452
 
5468
- <xsl:variable name="isNoteOrFnExist" select="./*[local-name()='note'] or .//*[local-name()='fn'][local-name(..) != 'name']"/>
5453
+ <xsl:variable name="isNoteOrFnExist" select="./*[local-name()='note'] or .//*[local-name()='fn'][local-name(..) != 'name'] or ./*[local-name()='source']"/>
5469
5454
  <xsl:if test="$isNoteOrFnExist = 'true'">
5470
5455
  <xsl:attribute name="border-bottom">0pt solid black</xsl:attribute> <!-- set 0pt border, because there is a separete table below for footer -->
5471
5456
  </xsl:if>
@@ -5509,7 +5494,7 @@
5509
5494
  <xsl:apply-templates select="*[local-name()='thead']" mode="process_tbody"/>
5510
5495
  </xsl:when>
5511
5496
  <xsl:otherwise>
5512
- <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 -->
5497
+ <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 -->
5513
5498
  </xsl:otherwise>
5514
5499
  </xsl:choose>
5515
5500
 
@@ -5590,6 +5575,11 @@
5590
5575
  </xsl:if>
5591
5576
  </xsl:template> <!-- table/name -->
5592
5577
 
5578
+ <!-- SOURCE: ... -->
5579
+ <xsl:template match="*[local-name()='table']/*[local-name() = 'source']" priority="2">
5580
+ <xsl:call-template name="termsource"/>
5581
+ </xsl:template>
5582
+
5593
5583
  <xsl:template name="calculate-columns-numbers">
5594
5584
  <xsl:param name="table-row"/>
5595
5585
  <xsl:variable name="columns-count" select="count($table-row/*)"/>
@@ -5950,7 +5940,7 @@
5950
5940
  </fo:table-header>
5951
5941
  </xsl:template> <!-- thead -->
5952
5942
 
5953
- <!-- template is using for iso, jcgm, bsi only -->
5943
+ <!-- template is using for iec, iso, jcgm, bsi only -->
5954
5944
  <xsl:template name="table-header-title">
5955
5945
  <xsl:param name="cols-count"/>
5956
5946
  <!-- row for title -->
@@ -6000,7 +5990,7 @@
6000
5990
  <xsl:param name="colwidths"/>
6001
5991
  <xsl:param name="colgroup"/>
6002
5992
 
6003
- <xsl:variable name="isNoteOrFnExist" select="../*[local-name()='note'] or ..//*[local-name()='fn'][local-name(..) != 'name']"/>
5993
+ <xsl:variable name="isNoteOrFnExist" select="../*[local-name()='note'] or ../*[local-name()='dl'] or ..//*[local-name()='fn'][local-name(..) != 'name'] or ../*[local-name()='source']"/>
6004
5994
 
6005
5995
  <xsl:variable name="isNoteOrFnExistShowAfterTable">
6006
5996
 
@@ -6068,7 +6058,9 @@
6068
6058
 
6069
6059
  <!-- except gb and bsi -->
6070
6060
 
6061
+ <xsl:apply-templates select="../*[local-name()='dl']"/>
6071
6062
  <xsl:apply-templates select="../*[local-name()='note']"/>
6063
+ <xsl:apply-templates select="../*[local-name()='source']"/>
6072
6064
 
6073
6065
  <xsl:variable name="isDisplayRowSeparator">
6074
6066
 
@@ -6235,7 +6227,7 @@
6235
6227
  <!-- ===================== -->
6236
6228
  <!-- Table's row processing -->
6237
6229
  <!-- ===================== -->
6238
- <!-- row in table header (thead) -->
6230
+ <!-- row in table header (thead) thead/tr -->
6239
6231
  <xsl:template match="*[local-name()='thead']/*[local-name()='tr']" priority="2">
6240
6232
  <fo:table-row xsl:use-attribute-sets="table-header-row-style">
6241
6233
 
@@ -6276,7 +6268,7 @@
6276
6268
  </xsl:choose>
6277
6269
  </xsl:template>
6278
6270
 
6279
- <!-- row in table footer (tfoot) -->
6271
+ <!-- row in table footer (tfoot), tfoot/tr -->
6280
6272
  <xsl:template match="*[local-name()='tfoot']/*[local-name()='tr']" priority="2">
6281
6273
  <fo:table-row xsl:use-attribute-sets="table-footer-row-style">
6282
6274
 
@@ -6770,12 +6762,26 @@
6770
6762
  <xsl:variable name="isAdded" select="@added"/>
6771
6763
  <xsl:variable name="isDeleted" select="@deleted"/>
6772
6764
  <!-- <dl><xsl:copy-of select="."/></dl> -->
6773
- <fo:block-container>
6765
+ <fo:block-container xsl:use-attribute-sets="dl-block-style">
6766
+
6767
+ <xsl:call-template name="setBlockSpanAll"/>
6774
6768
 
6775
6769
  <xsl:if test="not(ancestor::*[local-name() = 'quote'])">
6776
6770
  <xsl:attribute name="margin-left">0mm</xsl:attribute>
6777
6771
  </xsl:if>
6778
6772
 
6773
+ <xsl:if test="ancestor::*[local-name() = 'sourcecode']">
6774
+ <!-- set font-size as sourcecode font-size -->
6775
+ <xsl:variable name="sourcecode_attributes">
6776
+ <xsl:call-template name="get_sourcecode_attributes"/>
6777
+ </xsl:variable>
6778
+ <xsl:for-each select="xalan:nodeset($sourcecode_attributes)/sourcecode_attributes/@font-size">
6779
+ <xsl:attribute name="{local-name()}">
6780
+ <xsl:value-of select="."/>
6781
+ </xsl:attribute>
6782
+ </xsl:for-each>
6783
+ </xsl:if>
6784
+
6779
6785
  <xsl:if test="parent::*[local-name() = 'note']">
6780
6786
  <xsl:attribute name="margin-left">
6781
6787
  <xsl:choose>
@@ -7209,6 +7215,7 @@
7209
7215
  <xsl:param name="split_keep-within-line"/>
7210
7216
 
7211
7217
  <fo:table-row xsl:use-attribute-sets="dt-row-style">
7218
+
7212
7219
  <xsl:call-template name="insert_dt_cell">
7213
7220
  <xsl:with-param name="key_iso" select="$key_iso"/>
7214
7221
  <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
@@ -7230,6 +7237,7 @@
7230
7237
  <!-- border is mandatory, to calculate real width -->
7231
7238
  <xsl:attribute name="border">0.1pt solid black</xsl:attribute>
7232
7239
  <xsl:attribute name="text-align">left</xsl:attribute>
7240
+
7233
7241
  </xsl:if>
7234
7242
 
7235
7243
  <fo:block xsl:use-attribute-sets="dt-block-style">
@@ -7672,6 +7680,7 @@
7672
7680
  <fo:inline>
7673
7681
  <xsl:for-each select="$styles/style">
7674
7682
  <xsl:attribute name="{@name}"><xsl:value-of select="."/></xsl:attribute>
7683
+
7675
7684
  </xsl:for-each>
7676
7685
  <xsl:apply-templates/>
7677
7686
  </fo:inline>
@@ -8848,13 +8857,17 @@
8848
8857
  </xsl:template>
8849
8858
 
8850
8859
  <xsl:template match="*[local-name() = 'callout']">
8851
- <fo:basic-link internal-destination="{@target}" fox:alt-text="{@target}">&lt;<xsl:apply-templates/>&gt;</fo:basic-link>
8860
+ <xsl:choose>
8861
+ <xsl:when test="normalize-space(@target) = ''">&lt;<xsl:apply-templates/>&gt;</xsl:when>
8862
+ <xsl:otherwise><fo:basic-link internal-destination="{@target}" fox:alt-text="{@target}">&lt;<xsl:apply-templates/>&gt;</fo:basic-link></xsl:otherwise>
8863
+ </xsl:choose>
8852
8864
  </xsl:template>
8853
8865
 
8854
8866
  <xsl:template match="*[local-name() = 'annotation']">
8855
8867
  <xsl:variable name="annotation-id" select="@id"/>
8856
8868
  <xsl:variable name="callout" select="//*[@target = $annotation-id]/text()"/>
8857
8869
  <fo:block id="{$annotation-id}" white-space="nowrap">
8870
+
8858
8871
  <fo:inline>
8859
8872
  <xsl:apply-templates>
8860
8873
  <xsl:with-param name="callout" select="concat('&lt;', $callout, '&gt; ')"/>
@@ -8959,6 +8972,10 @@
8959
8972
  <!-- ====== -->
8960
8973
  <!-- ====== -->
8961
8974
 
8975
+ <xsl:template name="setBlockSpanAll">
8976
+ <xsl:if test="@columns = 1 or (local-name() = 'p' and *[@columns = 1])"><xsl:attribute name="span">all</xsl:attribute></xsl:if>
8977
+ </xsl:template>
8978
+
8962
8979
  <!-- ====== -->
8963
8980
  <!-- note -->
8964
8981
  <!-- termnote -->
@@ -8968,6 +8985,8 @@
8968
8985
 
8969
8986
  <fo:block-container id="{@id}" xsl:use-attribute-sets="note-style">
8970
8987
 
8988
+ <xsl:call-template name="setBlockSpanAll"/>
8989
+
8971
8990
  <fo:block-container margin-left="0mm" margin-right="0mm">
8972
8991
 
8973
8992
  <fo:block>
@@ -9018,6 +9037,8 @@
9018
9037
  <xsl:template match="*[local-name() = 'termnote']">
9019
9038
  <fo:block id="{@id}" xsl:use-attribute-sets="termnote-style">
9020
9039
 
9040
+ <xsl:call-template name="setBlockSpanAll"/>
9041
+
9021
9042
  <fo:inline xsl:use-attribute-sets="termnote-name-style">
9022
9043
 
9023
9044
  <xsl:if test="not(*[local-name() = 'name']/following-sibling::node()[1][self::text()][normalize-space()=''])">
@@ -9177,6 +9198,13 @@
9177
9198
  </fo:block>
9178
9199
  </xsl:template>
9179
9200
 
9201
+ <!-- SOURCE: ... -->
9202
+ <xsl:template match="*[local-name() = 'figure']/*[local-name() = 'source']" priority="2">
9203
+
9204
+ <xsl:call-template name="termsource"/>
9205
+
9206
+ </xsl:template>
9207
+
9180
9208
  <xsl:template match="*[local-name() = 'image']">
9181
9209
  <xsl:variable name="isAdded" select="../@added"/>
9182
9210
  <xsl:variable name="isDeleted" select="../@deleted"/>
@@ -10311,9 +10339,11 @@
10311
10339
  <xsl:attribute name="margin-bottom">0pt</xsl:attribute>
10312
10340
  </xsl:if>
10313
10341
 
10314
- <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
10342
+ <xsl:apply-templates select="node()[not(local-name() = 'name' or local-name() = 'dl')]"/>
10315
10343
  </fo:block>
10316
10344
 
10345
+ <xsl:apply-templates select="*[local-name() = 'dl']"/> <!-- Key table -->
10346
+
10317
10347
  <xsl:apply-templates select="*[local-name()='name']"/> <!-- show sourcecode's name AFTER content -->
10318
10348
 
10319
10349
  </fo:block-container>
@@ -10345,11 +10375,22 @@
10345
10375
  <!-- add sourcecode highlighting -->
10346
10376
  <xsl:template match="*[local-name()='sourcecode']//*[local-name()='span'][@class]" priority="2">
10347
10377
  <xsl:variable name="class" select="@class"/>
10378
+
10379
+ <!-- Example: <1> -->
10380
+ <xsl:variable name="is_callout">
10381
+ <xsl:if test="parent::*[local-name() = 'dt']">
10382
+ <xsl:variable name="dt_id" select="../@id"/>
10383
+ <xsl:if test="ancestor::*[local-name() = 'sourcecode']//*[local-name() = 'callout'][@target = $dt_id]">true</xsl:if>
10384
+ </xsl:if>
10385
+ </xsl:variable>
10386
+
10348
10387
  <xsl:choose>
10349
10388
  <xsl:when test="$sourcecode_css//class[@name = $class]">
10350
10389
  <fo:inline>
10351
10390
  <xsl:apply-templates select="$sourcecode_css//class[@name = $class]" mode="css"/>
10391
+ <xsl:if test="$is_callout = 'true'">&lt;</xsl:if>
10352
10392
  <xsl:apply-templates/>
10393
+ <xsl:if test="$is_callout = 'true'">&gt;</xsl:if>
10353
10394
  </fo:inline>
10354
10395
  </xsl:when>
10355
10396
  <xsl:otherwise>
@@ -10773,6 +10814,10 @@
10773
10814
  </fo:block>
10774
10815
  </xsl:template>
10775
10816
 
10817
+ <xsl:template match="*[local-name() = 'div']">
10818
+ <fo:block><xsl:apply-templates/></fo:block>
10819
+ </xsl:template>
10820
+
10776
10821
  <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']">
10777
10822
  <fo:block xsl:use-attribute-sets="inherit-style">
10778
10823
  <xsl:text>Dependency </xsl:text><xsl:apply-templates/>
@@ -10936,6 +10981,9 @@
10936
10981
  <!-- ====== -->
10937
10982
  <xsl:template match="*[local-name() = 'termexample']">
10938
10983
  <fo:block id="{@id}" xsl:use-attribute-sets="termexample-style">
10984
+
10985
+ <xsl:call-template name="setBlockSpanAll"/>
10986
+
10939
10987
  <xsl:apply-templates select="*[local-name()='name']"/>
10940
10988
  <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
10941
10989
  </fo:block>
@@ -10991,6 +11039,8 @@
10991
11039
 
10992
11040
  <fo:block-container id="{@id}" xsl:use-attribute-sets="example-style">
10993
11041
 
11042
+ <xsl:call-template name="setBlockSpanAll"/>
11043
+
10994
11044
  <xsl:variable name="fo_element">
10995
11045
  <xsl:if test=".//*[local-name() = 'table'] or .//*[local-name() = 'dl'] or *[not(local-name() = 'name')][1][local-name() = 'sourcecode']">block</xsl:if>
10996
11046
  block
@@ -11018,6 +11068,35 @@
11018
11068
  </fo:block-container>
11019
11069
  </xsl:when> <!-- end block -->
11020
11070
 
11071
+ <xsl:when test="contains(normalize-space($fo_element), 'list')">
11072
+
11073
+ <xsl:variable name="provisional_distance_between_starts">
11074
+ 7
11075
+ </xsl:variable>
11076
+ <xsl:variable name="indent">
11077
+ 0
11078
+ </xsl:variable>
11079
+
11080
+ <fo:list-block provisional-distance-between-starts="{$provisional_distance_between_starts}mm">
11081
+ <fo:list-item>
11082
+ <fo:list-item-label start-indent="{$indent}mm" end-indent="label-end()">
11083
+ <fo:block>
11084
+ <xsl:apply-templates select="*[local-name()='name']">
11085
+ <xsl:with-param name="fo_element">block</xsl:with-param>
11086
+ </xsl:apply-templates>
11087
+ </fo:block>
11088
+ </fo:list-item-label>
11089
+ <fo:list-item-body start-indent="body-start()">
11090
+ <fo:block>
11091
+ <xsl:apply-templates select="node()[not(local-name() = 'name')]">
11092
+ <xsl:with-param name="fo_element" select="$fo_element"/>
11093
+ </xsl:apply-templates>
11094
+ </fo:block>
11095
+ </fo:list-item-body>
11096
+ </fo:list-item>
11097
+ </fo:list-block>
11098
+ </xsl:when> <!-- end list -->
11099
+
11021
11100
  <xsl:otherwise> <!-- inline -->
11022
11101
 
11023
11102
  <!-- display 'EXAMPLE' and first element in the same line -->
@@ -11097,6 +11176,11 @@
11097
11176
  </fo:block>
11098
11177
  </fo:block-container>
11099
11178
  </xsl:when>
11179
+ <xsl:when test="starts-with(normalize-space($element), 'list')">
11180
+ <fo:block xsl:use-attribute-sets="example-p-style">
11181
+ <xsl:apply-templates/>
11182
+ </fo:block>
11183
+ </xsl:when>
11100
11184
  <xsl:otherwise>
11101
11185
  <fo:inline xsl:use-attribute-sets="example-p-style">
11102
11186
  <xsl:apply-templates/>
@@ -11214,6 +11298,9 @@
11214
11298
  <!-- ====== -->
11215
11299
  <xsl:template match="*[local-name() = 'quote']">
11216
11300
  <fo:block-container margin-left="0mm">
11301
+
11302
+ <xsl:call-template name="setBlockSpanAll"/>
11303
+
11217
11304
  <xsl:if test="parent::*[local-name() = 'note']">
11218
11305
  <xsl:if test="not(ancestor::*[local-name() = 'table'])">
11219
11306
  <xsl:attribute name="margin-left">5mm</xsl:attribute>
@@ -11433,13 +11520,8 @@
11433
11520
  </xsl:template>
11434
11521
 
11435
11522
  <xsl:template match="*[local-name() = 'deprecates']">
11436
- <xsl:variable name="title-deprecated">
11437
- <xsl:call-template name="getLocalizedString">
11438
- <xsl:with-param name="key">deprecated</xsl:with-param>
11439
- </xsl:call-template>
11440
- </xsl:variable>
11441
11523
  <fo:block xsl:use-attribute-sets="deprecates-style">
11442
- <xsl:value-of select="$title-deprecated"/>: <xsl:apply-templates/>
11524
+ <xsl:apply-templates/>
11443
11525
  </fo:block>
11444
11526
  </xsl:template>
11445
11527
 
@@ -11499,6 +11581,8 @@
11499
11581
  <fo:block>
11500
11582
  <xsl:call-template name="setId"/>
11501
11583
 
11584
+ <xsl:call-template name="setBlockSpanAll"/>
11585
+
11502
11586
  <xsl:apply-templates/>
11503
11587
  </fo:block>
11504
11588
  </xsl:template>
@@ -11513,6 +11597,8 @@
11513
11597
  <fo:block break-after="page"/>
11514
11598
  <fo:block id="{@id}">
11515
11599
 
11600
+ <xsl:call-template name="setBlockSpanAll"/>
11601
+
11516
11602
  </fo:block>
11517
11603
  <xsl:apply-templates/>
11518
11604
  </xsl:template>
@@ -12489,6 +12575,8 @@
12489
12575
  <!-- text in the box -->
12490
12576
  <fo:block-container id="{@id}" xsl:use-attribute-sets="admonition-style">
12491
12577
 
12578
+ <xsl:call-template name="setBlockSpanAll"/>
12579
+
12492
12580
  <xsl:if test="@type = 'editorial'">
12493
12581
  <xsl:attribute name="border">none</xsl:attribute>
12494
12582
  <!-- <xsl:attribute name="font-weight">bold</xsl:attribute>
@@ -12700,6 +12788,33 @@
12700
12788
  <xsl:apply-templates mode="update_xml_step1"/>
12701
12789
  </xsl:copy>
12702
12790
  </xsl:template>
12791
+
12792
+ <!-- remove semantic xml -->
12793
+ <xsl:template match="*[local-name() = 'metanorma-extension']/*[local-name() = 'metanorma']/*[local-name() = 'source']" mode="update_xml_step1"/>
12794
+
12795
+ <!-- remove image/emf -->
12796
+ <xsl:template match="*[local-name() = 'image']/*[local-name() = 'emf']" mode="update_xml_step1"/>
12797
+
12798
+ <xsl:template match="*[local-name() = 'stem'] | *[local-name() = 'image']" mode="update_xml_step1">
12799
+ <xsl:copy-of select="."/>
12800
+ </xsl:template>
12801
+
12802
+ <!-- add @id, redundant for table auto-layout algorithm -->
12803
+ <xsl:template match="*[local-name() = 'dl' or local-name() = 'table'][not(@id)]" mode="update_xml_step1">
12804
+ <xsl:copy>
12805
+ <xsl:copy-of select="@*"/>
12806
+ <xsl:call-template name="add_id"/>
12807
+ <xsl:apply-templates mode="update_xml_step1"/>
12808
+ </xsl:copy>
12809
+ </xsl:template>
12810
+
12811
+ <xsl:template name="add_id">
12812
+ <xsl:if test="not(@id)">
12813
+ <!-- add @id - first element with @id plus '_element_name' -->
12814
+ <xsl:attribute name="id"><xsl:value-of select="(.//*[@id])[1]/@id"/>_<xsl:value-of select="local-name()"/></xsl:attribute>
12815
+ </xsl:if>
12816
+ </xsl:template>
12817
+
12703
12818
  <!-- =========================================================================== -->
12704
12819
  <!-- END STEP1: Re-order elements in 'preface', 'sections' based on @displayorder -->
12705
12820
  <!-- =========================================================================== -->
@@ -12800,6 +12915,10 @@
12800
12915
  </xsl:call-template>
12801
12916
  </xsl:template>
12802
12917
 
12918
+ <xsl:template match="*[local-name() = 'stem'] | *[local-name() = 'image']" mode="update_xml_step2">
12919
+ <xsl:copy-of select="."/>
12920
+ </xsl:template>
12921
+
12803
12922
  <!-- =========================================================================== -->
12804
12923
  <!-- END STEP2: add 'fn' after 'eref' and 'origin', if referenced to bibitem with 'note' = Withdrawn.' or 'Cancelled and replaced...' -->
12805
12924
  <!-- =========================================================================== -->
@@ -12821,7 +12940,7 @@
12821
12940
 
12822
12941
  <xsl:variable name="element_name_keep-together_within-line">keep-together_within-line</xsl:variable>
12823
12942
 
12824
- <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">
12943
+ <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">
12825
12944
 
12826
12945
  <!-- enclose standard's number into tag 'keep-together_within-line' -->
12827
12946
  <xsl:variable name="tag_keep-together_within-line_open">###<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable>
@@ -12895,6 +13014,10 @@
12895
13014
 
12896
13015
  </xsl:template>
12897
13016
 
13017
+ <xsl:template match="*[local-name() = 'stem'] | *[local-name() = 'image']" mode="update_xml_enclose_keep-together_within-line">
13018
+ <xsl:copy-of select="."/>
13019
+ </xsl:template>
13020
+
12898
13021
  <xsl:template name="replace_text_tags">
12899
13022
  <xsl:param name="tag_open"/>
12900
13023
  <xsl:param name="tag_close"/>
@@ -12921,6 +13044,194 @@
12921
13044
  <!-- END XML UPDATE STEP: enclose standard's name into tag 'keep-together_within-line' -->
12922
13045
  <!-- ===================================== -->
12923
13046
 
13047
+ <!-- ===================================== -->
13048
+ <!-- ===================================== -->
13049
+ <!-- Make linear XML (need for landscape orientation) -->
13050
+ <!-- ===================================== -->
13051
+ <!-- ===================================== -->
13052
+ <xsl:template match="@*|node()" mode="linear_xml">
13053
+ <xsl:copy>
13054
+ <xsl:apply-templates select="@*|node()" mode="linear_xml"/>
13055
+ </xsl:copy>
13056
+ </xsl:template>
13057
+
13058
+ <xsl:template match="processing-instruction()" mode="linear_xml">
13059
+ <xsl:copy-of select="."/>
13060
+ </xsl:template>
13061
+
13062
+ <!-- From:
13063
+ <clause>
13064
+ <title>...</title>
13065
+ <p>...</p>
13066
+ </clause>
13067
+ To:
13068
+ <clause/>
13069
+ <title>...</title>
13070
+ <p>...</p>
13071
+ -->
13072
+ <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">
13073
+
13074
+ <xsl:copy>
13075
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
13076
+
13077
+ <xsl:attribute name="keep-with-next">always</xsl:attribute>
13078
+
13079
+ <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'">
13080
+ <xsl:attribute name="mainsection">true</xsl:attribute>
13081
+ </xsl:if>
13082
+ </xsl:copy>
13083
+
13084
+ <xsl:apply-templates mode="linear_xml"/>
13085
+ </xsl:template>
13086
+
13087
+ <xsl:template match="*[local-name() = 'term']" mode="linear_xml" priority="2">
13088
+ <xsl:copy>
13089
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
13090
+ <xsl:attribute name="keep-with-next">always</xsl:attribute>
13091
+ <xsl:variable name="level">
13092
+ <xsl:call-template name="getLevel"/>
13093
+ </xsl:variable>
13094
+ <xsl:attribute name="depth"><xsl:value-of select="$level"/></xsl:attribute>
13095
+ <xsl:attribute name="ancestor">sections</xsl:attribute>
13096
+ <xsl:apply-templates select="node()[not(local-name() = 'term')]" mode="linear_xml"/>
13097
+ </xsl:copy>
13098
+ <xsl:apply-templates select="*[local-name() = 'term']" mode="linear_xml"/>
13099
+ </xsl:template>
13100
+
13101
+ <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">
13102
+ <xsl:copy>
13103
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
13104
+
13105
+ <xsl:attribute name="keep-with-next">always</xsl:attribute>
13106
+
13107
+ <xsl:variable name="level">
13108
+ <xsl:call-template name="getLevel"/>
13109
+ </xsl:variable>
13110
+ <xsl:attribute name="depth"><xsl:value-of select="$level"/></xsl:attribute>
13111
+
13112
+ <xsl:if test="parent::*[local-name() = 'annex']">
13113
+ <xsl:attribute name="depth">1</xsl:attribute>
13114
+ </xsl:if>
13115
+
13116
+ <xsl:if test="../@inline-header = 'true' and following-sibling::*[1][local-name() = 'p']">
13117
+ <xsl:copy-of select="../@inline-header"/>
13118
+ </xsl:if>
13119
+
13120
+ <xsl:attribute name="ancestor">
13121
+ <xsl:choose>
13122
+ <xsl:when test="ancestor::*[local-name() = 'foreword']">foreword</xsl:when>
13123
+ <xsl:when test="ancestor::*[local-name() = 'introduction']">introduction</xsl:when>
13124
+ <xsl:when test="ancestor::*[local-name() = 'sections']">sections</xsl:when>
13125
+ <xsl:when test="ancestor::*[local-name() = 'annex']">annex</xsl:when>
13126
+ <xsl:when test="ancestor::*[local-name() = 'bibliography']">bibliography</xsl:when>
13127
+ </xsl:choose>
13128
+ </xsl:attribute>
13129
+
13130
+ <xsl:apply-templates mode="linear_xml"/>
13131
+ </xsl:copy>
13132
+ </xsl:template>
13133
+
13134
+ <!-- add @to = figure, table, clause -->
13135
+ <!-- add @depth = from -->
13136
+ <xsl:template match="*[local-name() = 'xref']" mode="linear_xml">
13137
+ <xsl:copy>
13138
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
13139
+ <xsl:variable name="target" select="@target"/>
13140
+ <xsl:attribute name="to">
13141
+ <xsl:value-of select="local-name(//*[@id = current()/@target][1])"/>
13142
+ </xsl:attribute>
13143
+ <xsl:attribute name="depth">
13144
+ <xsl:value-of select="//*[@id = current()/@target][1]/*[local-name() = 'title']/@depth"/>
13145
+ </xsl:attribute>
13146
+ <xsl:apply-templates select="node()" mode="linear_xml"/>
13147
+ </xsl:copy>
13148
+ </xsl:template>
13149
+
13150
+ <xsl:template match="*[not(ancestor::*[local-name() = 'sourcecode'])]/*[local-name() = 'p' or local-name() = 'strong' or local-name() = 'em']/text()" mode="linear_xml">
13151
+ <xsl:choose>
13152
+ <xsl:when test="contains(., $non_breaking_hyphen)">
13153
+ <xsl:call-template name="replaceChar">
13154
+ <xsl:with-param name="text" select="."/>
13155
+ <xsl:with-param name="replace" select="$non_breaking_hyphen"/>
13156
+ <xsl:with-param name="by" select="'-'"/>
13157
+ </xsl:call-template>
13158
+ </xsl:when>
13159
+ <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
13160
+ </xsl:choose>
13161
+ </xsl:template>
13162
+
13163
+ <xsl:template name="replaceChar">
13164
+ <xsl:param name="text"/>
13165
+ <xsl:param name="replace"/>
13166
+ <xsl:param name="by"/>
13167
+ <xsl:choose>
13168
+ <xsl:when test="$text = '' or $replace = '' or not($replace)">
13169
+ <xsl:value-of select="$text"/>
13170
+ </xsl:when>
13171
+ <xsl:when test="contains($text, $replace)">
13172
+ <xsl:value-of select="substring-before($text,$replace)"/>
13173
+ <xsl:element name="inlineChar" namespace="https://www.metanorma.org/ns/jis"><xsl:value-of select="$by"/></xsl:element>
13174
+ <xsl:call-template name="replaceChar">
13175
+ <xsl:with-param name="text" select="substring-after($text,$replace)"/>
13176
+ <xsl:with-param name="replace" select="$replace"/>
13177
+ <xsl:with-param name="by" select="$by"/>
13178
+ </xsl:call-template>
13179
+ </xsl:when>
13180
+ <xsl:otherwise>
13181
+ <xsl:value-of select="$text"/>
13182
+ </xsl:otherwise>
13183
+ </xsl:choose>
13184
+ </xsl:template>
13185
+
13186
+ <xsl:template match="*[local-name() = 'inlineChar']">
13187
+ <fo:inline><xsl:value-of select="."/></fo:inline>
13188
+ </xsl:template>
13189
+
13190
+ <!-- change @reference to actual value, and add skip_footnote_body="true" for repeatable (2nd, 3rd, ...) -->
13191
+ <!--
13192
+ <fn reference="1">
13193
+ <p id="_8e5cf917-f75a-4a49-b0aa-1714cb6cf954">Formerly denoted as 15 % (m/m).</p>
13194
+ </fn>
13195
+ -->
13196
+ <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">
13197
+ <xsl:variable name="p_fn_">
13198
+ <xsl:call-template name="get_fn_list"/>
13199
+ </xsl:variable>
13200
+ <xsl:variable name="p_fn" select="xalan:nodeset($p_fn_)"/>
13201
+ <xsl:variable name="gen_id" select="generate-id(.)"/>
13202
+ <xsl:variable name="lang" select="ancestor::*[contains(local-name(), '-standard')]/*[local-name()='bibdata']//*[local-name()='language'][@current = 'true']"/>
13203
+ <xsl:variable name="reference" select="@reference"/>
13204
+ <!-- fn sequence number in document -->
13205
+ <xsl:variable name="current_fn_number" select="count($p_fn//fn[@reference = $reference]/preceding-sibling::fn) + 1"/>
13206
+
13207
+ <xsl:copy>
13208
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
13209
+ <!-- put actual reference number -->
13210
+ <xsl:attribute name="current_fn_number">
13211
+ <xsl:value-of select="$current_fn_number"/>
13212
+ </xsl:attribute>
13213
+ <xsl:attribute name="skip_footnote_body"> <!-- false for repeatable footnote -->
13214
+ <xsl:value-of select="not($p_fn//fn[@gen_id = $gen_id] and (1 = 1))"/>
13215
+ </xsl:attribute>
13216
+ <xsl:apply-templates select="node()" mode="linear_xml"/>
13217
+ </xsl:copy>
13218
+ </xsl:template>
13219
+
13220
+ <xsl:template match="*[local-name() = 'p'][@type = 'section-title']" priority="3" mode="linear_xml">
13221
+ <xsl:copy>
13222
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
13223
+ <xsl:if test="@depth = '1'">
13224
+ <xsl:attribute name="mainsection">true</xsl:attribute>
13225
+ </xsl:if>
13226
+ <xsl:apply-templates select="node()" mode="linear_xml"/>
13227
+ </xsl:copy>
13228
+ </xsl:template>
13229
+ <!-- ===================================== -->
13230
+ <!-- ===================================== -->
13231
+ <!-- END: Make linear XML (need for landscape orientation) -->
13232
+ <!-- ===================================== -->
13233
+ <!-- ===================================== -->
13234
+
12924
13235
  <!-- for correct rendering combining chars -->
12925
13236
  <xsl:template match="*[local-name() = 'lang_none']">
12926
13237
  <fo:inline xml:lang="none"><xsl:value-of select="."/></fo:inline>