metanorma-un 0.6.7 → 0.6.11

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.
@@ -127,7 +127,7 @@
127
127
  </fo:block>
128
128
  </fo:block>
129
129
  <fo:block-container absolute-position="fixed" left="50mm" top="30mm" width="139mm" height="40mm" text-align="right" display-align="after">
130
- <fo:block font-family="Arial" font-size="24.5pt" font-weight="bold" margin-right="3mm"> <!-- margin-top="19mm" -->
130
+ <fo:block font-family="Arial" font-size="24.5pt" font-weight="bold" margin-right="3mm" role="H1"> <!-- margin-top="19mm" -->
131
131
  <xsl:if test="string-length($title) &gt; 70">
132
132
  <xsl:attribute name="font-size">22pt</xsl:attribute>
133
133
  </xsl:if>
@@ -142,7 +142,7 @@
142
142
  <fo:flow flow-name="xsl-region-body" font-family="Arial">
143
143
  <fo:block font-size="14pt" font-weight="bold" text-align="center">United Nations Economic Commission for Europe</fo:block>
144
144
  <fo:block font-size="12pt" font-weight="normal" text-align="center" margin-top="46pt" margin-bottom="128pt" keep-together="always">United Nations Centre for Trade Facilitation and Electronic Business</fo:block>
145
- <fo:block font-size="22pt" font-weight="bold" text-align="center">
145
+ <fo:block font-size="22pt" font-weight="bold" text-align="center" role="H1">
146
146
  <xsl:value-of select="$title"/>
147
147
  <xsl:value-of select="$linebreak"/>
148
148
  <xsl:value-of select="$doctypenumber"/>
@@ -200,17 +200,17 @@
200
200
  <xsl:with-param name="name" select="'title-toc'"/>
201
201
  </xsl:call-template>
202
202
  </xsl:variable>
203
- <fo:block font-size="14pt" margin-top="4pt" margin-bottom="8pt"><xsl:value-of select="$title-toc"/></fo:block>
203
+ <fo:block font-size="14pt" margin-top="4pt" margin-bottom="8pt" role="H1"><xsl:value-of select="$title-toc"/></fo:block>
204
204
  <xsl:variable name="title-page">
205
205
  <xsl:call-template name="getTitle">
206
206
  <xsl:with-param name="name" select="'title-page'"/>
207
207
  </xsl:call-template>
208
208
  </xsl:variable>
209
209
  <fo:block font-size="9pt" text-align="right" font-style="italic" margin-bottom="6pt"><xsl:value-of select="$title-page"/></fo:block>
210
- <fo:block>
210
+ <fo:block role="TOC">
211
211
  <xsl:for-each select="xalan:nodeset($contents)//item[not (@type = 'annex' or @parent = 'annex') and @display = 'true']">
212
212
 
213
- <fo:block>
213
+ <fo:block role="TOCI">
214
214
 
215
215
  <fo:block text-align-last="justify" margin-left="12mm" text-indent="-12mm">
216
216
  <xsl:if test="@level = 2 and @section != ''">
@@ -249,7 +249,7 @@
249
249
  <xsl:if test="xalan:nodeset($contents)//item[@type = 'annex' and @display = 'true']">
250
250
  <fo:block text-align="center" margin-top="12pt" margin-bottom="12pt">ANNEXES</fo:block>
251
251
  <xsl:for-each select="xalan:nodeset($contents)//item[@type = 'annex' and @display = 'true']">
252
- <fo:block>
252
+ <fo:block role="TOCI">
253
253
  <fo:block text-align-last="justify" margin-left="12mm" text-indent="-12mm">
254
254
  <fo:basic-link internal-destination="{@id}" fox:alt-text="{@section}">
255
255
  <xsl:if test="@section != ''">
@@ -423,7 +423,10 @@
423
423
 
424
424
 
425
425
  <xsl:template match="un:legal-statement//un:clause/un:title">
426
- <fo:block font-weight="bold">
426
+ <xsl:variable name="level">
427
+ <xsl:call-template name="getLevel"/>
428
+ </xsl:variable>
429
+ <fo:block font-weight="bold" role="H{$level}">
427
430
  <xsl:choose>
428
431
  <xsl:when test="text() = 'Note'">
429
432
  <xsl:attribute name="font-size">14pt</xsl:attribute>
@@ -567,7 +570,10 @@
567
570
  </xsl:template>
568
571
 
569
572
  <xsl:template match="un:title" mode="inline-header">
570
- <fo:inline>
573
+ <xsl:variable name="level">
574
+ <xsl:call-template name="getLevel"/>
575
+ </xsl:variable>
576
+ <fo:inline role="H{$level}">
571
577
  <xsl:apply-templates/>
572
578
  </fo:inline>
573
579
  </xsl:template>
@@ -739,8 +745,9 @@
739
745
  <xsl:otherwise>12pt</xsl:otherwise>
740
746
  </xsl:choose>
741
747
  </xsl:variable>
742
- <fo:block font-size="{$font-size}" font-weight="bold" margin-top="30pt" margin-bottom="16pt" keep-with-next="always">
748
+ <fo:block font-size="{$font-size}" font-weight="bold" margin-top="30pt" margin-bottom="16pt" keep-with-next="always" role="H{$level}">
743
749
  <xsl:apply-templates/>
750
+ <xsl:apply-templates select="following-sibling::*[1][local-name() = 'variant-title'][@type = 'sub']" mode="subtitle"/>
744
751
  </fo:block>
745
752
  </xsl:template>
746
753
 
@@ -758,12 +765,13 @@
758
765
 
759
766
  <xsl:choose>
760
767
  <xsl:when test="$level = 1">
761
- <fo:block font-size="{$font-size}" font-weight="bold" space-before="3pt" margin-top="12pt" margin-bottom="16pt" keep-with-next="always" line-height="18pt">
768
+ <fo:block font-size="{$font-size}" font-weight="bold" space-before="3pt" margin-top="12pt" margin-bottom="16pt" keep-with-next="always" line-height="18pt" role="H{$level}">
762
769
  <xsl:apply-templates/>
770
+ <xsl:apply-templates select="following-sibling::*[1][local-name() = 'variant-title'][@type = 'sub']" mode="subtitle"/>
763
771
  </fo:block>
764
772
  </xsl:when>
765
773
  <xsl:when test="$level &gt;= 2">
766
- <fo:block font-size="{$font-size}" font-weight="bold" space-before="3pt" margin-bottom="12pt" margin-left="-9.5mm" line-height="108%" keep-with-next="always"> <!-- line-height="14.5pt" text-indent="-9.5mm" -->
774
+ <fo:block font-size="{$font-size}" font-weight="bold" space-before="3pt" margin-bottom="12pt" margin-left="-9.5mm" line-height="108%" keep-with-next="always" role="H{$level}"> <!-- line-height="14.5pt" text-indent="-9.5mm" -->
767
775
  <xsl:if test="$level = 2">
768
776
  <xsl:attribute name="margin-top">16pt</xsl:attribute>
769
777
  </xsl:if>
@@ -796,7 +804,7 @@
796
804
 
797
805
  <xsl:choose>
798
806
  <xsl:when test="ancestor::un:sections">
799
- <fo:block font-size="{$font-size}" font-weight="bold" space-before="3pt" margin-bottom="12pt" margin-left="-9.5mm" line-height="108%" keep-with-next="always"> <!-- line-height="14.5pt" text-indent="-9.5mm" -->
807
+ <fo:block font-size="{$font-size}" font-weight="bold" space-before="3pt" margin-bottom="12pt" margin-left="-9.5mm" line-height="108%" keep-with-next="always" role="H{$level}"> <!-- line-height="14.5pt" text-indent="-9.5mm" -->
800
808
  <xsl:if test="$level = 1">
801
809
  <!-- <xsl:attribute name="margin-left">-8.5mm</xsl:attribute> -->
802
810
  <xsl:attribute name="margin-top">18pt</xsl:attribute>
@@ -813,8 +821,9 @@
813
821
  </xsl:when>
814
822
 
815
823
  <xsl:otherwise>
816
- <fo:block font-size="{$font-size}" font-weight="bold" text-align="left" keep-with-next="always">
824
+ <fo:block font-size="{$font-size}" font-weight="bold" text-align="left" keep-with-next="always" role="H{$level}">
817
825
  <xsl:apply-templates/>
826
+ <xsl:apply-templates select="following-sibling::*[1][local-name() = 'variant-title'][@type = 'sub']" mode="subtitle"/>
818
827
  </fo:block>
819
828
  </xsl:otherwise>
820
829
  </xsl:choose>
@@ -1017,7 +1026,7 @@
1017
1026
  <!-- ============================ -->
1018
1027
 
1019
1028
  <xsl:template name="insertHeaderPreface">
1020
- <fo:static-content flow-name="header">
1029
+ <fo:static-content flow-name="header" role="artifact">
1021
1030
  <fo:block-container height="25.5mm" display-align="before" border-bottom="0.5pt solid black">
1022
1031
  <fo:block font-weight="bold" padding-top="20.5mm" text-align="center">
1023
1032
  <!-- <xsl:text>UN/CEFACT </xsl:text> -->
@@ -1028,7 +1037,7 @@
1028
1037
  </xsl:template>
1029
1038
 
1030
1039
  <xsl:template name="insertHeader">
1031
- <fo:static-content flow-name="header">
1040
+ <fo:static-content flow-name="header" role="artifact">
1032
1041
  <fo:block-container height="28.5mm" display-align="before" border-bottom="0.5pt solid black">
1033
1042
  <fo:block font-weight="bold" padding-top="20.5mm" text-align="center">
1034
1043
  <!-- <xsl:text>UN/CEFACT </xsl:text> -->
@@ -1039,7 +1048,7 @@
1039
1048
  </xsl:template>
1040
1049
 
1041
1050
  <xsl:template name="insertFooter">
1042
- <fo:static-content flow-name="footer">
1051
+ <fo:static-content flow-name="footer" role="artifact">
1043
1052
  <fo:block-container height="29mm" display-align="after">
1044
1053
  <fo:block font-size="9pt" font-weight="bold" text-align="center" padding-bottom="24mm"><fo:page-number/></fo:block>
1045
1054
  </fo:block-container>
@@ -1227,12 +1236,13 @@
1227
1236
  </xsl:attribute-set><xsl:attribute-set name="sourcecode-style">
1228
1237
  <xsl:attribute name="white-space">pre</xsl:attribute>
1229
1238
  <xsl:attribute name="wrap-option">wrap</xsl:attribute>
1239
+ <xsl:attribute name="role">Code</xsl:attribute>
1230
1240
 
1231
1241
 
1232
1242
 
1233
1243
 
1234
1244
 
1235
- <xsl:attribute name="font-family">Courier</xsl:attribute>
1245
+ <xsl:attribute name="font-family">Courier New</xsl:attribute>
1236
1246
  <xsl:attribute name="margin-top">6pt</xsl:attribute>
1237
1247
  <xsl:attribute name="margin-bottom">6pt</xsl:attribute>
1238
1248
 
@@ -1252,8 +1262,13 @@
1252
1262
 
1253
1263
  </xsl:attribute-set><xsl:attribute-set name="requirement-label-style">
1254
1264
 
1255
- </xsl:attribute-set><xsl:attribute-set name="requirement-subject-style">
1256
- </xsl:attribute-set><xsl:attribute-set name="requirement-inherit-style">
1265
+ </xsl:attribute-set><xsl:attribute-set name="subject-style">
1266
+ </xsl:attribute-set><xsl:attribute-set name="inherit-style">
1267
+ </xsl:attribute-set><xsl:attribute-set name="description-style">
1268
+ </xsl:attribute-set><xsl:attribute-set name="specification-style">
1269
+ </xsl:attribute-set><xsl:attribute-set name="measurement-target-style">
1270
+ </xsl:attribute-set><xsl:attribute-set name="verification-style">
1271
+ </xsl:attribute-set><xsl:attribute-set name="import-style">
1257
1272
  </xsl:attribute-set><xsl:attribute-set name="recommendation-style">
1258
1273
 
1259
1274
 
@@ -1321,6 +1336,7 @@
1321
1336
 
1322
1337
 
1323
1338
 
1339
+
1324
1340
  <xsl:attribute name="font-size">11pt</xsl:attribute>
1325
1341
  <xsl:attribute name="margin-top">12pt</xsl:attribute>
1326
1342
  <xsl:attribute name="margin-bottom">12pt</xsl:attribute>
@@ -1335,7 +1351,9 @@
1335
1351
 
1336
1352
 
1337
1353
 
1338
- </xsl:attribute-set><xsl:attribute-set name="table-name-style">
1354
+ </xsl:attribute-set><xsl:variable name="table-border_">
1355
+
1356
+ </xsl:variable><xsl:variable name="table-border" select="normalize-space($table-border_)"/><xsl:attribute-set name="table-name-style">
1339
1357
  <xsl:attribute name="keep-with-next">always</xsl:attribute>
1340
1358
 
1341
1359
 
@@ -1451,7 +1469,8 @@
1451
1469
 
1452
1470
 
1453
1471
 
1454
- </xsl:attribute-set><xsl:attribute-set name="quote-style">
1472
+ </xsl:attribute-set><xsl:attribute-set name="quote-style">
1473
+ <xsl:attribute name="role">BlockQuote</xsl:attribute>
1455
1474
 
1456
1475
 
1457
1476
 
@@ -1636,11 +1655,15 @@
1636
1655
  <fo:block>&#xA0;</fo:block>
1637
1656
  </xsl:if> -->
1638
1657
 
1658
+
1659
+ <!-- Display table's name before table as standalone block -->
1639
1660
  <!-- $namespace = 'iso' or -->
1640
1661
 
1641
1662
  <xsl:apply-templates select="*[local-name()='name']" mode="presentation"/>
1642
1663
 
1643
-
1664
+
1665
+
1666
+
1644
1667
 
1645
1668
  <xsl:call-template name="fn_name_display"/>
1646
1669
 
@@ -1716,6 +1739,12 @@
1716
1739
 
1717
1740
 
1718
1741
 
1742
+
1743
+
1744
+
1745
+ <!-- display table's name before table for PAS inside block-container (2-columnn layout) -->
1746
+
1747
+
1719
1748
  <xsl:variable name="table_width">
1720
1749
  <!-- for centered table always 100% (@width will be set for middle/second cell of outer table) -->
1721
1750
 
@@ -1739,6 +1768,7 @@
1739
1768
 
1740
1769
 
1741
1770
 
1771
+
1742
1772
 
1743
1773
 
1744
1774
  <xsl:if test="ancestor::*[local-name()='sections']">
@@ -1767,6 +1797,8 @@
1767
1797
  <xsl:attribute name="border-bottom">0pt solid black</xsl:attribute> <!-- set 0pt border, because there is a separete table below for footer -->
1768
1798
  </xsl:if>
1769
1799
 
1800
+
1801
+
1770
1802
  <xsl:choose>
1771
1803
  <xsl:when test="*[local-name()='colgroup']/*[local-name()='col']">
1772
1804
  <xsl:for-each select="*[local-name()='colgroup']/*[local-name()='col']">
@@ -2051,9 +2083,9 @@
2051
2083
  <xsl:apply-templates select="ancestor::*[local-name()='table']/*[local-name()='name']" mode="presentation">
2052
2084
  <xsl:with-param name="continued">true</xsl:with-param>
2053
2085
  </xsl:apply-templates>
2054
- <xsl:for-each select="ancestor::*[local-name()='table'][1]">
2055
- <xsl:call-template name="fn_name_display"/>
2056
- </xsl:for-each>
2086
+
2087
+
2088
+
2057
2089
 
2058
2090
  </fo:table-cell>
2059
2091
  </fo:table-row>
@@ -2135,7 +2167,11 @@
2135
2167
 
2136
2168
  <xsl:variable name="isNoteOrFnExist" select="../*[local-name()='note'] or ..//*[local-name()='fn'][local-name(..) != 'name']"/>
2137
2169
 
2138
- <xsl:if test="$isNoteOrFnExist = 'true'">
2170
+ <xsl:variable name="isNoteOrFnExistShowAfterTable">
2171
+
2172
+ </xsl:variable>
2173
+
2174
+ <xsl:if test="$isNoteOrFnExist = 'true' or normalize-space($isNoteOrFnExistShowAfterTable) = 'true'">
2139
2175
 
2140
2176
  <xsl:variable name="cols-count">
2141
2177
  <xsl:choose>
@@ -2164,6 +2200,8 @@
2164
2200
  </xsl:choose>
2165
2201
  </xsl:for-each>
2166
2202
 
2203
+
2204
+
2167
2205
  <xsl:choose>
2168
2206
  <xsl:when test="xalan:nodeset($colgroup)//*[local-name()='col']">
2169
2207
  <xsl:for-each select="xalan:nodeset($colgroup)//*[local-name()='col']">
@@ -2200,6 +2238,7 @@
2200
2238
 
2201
2239
 
2202
2240
 
2241
+
2203
2242
  <!-- for BSI (not PAS) display Notes before footnotes -->
2204
2243
 
2205
2244
 
@@ -2273,6 +2312,19 @@
2273
2312
 
2274
2313
  </fo:table-body>
2275
2314
 
2315
+ </xsl:template><xsl:template match="*[local-name()='table']/*[local-name()='name']/text()[1]" priority="2" mode="presentation_name">
2316
+ <xsl:choose>
2317
+ <xsl:when test="substring-after(., '—') != ''">
2318
+ <xsl:text>—</xsl:text><xsl:value-of select="substring-after(., '—')"/>
2319
+ </xsl:when>
2320
+ <xsl:otherwise>
2321
+ <xsl:value-of select="."/>
2322
+ </xsl:otherwise>
2323
+ </xsl:choose>
2324
+ </xsl:template><xsl:template match="*[local-name()='table']/*[local-name()='name']" mode="presentation_name">
2325
+ <xsl:apply-templates mode="presentation_name"/>
2326
+ </xsl:template><xsl:template match="*[local-name()='table']/*[local-name()='name']/node()" mode="presentation_name">
2327
+ <xsl:apply-templates select="."/>
2276
2328
  </xsl:template><xsl:template match="*[local-name()='tr']">
2277
2329
  <xsl:variable name="parent-name" select="local-name(..)"/>
2278
2330
  <!-- <xsl:variable name="namespace" select="substring-before(name(/*), '-')"/> -->
@@ -2285,6 +2337,8 @@
2285
2337
 
2286
2338
 
2287
2339
 
2340
+
2341
+
2288
2342
  </xsl:if>
2289
2343
  <xsl:if test="$parent-name = 'tfoot'">
2290
2344
 
@@ -2299,6 +2353,8 @@
2299
2353
 
2300
2354
 
2301
2355
 
2356
+
2357
+
2302
2358
  <!-- <xsl:if test="$namespace = 'bipm'">
2303
2359
  <xsl:attribute name="height">8mm</xsl:attribute>
2304
2360
  </xsl:if> -->
@@ -2473,14 +2529,12 @@
2473
2529
  <xsl:apply-templates/>
2474
2530
  </xsl:template><xsl:template name="fn_display">
2475
2531
  <xsl:variable name="references">
2532
+
2476
2533
  <xsl:for-each select="..//*[local-name()='fn'][local-name(..) != 'name']">
2477
- <fn reference="{@reference}" id="{@reference}_{ancestor::*[@id][1]/@id}">
2478
-
2479
-
2480
- <xsl:apply-templates/>
2481
- </fn>
2534
+ <xsl:call-template name="create_fn"/>
2482
2535
  </xsl:for-each>
2483
2536
  </xsl:variable>
2537
+
2484
2538
  <xsl:for-each select="xalan:nodeset($references)//fn">
2485
2539
  <xsl:variable name="reference" select="@reference"/>
2486
2540
  <xsl:if test="not(preceding-sibling::*[@reference = $reference])"> <!-- only unique reference puts in note-->
@@ -2516,6 +2570,12 @@
2516
2570
  </fo:block>
2517
2571
  </xsl:if>
2518
2572
  </xsl:for-each>
2573
+ </xsl:template><xsl:template name="create_fn">
2574
+ <fn reference="{@reference}" id="{@reference}_{ancestor::*[@id][1]/@id}">
2575
+
2576
+
2577
+ <xsl:apply-templates/>
2578
+ </fn>
2519
2579
  </xsl:template><xsl:template name="fn_name_display">
2520
2580
  <!-- <xsl:variable name="references">
2521
2581
  <xsl:for-each select="*[local-name()='name']//*[local-name()='fn']">
@@ -3495,16 +3555,68 @@
3495
3555
  <xsl:with-param name="isDeleted" select="$isDeleted"/>
3496
3556
  </xsl:call-template>
3497
3557
 
3558
+
3559
+
3498
3560
  <xsl:variable name="mathml">
3499
3561
  <xsl:apply-templates select="." mode="mathml"/>
3500
3562
  </xsl:variable>
3501
3563
  <fo:instream-foreign-object fox:alt-text="Math">
3502
3564
 
3503
3565
 
3566
+ <xsl:variable name="comment_text_following" select="following-sibling::node()[1][self::comment()]"/>
3567
+ <xsl:variable name="comment_text_">
3568
+ <xsl:choose>
3569
+ <xsl:when test="normalize-space($comment_text_following) != ''">
3570
+ <xsl:value-of select="$comment_text_following"/>
3571
+ </xsl:when>
3572
+ <xsl:otherwise>
3573
+ <xsl:value-of select="normalize-space(translate(.,' ⁢',' '))"/>
3574
+ </xsl:otherwise>
3575
+ </xsl:choose>
3576
+ </xsl:variable>
3577
+ <xsl:variable name="comment_text" select="java:org.metanorma.fop.Util.unescape($comment_text_)"/>
3578
+
3579
+ <xsl:if test="normalize-space($comment_text) != ''">
3580
+ <!-- put Mathin Alternate Text -->
3581
+ <xsl:attribute name="fox:alt-text">
3582
+ <xsl:value-of select="java:org.metanorma.fop.Util.unescape($comment_text)"/>
3583
+ </xsl:attribute>
3584
+ </xsl:if>
3585
+
3586
+ <xsl:variable name="mathml_content">
3587
+ <xsl:apply-templates select="." mode="mathml_actual_text"/>
3588
+ </xsl:variable>
3589
+ <!-- put MathML in Actual Text -->
3590
+ <xsl:attribute name="fox:actual-text">
3591
+ <xsl:value-of select="$mathml_content"/>
3592
+ </xsl:attribute>
3593
+
3594
+
3504
3595
  <!-- <xsl:copy-of select="."/> -->
3505
3596
  <xsl:copy-of select="xalan:nodeset($mathml)"/>
3506
3597
  </fo:instream-foreign-object>
3507
3598
  </fo:inline>
3599
+ </xsl:template><xsl:template match="mathml:*" mode="mathml_actual_text">
3600
+ <!-- <xsl:text>a+b</xsl:text> -->
3601
+ <xsl:text>&lt;</xsl:text>
3602
+ <xsl:value-of select="local-name()"/>
3603
+ <xsl:if test="local-name() = 'math'">
3604
+ <xsl:text> xmlns="http://www.w3.org/1998/Math/MathML"</xsl:text>
3605
+ </xsl:if>
3606
+ <xsl:for-each select="@*">
3607
+ <xsl:text> </xsl:text>
3608
+ <xsl:value-of select="local-name()"/>
3609
+ <xsl:text>="</xsl:text>
3610
+ <xsl:value-of select="."/>
3611
+ <xsl:text>"</xsl:text>
3612
+ </xsl:for-each>
3613
+ <xsl:text>&gt;</xsl:text>
3614
+ <xsl:apply-templates mode="mathml_actual_text"/>
3615
+ <xsl:text>&lt;/</xsl:text>
3616
+ <xsl:value-of select="local-name()"/>
3617
+ <xsl:text>&gt;</xsl:text>
3618
+ </xsl:template><xsl:template match="text()" mode="mathml_actual_text">
3619
+ <xsl:value-of select="normalize-space()"/>
3508
3620
  </xsl:template><xsl:template match="@*|node()" mode="mathml">
3509
3621
  <xsl:copy>
3510
3622
  <xsl:apply-templates select="@*|node()" mode="mathml"/>
@@ -3514,19 +3626,6 @@
3514
3626
  <!-- replace start and end spaces to non-break space -->
3515
3627
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'(^ )|( $)',' ')"/>
3516
3628
  </xsl:copy>
3517
- </xsl:template><xsl:template match="mathml:mi[. = ',' and not(following-sibling::*[1][local-name() = 'mtext' and text() = ' '])]" mode="mathml">
3518
- <xsl:copy>
3519
- <xsl:apply-templates select="@*|node()" mode="mathml"/>
3520
- </xsl:copy>
3521
- <xsl:choose>
3522
- <!-- if in msub, then don't add space -->
3523
- <xsl:when test="ancestor::mathml:mrow[parent::mathml:msub and preceding-sibling::*[1][self::mathml:mrow]]"/>
3524
- <!-- if next char in digit, don't add space -->
3525
- <xsl:when test="translate(substring(following-sibling::*[1]/text(),1,1),'0123456789','') = ''"/>
3526
- <xsl:otherwise>
3527
- <mathml:mspace width="0.5ex"/>
3528
- </xsl:otherwise>
3529
- </xsl:choose>
3530
3629
  </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">
3531
3630
  <xsl:variable name="target">
3532
3631
  <xsl:choose>
@@ -3579,7 +3678,10 @@
3579
3678
  </fo:block>
3580
3679
  <xsl:apply-templates/>
3581
3680
  </xsl:template><xsl:template match="*[local-name()='appendix']/*[local-name()='title']"/><xsl:template match="*[local-name()='appendix']/*[local-name()='title']" mode="process">
3582
- <fo:inline><xsl:apply-templates/></fo:inline>
3681
+ <xsl:variable name="level">
3682
+ <xsl:call-template name="getLevel"/>
3683
+ </xsl:variable>
3684
+ <fo:inline role="H{$level}"><xsl:apply-templates/></fo:inline>
3583
3685
  </xsl:template><xsl:template match="*[local-name()='appendix']//*[local-name()='example']" priority="2">
3584
3686
  <fo:block id="{@id}" xsl:use-attribute-sets="appendix-example-style">
3585
3687
  <xsl:apply-templates select="*[local-name()='name']" mode="presentation"/>
@@ -3614,9 +3716,10 @@
3614
3716
 
3615
3717
  </xsl:variable>
3616
3718
 
3719
+ <xsl:variable name="text"><xsl:apply-templates/></xsl:variable>
3617
3720
  <xsl:choose>
3618
- <xsl:when test="$lang = 'zh'"><xsl:text>、</xsl:text><xsl:value-of select="$title-modified"/><xsl:text>—</xsl:text></xsl:when>
3619
- <xsl:otherwise><xsl:text>, </xsl:text><xsl:value-of select="$title-modified"/><xsl:text> — </xsl:text></xsl:otherwise>
3721
+ <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>
3722
+ <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>
3620
3723
  </xsl:choose>
3621
3724
  <xsl:apply-templates/>
3622
3725
  </xsl:template><xsl:template match="*[local-name() = 'xref']">
@@ -3777,7 +3880,10 @@
3777
3880
  </fo:block>
3778
3881
  </xsl:template><xsl:template match="*[local-name() = 'term']/*[local-name() = 'name']"/><xsl:template match="*[local-name() = 'term']/*[local-name() = 'name']" mode="presentation">
3779
3882
  <xsl:if test="normalize-space() != ''">
3780
- <fo:inline>
3883
+ <xsl:variable name="level">
3884
+ <xsl:call-template name="getLevelTermName"/>
3885
+ </xsl:variable>
3886
+ <fo:inline role="H{$level}">
3781
3887
  <xsl:apply-templates/>
3782
3888
  <!-- <xsl:if test="$namespace = 'gb' or $namespace = 'ogc'">
3783
3889
  <xsl:text>.</xsl:text>
@@ -3855,7 +3961,24 @@
3855
3961
  </fo:instream-foreign-object>
3856
3962
  </xsl:when>
3857
3963
  <xsl:otherwise>
3858
- <fo:external-graphic src="{$src}" fox:alt-text="Image {@alt}" xsl:use-attribute-sets="image-graphic-style"/>
3964
+ <fo:external-graphic src="{$src}" fox:alt-text="Image {@alt}" xsl:use-attribute-sets="image-graphic-style">
3965
+ <xsl:if test="not(@mimetype = 'image/svg+xml') and ../*[local-name() = 'name'] and not(ancestor::*[local-name() = 'table'])">
3966
+
3967
+ <xsl:variable name="img_src">
3968
+ <xsl:choose>
3969
+ <xsl:when test="not(starts-with(@src, 'data:'))"><xsl:value-of select="concat($basepath, @src)"/></xsl:when>
3970
+ <xsl:otherwise><xsl:value-of select="@src"/></xsl:otherwise>
3971
+ </xsl:choose>
3972
+ </xsl:variable>
3973
+
3974
+ <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $width_effective, $height_effective)"/>
3975
+ <xsl:if test="number($scale) &lt; 100">
3976
+ <xsl:attribute name="content-width"><xsl:value-of select="$scale"/>%</xsl:attribute>
3977
+ </xsl:if>
3978
+
3979
+ </xsl:if>
3980
+
3981
+ </fo:external-graphic>
3859
3982
  </xsl:otherwise>
3860
3983
  </xsl:choose>
3861
3984
 
@@ -4026,11 +4149,13 @@
4026
4149
  <xsl:attribute name="width">100%</xsl:attribute>
4027
4150
  <xsl:attribute name="content-height">100%</xsl:attribute>
4028
4151
  <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
4152
+ <xsl:variable name="svg_width" select="xalan:nodeset($svg_content)/*/@width"/>
4153
+ <xsl:variable name="svg_height" select="xalan:nodeset($svg_content)/*/@height"/>
4029
4154
  <!-- effective height 297 - 27.4 - 13 = 256.6 -->
4030
4155
  <!-- effective width 210 - 12.5 - 25 = 172.5 -->
4031
4156
  <!-- effective height / width = 1.48, 1.4 - with title -->
4032
- <xsl:if test="@height &gt; (@width * 1.4)"> <!-- for images with big height -->
4033
- <xsl:variable name="width" select="((@width * 1.4) div @height) * 100"/>
4157
+ <xsl:if test="$svg_height &gt; ($svg_width * 1.4)"> <!-- for images with big height -->
4158
+ <xsl:variable name="width" select="(($svg_width * 1.4) div $svg_height) * 100"/>
4034
4159
  <xsl:attribute name="width"><xsl:value-of select="$width"/>%</xsl:attribute>
4035
4160
  </xsl:if>
4036
4161
  <xsl:attribute name="scaling">uniform</xsl:attribute>
@@ -4047,6 +4172,23 @@
4047
4172
  <xsl:attribute name="href" namespace="http://www.w3.org/1999/xlink">
4048
4173
  <xsl:value-of select="."/>
4049
4174
  </xsl:attribute>
4175
+ </xsl:template><xsl:template match="*[local-name() = 'svg'][not(@width and @height)]" mode="svg_update">
4176
+ <xsl:copy>
4177
+ <xsl:apply-templates select="@*" mode="svg_update"/>
4178
+ <xsl:variable name="viewbox">
4179
+ <xsl:call-template name="split">
4180
+ <xsl:with-param name="pText" select="@viewBox"/>
4181
+ <xsl:with-param name="sep" select="' '"/>
4182
+ </xsl:call-template>
4183
+ </xsl:variable>
4184
+ <xsl:attribute name="width">
4185
+ <xsl:value-of select="round(xalan:nodeset($viewbox)//item[3])"/>
4186
+ </xsl:attribute>
4187
+ <xsl:attribute name="height">
4188
+ <xsl:value-of select="round(xalan:nodeset($viewbox)//item[4])"/>
4189
+ </xsl:attribute>
4190
+ <xsl:apply-templates mode="svg_update"/>
4191
+ </xsl:copy>
4050
4192
  </xsl:template><xsl:template match="*[local-name() = 'figure']/*[local-name() = 'image'][@mimetype = 'image/svg+xml' and @src[not(starts-with(., 'data:image/'))]]" priority="2">
4051
4193
  <xsl:variable name="svg_content" select="document(@src)"/>
4052
4194
  <xsl:variable name="name" select="ancestor::*[local-name() = 'figure']/*[local-name() = 'name']"/>
@@ -4377,6 +4519,7 @@
4377
4519
  </xsl:when>
4378
4520
  <xsl:otherwise>
4379
4521
  <xsl:apply-templates/>
4522
+ <xsl:apply-templates select="following-sibling::*[1][local-name() = 'variant-title'][@type = 'sub']" mode="subtitle"/>
4380
4523
  </xsl:otherwise>
4381
4524
  </xsl:choose>
4382
4525
  </fo:block>
@@ -4517,14 +4660,6 @@
4517
4660
  <fo:block>
4518
4661
  <fo:inline padding-right="3mm">Obligation</fo:inline><xsl:value-of select="."/>
4519
4662
  </fo:block>
4520
- </xsl:template><xsl:template match="*[local-name() = 'requirement']/*[local-name() = 'subject']"/><xsl:template match="*[local-name() = 'requirement']/*[local-name() = 'subject']" mode="presentation">
4521
- <fo:block xsl:use-attribute-sets="requirement-subject-style">
4522
- <xsl:text>Target Type </xsl:text><xsl:apply-templates/>
4523
- </fo:block>
4524
- </xsl:template><xsl:template match="*[local-name() = 'requirement']/*[local-name() = 'inherit']">
4525
- <fo:block xsl:use-attribute-sets="requirement-inherit-style">
4526
- <xsl:text>Dependency </xsl:text><xsl:apply-templates/>
4527
- </fo:block>
4528
4663
  </xsl:template><xsl:template match="*[local-name() = 'recommendation']">
4529
4664
  <fo:block id="{@id}" xsl:use-attribute-sets="recommendation-style">
4530
4665
  <xsl:apply-templates select="*[local-name()='name']" mode="presentation"/>
@@ -4541,6 +4676,38 @@
4541
4676
  <fo:block xsl:use-attribute-sets="recommendation-label-style">
4542
4677
  <xsl:apply-templates/>
4543
4678
  </fo:block>
4679
+ </xsl:template><xsl:template match="*[local-name() = 'requirement']/*[local-name() = 'subject']" priority="2"/><xsl:template match="*[local-name() = 'requirement']/*[local-name() = 'subject']" mode="presentation">
4680
+ <fo:block xsl:use-attribute-sets="subject-style">
4681
+ <xsl:text>Target Type </xsl:text><xsl:apply-templates/>
4682
+ </fo:block>
4683
+ </xsl:template><xsl:template match="*[local-name() = 'subject']">
4684
+ <fo:block xsl:use-attribute-sets="subject-style">
4685
+ <xsl:text>Target Type </xsl:text><xsl:apply-templates/>
4686
+ </fo:block>
4687
+ </xsl:template><xsl:template match="*[local-name() = 'inherit'] | *[local-name() = 'component'][@class = 'inherit']">
4688
+ <fo:block xsl:use-attribute-sets="inherit-style">
4689
+ <xsl:text>Dependency </xsl:text><xsl:apply-templates/>
4690
+ </fo:block>
4691
+ </xsl:template><xsl:template match="*[local-name() = 'description'] | *[local-name() = 'component'][@class = 'description']">
4692
+ <fo:block xsl:use-attribute-sets="description-style">
4693
+ <xsl:apply-templates/>
4694
+ </fo:block>
4695
+ </xsl:template><xsl:template match="*[local-name() = 'specification'] | *[local-name() = 'component'][@class = 'specification']">
4696
+ <fo:block xsl:use-attribute-sets="specification-style">
4697
+ <xsl:apply-templates/>
4698
+ </fo:block>
4699
+ </xsl:template><xsl:template match="*[local-name() = 'measurement-target'] | *[local-name() = 'component'][@class = 'measurement-target']">
4700
+ <fo:block xsl:use-attribute-sets="measurement-target-style">
4701
+ <xsl:apply-templates/>
4702
+ </fo:block>
4703
+ </xsl:template><xsl:template match="*[local-name() = 'verification'] | *[local-name() = 'component'][@class = 'verification']">
4704
+ <fo:block xsl:use-attribute-sets="verification-style">
4705
+ <xsl:apply-templates/>
4706
+ </fo:block>
4707
+ </xsl:template><xsl:template match="*[local-name() = 'import'] | *[local-name() = 'component'][@class = 'import']">
4708
+ <fo:block xsl:use-attribute-sets="import-style">
4709
+ <xsl:apply-templates/>
4710
+ </fo:block>
4544
4711
  </xsl:template><xsl:template match="*[local-name() = 'table'][@class = 'recommendation' or @class='requirement' or @class='permission']">
4545
4712
  <fo:block-container margin-left="0mm" margin-right="0mm" margin-bottom="12pt">
4546
4713
  <xsl:if test="ancestor::*[local-name() = 'table'][@class = 'recommendation' or @class='requirement' or @class='permission']">
@@ -4692,7 +4859,19 @@
4692
4859
  </fo:inline>
4693
4860
  </xsl:if>
4694
4861
  </xsl:template><xsl:template match="*[local-name() = 'termexample']/*[local-name() = 'p']">
4695
- <fo:inline><xsl:apply-templates/></fo:inline>
4862
+ <xsl:variable name="element">inline
4863
+
4864
+ </xsl:variable>
4865
+ <xsl:choose>
4866
+ <xsl:when test="contains($element, 'block')">
4867
+ <fo:block xsl:use-attribute-sets="example-p-style">
4868
+ <xsl:apply-templates/>
4869
+ </fo:block>
4870
+ </xsl:when>
4871
+ <xsl:otherwise>
4872
+ <fo:inline><xsl:apply-templates/></fo:inline>
4873
+ </xsl:otherwise>
4874
+ </xsl:choose>
4696
4875
  </xsl:template><xsl:template match="*[local-name() = 'example']">
4697
4876
  <fo:block id="{@id}" xsl:use-attribute-sets="example-style">
4698
4877
 
@@ -5233,6 +5412,7 @@
5233
5412
  </xsl:template><xsl:template match="*[local-name() = 'indexsect']//*[local-name() = 'li']" priority="4">
5234
5413
  <xsl:variable name="level" select="count(ancestor::*[local-name() = 'ul'])"/>
5235
5414
  <fo:block start-indent="{5 * $level}mm" text-indent="-5mm">
5415
+
5236
5416
  <xsl:apply-templates/>
5237
5417
  </fo:block>
5238
5418
  </xsl:template><xsl:template match="*[local-name() = 'bookmark']" name="bookmark">
@@ -5272,7 +5452,6 @@
5272
5452
  </xsl:template><xsl:template name="processBibitem">
5273
5453
 
5274
5454
 
5275
- <!-- end BIPM bibitem processing-->
5276
5455
 
5277
5456
 
5278
5457
 
@@ -5402,6 +5581,9 @@
5402
5581
  <fo:block-container border="1pt solid black" width="50%">
5403
5582
  <fo:block> </fo:block>
5404
5583
  </fo:block-container>
5584
+ </xsl:template><xsl:template match="*[local-name() = 'variant-title'][@type = 'sub']"/><xsl:template match="*[local-name() = 'variant-title'][@type = 'sub']" mode="subtitle">
5585
+ <fo:inline padding-right="5mm"> </fo:inline>
5586
+ <fo:inline><xsl:apply-templates/></fo:inline>
5405
5587
  </xsl:template><xsl:template name="convertDate">
5406
5588
  <xsl:param name="date"/>
5407
5589
  <xsl:param name="format" select="'short'"/>
@@ -5640,6 +5822,26 @@
5640
5822
  <xsl:value-of select="$level"/>
5641
5823
  </xsl:otherwise>
5642
5824
  </xsl:choose>
5825
+ </xsl:template><xsl:template name="getLevelTermName">
5826
+ <xsl:choose>
5827
+ <xsl:when test="normalize-space(../@depth) != ''">
5828
+ <xsl:value-of select="../@depth"/>
5829
+ </xsl:when>
5830
+ <xsl:otherwise>
5831
+ <xsl:variable name="title_level_">
5832
+ <xsl:for-each select="../preceding-sibling::*[local-name() = 'title'][1]">
5833
+ <xsl:call-template name="getLevel"/>
5834
+ </xsl:for-each>
5835
+ </xsl:variable>
5836
+ <xsl:variable name="title_level" select="normalize-space($title_level_)"/>
5837
+ <xsl:choose>
5838
+ <xsl:when test="$title_level != ''"><xsl:value-of select="$title_level + 1"/></xsl:when>
5839
+ <xsl:otherwise>
5840
+ <xsl:call-template name="getLevel"/>
5841
+ </xsl:otherwise>
5842
+ </xsl:choose>
5843
+ </xsl:otherwise>
5844
+ </xsl:choose>
5643
5845
  </xsl:template><xsl:template name="split">
5644
5846
  <xsl:param name="pText" select="."/>
5645
5847
  <xsl:param name="sep" select="','"/>
@@ -5737,20 +5939,40 @@
5737
5939
  </xsl:call-template>
5738
5940
  </xsl:if>
5739
5941
  </xsl:template><xsl:template name="getLocalizedString">
5740
- <xsl:param name="key"/>
5942
+ <xsl:param name="key"/>
5943
+ <xsl:param name="formatted">false</xsl:param>
5741
5944
 
5742
5945
  <xsl:variable name="curr_lang">
5743
5946
  <xsl:call-template name="getLang"/>
5744
5947
  </xsl:variable>
5745
5948
 
5746
- <xsl:variable name="data_value" select="normalize-space(xalan:nodeset($bibdata)//*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang])"/>
5949
+ <xsl:variable name="data_value">
5950
+ <xsl:choose>
5951
+ <xsl:when test="$formatted = 'true'">
5952
+ <xsl:apply-templates select="xalan:nodeset($bibdata)//*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang]"/>
5953
+ </xsl:when>
5954
+ <xsl:otherwise>
5955
+ <xsl:value-of select="normalize-space(xalan:nodeset($bibdata)//*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang])"/>
5956
+ </xsl:otherwise>
5957
+ </xsl:choose>
5958
+ </xsl:variable>
5747
5959
 
5748
5960
  <xsl:choose>
5749
- <xsl:when test="$data_value != ''">
5750
- <xsl:value-of select="$data_value"/>
5961
+ <xsl:when test="normalize-space($data_value) != ''">
5962
+ <xsl:choose>
5963
+ <xsl:when test="$formatted = 'true'"><xsl:copy-of select="$data_value"/></xsl:when>
5964
+ <xsl:otherwise><xsl:value-of select="$data_value"/></xsl:otherwise>
5965
+ </xsl:choose>
5751
5966
  </xsl:when>
5752
5967
  <xsl:when test="/*/*[local-name() = 'localized-strings']/*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang]">
5753
- <xsl:value-of select="/*/*[local-name() = 'localized-strings']/*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang]"/>
5968
+ <xsl:choose>
5969
+ <xsl:when test="$formatted = 'true'">
5970
+ <xsl:apply-templates select="/*/*[local-name() = 'localized-strings']/*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang]"/>
5971
+ </xsl:when>
5972
+ <xsl:otherwise>
5973
+ <xsl:value-of select="/*/*[local-name() = 'localized-strings']/*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang]"/>
5974
+ </xsl:otherwise>
5975
+ </xsl:choose>
5754
5976
  </xsl:when>
5755
5977
  <xsl:otherwise>
5756
5978
  <xsl:variable name="key_">
@@ -5761,7 +5983,7 @@
5761
5983
  <xsl:value-of select="$key_"/>
5762
5984
  </xsl:otherwise>
5763
5985
  </xsl:choose>
5764
-
5986
+
5765
5987
  </xsl:template><xsl:template name="setTrackChangesStyles">
5766
5988
  <xsl:param name="isAdded"/>
5767
5989
  <xsl:param name="isDeleted"/>