metanorma-bipm 1.1.7 → 1.1.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a37d2fd29c1b02eb058c4c0c373a9ddc7a6cf5b2ec2eec8f042b3c12ef98fe15
4
- data.tar.gz: 2d8183dcbee89f5cf9b2f658cc7ce8fe3cbe6fdfc1d3b475ec4428dc46052c52
3
+ metadata.gz: 0f258a2387575d227d79ffe3950fa8768f29cd319eaf4e929197a635304ef247
4
+ data.tar.gz: e4f8f7a88bdec337362131fd8535a96f904dba6b703fcc8d9604fca5026563e9
5
5
  SHA512:
6
- metadata.gz: aab514fe6c0f136bb64cc8a19b44b053b38ab54d9584d8f12b01c552336ff542f5f820533d8aa55c565dd52ac08fda1cd39d8a27af6b4cdc0dd9f98d7ac68872
7
- data.tar.gz: 8b6f1adc6406fb596bac1f9525e4381e17b2701443eb158a010b988289eccb2a7fd63326d9c690b327fc3329ebb2a23be652b0e6ef3ca562a1516de376432720
6
+ metadata.gz: 2f3819a2b709b1befe0df2ed04f53647b12cee97be3494b8477e3326f5ec531f2558274e1fae49b5be4071117e0e34cef0ff47a4dacadee28ec46be064cb61b2
7
+ data.tar.gz: '031558adb23c13e72bf4995e78a7979c26b0438f897ae85f4181dfa03870d2062701df86f80ab3e894f5816aaabbc9c7e3ad5b3865f4febc265821c02dd08244'
@@ -32,6 +32,18 @@
32
32
  <ref name="DocumentType"/>
33
33
  </element>
34
34
  </define>
35
+ <define name="section-title">
36
+ <element name="title">
37
+ <zeroOrMore>
38
+ <ref name="TextElement"/>
39
+ </zeroOrMore>
40
+ </element>
41
+ <zeroOrMore>
42
+ <element name="variant-title">
43
+ <ref name="TypedTitleString"/>
44
+ </element>
45
+ </zeroOrMore>
46
+ </define>
35
47
  <define name="hyperlink">
36
48
  <element name="link">
37
49
  <attribute name="target">
@@ -158,15 +170,17 @@
158
170
  <data type="boolean"/>
159
171
  </attribute>
160
172
  </optional>
161
- <attribute name="type">
162
- <choice>
163
- <value>roman</value>
164
- <value>alphabet</value>
165
- <value>arabic</value>
166
- <value>roman_upper</value>
167
- <value>alphabet_upper</value>
168
- </choice>
169
- </attribute>
173
+ <optional>
174
+ <attribute name="type">
175
+ <choice>
176
+ <value>roman</value>
177
+ <value>alphabet</value>
178
+ <value>arabic</value>
179
+ <value>roman_upper</value>
180
+ <value>alphabet_upper</value>
181
+ </choice>
182
+ </attribute>
183
+ </optional>
170
184
  <oneOrMore>
171
185
  <ref name="li"/>
172
186
  </oneOrMore>
@@ -1,4 +1,4 @@
1
- <?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:bipm="https://www.metanorma.org/ns/bipm" xmlns:mathml="http://www.w3.org/1998/Math/MathML" xmlns:xalan="http://xml.apache.org/xalan" xmlns:fox="http://xmlgraphics.apache.org/fop/extensions" xmlns:java="http://xml.apache.org/xalan/java" exclude-result-prefixes="java" version="1.0">
1
+ <?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:bipm="https://www.metanorma.org/ns/bipm" xmlns:mathml="http://www.w3.org/1998/Math/MathML" xmlns:xalan="http://xml.apache.org/xalan" xmlns:fox="http://xmlgraphics.apache.org/fop/extensions" xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" xmlns:java="http://xml.apache.org/xalan/java" exclude-result-prefixes="java" version="1.0">
2
2
 
3
3
  <xsl:output version="1.0" method="xml" encoding="UTF-8" indent="no"/>
4
4
 
@@ -13,6 +13,10 @@
13
13
  <!-- param for second pass -->
14
14
  <xsl:param name="external_index"/><!-- path to index xml, generated on 1st pass, based on FOP Intermediate Format -->
15
15
 
16
+ <xsl:param name="add_math_as_text">true</xsl:param>
17
+
18
+ <xsl:param name="add_math_as_attachment">true</xsl:param>
19
+
16
20
  <xsl:variable name="first_pass" select="count($index//item) = 0"/>
17
21
 
18
22
  <xsl:variable name="pageWidth" select="210"/>
@@ -206,6 +210,37 @@
206
210
  </xsl:template>
207
211
 
208
212
 
213
+ <xsl:variable name="mathml_attachments">
214
+ <xsl:if test="$add_math_as_attachment = 'true'">
215
+ <xsl:for-each select="//mathml:math">
216
+
217
+ <xsl:variable name="sequence_number"><xsl:number level="any" format="00001"/></xsl:variable>
218
+
219
+ <xsl:variable name="clause_title_number" select="ancestor-or-self::bipm:clause[bipm:title[bipm:tab]][1]/bipm:title/node()[1]"/>
220
+
221
+ <xsl:variable name="mathml_filename">
222
+ <xsl:text>math</xsl:text>
223
+ <xsl:if test="$clause_title_number != '' and translate($clause_title_number, '.123456789', '') = ''">
224
+ <xsl:text>_</xsl:text>
225
+ <xsl:value-of select="$clause_title_number"/>
226
+ <xsl:text>_</xsl:text>
227
+ </xsl:if>
228
+ <xsl:value-of select="$sequence_number"/>
229
+ <xsl:text>.mml</xsl:text>
230
+ </xsl:variable>
231
+
232
+ <xsl:variable name="mathml_content">
233
+ <xsl:apply-templates select="." mode="mathml_actual_text"/>
234
+ </xsl:variable>
235
+
236
+ <attachment filename="{$mathml_filename}">
237
+ <xsl:value-of select="$mathml_content"/>
238
+ </attachment>
239
+
240
+ </xsl:for-each>
241
+ </xsl:if>
242
+ </xsl:variable>
243
+
209
244
 
210
245
  <xsl:template match="/">
211
246
  <fo:root xsl:use-attribute-sets="root-style" xml:lang="{$lang}">
@@ -308,6 +343,23 @@
308
343
 
309
344
  <fo:declarations>
310
345
  <xsl:call-template name="addPDFUAmeta"/>
346
+
347
+ <xsl:if test="$add_math_as_attachment = 'true'">
348
+ <xsl:for-each select="xalan:nodeset($mathml_attachments)//attachment">
349
+
350
+ <xsl:variable name="mathml_filename" select="@filename"/>
351
+ <xsl:variable name="mathml_content" select="."/>
352
+
353
+ <xsl:variable name="basepath" select="java:org.metanorma.fop.Util.saveFileToDisk($mathml_filename,$mathml_content)"/>
354
+
355
+ <xsl:variable name="url" select="concat('url(file:',$basepath, ')')"/>
356
+
357
+ <xsl:if test="normalize-space($url) != ''">
358
+ <pdf:embedded-file src="{$url}" filename="{$mathml_filename}"/>
359
+ </xsl:if>
360
+ </xsl:for-each>
361
+ </xsl:if>
362
+
311
363
  </fo:declarations>
312
364
 
313
365
  <xsl:call-template name="addBookmarks">
@@ -1066,7 +1118,7 @@
1066
1118
  </fo:block-container>
1067
1119
 
1068
1120
  <fo:block-container font-size="18pt" font-weight="bold" text-align="center">
1069
- <fo:block>
1121
+ <fo:block role="H1">
1070
1122
  <xsl:value-of select="//bipm:bipm-standard/bipm:bibdata/bipm:title[@language = $curr_lang and @type='cover']"/>
1071
1123
  </fo:block>
1072
1124
  </fo:block-container>
@@ -1165,7 +1217,7 @@
1165
1217
 
1166
1218
  <fo:block-container margin-left="-14mm" margin-right="0mm">
1167
1219
  <fo:block-container margin-left="0mm" margin-right="0mm">
1168
- <fo:block font-family="Arial" font-size="16pt" font-weight="bold" text-align-last="justify" margin-bottom="82pt">
1220
+ <fo:block font-family="Arial" font-size="16pt" font-weight="bold" text-align-last="justify" margin-bottom="82pt" role="H1">
1169
1221
  <!-- <fo:marker marker-class-name="header-title"><xsl:value-of select="$title-toc"/></fo:marker> -->
1170
1222
  <fo:inline><xsl:value-of select="//bipm:bipm-standard/bipm:bibdata/bipm:title[@language = $curr_lang and @type='main']"/></fo:inline>
1171
1223
  <fo:inline keep-together.within-line="always">
@@ -1179,7 +1231,7 @@
1179
1231
  </fo:block-container>
1180
1232
 
1181
1233
  <fo:block-container line-height="135%">
1182
- <fo:block>
1234
+ <fo:block role="TOC">
1183
1235
  <!-- <xsl:copy-of select="$contents"/> -->
1184
1236
 
1185
1237
  <xsl:if test="xalan:nodeset($contents)/doc[@id = $docid]//item[@display='true']">
@@ -1280,7 +1332,7 @@
1280
1332
  </fo:block-container>
1281
1333
 
1282
1334
  <fo:block-container font-size="18pt" font-weight="bold" text-align="center">
1283
- <fo:block>
1335
+ <fo:block role="H1">
1284
1336
 
1285
1337
  <!-- <xsl:variable name="title"> -->
1286
1338
  <xsl:choose>
@@ -1315,7 +1367,7 @@
1315
1367
 
1316
1368
  <xsl:variable name="part_num" select="normalize-space(/bipm:bipm-standard/bipm:bibdata/bipm:ext/bipm:structuredidentifier/bipm:part)"/>
1317
1369
  <xsl:if test="/bipm:bipm-standard/bipm:bibdata/bipm:title[@language = $curr_lang and @type = 'part']">
1318
- <fo:block>
1370
+ <fo:block role="H2">
1319
1371
  <xsl:if test="$part_num != ''">
1320
1372
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new($titles/title-part[@lang=$curr_lang]),'#',$part_num)"/>
1321
1373
  </xsl:if>
@@ -1325,7 +1377,7 @@
1325
1377
  </xsl:if>
1326
1378
  <xsl:variable name="subpart_num" select="normalize-space(/bipm:bipm-standard/bipm:bibdata/bipm:ext/bipm:structuredidentifier/bipm:subpart)"/>
1327
1379
  <xsl:if test="/bipm:bipm-standard/bipm:bibdata/bipm:title[@language = $curr_lang and @type = 'subpart']">
1328
- <fo:block>
1380
+ <fo:block role="H3">
1329
1381
  <xsl:if test="$subpart_num != ''">
1330
1382
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new($titles/title-subpart[@lang=$curr_lang]),'#',$subpart_num)"/>
1331
1383
  </xsl:if>
@@ -1464,7 +1516,7 @@
1464
1516
  <xsl:otherwise>400</xsl:otherwise>
1465
1517
  </xsl:choose>
1466
1518
  </xsl:variable>
1467
- <fo:block>
1519
+ <fo:block role="H1">
1468
1520
  <xsl:if test="$title_num != 1">
1469
1521
  <xsl:attribute name="text-align">right</xsl:attribute>
1470
1522
  </xsl:if>
@@ -1504,8 +1556,8 @@
1504
1556
 
1505
1557
  <fo:block-container absolute-position="fixed" left="12.5mm" top="60mm">
1506
1558
 
1507
- <fo:block font-size="22.2pt" font-weight="{$weight-normal}"><xsl:value-of select="(//bipm:bipm-standard)[1]/bipm:bibdata/bipm:title[@language = 'fr' and @type = 'main']"/></fo:block>
1508
- <fo:block font-size="22.2pt" font-weight="{$weight-bold}" margin-top="1mm"><xsl:value-of select="(//bipm:bipm-standard)[1]/bipm:bibdata/bipm:title[@language = 'en' and @type = 'main']"/></fo:block>
1559
+ <fo:block font-size="22.2pt" font-weight="{$weight-normal}" role="H1"><xsl:value-of select="(//bipm:bipm-standard)[1]/bipm:bibdata/bipm:title[@language = 'fr' and @type = 'main']"/></fo:block>
1560
+ <fo:block font-size="22.2pt" font-weight="{$weight-bold}" margin-top="1mm" role="H1"><xsl:value-of select="(//bipm:bipm-standard)[1]/bipm:bibdata/bipm:title[@language = 'en' and @type = 'main']"/></fo:block>
1509
1561
 
1510
1562
  <xsl:variable name="edition_str">édition</xsl:variable>
1511
1563
  <!-- <xsl:choose>
@@ -1518,7 +1570,7 @@
1518
1570
 
1519
1571
  <!-- <fo:block-container height="98%" display-align="center"> -->
1520
1572
  <fo:block-container absolute-position="fixed" left="12.5mm" top="92mm" height="170mm" width="144mm" display-align="center">
1521
- <fo:block>
1573
+ <fo:block role="H1">
1522
1574
 
1523
1575
  <xsl:variable name="title_appendix_fr">
1524
1576
  <xsl:apply-templates select="(//bipm:bipm-standard)[1]/bipm:bibdata/bipm:title[@language = 'fr' and @type = 'appendix']" mode="title"/>
@@ -1823,7 +1875,7 @@
1823
1875
  </xsl:call-template>
1824
1876
  </fo:block>
1825
1877
  <fo:block-container font-size="12pt" font-weight="bold" border-top="0.5pt solid black" padding-top="2mm" width="45mm">
1826
- <fo:block>
1878
+ <fo:block role="H1">
1827
1879
  <xsl:call-template name="add-letter-spacing">
1828
1880
  <xsl:with-param name="text" select="$title"/>
1829
1881
  <xsl:with-param name="letter-spacing" select="0.09"/>
@@ -1932,7 +1984,7 @@
1932
1984
  <xsl:if test="normalize-space($space-after) != ''">
1933
1985
  <xsl:attribute name="padding-bottom"><xsl:value-of select="normalize-space($space-after)"/></xsl:attribute>
1934
1986
  </xsl:if>
1935
- <fo:block>
1987
+ <fo:block role="TOCI">
1936
1988
  <xsl:if test="@level = 1">
1937
1989
  <!-- <xsl:attribute name="space-after">6pt</xsl:attribute> -->
1938
1990
  <xsl:attribute name="font-family">Arial</xsl:attribute>
@@ -2247,7 +2299,10 @@
2247
2299
  </xsl:template>
2248
2300
 
2249
2301
  <xsl:template match="bipm:license-statement//bipm:title">
2250
- <fo:block text-decoration="underline" margin-bottom="6pt">
2302
+ <xsl:variable name="level">
2303
+ <xsl:call-template name="getLevel"/>
2304
+ </xsl:variable>
2305
+ <fo:block text-decoration="underline" margin-bottom="6pt" role="H{$level}">
2251
2306
  <xsl:apply-templates/>
2252
2307
  </fo:block>
2253
2308
  </xsl:template>
@@ -2378,19 +2433,20 @@
2378
2433
 
2379
2434
  <xsl:choose>
2380
2435
  <xsl:when test="*[local-name() = 'tab'] and not(ancestor::bipm:annex) "><!-- split number and title --> <!-- and $independentAppendix = '' -->
2381
- <fo:table table-layout="fixed" width="100%">
2436
+ <fo:table table-layout="fixed" width="100%" role="H{$level}">
2382
2437
  <fo:table-column column-width="14mm"/>
2383
2438
  <fo:table-column column-width="136mm"/>
2384
2439
  <fo:table-body>
2385
2440
  <fo:table-row>
2386
2441
  <fo:table-cell>
2387
- <fo:block>
2442
+ <fo:block role="H{$level}">
2388
2443
  <xsl:value-of select="*[local-name() = 'tab'][1]/preceding-sibling::node()"/>
2389
2444
  </fo:block>
2390
2445
  </fo:table-cell>
2391
2446
  <fo:table-cell>
2392
- <fo:block line-height-shift-adjustment="disregard-shifts">
2447
+ <fo:block line-height-shift-adjustment="disregard-shifts" role="H{$level}">
2393
2448
  <xsl:call-template name="extractTitle"/>
2449
+ <xsl:apply-templates select="following-sibling::*[1][local-name() = 'variant-title'][@type = 'sub']" mode="subtitle"/>
2394
2450
  </fo:block>
2395
2451
  </fo:table-cell>
2396
2452
  </fo:table-row>
@@ -2398,7 +2454,7 @@
2398
2454
  </fo:table>
2399
2455
  </xsl:when>
2400
2456
  <xsl:otherwise>
2401
- <fo:block>
2457
+ <fo:block role="H{$level}">
2402
2458
  <!-- <xsl:if test="$independentAppendix != ''">
2403
2459
  <xsl:attribute name="margin-left">14mm</xsl:attribute>
2404
2460
  </xsl:if> -->
@@ -2420,11 +2476,13 @@
2420
2476
  <xsl:attribute name="text-align">center</xsl:attribute>
2421
2477
  </xsl:if>
2422
2478
  <xsl:call-template name="extractTitle"/>
2479
+ <xsl:apply-templates select="following-sibling::*[1][local-name() = 'variant-title'][@type = 'sub']" mode="subtitle"/>
2423
2480
  </xsl:when>
2424
2481
  <xsl:otherwise>
2425
2482
  <!-- <xsl:choose>
2426
2483
  <xsl:when test="$independentAppendix = ''"> -->
2427
2484
  <xsl:apply-templates/>
2485
+ <xsl:apply-templates select="following-sibling::*[1][local-name() = 'variant-title'][@type = 'sub']" mode="subtitle"/>
2428
2486
  <!-- </xsl:when>
2429
2487
  <xsl:otherwise>
2430
2488
  <xsl:variable name="section" select="*[local-name() = 'tab'][1]/preceding-sibling::node()"/>
@@ -3039,6 +3097,7 @@
3039
3097
  <xsl:attribute name="font-family">Arial</xsl:attribute>
3040
3098
  <xsl:attribute name="font-size">9pt</xsl:attribute>
3041
3099
  <xsl:attribute name="line-height">130%</xsl:attribute>
3100
+ <xsl:attribute name="role">BlockQuote</xsl:attribute>
3042
3101
  </xsl:if>
3043
3102
  <xsl:attribute name="line-height-shift-adjustment">disregard-shifts</xsl:attribute>
3044
3103
  <xsl:apply-templates/>
@@ -3083,6 +3142,7 @@
3083
3142
  <xsl:attribute name="font-family">Arial</xsl:attribute>
3084
3143
  <xsl:attribute name="font-size">9pt</xsl:attribute>
3085
3144
  <xsl:attribute name="line-height">130%</xsl:attribute>
3145
+ <xsl:attribute name="role">BlockQuote</xsl:attribute>
3086
3146
  </xsl:if>
3087
3147
 
3088
3148
  <!-- last item -->
@@ -3240,16 +3300,19 @@
3240
3300
  </fo:block>
3241
3301
  </xsl:template>
3242
3302
 
3243
- <xsl:template match="bipm:preferred">
3244
- <fo:block font-weight="bold" keep-with-next="always" space-before="8pt" margin-bottom="6pt">
3245
- <xsl:if test="ancestor::bipm:term/bipm:name">
3246
- <fo:inline>
3247
- <xsl:attribute name="padding-right">2mm</xsl:attribute>
3248
- <xsl:apply-templates select="ancestor::bipm:term/bipm:name" mode="presentation"/>
3249
- </fo:inline>
3250
- </xsl:if>
3251
- <xsl:apply-templates/>
3252
- </fo:block>
3303
+ <xsl:template match="bipm:preferred">
3304
+ <fo:block font-weight="bold" keep-with-next="always" space-before="8pt" margin-bottom="6pt">
3305
+ <xsl:if test="ancestor::bipm:term/bipm:name">
3306
+ <xsl:variable name="level">
3307
+ <xsl:call-template name="getLevelTermName"/>
3308
+ </xsl:variable>
3309
+ <fo:inline role="H{$level}">
3310
+ <xsl:attribute name="padding-right">2mm</xsl:attribute>
3311
+ <xsl:apply-templates select="ancestor::bipm:term/bipm:name" mode="presentation"/>
3312
+ </fo:inline>
3313
+ </xsl:if>
3314
+ <xsl:apply-templates/>
3315
+ </fo:block>
3253
3316
  </xsl:template>
3254
3317
 
3255
3318
  <xsl:template match="bipm:bibitem">
@@ -3647,10 +3710,116 @@
3647
3710
  <xsl:value-of select="translate(., ' ', ' ')"/>
3648
3711
  </xsl:template>
3649
3712
 
3713
+ <xsl:template match="mathml:math" priority="2">
3714
+ <xsl:variable name="isAdded" select="@added"/>
3715
+ <xsl:variable name="isDeleted" select="@deleted"/>
3716
+
3717
+ <fo:inline xsl:use-attribute-sets="mathml-style">
3718
+
3719
+ <xsl:if test="ancestor::*[local-name()='table']">
3720
+ <xsl:attribute name="font-size">95%</xsl:attribute> <!-- base font in table is 10pt -->
3721
+ </xsl:if>
3722
+
3723
+ <xsl:call-template name="setTrackChangesStyles">
3724
+ <xsl:with-param name="isAdded" select="$isAdded"/>
3725
+ <xsl:with-param name="isDeleted" select="$isDeleted"/>
3726
+ </xsl:call-template>
3727
+
3728
+ <xsl:if test="$add_math_as_text = 'true'">
3729
+ <!-- set unique font-size (fiction) -->
3730
+ <xsl:variable name="font-size_sfx"><xsl:number level="any"/></xsl:variable>
3731
+ <fo:inline color="white" font-size="1.{$font-size_sfx}pt" font-style="normal" font-weight="normal">​</fo:inline> <!-- zero width space -->
3732
+ </xsl:if>
3733
+
3734
+ <!-- <fo:wrapper role="artifact"> -->
3735
+
3736
+ <xsl:variable name="mathml_content">
3737
+ <xsl:apply-templates select="." mode="mathml_actual_text"/>
3738
+ </xsl:variable>
3739
+
3740
+ <xsl:variable name="comment_text_following" select="following-sibling::node()[1][self::comment()]"/>
3741
+ <xsl:variable name="comment_text_">
3742
+ <xsl:choose>
3743
+ <xsl:when test="normalize-space($comment_text_following) != ''">
3744
+ <xsl:value-of select="$comment_text_following"/>
3745
+ </xsl:when>
3746
+ <xsl:otherwise>
3747
+ <xsl:value-of select="normalize-space(translate(.,' ⁢',' '))"/>
3748
+ </xsl:otherwise>
3749
+ </xsl:choose>
3750
+ </xsl:variable>
3751
+ <xsl:variable name="comment_text" select="java:org.metanorma.fop.Util.unescape($comment_text_)"/>
3752
+
3753
+ <xsl:choose>
3754
+ <xsl:when test="$add_math_as_attachment = 'true'">
3755
+
3756
+ <xsl:variable name="filename" select="xalan:nodeset($mathml_attachments)//attachment[. = $mathml_content]/@filename"/>
3757
+ <xsl:if test="$filename != ''">
3758
+ <xsl:variable name="url" select="concat('url(embedded-file:', $filename, ')')"/>
3759
+ <fo:basic-link external-destination="{$url}" fox:alt-text="MathLink">
3760
+ <xsl:if test="normalize-space($comment_text) != ''">
3761
+ <!-- put Mathin Alternate Text -->
3762
+ <xsl:attribute name="fox:alt-text">
3763
+ <xsl:value-of select="$comment_text"/>
3764
+ </xsl:attribute>
3765
+ </xsl:if>
3766
+ <xsl:call-template name="mathml_instream_object">
3767
+ <xsl:with-param name="mathml_content" select="$mathml_content"/>
3768
+ <xsl:with-param name="comment_text" select="$comment_text"/>
3769
+ </xsl:call-template>
3770
+ </fo:basic-link>
3771
+ </xsl:if>
3772
+ </xsl:when>
3773
+ <xsl:otherwise>
3774
+ <xsl:call-template name="mathml_instream_object">
3775
+ <xsl:with-param name="mathml_content" select="$mathml_content"/>
3776
+ <xsl:with-param name="comment_text" select="$comment_text"/>
3777
+ </xsl:call-template>
3778
+ </xsl:otherwise>
3779
+ </xsl:choose>
3780
+ <!-- </fo:wrapper> -->
3781
+ </fo:inline>
3782
+ </xsl:template>
3783
+
3784
+ <xsl:template name="mathml_instream_object">
3785
+ <xsl:param name="mathml_content"/>
3786
+ <xsl:param name="comment_text"/>
3787
+
3788
+ <xsl:variable name="mathml">
3789
+ <xsl:apply-templates select="." mode="mathml"/>
3790
+ </xsl:variable>
3791
+
3792
+ <fo:instream-foreign-object fox:alt-text="Math">
3793
+
3794
+ <xsl:if test="local-name(../..) = 'formula'">
3795
+ <xsl:attribute name="width">95%</xsl:attribute>
3796
+ <xsl:attribute name="content-height">100%</xsl:attribute>
3797
+ <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
3798
+ <xsl:attribute name="scaling">uniform</xsl:attribute>
3799
+ </xsl:if>
3800
+
3801
+ <!-- put MathML in Actual Text -->
3802
+ <xsl:attribute name="fox:actual-text">
3803
+ <xsl:value-of select="$mathml_content"/>
3804
+ </xsl:attribute>
3805
+
3806
+ <xsl:if test="$add_math_as_text = 'true'">
3807
+ <xsl:if test="normalize-space($comment_text) != ''">
3808
+ <!-- put Mathin Alternate Text -->
3809
+ <xsl:attribute name="fox:alt-text">
3810
+ <xsl:value-of select="$comment_text"/>
3811
+ </xsl:attribute>
3812
+ </xsl:if>
3813
+ </xsl:if>
3814
+
3815
+ <xsl:copy-of select="xalan:nodeset($mathml)"/>
3816
+ </fo:instream-foreign-object>
3817
+ </xsl:template>
3818
+
3650
3819
  <xsl:template name="insertHeaderFooter">
3651
3820
  <xsl:param name="header-title"/>
3652
3821
  <xsl:param name="orientation"/>
3653
- <fo:static-content flow-name="header-odd">
3822
+ <fo:static-content flow-name="header-odd" role="artifact">
3654
3823
  <fo:block-container font-family="Arial" font-size="8pt" padding-top="12.5mm">
3655
3824
  <fo:block text-align="right">
3656
3825
  <xsl:copy-of select="$header-title"/>
@@ -3670,7 +3839,7 @@
3670
3839
  <fo:block> </fo:block>
3671
3840
  </fo:block-container>
3672
3841
  </fo:static-content>
3673
- <fo:static-content flow-name="header-even">
3842
+ <fo:static-content flow-name="header-even" role="artifact">
3674
3843
  <fo:block-container font-family="Arial" font-size="8pt" padding-top="12.5mm">
3675
3844
  <fo:block>
3676
3845
  <fo:inline font-weight="bold"><fo:page-number/></fo:inline>
@@ -3851,7 +4020,7 @@
3851
4020
  <fo:block id="{@id}" span="all">
3852
4021
  <xsl:apply-templates select="bipm:title"/>
3853
4022
  </fo:block>
3854
- <fo:block>
4023
+ <fo:block role="Index">
3855
4024
  <xsl:apply-templates select="*[not(local-name() = 'title')]"/>
3856
4025
 
3857
4026
  <!-- TEST <xsl:variable name="alphabet" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
@@ -3877,7 +4046,7 @@
3877
4046
 
3878
4047
  <!-- <xsl:template match="bipm:clause[@type = 'index']/bipm:title" priority="4"> -->
3879
4048
  <xsl:template match="bipm:indexsect/bipm:title" priority="4">
3880
- <fo:block font-size="16pt" font-weight="bold" margin-bottom="84pt" margin-left="-18mm">
4049
+ <fo:block font-size="16pt" font-weight="bold" margin-bottom="84pt" margin-left="-18mm" role="H1">
3881
4050
  <!-- Index -->
3882
4051
  <xsl:apply-templates/>
3883
4052
  </fo:block>
@@ -4470,6 +4639,7 @@
4470
4639
  </xsl:attribute-set><xsl:attribute-set name="sourcecode-style">
4471
4640
  <xsl:attribute name="white-space">pre</xsl:attribute>
4472
4641
  <xsl:attribute name="wrap-option">wrap</xsl:attribute>
4642
+ <xsl:attribute name="role">Code</xsl:attribute>
4473
4643
 
4474
4644
 
4475
4645
 
@@ -4491,8 +4661,13 @@
4491
4661
 
4492
4662
  </xsl:attribute-set><xsl:attribute-set name="requirement-label-style">
4493
4663
 
4494
- </xsl:attribute-set><xsl:attribute-set name="requirement-subject-style">
4495
- </xsl:attribute-set><xsl:attribute-set name="requirement-inherit-style">
4664
+ </xsl:attribute-set><xsl:attribute-set name="subject-style">
4665
+ </xsl:attribute-set><xsl:attribute-set name="inherit-style">
4666
+ </xsl:attribute-set><xsl:attribute-set name="description-style">
4667
+ </xsl:attribute-set><xsl:attribute-set name="specification-style">
4668
+ </xsl:attribute-set><xsl:attribute-set name="measurement-target-style">
4669
+ </xsl:attribute-set><xsl:attribute-set name="verification-style">
4670
+ </xsl:attribute-set><xsl:attribute-set name="import-style">
4496
4671
  </xsl:attribute-set><xsl:attribute-set name="recommendation-style">
4497
4672
 
4498
4673
 
@@ -4682,7 +4857,8 @@
4682
4857
  <xsl:attribute name="padding-right">1mm</xsl:attribute>
4683
4858
 
4684
4859
 
4685
- </xsl:attribute-set><xsl:attribute-set name="quote-style">
4860
+ </xsl:attribute-set><xsl:attribute-set name="quote-style">
4861
+ <xsl:attribute name="role">BlockQuote</xsl:attribute>
4686
4862
 
4687
4863
 
4688
4864
 
@@ -4870,7 +5046,9 @@
4870
5046
 
4871
5047
  <xsl:apply-templates select="*[local-name()='name']" mode="presentation"/>
4872
5048
 
4873
-
5049
+
5050
+
5051
+
4874
5052
 
4875
5053
  <xsl:call-template name="fn_name_display"/>
4876
5054
 
@@ -6856,6 +7034,12 @@
6856
7034
  <xsl:with-param name="isDeleted" select="$isDeleted"/>
6857
7035
  </xsl:call-template>
6858
7036
 
7037
+ <!-- insert helper tag -->
7038
+ <xsl:if test="$add_math_as_text = 'true'">
7039
+ <fo:inline color="white" font-size="1pt" font-style="normal" font-weight="normal">​</fo:inline> <!-- zero width space -->
7040
+ </xsl:if>
7041
+
7042
+
6859
7043
  <xsl:variable name="mathml">
6860
7044
  <xsl:apply-templates select="." mode="mathml"/>
6861
7045
  </xsl:variable>
@@ -6867,15 +7051,75 @@
6867
7051
  <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
6868
7052
  <xsl:attribute name="scaling">uniform</xsl:attribute>
6869
7053
  </xsl:if>
6870
- <!-- <xsl:attribute name="fox:alt-text">
6871
- put AsciiMath/LaTeX math
6872
- </xsl:attribute> -->
7054
+
7055
+ <xsl:if test="$add_math_as_text = 'true'">
7056
+ <!-- <xsl:variable name="comment_text" select="following-sibling::node()[1][self::comment()]"/> -->
7057
+ <xsl:variable name="comment_text" select="normalize-space(translate(.,' ⁢',' '))"/>
7058
+ <!-- <xsl:variable name="comment_text" select="normalize-space(.)"/> -->
7059
+ <xsl:if test="normalize-space($comment_text) != ''">
7060
+ <!-- put Mathin Alternate Text -->
7061
+ <xsl:attribute name="fox:alt-text">
7062
+ <xsl:value-of select="java:org.metanorma.fop.Util.unescape($comment_text)"/>
7063
+ <!-- <xsl:value-of select="$comment_text"/> -->
7064
+ </xsl:attribute>
7065
+ </xsl:if>
7066
+ </xsl:if>
7067
+
7068
+
7069
+ <xsl:variable name="comment_text_following" select="following-sibling::node()[1][self::comment()]"/>
7070
+ <xsl:variable name="comment_text_">
7071
+ <xsl:choose>
7072
+ <xsl:when test="normalize-space($comment_text_following) != ''">
7073
+ <xsl:value-of select="$comment_text_following"/>
7074
+ </xsl:when>
7075
+ <xsl:otherwise>
7076
+ <xsl:value-of select="normalize-space(translate(.,' ⁢',' '))"/>
7077
+ </xsl:otherwise>
7078
+ </xsl:choose>
7079
+ </xsl:variable>
7080
+ <xsl:variable name="comment_text" select="java:org.metanorma.fop.Util.unescape($comment_text_)"/>
7081
+
7082
+ <xsl:if test="normalize-space($comment_text) != ''">
7083
+ <!-- put Mathin Alternate Text -->
7084
+ <xsl:attribute name="fox:alt-text">
7085
+ <xsl:value-of select="java:org.metanorma.fop.Util.unescape($comment_text)"/>
7086
+ </xsl:attribute>
7087
+ </xsl:if>
7088
+
7089
+ <xsl:variable name="mathml_content">
7090
+ <xsl:apply-templates select="." mode="mathml_actual_text"/>
7091
+ </xsl:variable>
7092
+ <!-- put MathML in Actual Text -->
7093
+ <xsl:attribute name="fox:actual-text">
7094
+ <xsl:value-of select="$mathml_content"/>
7095
+ </xsl:attribute>
6873
7096
 
6874
7097
 
6875
7098
  <!-- <xsl:copy-of select="."/> -->
6876
7099
  <xsl:copy-of select="xalan:nodeset($mathml)"/>
6877
7100
  </fo:instream-foreign-object>
6878
7101
  </fo:inline>
7102
+ </xsl:template><xsl:template match="mathml:*" mode="mathml_actual_text">
7103
+ <!-- <xsl:text>a+b</xsl:text> -->
7104
+ <xsl:text>&lt;</xsl:text>
7105
+ <xsl:value-of select="local-name()"/>
7106
+ <xsl:if test="local-name() = 'math'">
7107
+ <xsl:text> xmlns="http://www.w3.org/1998/Math/MathML"</xsl:text>
7108
+ </xsl:if>
7109
+ <xsl:for-each select="@*">
7110
+ <xsl:text> </xsl:text>
7111
+ <xsl:value-of select="local-name()"/>
7112
+ <xsl:text>="</xsl:text>
7113
+ <xsl:value-of select="."/>
7114
+ <xsl:text>"</xsl:text>
7115
+ </xsl:for-each>
7116
+ <xsl:text>&gt;</xsl:text>
7117
+ <xsl:apply-templates mode="mathml_actual_text"/>
7118
+ <xsl:text>&lt;/</xsl:text>
7119
+ <xsl:value-of select="local-name()"/>
7120
+ <xsl:text>&gt;</xsl:text>
7121
+ </xsl:template><xsl:template match="text()" mode="mathml_actual_text">
7122
+ <xsl:value-of select="normalize-space()"/>
6879
7123
  </xsl:template><xsl:template match="@*|node()" mode="mathml">
6880
7124
  <xsl:copy>
6881
7125
  <xsl:apply-templates select="@*|node()" mode="mathml"/>
@@ -6937,7 +7181,10 @@
6937
7181
  </fo:block>
6938
7182
  <xsl:apply-templates/>
6939
7183
  </xsl:template><xsl:template match="*[local-name()='appendix']/*[local-name()='title']"/><xsl:template match="*[local-name()='appendix']/*[local-name()='title']" mode="process">
6940
- <fo:inline><xsl:apply-templates/></fo:inline>
7184
+ <xsl:variable name="level">
7185
+ <xsl:call-template name="getLevel"/>
7186
+ </xsl:variable>
7187
+ <fo:inline role="H{$level}"><xsl:apply-templates/></fo:inline>
6941
7188
  </xsl:template><xsl:template match="*[local-name()='appendix']//*[local-name()='example']" priority="2">
6942
7189
  <fo:block id="{@id}" xsl:use-attribute-sets="appendix-example-style">
6943
7190
  <xsl:apply-templates select="*[local-name()='name']" mode="presentation"/>
@@ -6972,9 +7219,10 @@
6972
7219
 
6973
7220
  </xsl:variable>
6974
7221
 
7222
+ <xsl:variable name="text"><xsl:apply-templates/></xsl:variable>
6975
7223
  <xsl:choose>
6976
- <xsl:when test="$lang = 'zh'"><xsl:text>、</xsl:text><xsl:value-of select="$title-modified"/><xsl:text>—</xsl:text></xsl:when>
6977
- <xsl:otherwise><xsl:text>, </xsl:text><xsl:value-of select="$title-modified"/><xsl:text> — </xsl:text></xsl:otherwise>
7224
+ <xsl:when test="$lang = 'zh'"><xsl:text>、</xsl:text><xsl:value-of select="$title-modified"/><xsl:if test="normalize-space($text) != ''"><xsl:text>—</xsl:text></xsl:if></xsl:when>
7225
+ <xsl:otherwise><xsl:text>, </xsl:text><xsl:value-of select="$title-modified"/><xsl:if test="normalize-space($text) != ''"><xsl:text> — </xsl:text></xsl:if></xsl:otherwise>
6978
7226
  </xsl:choose>
6979
7227
  <xsl:apply-templates/>
6980
7228
  </xsl:template><xsl:template match="*[local-name() = 'xref']">
@@ -7134,7 +7382,10 @@
7134
7382
  </fo:block>
7135
7383
  </xsl:template><xsl:template match="*[local-name() = 'term']/*[local-name() = 'name']"/><xsl:template match="*[local-name() = 'term']/*[local-name() = 'name']" mode="presentation">
7136
7384
  <xsl:if test="normalize-space() != ''">
7137
- <fo:inline>
7385
+ <xsl:variable name="level">
7386
+ <xsl:call-template name="getLevelTermName"/>
7387
+ </xsl:variable>
7388
+ <fo:inline role="H{$level}">
7138
7389
  <xsl:apply-templates/>
7139
7390
  <!-- <xsl:if test="$namespace = 'gb' or $namespace = 'ogc'">
7140
7391
  <xsl:text>.</xsl:text>
@@ -7783,6 +8034,7 @@
7783
8034
  </xsl:when>
7784
8035
  <xsl:otherwise>
7785
8036
  <xsl:apply-templates/>
8037
+ <xsl:apply-templates select="following-sibling::*[1][local-name() = 'variant-title'][@type = 'sub']" mode="subtitle"/>
7786
8038
  </xsl:otherwise>
7787
8039
  </xsl:choose>
7788
8040
  </fo:block>
@@ -7923,14 +8175,6 @@
7923
8175
  <fo:block>
7924
8176
  <fo:inline padding-right="3mm">Obligation</fo:inline><xsl:value-of select="."/>
7925
8177
  </fo:block>
7926
- </xsl:template><xsl:template match="*[local-name() = 'requirement']/*[local-name() = 'subject']"/><xsl:template match="*[local-name() = 'requirement']/*[local-name() = 'subject']" mode="presentation">
7927
- <fo:block xsl:use-attribute-sets="requirement-subject-style">
7928
- <xsl:text>Target Type </xsl:text><xsl:apply-templates/>
7929
- </fo:block>
7930
- </xsl:template><xsl:template match="*[local-name() = 'requirement']/*[local-name() = 'inherit']">
7931
- <fo:block xsl:use-attribute-sets="requirement-inherit-style">
7932
- <xsl:text>Dependency </xsl:text><xsl:apply-templates/>
7933
- </fo:block>
7934
8178
  </xsl:template><xsl:template match="*[local-name() = 'recommendation']">
7935
8179
  <fo:block id="{@id}" xsl:use-attribute-sets="recommendation-style">
7936
8180
  <xsl:apply-templates select="*[local-name()='name']" mode="presentation"/>
@@ -7947,6 +8191,38 @@
7947
8191
  <fo:block xsl:use-attribute-sets="recommendation-label-style">
7948
8192
  <xsl:apply-templates/>
7949
8193
  </fo:block>
8194
+ </xsl:template><xsl:template match="*[local-name() = 'requirement']/*[local-name() = 'subject']" priority="2"/><xsl:template match="*[local-name() = 'requirement']/*[local-name() = 'subject']" mode="presentation">
8195
+ <fo:block xsl:use-attribute-sets="subject-style">
8196
+ <xsl:text>Target Type </xsl:text><xsl:apply-templates/>
8197
+ </fo:block>
8198
+ </xsl:template><xsl:template match="*[local-name() = 'subject']">
8199
+ <fo:block xsl:use-attribute-sets="subject-style">
8200
+ <xsl:text>Target Type </xsl:text><xsl:apply-templates/>
8201
+ </fo:block>
8202
+ </xsl:template><xsl:template match="*[local-name() = 'inherit'] | *[local-name() = 'component'][@class = 'inherit']">
8203
+ <fo:block xsl:use-attribute-sets="inherit-style">
8204
+ <xsl:text>Dependency </xsl:text><xsl:apply-templates/>
8205
+ </fo:block>
8206
+ </xsl:template><xsl:template match="*[local-name() = 'description'] | *[local-name() = 'component'][@class = 'description']">
8207
+ <fo:block xsl:use-attribute-sets="description-style">
8208
+ <xsl:apply-templates/>
8209
+ </fo:block>
8210
+ </xsl:template><xsl:template match="*[local-name() = 'specification'] | *[local-name() = 'component'][@class = 'specification']">
8211
+ <fo:block xsl:use-attribute-sets="specification-style">
8212
+ <xsl:apply-templates/>
8213
+ </fo:block>
8214
+ </xsl:template><xsl:template match="*[local-name() = 'measurement-target'] | *[local-name() = 'component'][@class = 'measurement-target']">
8215
+ <fo:block xsl:use-attribute-sets="measurement-target-style">
8216
+ <xsl:apply-templates/>
8217
+ </fo:block>
8218
+ </xsl:template><xsl:template match="*[local-name() = 'verification'] | *[local-name() = 'component'][@class = 'verification']">
8219
+ <fo:block xsl:use-attribute-sets="verification-style">
8220
+ <xsl:apply-templates/>
8221
+ </fo:block>
8222
+ </xsl:template><xsl:template match="*[local-name() = 'import'] | *[local-name() = 'component'][@class = 'import']">
8223
+ <fo:block xsl:use-attribute-sets="import-style">
8224
+ <xsl:apply-templates/>
8225
+ </fo:block>
7950
8226
  </xsl:template><xsl:template match="*[local-name() = 'table'][@class = 'recommendation' or @class='requirement' or @class='permission']">
7951
8227
  <fo:block-container margin-left="0mm" margin-right="0mm" margin-bottom="12pt">
7952
8228
  <xsl:if test="ancestor::*[local-name() = 'table'][@class = 'recommendation' or @class='requirement' or @class='permission']">
@@ -8857,6 +9133,9 @@
8857
9133
  <fo:block-container border="1pt solid black" width="50%">
8858
9134
  <fo:block> </fo:block>
8859
9135
  </fo:block-container>
9136
+ </xsl:template><xsl:template match="*[local-name() = 'variant-title'][@type = 'sub']"/><xsl:template match="*[local-name() = 'variant-title'][@type = 'sub']" mode="subtitle">
9137
+ <fo:inline padding-right="5mm"> </fo:inline>
9138
+ <fo:inline><xsl:apply-templates/></fo:inline>
8860
9139
  </xsl:template><xsl:template name="convertDate">
8861
9140
  <xsl:param name="date"/>
8862
9141
  <xsl:param name="format" select="'short'"/>
@@ -8976,7 +9255,7 @@
8976
9255
  <xsl:variable name="lang">
8977
9256
  <xsl:call-template name="getLang"/>
8978
9257
  </xsl:variable>
8979
- <pdf:catalog xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf">
9258
+ <pdf:catalog>
8980
9259
  <pdf:dictionary type="normal" key="ViewerPreferences">
8981
9260
  <pdf:boolean key="DisplayDocTitle">true</pdf:boolean>
8982
9261
  </pdf:dictionary>
@@ -9095,6 +9374,26 @@
9095
9374
  <xsl:value-of select="$level"/>
9096
9375
  </xsl:otherwise>
9097
9376
  </xsl:choose>
9377
+ </xsl:template><xsl:template name="getLevelTermName">
9378
+ <xsl:choose>
9379
+ <xsl:when test="normalize-space(../@depth) != ''">
9380
+ <xsl:value-of select="../@depth"/>
9381
+ </xsl:when>
9382
+ <xsl:otherwise>
9383
+ <xsl:variable name="title_level_">
9384
+ <xsl:for-each select="../preceding-sibling::*[local-name() = 'title'][1]">
9385
+ <xsl:call-template name="getLevel"/>
9386
+ </xsl:for-each>
9387
+ </xsl:variable>
9388
+ <xsl:variable name="title_level" select="normalize-space($title_level_)"/>
9389
+ <xsl:choose>
9390
+ <xsl:when test="$title_level != ''"><xsl:value-of select="$title_level + 1"/></xsl:when>
9391
+ <xsl:otherwise>
9392
+ <xsl:call-template name="getLevel"/>
9393
+ </xsl:otherwise>
9394
+ </xsl:choose>
9395
+ </xsl:otherwise>
9396
+ </xsl:choose>
9098
9397
  </xsl:template><xsl:template name="split">
9099
9398
  <xsl:param name="pText" select="."/>
9100
9399
  <xsl:param name="sep" select="','"/>