metanorma-mpfa 0.6.1 → 0.6.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -32,6 +32,9 @@
32
32
  <optional>
33
33
  <ref name="doctype"/>
34
34
  </optional>
35
+ <optional>
36
+ <ref name="docsubtype"/>
37
+ </optional>
35
38
  <ref name="editorialgroup"/>
36
39
  <zeroOrMore>
37
40
  <ref name="ics"/>
@@ -10,7 +10,7 @@ module IsoDoc
10
10
  @meta = Metadata.new(lang, script, labels)
11
11
  end
12
12
 
13
- def xref_init(lang, script, klass, labels, options)
13
+ def xref_init(lang, script, _klass, labels, options)
14
14
  html = HtmlConvert.new(language: lang, script: script)
15
15
  @xrefs = Xref.new(lang, script, html, labels, options)
16
16
  end
@@ -25,4 +25,3 @@ module IsoDoc
25
25
  end
26
26
  end
27
27
  end
28
-
@@ -1,15 +1,15 @@
1
1
  require "isodoc"
2
2
  require "twitter_cldr"
3
- require 'date'
3
+ require "date"
4
4
 
5
5
  module IsoDoc
6
6
  module MPFA
7
-
8
7
  class Metadata < IsoDoc::Metadata
9
8
  def initialize(lang, script, labels)
10
9
  super
11
- here = File.dirname(__FILE__)
12
- set(:logo, File.expand_path(File.join(here, "html", "mpfa-logo-no-text@4x.png")))
10
+ here = File.dirname(__FILE__)
11
+ set(:logo, File.expand_path(File.join(here, "html",
12
+ "mpfa-logo-no-text@4x.png")))
13
13
  end
14
14
 
15
15
  def title(isoxml, _out)
@@ -32,10 +32,10 @@ module IsoDoc
32
32
  end
33
33
 
34
34
  def doctype(isoxml, _out)
35
- b = isoxml&.at(ns("//bibdata/ext/doctype"))&.text || return
36
- return unless b
37
- t = b.split(/[- ]/).
38
- map{ |w| w.capitalize unless w == "MPF" }.join(" ")
35
+ b = isoxml&.at(ns("//bibdata/ext/doctype"))&.text or return
36
+
37
+ t = b.split(/[- ]/)
38
+ .map { |w| w.capitalize unless w == "MPF" }.join(" ")
39
39
  set(:doctype, t)
40
40
  end
41
41
 
@@ -51,21 +51,21 @@ module IsoDoc
51
51
 
52
52
  def version(isoxml, _out)
53
53
  super
54
- edition = isoxml.at(ns("//version/edition"))
54
+ edition = isoxml.at(ns("//bibdata/version/edition"))
55
55
  if edition
56
56
  set(
57
57
  :edition,
58
- edition.text.to_i.localize.
59
- to_rbnf_s("SpelloutRules", "spellout-ordinal").
60
- split(/(\W)/).map(&:capitalize).join
58
+ edition.text.to_i.localize
59
+ .to_rbnf_s("SpelloutRules", "spellout-ordinal")
60
+ .split(/(\W)/).map(&:capitalize).join,
61
61
  )
62
62
  end
63
63
  end
64
64
 
65
65
  def monthyr(isodate)
66
66
  date = DateTime.parse(isodate)
67
- date.strftime('%-d %B %Y') #=> "Sun 04 Feb 2001"
68
- rescue
67
+ date.strftime("%-d %B %Y") #=> "Sun 04 Feb 2001"
68
+ rescue StandardError
69
69
  # invalid dates get thrown
70
70
  isodate
71
71
  end
@@ -12,8 +12,12 @@
12
12
 
13
13
 
14
14
  <xsl:variable name="debug">false</xsl:variable>
15
- <xsl:variable name="pageWidth" select="'210mm'"/>
16
- <xsl:variable name="pageHeight" select="'297mm'"/>
15
+ <xsl:variable name="pageWidth" select="210"/>
16
+ <xsl:variable name="pageHeight" select="297"/>
17
+ <xsl:variable name="marginLeftRight1" select="19"/>
18
+ <xsl:variable name="marginLeftRight2" select="19"/>
19
+ <xsl:variable name="marginTop" select="16.5"/>
20
+ <xsl:variable name="marginBottom" select="10"/>
17
21
 
18
22
  <xsl:variable name="copyrightHolder">Ribose Group Inc.</xsl:variable>
19
23
 
@@ -63,7 +67,7 @@
63
67
  <fo:layout-master-set>
64
68
 
65
69
  <!-- cover page -->
66
- <fo:simple-page-master master-name="cover" page-width="{$pageWidth}" page-height="{$pageHeight}">
70
+ <fo:simple-page-master master-name="cover" page-width="{$pageWidth}mm" page-height="{$pageHeight}mm">
67
71
  <fo:region-body margin-top="24mm" margin-bottom="10mm" margin-left="19mm" margin-right="19mm"/>
68
72
  <fo:region-before region-name="cover-header" extent="24mm"/>
69
73
  <fo:region-after region-name="footer" extent="10mm"/>
@@ -72,19 +76,19 @@
72
76
  </fo:simple-page-master>
73
77
 
74
78
  <!-- document pages -->
75
- <fo:simple-page-master master-name="odd" page-width="{$pageWidth}" page-height="{$pageHeight}">
76
- <fo:region-body margin-top="16.5mm" margin-bottom="10mm" margin-left="19mm" margin-right="19mm"/>
77
- <fo:region-before region-name="header-odd" extent="16.5mm"/>
78
- <fo:region-after region-name="footer-odd" extent="10mm"/>
79
- <fo:region-start region-name="left-region" extent="19mm"/>
80
- <fo:region-end region-name="right-region" extent="19mm"/>
79
+ <fo:simple-page-master master-name="odd" page-width="{$pageWidth}mm" page-height="{$pageHeight}mm">
80
+ <fo:region-body margin-top="{$marginTop}mm" margin-bottom="{$marginBottom}mm" margin-left="{$marginLeftRight1}mm" margin-right="{$marginLeftRight2}mm"/>
81
+ <fo:region-before region-name="header-odd" extent="{$marginTop}mm"/>
82
+ <fo:region-after region-name="footer-odd" extent="{$marginBottom}mm"/>
83
+ <fo:region-start region-name="left-region" extent="{$marginLeftRight1}mm"/>
84
+ <fo:region-end region-name="right-region" extent="{$marginLeftRight2}mm"/>
81
85
  </fo:simple-page-master>
82
- <fo:simple-page-master master-name="even" page-width="{$pageWidth}" page-height="{$pageHeight}">
83
- <fo:region-body margin-top="16.5mm" margin-bottom="10mm" margin-left="19mm" margin-right="19mm"/>
84
- <fo:region-before region-name="header-even" extent="16.5mm"/>
85
- <fo:region-after region-name="footer-even" extent="10mm"/>
86
- <fo:region-start region-name="left-region" extent="19mm"/>
87
- <fo:region-end region-name="right-region" extent="19mm"/>
86
+ <fo:simple-page-master master-name="even" page-width="{$pageWidth}mm" page-height="{$pageHeight}mm">
87
+ <fo:region-body margin-top="{$marginTop}mm" margin-bottom="{$marginBottom}mm" margin-left="{$marginLeftRight2}mm" margin-right="{$marginLeftRight1}mm"/>
88
+ <fo:region-before region-name="header-even" extent="{$marginTop}mm"/>
89
+ <fo:region-after region-name="footer-even" extent="{$marginBottom}mm"/>
90
+ <fo:region-start region-name="left-region" extent="{$marginLeftRight2}mm"/>
91
+ <fo:region-end region-name="right-region" extent="{$marginLeftRight1}mm"/>
88
92
  </fo:simple-page-master>
89
93
 
90
94
  <fo:page-sequence-master master-name="document">
@@ -912,6 +916,9 @@
912
916
  <title-continued lang="en">(continued)</title-continued>
913
917
  <title-continued lang="fr">(continué)</title-continued>
914
918
 
919
+ </xsl:variable><xsl:variable name="bibdata">
920
+ <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']"/>
921
+ <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'localized-strings']"/>
915
922
  </xsl:variable><xsl:variable name="tab_zh"> </xsl:variable><xsl:template name="getTitle">
916
923
  <xsl:param name="name"/>
917
924
  <xsl:param name="lang"/>
@@ -940,11 +947,13 @@
940
947
 
941
948
  </xsl:attribute-set><xsl:attribute-set name="link-style">
942
949
 
950
+
943
951
  <xsl:attribute name="color">blue</xsl:attribute>
944
952
  <xsl:attribute name="text-decoration">underline</xsl:attribute>
945
953
 
946
954
 
947
955
 
956
+
948
957
  </xsl:attribute-set><xsl:attribute-set name="sourcecode-style">
949
958
  <xsl:attribute name="white-space">pre</xsl:attribute>
950
959
  <xsl:attribute name="wrap-option">wrap</xsl:attribute>
@@ -986,7 +995,7 @@
986
995
 
987
996
 
988
997
 
989
-
998
+
990
999
  </xsl:attribute-set><xsl:attribute-set name="example-style">
991
1000
 
992
1001
 
@@ -999,6 +1008,7 @@
999
1008
 
1000
1009
 
1001
1010
 
1011
+
1002
1012
  </xsl:attribute-set><xsl:attribute-set name="example-body-style">
1003
1013
 
1004
1014
 
@@ -1018,9 +1028,7 @@
1018
1028
 
1019
1029
 
1020
1030
 
1021
-
1022
-
1023
-
1031
+
1024
1032
 
1025
1033
 
1026
1034
 
@@ -1053,8 +1061,10 @@
1053
1061
 
1054
1062
 
1055
1063
 
1064
+
1056
1065
  </xsl:attribute-set><xsl:attribute-set name="table-name-style">
1057
1066
  <xsl:attribute name="keep-with-next">always</xsl:attribute>
1067
+
1058
1068
 
1059
1069
 
1060
1070
 
@@ -1071,6 +1081,9 @@
1071
1081
  <xsl:attribute name="font-size">11pt</xsl:attribute>
1072
1082
 
1073
1083
 
1084
+
1085
+ </xsl:attribute-set><xsl:attribute-set name="table-footer-cell-style">
1086
+
1074
1087
  </xsl:attribute-set><xsl:attribute-set name="appendix-style">
1075
1088
 
1076
1089
 
@@ -1082,22 +1095,27 @@
1082
1095
  </xsl:attribute-set><xsl:attribute-set name="xref-style">
1083
1096
 
1084
1097
 
1098
+
1085
1099
  <xsl:attribute name="color">blue</xsl:attribute>
1086
1100
  <xsl:attribute name="text-decoration">underline</xsl:attribute>
1087
1101
 
1088
1102
 
1103
+
1089
1104
  </xsl:attribute-set><xsl:attribute-set name="eref-style">
1090
1105
 
1091
1106
 
1107
+
1092
1108
  <xsl:attribute name="color">blue</xsl:attribute>
1093
1109
  <xsl:attribute name="text-decoration">underline</xsl:attribute>
1094
1110
 
1095
1111
 
1096
1112
 
1113
+
1097
1114
  </xsl:attribute-set><xsl:attribute-set name="note-style">
1098
1115
 
1099
1116
 
1100
1117
 
1118
+
1101
1119
 
1102
1120
 
1103
1121
 
@@ -1109,6 +1127,7 @@
1109
1127
 
1110
1128
 
1111
1129
 
1130
+
1112
1131
  </xsl:attribute-set><xsl:variable name="note-body-indent">10mm</xsl:variable><xsl:variable name="note-body-indent-table">5mm</xsl:variable><xsl:attribute-set name="note-name-style">
1113
1132
 
1114
1133
 
@@ -1122,6 +1141,7 @@
1122
1141
 
1123
1142
 
1124
1143
 
1144
+
1125
1145
  </xsl:attribute-set><xsl:attribute-set name="note-p-style">
1126
1146
 
1127
1147
 
@@ -1142,9 +1162,13 @@
1142
1162
 
1143
1163
 
1144
1164
 
1165
+
1166
+
1145
1167
  </xsl:attribute-set><xsl:attribute-set name="termnote-name-style">
1168
+
1146
1169
 
1147
1170
 
1171
+
1148
1172
  </xsl:attribute-set><xsl:attribute-set name="quote-style">
1149
1173
 
1150
1174
 
@@ -1168,14 +1192,18 @@
1168
1192
 
1169
1193
 
1170
1194
 
1195
+
1196
+
1171
1197
  </xsl:attribute-set><xsl:attribute-set name="origin-style">
1172
1198
 
1173
1199
 
1174
1200
 
1201
+
1175
1202
  </xsl:attribute-set><xsl:attribute-set name="term-style">
1176
1203
 
1177
1204
  </xsl:attribute-set><xsl:attribute-set name="figure-name-style">
1178
1205
 
1206
+
1179
1207
 
1180
1208
 
1181
1209
 
@@ -1189,6 +1217,7 @@
1189
1217
 
1190
1218
 
1191
1219
 
1220
+
1192
1221
 
1193
1222
 
1194
1223
 
@@ -1209,10 +1238,12 @@
1209
1238
 
1210
1239
 
1211
1240
 
1241
+
1212
1242
  </xsl:attribute-set><xsl:attribute-set name="figure-pseudocode-p-style">
1213
1243
 
1214
1244
  </xsl:attribute-set><xsl:attribute-set name="image-graphic-style">
1215
1245
 
1246
+
1216
1247
  <xsl:attribute name="width">100%</xsl:attribute>
1217
1248
  <xsl:attribute name="content-height">scale-to-fit</xsl:attribute>
1218
1249
  <xsl:attribute name="scaling">uniform</xsl:attribute>
@@ -1237,11 +1268,14 @@
1237
1268
  </xsl:attribute-set><xsl:attribute-set name="admitted-style">
1238
1269
 
1239
1270
 
1271
+
1240
1272
  </xsl:attribute-set><xsl:attribute-set name="deprecates-style">
1241
1273
 
1274
+
1242
1275
  </xsl:attribute-set><xsl:attribute-set name="definition-style">
1243
1276
 
1244
1277
 
1278
+
1245
1279
  </xsl:attribute-set><xsl:variable name="color-added-text">
1246
1280
  <xsl:text>rgb(0, 255, 0)</xsl:text>
1247
1281
  </xsl:variable><xsl:attribute-set name="add-style">
@@ -1260,6 +1294,8 @@
1260
1294
  <xsl:attribute name="font-family">STIX Two Math</xsl:attribute>
1261
1295
 
1262
1296
 
1297
+ </xsl:attribute-set><xsl:attribute-set name="list-style">
1298
+
1263
1299
  </xsl:attribute-set><xsl:variable name="border-block-added">2.5pt solid rgb(0, 176, 80)</xsl:variable><xsl:variable name="border-block-deleted">2.5pt solid rgb(255, 0, 0)</xsl:variable><xsl:template name="processPrefaceSectionsDefault_Contents">
1264
1300
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='abstract']" mode="contents"/>
1265
1301
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='foreword']" mode="contents"/>
@@ -1270,14 +1306,15 @@
1270
1306
  <xsl:apply-templates select="/*/*[local-name()='sections']/*[local-name()='clause'][@type='scope']" mode="contents"/>
1271
1307
 
1272
1308
  <!-- Normative references -->
1273
- <xsl:apply-templates select="/*/*[local-name()='bibliography']/*[local-name()='references'][@normative='true']" mode="contents"/>
1309
+ <xsl:apply-templates select="/*/*[local-name()='bibliography']/*[local-name()='references'][@normative='true'] | /*/*[local-name()='bibliography']/*[local-name()='clause'][*[local-name()='references'][@normative='true']]" mode="contents"/>
1274
1310
  <!-- Terms and definitions -->
1275
1311
  <xsl:apply-templates select="/*/*[local-name()='sections']/*[local-name()='terms'] | /*/*[local-name()='sections']/*[local-name()='clause'][.//*[local-name()='terms']] | /*/*[local-name()='sections']/*[local-name()='definitions'] | /*/*[local-name()='sections']/*[local-name()='clause'][.//*[local-name()='definitions']]" mode="contents"/>
1276
1312
  <!-- Another main sections -->
1277
1313
  <xsl:apply-templates select="/*/*[local-name()='sections']/*[local-name() != 'terms' and local-name() != 'definitions' and not(@type='scope') and not(local-name() = 'clause' and .//*[local-name()='terms']) and not(local-name() = 'clause' and .//*[local-name()='definitions'])]" mode="contents"/>
1278
1314
  <xsl:apply-templates select="/*/*[local-name()='annex']" mode="contents"/>
1279
1315
  <!-- Bibliography -->
1280
- <xsl:apply-templates select="/*/*[local-name()='bibliography']/*[local-name()='references'][not(@normative='true')]" mode="contents"/>
1316
+ <xsl:apply-templates select="/*/*[local-name()='bibliography']/*[local-name()='references'][not(@normative='true')] | /*/*[local-name()='bibliography']/*[local-name()='clause'][*[local-name()='references'][not(@normative='true')]]" mode="contents"/>
1317
+
1281
1318
  </xsl:template><xsl:template name="processPrefaceSectionsDefault">
1282
1319
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='abstract']"/>
1283
1320
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='foreword']"/>
@@ -1313,11 +1350,11 @@
1313
1350
  <xsl:variable name="table">
1314
1351
 
1315
1352
  <xsl:variable name="simple-table">
1316
- <xsl:call-template name="getSimpleTable"/>
1353
+ <xsl:call-template name="getSimpleTable"/>
1317
1354
  </xsl:variable>
1318
1355
 
1319
1356
  <!-- <xsl:if test="$namespace = 'bipm'">
1320
- <fo:block>&#xA0;</fo:block>
1357
+ <fo:block>&#xA0;</fo:block>
1321
1358
  </xsl:if> -->
1322
1359
 
1323
1360
  <!-- $namespace = 'iso' or -->
@@ -1380,6 +1417,7 @@
1380
1417
  <fo:block-container margin-left="-{$margin-left}mm" margin-right="-{$margin-left}mm">
1381
1418
 
1382
1419
 
1420
+
1383
1421
 
1384
1422
 
1385
1423
 
@@ -1390,6 +1428,8 @@
1390
1428
 
1391
1429
 
1392
1430
 
1431
+
1432
+
1393
1433
  <xsl:attribute name="space-after">12pt</xsl:attribute>
1394
1434
  <xsl:attribute name="margin-left">0mm</xsl:attribute>
1395
1435
  <xsl:attribute name="margin-right">0mm</xsl:attribute>
@@ -1413,6 +1453,7 @@
1413
1453
 
1414
1454
 
1415
1455
 
1456
+
1416
1457
 
1417
1458
 
1418
1459
 
@@ -1422,6 +1463,7 @@
1422
1463
  <attribute name="border-bottom">2pt solid black</attribute>
1423
1464
 
1424
1465
 
1466
+
1425
1467
  </xsl:variable>
1426
1468
 
1427
1469
 
@@ -1558,11 +1600,25 @@
1558
1600
  </xsl:choose>
1559
1601
 
1560
1602
  </xsl:template><xsl:template match="*[local-name()='table']/*[local-name() = 'name']"/><xsl:template match="*[local-name()='table']/*[local-name() = 'name']" mode="presentation">
1603
+ <xsl:param name="continued"/>
1561
1604
  <xsl:if test="normalize-space() != ''">
1562
1605
  <fo:block xsl:use-attribute-sets="table-name-style">
1563
1606
 
1564
1607
 
1565
- <xsl:apply-templates/>
1608
+
1609
+
1610
+
1611
+ <xsl:choose>
1612
+ <xsl:when test="$continued = 'true'">
1613
+ <!-- <xsl:if test="$namespace = 'bsi'"></xsl:if> -->
1614
+
1615
+ </xsl:when>
1616
+ <xsl:otherwise>
1617
+ <xsl:apply-templates/>
1618
+ </xsl:otherwise>
1619
+ </xsl:choose>
1620
+
1621
+
1566
1622
  </fo:block>
1567
1623
  </xsl:if>
1568
1624
  </xsl:template><xsl:template name="calculate-columns-numbers">
@@ -1699,21 +1755,22 @@
1699
1755
  <!-- font-weight="bold" -->
1700
1756
  <fo:table-header>
1701
1757
 
1758
+
1702
1759
  <xsl:apply-templates/>
1703
1760
  </fo:table-header>
1704
1761
  </xsl:template><xsl:template name="table-header-title">
1705
- <xsl:param name="cols-count"/>
1762
+ <xsl:param name="cols-count"/>
1706
1763
  <!-- row for title -->
1707
1764
  <fo:table-row>
1708
1765
  <fo:table-cell number-columns-spanned="{$cols-count}" border-left="1.5pt solid white" border-right="1.5pt solid white" border-top="1.5pt solid white" border-bottom="1.5pt solid black">
1709
- <xsl:apply-templates select="ancestor::*[local-name()='table']/*[local-name()='name']" mode="presentation"/>
1766
+
1767
+ <xsl:apply-templates select="ancestor::*[local-name()='table']/*[local-name()='name']" mode="presentation">
1768
+ <xsl:with-param name="continued">true</xsl:with-param>
1769
+ </xsl:apply-templates>
1710
1770
  <xsl:for-each select="ancestor::*[local-name()='table'][1]">
1711
1771
  <xsl:call-template name="fn_name_display"/>
1712
- </xsl:for-each>
1713
- <fo:block text-align="right" font-style="italic">
1714
- <xsl:text> </xsl:text>
1715
- <fo:retrieve-table-marker retrieve-class-name="table_continued"/>
1716
- </fo:block>
1772
+ </xsl:for-each>
1773
+
1717
1774
  </fo:table-cell>
1718
1775
  </fo:table-row>
1719
1776
  </xsl:template><xsl:template match="*[local-name()='thead']" mode="process_tbody">
@@ -1934,6 +1991,7 @@
1934
1991
 
1935
1992
 
1936
1993
 
1994
+
1937
1995
  </xsl:if>
1938
1996
  <xsl:if test="$parent-name = 'tfoot'">
1939
1997
 
@@ -1943,6 +2001,10 @@
1943
2001
 
1944
2002
 
1945
2003
 
2004
+
2005
+
2006
+
2007
+
1946
2008
  <!-- <xsl:if test="$namespace = 'bipm'">
1947
2009
  <xsl:attribute name="height">8mm</xsl:attribute>
1948
2010
  </xsl:if> -->
@@ -1969,11 +2031,13 @@
1969
2031
 
1970
2032
 
1971
2033
 
2034
+
1972
2035
 
1973
2036
  <xsl:attribute name="border-top">solid black 2pt</xsl:attribute>
1974
2037
  <xsl:attribute name="border-bottom">solid black 2pt</xsl:attribute>
1975
2038
 
1976
2039
 
2040
+
1977
2041
  <xsl:if test="$lang = 'ar'">
1978
2042
  <xsl:attribute name="padding-right">1mm</xsl:attribute>
1979
2043
  </xsl:if>
@@ -2028,6 +2092,11 @@
2028
2092
 
2029
2093
 
2030
2094
 
2095
+
2096
+
2097
+
2098
+
2099
+
2031
2100
  <xsl:if test=".//*[local-name() = 'table']">
2032
2101
  <xsl:attribute name="padding-right">1mm</xsl:attribute>
2033
2102
  </xsl:if>
@@ -2057,6 +2126,7 @@
2057
2126
 
2058
2127
 
2059
2128
 
2129
+
2060
2130
  <fo:inline padding-right="2mm">
2061
2131
 
2062
2132
 
@@ -2098,6 +2168,7 @@
2098
2168
 
2099
2169
 
2100
2170
 
2171
+
2101
2172
  <xsl:value-of select="@reference"/>
2102
2173
 
2103
2174
 
@@ -2241,6 +2312,10 @@
2241
2312
 
2242
2313
 
2243
2314
 
2315
+
2316
+
2317
+
2318
+
2244
2319
  <fo:basic-link internal-destination="{@reference}_{ancestor::*[@id][1]/@id}" fox:alt-text="{@reference}"> <!-- @reference | ancestor::*[local-name()='clause'][1]/@id-->
2245
2320
 
2246
2321
 
@@ -2332,6 +2407,7 @@
2332
2407
 
2333
2408
 
2334
2409
 
2410
+
2335
2411
  <xsl:variable name="title-key">
2336
2412
 
2337
2413
 
@@ -2542,6 +2618,7 @@
2542
2618
 
2543
2619
  <fo:table-row>
2544
2620
 
2621
+
2545
2622
  <fo:table-cell>
2546
2623
 
2547
2624
  <fo:block margin-top="6pt">
@@ -2557,6 +2634,7 @@
2557
2634
 
2558
2635
 
2559
2636
 
2637
+
2560
2638
  <xsl:apply-templates/>
2561
2639
  <!-- <xsl:if test="$namespace = 'gb'">
2562
2640
  <xsl:if test="ancestor::*[local-name()='formula']">
@@ -2613,6 +2691,8 @@
2613
2691
 
2614
2692
  <xsl:apply-templates/>
2615
2693
  </fo:inline>
2694
+ </xsl:template><xsl:template match="*[local-name()='padding']">
2695
+ <fo:inline padding-right="{@value}"> </fo:inline>
2616
2696
  </xsl:template><xsl:template match="*[local-name()='sup']">
2617
2697
  <fo:inline font-size="80%" vertical-align="super">
2618
2698
  <xsl:apply-templates/>
@@ -2638,6 +2718,7 @@
2638
2718
 
2639
2719
 
2640
2720
 
2721
+
2641
2722
 
2642
2723
  </xsl:variable>
2643
2724
  <xsl:variable name="font-size" select="normalize-space($_font-size)"/>
@@ -3019,11 +3100,15 @@
3019
3100
  </xsl:apply-templates>
3020
3101
  </xsl:template><xsl:template name="getLang">
3021
3102
  <xsl:variable name="language_current" select="normalize-space(//*[local-name()='bibdata']//*[local-name()='language'][@current = 'true'])"/>
3103
+ <xsl:variable name="language_current_2" select="normalize-space(xalan:nodeset($bibdata)//*[local-name()='bibdata']//*[local-name()='language'][@current = 'true'])"/>
3022
3104
  <xsl:variable name="language">
3023
3105
  <xsl:choose>
3024
3106
  <xsl:when test="$language_current != ''">
3025
3107
  <xsl:value-of select="$language_current"/>
3026
3108
  </xsl:when>
3109
+ <xsl:when test="$language_current_2 != ''">
3110
+ <xsl:value-of select="$language_current_2"/>
3111
+ </xsl:when>
3027
3112
  <xsl:otherwise>
3028
3113
  <xsl:value-of select="//*[local-name()='bibdata']//*[local-name()='language']"/>
3029
3114
  </xsl:otherwise>
@@ -3097,9 +3182,27 @@
3097
3182
  <xsl:copy>
3098
3183
  <xsl:apply-templates select="@*|node()" mode="mathml"/>
3099
3184
  </xsl:copy>
3100
- <mathml:mspace width="0.5ex"/>
3185
+ <xsl:choose>
3186
+ <!-- if in msub, then don't add space -->
3187
+ <xsl:when test="ancestor::mathml:mrow[parent::mathml:msub and preceding-sibling::*[1][self::mathml:mrow]]"/>
3188
+ <!-- if next char in digit, don't add space -->
3189
+ <xsl:when test="translate(substring(following-sibling::*[1]/text(),1,1),'0123456789','') = ''"/>
3190
+ <xsl:otherwise>
3191
+ <mathml:mspace width="0.5ex"/>
3192
+ </xsl:otherwise>
3193
+ </xsl:choose>
3101
3194
  </xsl:template><xsl:template match="mathml:math/*[local-name()='unit']" mode="mathml"/><xsl:template match="mathml:math/*[local-name()='prefix']" mode="mathml"/><xsl:template match="mathml:math/*[local-name()='dimension']" mode="mathml"/><xsl:template match="mathml:math/*[local-name()='quantity']" mode="mathml"/><xsl:template match="*[local-name()='localityStack']"/><xsl:template match="*[local-name()='link']" name="link">
3102
3195
  <xsl:variable name="target">
3196
+ <xsl:choose>
3197
+ <xsl:when test="@updatetype = 'true'">
3198
+ <xsl:value-of select="concat(normalize-space(@target), '.pdf')"/>
3199
+ </xsl:when>
3200
+ <xsl:otherwise>
3201
+ <xsl:value-of select="normalize-space(@target)"/>
3202
+ </xsl:otherwise>
3203
+ </xsl:choose>
3204
+ </xsl:variable>
3205
+ <xsl:variable name="target_text">
3103
3206
  <xsl:choose>
3104
3207
  <xsl:when test="starts-with(normalize-space(@target), 'mailto:')">
3105
3208
  <xsl:value-of select="normalize-space(substring-after(@target, 'mailto:'))"/>
@@ -3111,20 +3214,22 @@
3111
3214
  </xsl:variable>
3112
3215
  <fo:inline xsl:use-attribute-sets="link-style">
3113
3216
 
3217
+
3218
+
3114
3219
  <xsl:choose>
3115
- <xsl:when test="$target = ''">
3220
+ <xsl:when test="$target_text = ''">
3116
3221
  <xsl:apply-templates/>
3117
3222
  </xsl:when>
3118
3223
  <xsl:otherwise>
3119
- <fo:basic-link external-destination="{@target}" fox:alt-text="{@target}">
3224
+ <fo:basic-link external-destination="{$target}" fox:alt-text="{$target}">
3120
3225
  <xsl:choose>
3121
3226
  <xsl:when test="normalize-space(.) = ''">
3122
- <!-- <xsl:value-of select="$target"/> -->
3123
3227
  <xsl:call-template name="add-zero-spaces-link-java">
3124
- <xsl:with-param name="text" select="$target"/>
3228
+ <xsl:with-param name="text" select="$target_text"/>
3125
3229
  </xsl:call-template>
3126
3230
  </xsl:when>
3127
3231
  <xsl:otherwise>
3232
+ <!-- output text from <link>text</link> -->
3128
3233
  <xsl:apply-templates/>
3129
3234
  </xsl:otherwise>
3130
3235
  </xsl:choose>
@@ -3236,6 +3341,7 @@
3236
3341
 
3237
3342
 
3238
3343
  <fo:inline xsl:use-attribute-sets="note-name-style">
3344
+
3239
3345
  <xsl:apply-templates select="*[local-name() = 'name']" mode="presentation"/>
3240
3346
  </fo:inline>
3241
3347
  <xsl:apply-templates/>
@@ -3261,7 +3367,9 @@
3261
3367
  </xsl:choose>
3262
3368
  </xsl:template><xsl:template match="*[local-name() = 'termnote']">
3263
3369
  <fo:block id="{@id}" xsl:use-attribute-sets="termnote-style">
3370
+
3264
3371
  <fo:inline xsl:use-attribute-sets="termnote-name-style">
3372
+
3265
3373
  <xsl:apply-templates select="*[local-name() = 'name']" mode="presentation"/>
3266
3374
  </fo:inline>
3267
3375
  <xsl:apply-templates/>
@@ -3333,13 +3441,17 @@
3333
3441
  </xsl:call-template>
3334
3442
 
3335
3443
  <fo:block>
3444
+
3336
3445
  <xsl:apply-templates/>
3337
3446
  </fo:block>
3338
3447
  <xsl:call-template name="fn_display_figure"/>
3339
3448
  <xsl:for-each select="*[local-name() = 'note']">
3340
3449
  <xsl:call-template name="note"/>
3341
3450
  </xsl:for-each>
3342
- <xsl:apply-templates select="*[local-name() = 'name']" mode="presentation"/>
3451
+
3452
+
3453
+ <xsl:apply-templates select="*[local-name() = 'name']" mode="presentation"/>
3454
+
3343
3455
  </fo:block-container>
3344
3456
  </xsl:template><xsl:template match="*[local-name() = 'figure'][@class = 'pseudocode']">
3345
3457
  <fo:block id="{@id}">
@@ -3452,21 +3564,249 @@
3452
3564
  <xsl:param name="height"/>
3453
3565
  <line xmlns="http://www.w3.org/2000/svg" x1="0" y1="0" x2="{$width}" y2="{$height}" style="stroke: rgb(255, 0, 0); stroke-width:4px; "/>
3454
3566
  <line xmlns="http://www.w3.org/2000/svg" x1="0" y1="{$height}" x2="{$width}" y2="0" style="stroke: rgb(255, 0, 0); stroke-width:4px; "/>
3567
+ </xsl:template><xsl:variable name="figure_name_height">14</xsl:variable><xsl:variable name="width_effective" select="$pageWidth - $marginLeftRight1 - $marginLeftRight2"/><xsl:variable name="height_effective" select="$pageHeight - $marginTop - $marginBottom - $figure_name_height"/><xsl:variable name="image_dpi" select="96"/><xsl:variable name="width_effective_px" select="$width_effective div 25.4 * $image_dpi"/><xsl:variable name="height_effective_px" select="$height_effective div 25.4 * $image_dpi"/><xsl:template match="*[local-name() = 'figure'][not(*[local-name() = 'image']) and *[local-name() = 'svg']]/*[local-name() = 'name']/*[local-name() = 'bookmark']" priority="2"/><xsl:template match="*[local-name() = 'figure'][not(*[local-name() = 'image'])]/*[local-name() = 'svg']" priority="2" name="image_svg">
3568
+ <xsl:param name="name"/>
3569
+
3570
+ <xsl:variable name="svg_content">
3571
+ <xsl:apply-templates select="." mode="svg_update"/>
3572
+ </xsl:variable>
3573
+
3574
+ <xsl:variable name="alt-text">
3575
+ <xsl:choose>
3576
+ <xsl:when test="normalize-space(../*[local-name() = 'name']) != ''">
3577
+ <xsl:value-of select="../*[local-name() = 'name']"/>
3578
+ </xsl:when>
3579
+ <xsl:when test="normalize-space($name) != ''">
3580
+ <xsl:value-of select="$name"/>
3581
+ </xsl:when>
3582
+ <xsl:otherwise>Figure</xsl:otherwise>
3583
+ </xsl:choose>
3584
+ </xsl:variable>
3585
+
3586
+ <xsl:choose>
3587
+ <xsl:when test=".//*[local-name() = 'a'][*[local-name() = 'rect'] or *[local-name() = 'polygon'] or *[local-name() = 'circle'] or *[local-name() = 'ellipse']]">
3588
+ <fo:block>
3589
+ <xsl:variable name="width" select="@width"/>
3590
+ <xsl:variable name="height" select="@height"/>
3591
+
3592
+ <xsl:variable name="scale_x">
3593
+ <xsl:choose>
3594
+ <xsl:when test="$width &gt; $width_effective_px">
3595
+ <xsl:value-of select="$width_effective_px div $width"/>
3596
+ </xsl:when>
3597
+ <xsl:otherwise>1</xsl:otherwise>
3598
+ </xsl:choose>
3599
+ </xsl:variable>
3600
+
3601
+ <xsl:variable name="scale_y">
3602
+ <xsl:choose>
3603
+ <xsl:when test="$height * $scale_x &gt; $height_effective_px">
3604
+ <xsl:value-of select="$height_effective_px div ($height * $scale_x)"/>
3605
+ </xsl:when>
3606
+ <xsl:otherwise>1</xsl:otherwise>
3607
+ </xsl:choose>
3608
+ </xsl:variable>
3609
+
3610
+ <xsl:variable name="scale">
3611
+ <xsl:choose>
3612
+ <xsl:when test="$scale_y != 1">
3613
+ <xsl:value-of select="$scale_x * $scale_y"/>
3614
+ </xsl:when>
3615
+ <xsl:otherwise>
3616
+ <xsl:value-of select="$scale_x"/>
3617
+ </xsl:otherwise>
3618
+ </xsl:choose>
3619
+ </xsl:variable>
3620
+
3621
+ <xsl:variable name="width_scale" select="round($width * $scale)"/>
3622
+ <xsl:variable name="height_scale" select="round($height * $scale)"/>
3623
+
3624
+ <fo:table table-layout="fixed" width="100%">
3625
+ <fo:table-column column-width="proportional-column-width(1)"/>
3626
+ <fo:table-column column-width="{$width_scale}px"/>
3627
+ <fo:table-column column-width="proportional-column-width(1)"/>
3628
+ <fo:table-body>
3629
+ <fo:table-row>
3630
+ <fo:table-cell column-number="2">
3631
+ <fo:block>
3632
+ <fo:block-container width="{$width_scale}px" height="{$height_scale}px">
3633
+ <xsl:if test="../*[local-name() = 'name']/*[local-name() = 'bookmark']">
3634
+ <fo:block line-height="0" font-size="0">
3635
+ <xsl:for-each select="../*[local-name() = 'name']/*[local-name() = 'bookmark']">
3636
+ <xsl:call-template name="bookmark"/>
3637
+ </xsl:for-each>
3638
+ </fo:block>
3639
+ </xsl:if>
3640
+ <fo:block text-depth="0" line-height="0" font-size="0">
3641
+
3642
+ <fo:instream-foreign-object fox:alt-text="{$alt-text}">
3643
+ <xsl:attribute name="width">100%</xsl:attribute>
3644
+ <xsl:attribute name="content-height">100%</xsl:attribute>
3645
+ <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
3646
+ <xsl:attribute name="scaling">uniform</xsl:attribute>
3647
+
3648
+ <xsl:apply-templates select="xalan:nodeset($svg_content)" mode="svg_remove_a"/>
3649
+ </fo:instream-foreign-object>
3650
+ </fo:block>
3651
+
3652
+ <xsl:apply-templates select=".//*[local-name() = 'a'][*[local-name() = 'rect'] or *[local-name() = 'polygon'] or *[local-name() = 'circle'] or *[local-name() = 'ellipse']]" mode="svg_imagemap_links">
3653
+ <xsl:with-param name="scale" select="$scale"/>
3654
+ </xsl:apply-templates>
3655
+ </fo:block-container>
3656
+ </fo:block>
3657
+ </fo:table-cell>
3658
+ </fo:table-row>
3659
+ </fo:table-body>
3660
+ </fo:table>
3661
+ </fo:block>
3662
+
3663
+ </xsl:when>
3664
+ <xsl:otherwise>
3665
+ <fo:block xsl:use-attribute-sets="image-style">
3666
+ <fo:instream-foreign-object fox:alt-text="{$alt-text}">
3667
+ <xsl:attribute name="width">100%</xsl:attribute>
3668
+ <xsl:attribute name="content-height">100%</xsl:attribute>
3669
+ <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
3670
+ <!-- effective height 297 - 27.4 - 13 = 256.6 -->
3671
+ <!-- effective width 210 - 12.5 - 25 = 172.5 -->
3672
+ <!-- effective height / width = 1.48, 1.4 - with title -->
3673
+ <xsl:if test="@height &gt; (@width * 1.4)"> <!-- for images with big height -->
3674
+ <xsl:variable name="width" select="((@width * 1.4) div @height) * 100"/>
3675
+ <xsl:attribute name="width"><xsl:value-of select="$width"/>%</xsl:attribute>
3676
+ </xsl:if>
3677
+ <xsl:attribute name="scaling">uniform</xsl:attribute>
3678
+ <xsl:copy-of select="$svg_content"/>
3679
+ </fo:instream-foreign-object>
3680
+ </fo:block>
3681
+ </xsl:otherwise>
3682
+ </xsl:choose>
3683
+ </xsl:template><xsl:template match="@*|node()" mode="svg_update">
3684
+ <xsl:copy>
3685
+ <xsl:apply-templates select="@*|node()" mode="svg_update"/>
3686
+ </xsl:copy>
3687
+ </xsl:template><xsl:template match="*[local-name() = 'image']/@href" mode="svg_update">
3688
+ <xsl:attribute name="href" namespace="http://www.w3.org/1999/xlink">
3689
+ <xsl:value-of select="."/>
3690
+ </xsl:attribute>
3691
+ </xsl:template><xsl:template match="*[local-name() = 'figure']/*[local-name() = 'image'][@mimetype = 'image/svg+xml' and @src[not(starts-with(., 'data:image/'))]]" priority="2">
3692
+ <xsl:variable name="svg_content" select="document(@src)"/>
3693
+ <xsl:variable name="name" select="ancestor::*[local-name() = 'figure']/*[local-name() = 'name']"/>
3694
+ <xsl:for-each select="xalan:nodeset($svg_content)/node()">
3695
+ <xsl:call-template name="image_svg">
3696
+ <xsl:with-param name="name" select="$name"/>
3697
+ </xsl:call-template>
3698
+ </xsl:for-each>
3699
+ </xsl:template><xsl:template match="@*|node()" mode="svg_remove_a">
3700
+ <xsl:copy>
3701
+ <xsl:apply-templates select="@*|node()" mode="svg_remove_a"/>
3702
+ </xsl:copy>
3703
+ </xsl:template><xsl:template match="*[local-name() = 'a']" mode="svg_remove_a">
3704
+ <xsl:apply-templates mode="svg_remove_a"/>
3705
+ </xsl:template><xsl:template match="*[local-name() = 'a']" mode="svg_imagemap_links">
3706
+ <xsl:param name="scale"/>
3707
+ <xsl:variable name="dest">
3708
+ <xsl:choose>
3709
+ <xsl:when test="starts-with(@href, '#')">
3710
+ <xsl:value-of select="substring-after(@href, '#')"/>
3711
+ </xsl:when>
3712
+ <xsl:otherwise>
3713
+ <xsl:value-of select="@href"/>
3714
+ </xsl:otherwise>
3715
+ </xsl:choose>
3716
+ </xsl:variable>
3717
+ <xsl:for-each select="./*[local-name() = 'rect']">
3718
+ <xsl:call-template name="insertSVGMapLink">
3719
+ <xsl:with-param name="left" select="floor(@x * $scale)"/>
3720
+ <xsl:with-param name="top" select="floor(@y * $scale)"/>
3721
+ <xsl:with-param name="width" select="floor(@width * $scale)"/>
3722
+ <xsl:with-param name="height" select="floor(@height * $scale)"/>
3723
+ <xsl:with-param name="dest" select="$dest"/>
3724
+ </xsl:call-template>
3725
+ </xsl:for-each>
3726
+
3727
+ <xsl:for-each select="./*[local-name() = 'polygon']">
3728
+ <xsl:variable name="points">
3729
+ <xsl:call-template name="split">
3730
+ <xsl:with-param name="pText" select="@points"/>
3731
+ </xsl:call-template>
3732
+ </xsl:variable>
3733
+ <xsl:variable name="x_coords">
3734
+ <xsl:for-each select="xalan:nodeset($points)//item[position() mod 2 = 1]">
3735
+ <xsl:sort select="." data-type="number"/>
3736
+ <x><xsl:value-of select="."/></x>
3737
+ </xsl:for-each>
3738
+ </xsl:variable>
3739
+ <xsl:variable name="y_coords">
3740
+ <xsl:for-each select="xalan:nodeset($points)//item[position() mod 2 = 0]">
3741
+ <xsl:sort select="." data-type="number"/>
3742
+ <y><xsl:value-of select="."/></y>
3743
+ </xsl:for-each>
3744
+ </xsl:variable>
3745
+ <xsl:variable name="x" select="xalan:nodeset($x_coords)//x[1]"/>
3746
+ <xsl:variable name="y" select="xalan:nodeset($y_coords)//y[1]"/>
3747
+ <xsl:variable name="width" select="xalan:nodeset($x_coords)//x[last()] - $x"/>
3748
+ <xsl:variable name="height" select="xalan:nodeset($y_coords)//y[last()] - $y"/>
3749
+ <xsl:call-template name="insertSVGMapLink">
3750
+ <xsl:with-param name="left" select="floor($x * $scale)"/>
3751
+ <xsl:with-param name="top" select="floor($y * $scale)"/>
3752
+ <xsl:with-param name="width" select="floor($width * $scale)"/>
3753
+ <xsl:with-param name="height" select="floor($height * $scale)"/>
3754
+ <xsl:with-param name="dest" select="$dest"/>
3755
+ </xsl:call-template>
3756
+ </xsl:for-each>
3757
+
3758
+ <xsl:for-each select="./*[local-name() = 'circle']">
3759
+ <xsl:call-template name="insertSVGMapLink">
3760
+ <xsl:with-param name="left" select="floor((@cx - @r) * $scale)"/>
3761
+ <xsl:with-param name="top" select="floor((@cy - @r) * $scale)"/>
3762
+ <xsl:with-param name="width" select="floor(@r * 2 * $scale)"/>
3763
+ <xsl:with-param name="height" select="floor(@r * 2 * $scale)"/>
3764
+ <xsl:with-param name="dest" select="$dest"/>
3765
+ </xsl:call-template>
3766
+ </xsl:for-each>
3767
+ <xsl:for-each select="./*[local-name() = 'ellipse']">
3768
+ <xsl:call-template name="insertSVGMapLink">
3769
+ <xsl:with-param name="left" select="floor((@cx - @rx) * $scale)"/>
3770
+ <xsl:with-param name="top" select="floor((@cy - @ry) * $scale)"/>
3771
+ <xsl:with-param name="width" select="floor(@rx * 2 * $scale)"/>
3772
+ <xsl:with-param name="height" select="floor(@ry * 2 * $scale)"/>
3773
+ <xsl:with-param name="dest" select="$dest"/>
3774
+ </xsl:call-template>
3775
+ </xsl:for-each>
3776
+ </xsl:template><xsl:template name="insertSVGMapLink">
3777
+ <xsl:param name="left"/>
3778
+ <xsl:param name="top"/>
3779
+ <xsl:param name="width"/>
3780
+ <xsl:param name="height"/>
3781
+ <xsl:param name="dest"/>
3782
+ <fo:block-container position="absolute" left="{$left}px" top="{$top}px" width="{$width}px" height="{$height}px">
3783
+ <fo:block font-size="1pt">
3784
+ <fo:basic-link internal-destination="{$dest}" fox:alt-text="svg link">
3785
+ <fo:inline-container inline-progression-dimension="100%">
3786
+ <fo:block-container height="{$height - 1}px" width="100%">
3787
+ <!-- DEBUG <xsl:if test="local-name()='polygon'">
3788
+ <xsl:attribute name="background-color">magenta</xsl:attribute>
3789
+ </xsl:if> -->
3790
+ <fo:block> </fo:block></fo:block-container>
3791
+ </fo:inline-container>
3792
+ </fo:basic-link>
3793
+ </fo:block>
3794
+ </fo:block-container>
3455
3795
  </xsl:template><xsl:template match="*[local-name() = 'figure']/*[local-name() = 'name']"/><xsl:template match="*[local-name() = 'figure']/*[local-name() = 'name'] | *[local-name() = 'table']/*[local-name() = 'name'] | *[local-name() = 'permission']/*[local-name() = 'name'] | *[local-name() = 'recommendation']/*[local-name() = 'name'] | *[local-name() = 'requirement']/*[local-name() = 'name']" mode="contents">
3456
3796
  <xsl:apply-templates mode="contents"/>
3457
3797
  <xsl:text> </xsl:text>
3458
3798
  </xsl:template><xsl:template match="*[local-name() = 'figure']/*[local-name() = 'name'] | *[local-name() = 'table']/*[local-name() = 'name'] | *[local-name() = 'permission']/*[local-name() = 'name'] | *[local-name() = 'recommendation']/*[local-name() = 'name'] | *[local-name() = 'requirement']/*[local-name() = 'name']" mode="bookmarks">
3459
3799
  <xsl:apply-templates mode="bookmarks"/>
3460
3800
  <xsl:text> </xsl:text>
3461
- </xsl:template><xsl:template match="*[local-name() = 'name']/text()" mode="contents" priority="2">
3801
+ </xsl:template><xsl:template match="*[local-name() = 'figure' or local-name() = 'table' or local-name() = 'permission' or local-name() = 'recommendation' or local-name() = 'requirement']/*[local-name() = 'name']/text()" mode="contents" priority="2">
3462
3802
  <xsl:value-of select="."/>
3463
- </xsl:template><xsl:template match="*[local-name() = 'name']/text()" mode="bookmarks" priority="2">
3803
+ </xsl:template><xsl:template match="*[local-name() = 'figure' or local-name() = 'table' or local-name() = 'permission' or local-name() = 'recommendation' or local-name() = 'requirement']/*[local-name() = 'name']/text()" mode="bookmarks" priority="2">
3464
3804
  <xsl:value-of select="."/>
3465
3805
  </xsl:template><xsl:template match="node()" mode="contents">
3466
3806
  <xsl:apply-templates mode="contents"/>
3467
3807
  </xsl:template><xsl:template match="node()" mode="bookmarks">
3468
3808
  <xsl:apply-templates mode="bookmarks"/>
3469
- </xsl:template><xsl:template match="*[local-name() = 'stem']" mode="contents">
3809
+ </xsl:template><xsl:template match="*[local-name() = 'title' or local-name() = 'name']//*[local-name() = 'stem']" mode="contents">
3470
3810
  <xsl:apply-templates select="."/>
3471
3811
  </xsl:template><xsl:template match="*[local-name() = 'references'][@hidden='true']" mode="contents" priority="3"/><xsl:template match="*[local-name() = 'stem']" mode="bookmarks">
3472
3812
  <xsl:apply-templates mode="bookmarks"/>
@@ -3480,28 +3820,39 @@
3480
3820
  <xsl:when test="count(xalan:nodeset($contents)/doc) &gt; 1">
3481
3821
  <xsl:for-each select="xalan:nodeset($contents)/doc">
3482
3822
  <fo:bookmark internal-destination="{contents/item[1]/@id}" starting-state="hide">
3823
+ <xsl:if test="@bundle = 'true'">
3824
+ <xsl:attribute name="internal-destination"><xsl:value-of select="@firstpage_id"/></xsl:attribute>
3825
+ </xsl:if>
3483
3826
  <fo:bookmark-title>
3484
- <xsl:variable name="bookmark-title_">
3485
- <xsl:call-template name="getLangVersion">
3486
- <xsl:with-param name="lang" select="@lang"/>
3487
- <xsl:with-param name="doctype" select="@doctype"/>
3488
- <xsl:with-param name="title" select="@title-part"/>
3489
- </xsl:call-template>
3490
- </xsl:variable>
3491
3827
  <xsl:choose>
3492
- <xsl:when test="normalize-space($bookmark-title_) != ''">
3493
- <xsl:value-of select="normalize-space($bookmark-title_)"/>
3494
- </xsl:when>
3495
- <xsl:otherwise>
3828
+ <xsl:when test="not(normalize-space(@bundle) = 'true')"> <!-- 'bundle' means several different documents (not language versions) in one xml -->
3829
+ <xsl:variable name="bookmark-title_">
3830
+ <xsl:call-template name="getLangVersion">
3831
+ <xsl:with-param name="lang" select="@lang"/>
3832
+ <xsl:with-param name="doctype" select="@doctype"/>
3833
+ <xsl:with-param name="title" select="@title-part"/>
3834
+ </xsl:call-template>
3835
+ </xsl:variable>
3496
3836
  <xsl:choose>
3497
- <xsl:when test="@lang = 'en'">English</xsl:when>
3498
- <xsl:when test="@lang = 'fr'">Français</xsl:when>
3499
- <xsl:when test="@lang = 'de'">Deutsche</xsl:when>
3500
- <xsl:otherwise><xsl:value-of select="@lang"/> version</xsl:otherwise>
3837
+ <xsl:when test="normalize-space($bookmark-title_) != ''">
3838
+ <xsl:value-of select="normalize-space($bookmark-title_)"/>
3839
+ </xsl:when>
3840
+ <xsl:otherwise>
3841
+ <xsl:choose>
3842
+ <xsl:when test="@lang = 'en'">English</xsl:when>
3843
+ <xsl:when test="@lang = 'fr'">Français</xsl:when>
3844
+ <xsl:when test="@lang = 'de'">Deutsche</xsl:when>
3845
+ <xsl:otherwise><xsl:value-of select="@lang"/> version</xsl:otherwise>
3846
+ </xsl:choose>
3847
+ </xsl:otherwise>
3501
3848
  </xsl:choose>
3849
+ </xsl:when>
3850
+ <xsl:otherwise>
3851
+ <xsl:value-of select="@title-part"/>
3502
3852
  </xsl:otherwise>
3503
3853
  </xsl:choose>
3504
3854
  </fo:bookmark-title>
3855
+
3505
3856
  <xsl:apply-templates select="contents/item" mode="bookmark"/>
3506
3857
 
3507
3858
  <xsl:call-template name="insertFigureBookmarks">
@@ -3600,20 +3951,28 @@
3600
3951
  <xsl:otherwise><xsl:value-of select="$lang"/> version</xsl:otherwise>
3601
3952
  </xsl:choose>
3602
3953
  </xsl:template><xsl:template match="item" mode="bookmark">
3603
- <fo:bookmark internal-destination="{@id}" starting-state="hide">
3604
- <fo:bookmark-title>
3605
- <xsl:if test="@section != ''">
3606
- <xsl:value-of select="@section"/>
3607
- <xsl:text> </xsl:text>
3608
- </xsl:if>
3609
- <xsl:value-of select="normalize-space(title)"/>
3610
- </fo:bookmark-title>
3611
- <xsl:apply-templates mode="bookmark"/>
3612
- </fo:bookmark>
3954
+ <xsl:choose>
3955
+ <xsl:when test="@id != ''">
3956
+ <fo:bookmark internal-destination="{@id}" starting-state="hide">
3957
+ <fo:bookmark-title>
3958
+ <xsl:if test="@section != ''">
3959
+ <xsl:value-of select="@section"/>
3960
+ <xsl:text> </xsl:text>
3961
+ </xsl:if>
3962
+ <xsl:value-of select="normalize-space(title)"/>
3963
+ </fo:bookmark-title>
3964
+ <xsl:apply-templates mode="bookmark"/>
3965
+ </fo:bookmark>
3966
+ </xsl:when>
3967
+ <xsl:otherwise>
3968
+ <xsl:apply-templates mode="bookmark"/>
3969
+ </xsl:otherwise>
3970
+ </xsl:choose>
3613
3971
  </xsl:template><xsl:template match="title" mode="bookmark"/><xsl:template match="text()" mode="bookmark"/><xsl:template match="*[local-name() = 'figure']/*[local-name() = 'name'] | *[local-name() = 'image']/*[local-name() = 'name']" mode="presentation">
3614
3972
  <xsl:if test="normalize-space() != ''">
3615
3973
  <fo:block xsl:use-attribute-sets="figure-name-style">
3616
3974
 
3975
+
3617
3976
  <xsl:apply-templates/>
3618
3977
  </fo:block>
3619
3978
  </xsl:if>
@@ -3665,6 +4024,8 @@
3665
4024
  </fo:list-item-body>
3666
4025
  </fo:list-item>
3667
4026
  </fo:list-block>
4027
+ </xsl:template><xsl:template name="extractSection">
4028
+ <xsl:value-of select="*[local-name() = 'tab'][1]/preceding-sibling::node()"/>
3668
4029
  </xsl:template><xsl:template name="extractTitle">
3669
4030
  <xsl:choose>
3670
4031
  <xsl:when test="*[local-name() = 'tab']">
@@ -3691,6 +4052,8 @@
3691
4052
  </xsl:template><xsl:template match="*[local-name()='sourcecode']" name="sourcecode">
3692
4053
 
3693
4054
  <fo:block-container margin-left="0mm">
4055
+ <xsl:copy-of select="@id"/>
4056
+
3694
4057
  <xsl:if test="parent::*[local-name() = 'note']">
3695
4058
  <xsl:attribute name="margin-left">
3696
4059
  <xsl:choose>
@@ -3701,7 +4064,9 @@
3701
4064
 
3702
4065
  </xsl:if>
3703
4066
  <fo:block-container margin-left="0mm">
3704
-
4067
+
4068
+
4069
+
3705
4070
  <fo:block xsl:use-attribute-sets="sourcecode-style">
3706
4071
  <xsl:variable name="_font-size">
3707
4072
 
@@ -3712,6 +4077,7 @@
3712
4077
 
3713
4078
 
3714
4079
 
4080
+
3715
4081
 
3716
4082
 
3717
4083
 
@@ -3729,10 +4095,14 @@
3729
4095
  </xsl:choose>
3730
4096
  </xsl:attribute>
3731
4097
  </xsl:if>
3732
- <xsl:apply-templates/>
3733
- </fo:block>
4098
+
4099
+ <xsl:apply-templates/>
4100
+ </fo:block>
4101
+
4102
+
3734
4103
  <xsl:apply-templates select="*[local-name()='name']" mode="presentation"/>
3735
4104
 
4105
+
3736
4106
  </fo:block-container>
3737
4107
  </fo:block-container>
3738
4108
  </xsl:template><xsl:template match="*[local-name()='sourcecode']/text()" priority="2">
@@ -3967,6 +4337,7 @@
3967
4337
  </xsl:template><xsl:template match="*[local-name() = 'example']">
3968
4338
  <fo:block id="{@id}" xsl:use-attribute-sets="example-style">
3969
4339
 
4340
+
3970
4341
  <xsl:apply-templates select="*[local-name()='name']" mode="presentation"/>
3971
4342
 
3972
4343
  <xsl:variable name="element">
@@ -4034,7 +4405,7 @@
4034
4405
  </fo:inline>
4035
4406
  </xsl:otherwise>
4036
4407
  </xsl:choose>
4037
- </xsl:template><xsl:template match="*[local-name() = 'termsource']">
4408
+ </xsl:template><xsl:template match="*[local-name() = 'termsource']" name="termsource">
4038
4409
  <fo:block xsl:use-attribute-sets="termsource-style">
4039
4410
  <!-- Example: [SOURCE: ISO 5127:2017, 3.1.6.02] -->
4040
4411
  <xsl:variable name="termsource_text">
@@ -4043,11 +4414,13 @@
4043
4414
 
4044
4415
  <xsl:choose>
4045
4416
  <xsl:when test="starts-with(normalize-space($termsource_text), '[')">
4046
- <xsl:apply-templates/>
4417
+ <!-- <xsl:apply-templates /> -->
4418
+ <xsl:copy-of select="$termsource_text"/>
4047
4419
  </xsl:when>
4048
4420
  <xsl:otherwise>
4049
4421
 
4050
- <xsl:apply-templates/>
4422
+ <!-- <xsl:apply-templates /> -->
4423
+ <xsl:copy-of select="$termsource_text"/>
4051
4424
 
4052
4425
  </xsl:otherwise>
4053
4426
  </xsl:choose>
@@ -4056,20 +4429,29 @@
4056
4429
  <xsl:if test="normalize-space() != ''">
4057
4430
  <xsl:value-of select="."/>
4058
4431
  </xsl:if>
4059
- </xsl:template><xsl:template match="*[local-name() = 'origin']">
4432
+ </xsl:template><xsl:variable name="localized.source">
4433
+ <xsl:call-template name="getLocalizedString">
4434
+ <xsl:with-param name="key">source</xsl:with-param>
4435
+ </xsl:call-template>
4436
+ </xsl:variable><xsl:template match="*[local-name() = 'origin']">
4060
4437
  <fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}">
4438
+ <xsl:if test="normalize-space(@citeas) = ''">
4439
+ <xsl:attribute name="fox:alt-text"><xsl:value-of select="@bibitemid"/></xsl:attribute>
4440
+ </xsl:if>
4061
4441
 
4062
4442
  <fo:inline>
4063
4443
 
4064
4444
 
4065
4445
 
4066
4446
 
4447
+
4448
+
4067
4449
  <xsl:call-template name="getTitle">
4068
4450
  <xsl:with-param name="name" select="'title-source'"/>
4069
4451
  </xsl:call-template>
4452
+ <xsl:text>: </xsl:text>
4070
4453
 
4071
4454
 
4072
- <xsl:text>: </xsl:text>
4073
4455
  </fo:inline>
4074
4456
 
4075
4457
  <fo:inline xsl:use-attribute-sets="origin-style">
@@ -4142,6 +4524,7 @@
4142
4524
  </xsl:if>
4143
4525
 
4144
4526
  <fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}">
4527
+
4145
4528
  <xsl:if test="normalize-space(@citeas) = ''">
4146
4529
  <xsl:attribute name="fox:alt-text"><xsl:value-of select="."/></xsl:attribute>
4147
4530
  </xsl:if>
@@ -4188,6 +4571,7 @@
4188
4571
 
4189
4572
 
4190
4573
 
4574
+
4191
4575
  3
4192
4576
 
4193
4577
  </xsl:variable>
@@ -4270,7 +4654,6 @@
4270
4654
 
4271
4655
 
4272
4656
 
4273
-
4274
4657
  <xsl:apply-templates/>
4275
4658
  </fo:block>
4276
4659
 
@@ -4287,6 +4670,7 @@
4287
4670
  <xsl:call-template name="setId"/>
4288
4671
 
4289
4672
 
4673
+
4290
4674
  <xsl:apply-templates/>
4291
4675
  </fo:block>
4292
4676
  </xsl:template><xsl:template match="*[local-name() = 'definitions']">
@@ -4313,7 +4697,7 @@
4313
4697
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),' ',' ')"/>
4314
4698
  </xsl:template><xsl:template match="*[local-name() = 'ul'] | *[local-name() = 'ol']">
4315
4699
  <xsl:choose>
4316
- <xsl:when test="parent::*[local-name() = 'note']">
4700
+ <xsl:when test="parent::*[local-name() = 'note'] or parent::*[local-name() = 'termnote']">
4317
4701
  <fo:block-container>
4318
4702
  <xsl:attribute name="margin-left">
4319
4703
  <xsl:choose>
@@ -4323,6 +4707,7 @@
4323
4707
  </xsl:attribute>
4324
4708
 
4325
4709
 
4710
+
4326
4711
  <fo:block-container margin-left="0mm">
4327
4712
  <fo:block>
4328
4713
  <xsl:apply-templates select="." mode="ul_ol"/>
@@ -4524,21 +4909,25 @@
4524
4909
 
4525
4910
 
4526
4911
 
4912
+
4913
+
4914
+
4915
+
4527
4916
  </xsl:template><xsl:template name="processBibitemDocId">
4528
4917
  <xsl:variable name="_doc_ident" select="*[local-name() = 'docidentifier'][not(@type = 'DOI' or @type = 'metanorma' or @type = 'ISSN' or @type = 'ISBN' or @type = 'rfc-anchor')]"/>
4529
4918
  <xsl:choose>
4530
4919
  <xsl:when test="normalize-space($_doc_ident) != ''">
4531
- <xsl:variable name="type" select="*[local-name() = 'docidentifier'][not(@type = 'DOI' or @type = 'metanorma' or @type = 'ISSN' or @type = 'ISBN' or @type = 'rfc-anchor')]/@type"/>
4920
+ <!-- <xsl:variable name="type" select="*[local-name() = 'docidentifier'][not(@type = 'DOI' or @type = 'metanorma' or @type = 'ISSN' or @type = 'ISBN' or @type = 'rfc-anchor')]/@type"/>
4532
4921
  <xsl:if test="$type != '' and not(contains($_doc_ident, $type))">
4533
4922
  <xsl:value-of select="$type"/><xsl:text> </xsl:text>
4534
- </xsl:if>
4923
+ </xsl:if> -->
4535
4924
  <xsl:value-of select="$_doc_ident"/>
4536
4925
  </xsl:when>
4537
4926
  <xsl:otherwise>
4538
- <xsl:variable name="type" select="*[local-name() = 'docidentifier'][not(@type = 'metanorma')]/@type"/>
4927
+ <!-- <xsl:variable name="type" select="*[local-name() = 'docidentifier'][not(@type = 'metanorma')]/@type"/>
4539
4928
  <xsl:if test="$type != ''">
4540
4929
  <xsl:value-of select="$type"/><xsl:text> </xsl:text>
4541
- </xsl:if>
4930
+ </xsl:if> -->
4542
4931
  <xsl:value-of select="*[local-name() = 'docidentifier'][not(@type = 'metanorma')]"/>
4543
4932
  </xsl:otherwise>
4544
4933
  </xsl:choose>
@@ -4580,6 +4969,70 @@
4580
4969
  <xsl:value-of select="substring(.,1,1)"/>
4581
4970
  </xsl:template><xsl:template match="*[local-name() = 'title']" mode="title">
4582
4971
  <fo:inline><xsl:apply-templates/></fo:inline>
4972
+ </xsl:template><xsl:template match="*[local-name() = 'form']">
4973
+ <fo:block>
4974
+ <xsl:apply-templates/>
4975
+ </fo:block>
4976
+ </xsl:template><xsl:template match="*[local-name() = 'form']//*[local-name() = 'label']">
4977
+ <fo:inline><xsl:apply-templates/></fo:inline>
4978
+ </xsl:template><xsl:template match="*[local-name() = 'form']//*[local-name() = 'input'][@type = 'text' or @type = 'date' or @type = 'file' or @type = 'password']">
4979
+ <fo:inline>
4980
+ <xsl:call-template name="text_input"/>
4981
+ </fo:inline>
4982
+ </xsl:template><xsl:template name="text_input">
4983
+ <xsl:variable name="count">
4984
+ <xsl:choose>
4985
+ <xsl:when test="normalize-space(@maxlength) != ''"><xsl:value-of select="@maxlength"/></xsl:when>
4986
+ <xsl:when test="normalize-space(@size) != ''"><xsl:value-of select="@size"/></xsl:when>
4987
+ <xsl:otherwise>10</xsl:otherwise>
4988
+ </xsl:choose>
4989
+ </xsl:variable>
4990
+ <xsl:call-template name="repeat">
4991
+ <xsl:with-param name="char" select="'_'"/>
4992
+ <xsl:with-param name="count" select="$count"/>
4993
+ </xsl:call-template>
4994
+ <xsl:text> </xsl:text>
4995
+ </xsl:template><xsl:template match="*[local-name() = 'form']//*[local-name() = 'input'][@type = 'button']">
4996
+ <xsl:variable name="caption">
4997
+ <xsl:choose>
4998
+ <xsl:when test="normalize-space(@value) != ''"><xsl:value-of select="@value"/></xsl:when>
4999
+ <xsl:otherwise>BUTTON</xsl:otherwise>
5000
+ </xsl:choose>
5001
+ </xsl:variable>
5002
+ <fo:inline>[<xsl:value-of select="$caption"/>]</fo:inline>
5003
+ </xsl:template><xsl:template match="*[local-name() = 'form']//*[local-name() = 'input'][@type = 'checkbox']">
5004
+ <fo:inline padding-right="1mm">
5005
+ <fo:instream-foreign-object fox:alt-text="Box" baseline-shift="-10%">
5006
+ <xsl:attribute name="height">3.5mm</xsl:attribute>
5007
+ <xsl:attribute name="content-width">100%</xsl:attribute>
5008
+ <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
5009
+ <xsl:attribute name="scaling">uniform</xsl:attribute>
5010
+ <svg xmlns="http://www.w3.org/2000/svg" width="80" height="80">
5011
+ <polyline points="0,0 80,0 80,80 0,80 0,0" stroke="black" stroke-width="5" fill="white"/>
5012
+ </svg>
5013
+ </fo:instream-foreign-object>
5014
+ </fo:inline>
5015
+ </xsl:template><xsl:template match="*[local-name() = 'form']//*[local-name() = 'input'][@type = 'radio']">
5016
+ <fo:inline padding-right="1mm">
5017
+ <fo:instream-foreign-object fox:alt-text="Box" baseline-shift="-10%">
5018
+ <xsl:attribute name="height">3.5mm</xsl:attribute>
5019
+ <xsl:attribute name="content-width">100%</xsl:attribute>
5020
+ <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
5021
+ <xsl:attribute name="scaling">uniform</xsl:attribute>
5022
+ <svg xmlns="http://www.w3.org/2000/svg" width="80" height="80">
5023
+ <circle cx="40" cy="40" r="30" stroke="black" stroke-width="5" fill="white"/>
5024
+ <circle cx="40" cy="40" r="15" stroke="black" stroke-width="5" fill="white"/>
5025
+ </svg>
5026
+ </fo:instream-foreign-object>
5027
+ </fo:inline>
5028
+ </xsl:template><xsl:template match="*[local-name() = 'form']//*[local-name() = 'select']">
5029
+ <fo:inline>
5030
+ <xsl:call-template name="text_input"/>
5031
+ </fo:inline>
5032
+ </xsl:template><xsl:template match="*[local-name() = 'form']//*[local-name() = 'textarea']">
5033
+ <fo:block-container border="1pt solid black" width="50%">
5034
+ <fo:block> </fo:block>
5035
+ </fo:block-container>
4583
5036
  </xsl:template><xsl:template name="convertDate">
4584
5037
  <xsl:param name="date"/>
4585
5038
  <xsl:param name="format" select="'short'"/>
@@ -4780,6 +5233,9 @@
4780
5233
  <xsl:when test="parent::*[local-name() = 'preface']">
4781
5234
  <xsl:value-of select="$level_total - 1"/>
4782
5235
  </xsl:when>
5236
+ <xsl:when test="ancestor::*[local-name() = 'preface'] and not(ancestor::*[local-name() = 'foreword']) and not(ancestor::*[local-name() = 'introduction'])"> <!-- for preface/clause -->
5237
+ <xsl:value-of select="$level_total - 1"/>
5238
+ </xsl:when>
4783
5239
  <xsl:when test="ancestor::*[local-name() = 'preface']">
4784
5240
  <xsl:value-of select="$level_total - 2"/>
4785
5241
  </xsl:when>
@@ -4844,6 +5300,7 @@
4844
5300
 
4845
5301
 
4846
5302
 
5303
+
4847
5304
 
4848
5305
 
4849
5306
 
@@ -4904,17 +5361,29 @@
4904
5361
  </xsl:call-template>
4905
5362
  </xsl:if>
4906
5363
  </xsl:template><xsl:template name="getLocalizedString">
4907
- <xsl:param name="key"/>
5364
+ <xsl:param name="key"/>
4908
5365
 
4909
5366
  <xsl:variable name="curr_lang">
4910
5367
  <xsl:call-template name="getLang"/>
4911
5368
  </xsl:variable>
4912
5369
 
5370
+ <xsl:variable name="data_value" select="normalize-space(xalan:nodeset($bibdata)//*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang])"/>
5371
+
4913
5372
  <xsl:choose>
5373
+ <xsl:when test="$data_value != ''">
5374
+ <xsl:value-of select="$data_value"/>
5375
+ </xsl:when>
4914
5376
  <xsl:when test="/*/*[local-name() = 'localized-strings']/*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang]">
4915
5377
  <xsl:value-of select="/*/*[local-name() = 'localized-strings']/*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang]"/>
4916
5378
  </xsl:when>
4917
- <xsl:otherwise><xsl:value-of select="$key"/></xsl:otherwise>
5379
+ <xsl:otherwise>
5380
+ <xsl:variable name="key_">
5381
+ <xsl:call-template name="capitalize">
5382
+ <xsl:with-param name="str" select="translate($key, '_', ' ')"/>
5383
+ </xsl:call-template>
5384
+ </xsl:variable>
5385
+ <xsl:value-of select="$key_"/>
5386
+ </xsl:otherwise>
4918
5387
  </xsl:choose>
4919
5388
 
4920
5389
  </xsl:template><xsl:template name="setTrackChangesStyles">
@@ -4957,4 +5426,14 @@
4957
5426
  <xsl:value-of select="$align"/>
4958
5427
  </xsl:when>
4959
5428
  </xsl:choose>
5429
+ </xsl:template><xsl:template name="setTextAlignment">
5430
+ <xsl:param name="default">left</xsl:param>
5431
+ <xsl:attribute name="text-align">
5432
+ <xsl:choose>
5433
+ <xsl:when test="@align"><xsl:value-of select="@align"/></xsl:when>
5434
+ <xsl:when test="ancestor::*[local-name() = 'td']/@align"><xsl:value-of select="ancestor::*[local-name() = 'td']/@align"/></xsl:when>
5435
+ <xsl:when test="ancestor::*[local-name() = 'th']/@align"><xsl:value-of select="ancestor::*[local-name() = 'th']/@align"/></xsl:when>
5436
+ <xsl:otherwise><xsl:value-of select="$default"/></xsl:otherwise>
5437
+ </xsl:choose>
5438
+ </xsl:attribute>
4960
5439
  </xsl:template></xsl:stylesheet>