metanorma-bipm 1.2.3 → 1.2.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -17,6 +17,8 @@
17
17
 
18
18
  <xsl:param name="add_math_as_attachment">true</xsl:param>
19
19
 
20
+ <xsl:key name="kfn" match="*[local-name() = 'fn'][not(ancestor::*[(local-name() = 'table' or local-name() = 'figure') and not(ancestor::*[local-name() = 'name'])])]" use="@reference"/>
21
+
20
22
  <xsl:variable name="first_pass" select="count($index//item) = 0"/>
21
23
 
22
24
  <xsl:variable name="pageWidth" select="210"/>
@@ -2179,7 +2181,7 @@
2179
2181
 
2180
2182
  <xsl:variable name="display">
2181
2183
  <xsl:choose>
2182
- <xsl:when test="$level &gt;= 4">false</xsl:when>
2184
+ <xsl:when test="$level &gt; $toc_level">false</xsl:when>
2183
2185
  <xsl:otherwise>true</xsl:otherwise>
2184
2186
  </xsl:choose>
2185
2187
  </xsl:variable>
@@ -3089,35 +3091,6 @@
3089
3091
  </xsl:choose>
3090
3092
  </xsl:template>
3091
3093
 
3092
- <!--
3093
- <fn reference="1">
3094
- <p id="_8e5cf917-f75a-4a49-b0aa-1714cb6cf954">Formerly denoted as 15 % (m/m).</p>
3095
- </fn>
3096
- -->
3097
- <xsl:template match="bipm:title//bipm:fn | bipm:name//bipm:fn | bipm:p/bipm:fn[not(ancestor::bipm:table)] | bipm:p/*/bipm:fn[not(ancestor::bipm:table)] | bipm:sourcecode/bipm:fn[not(ancestor::bipm:table)]" priority="2" name="fn">
3098
- <fo:footnote keep-with-previous.within-line="always">
3099
- <xsl:variable name="number"> <!-- select="@reference"/> -->
3100
- <xsl:number count="bipm:fn[not(ancestor::bipm:table)]" level="any"/>
3101
- </xsl:variable>
3102
- <xsl:variable name="gen_id" select="generate-id()"/>
3103
- <xsl:variable name="lang" select="ancestor::bipm:bipm-standard/*[local-name()='bibdata']//*[local-name()='language'][@current = 'true']"/>
3104
- <fo:inline font-size="65%" keep-with-previous.within-line="always" vertical-align="super">
3105
- <fo:basic-link internal-destination="{$lang}_footnote_{@reference}_{$number}_{$gen_id}" fox:alt-text="footnote {@reference}">
3106
- <xsl:value-of select="$number"/><!-- + count(//bipm:bibitem/bipm:note) -->
3107
- </fo:basic-link>
3108
- </fo:inline>
3109
- <fo:footnote-body>
3110
- <fo:block font-size="9pt" margin-bottom="12pt" font-weight="normal" text-indent="0" start-indent="0" line-height="124%" text-align="justify">
3111
- <fo:inline id="{$lang}_footnote_{@reference}_{$number}_{$gen_id}" keep-with-next.within-line="always" font-size="60%" vertical-align="super" padding-right="1mm"> <!-- baseline-shift="30%" padding-right="3mm" font-size="60%" alignment-baseline="hanging" -->
3112
- <xsl:value-of select="$number "/><!-- + count(//bipm:bibitem/bipm:note) -->
3113
- </fo:inline>
3114
- <xsl:for-each select="bipm:p">
3115
- <xsl:apply-templates/>
3116
- </xsl:for-each>
3117
- </fo:block>
3118
- </fo:footnote-body>
3119
- </fo:footnote>
3120
- </xsl:template>
3121
3094
 
3122
3095
  <xsl:template match="bipm:fn/bipm:p">
3123
3096
  <fo:block>
@@ -5209,6 +5182,80 @@
5209
5182
 
5210
5183
  </xsl:attribute-set><xsl:attribute-set name="toc-style">
5211
5184
  <xsl:attribute name="line-height">135%</xsl:attribute>
5185
+ </xsl:attribute-set><xsl:attribute-set name="fn-style">
5186
+ <xsl:attribute name="keep-with-previous.within-line">always</xsl:attribute>
5187
+ </xsl:attribute-set><xsl:attribute-set name="fn-num-style">
5188
+ <xsl:attribute name="keep-with-previous.within-line">always</xsl:attribute>
5189
+
5190
+ <xsl:attribute name="font-size">65%</xsl:attribute>
5191
+ <xsl:attribute name="vertical-align">super</xsl:attribute>
5192
+
5193
+
5194
+
5195
+
5196
+
5197
+
5198
+
5199
+
5200
+
5201
+
5202
+
5203
+
5204
+
5205
+
5206
+
5207
+
5208
+ </xsl:attribute-set><xsl:attribute-set name="fn-body-style">
5209
+ <xsl:attribute name="font-weight">normal</xsl:attribute>
5210
+ <xsl:attribute name="font-style">normal</xsl:attribute>
5211
+ <xsl:attribute name="text-indent">0</xsl:attribute>
5212
+ <xsl:attribute name="start-indent">0</xsl:attribute>
5213
+
5214
+
5215
+ <xsl:attribute name="font-size">9pt</xsl:attribute>
5216
+ <xsl:attribute name="margin-bottom">12pt</xsl:attribute>
5217
+ <xsl:attribute name="line-height">124%</xsl:attribute>
5218
+ <xsl:attribute name="text-align">justify</xsl:attribute>
5219
+
5220
+
5221
+
5222
+
5223
+
5224
+
5225
+
5226
+
5227
+
5228
+
5229
+
5230
+
5231
+
5232
+
5233
+
5234
+
5235
+
5236
+ </xsl:attribute-set><xsl:attribute-set name="fn-body-num-style">
5237
+ <xsl:attribute name="keep-with-next.within-line">always</xsl:attribute>
5238
+
5239
+ <xsl:attribute name="font-size">60%</xsl:attribute>
5240
+ <xsl:attribute name="vertical-align">super</xsl:attribute>
5241
+ <xsl:attribute name="padding-right">1mm</xsl:attribute>
5242
+
5243
+
5244
+
5245
+
5246
+
5247
+
5248
+
5249
+
5250
+
5251
+
5252
+
5253
+
5254
+
5255
+
5256
+
5257
+
5258
+
5212
5259
  </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="OLD_processPrefaceSectionsDefault_Contents">
5213
5260
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='abstract']" mode="contents"/>
5214
5261
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='foreword']" mode="contents"/>
@@ -6247,6 +6294,102 @@
6247
6294
 
6248
6295
  </xsl:template><xsl:template match="*[local-name()='table']/*[local-name()='note']/*[local-name()='name']" mode="process"/><xsl:template match="*[local-name()='table']/*[local-name()='note']/*[local-name()='p']" mode="process">
6249
6296
  <xsl:apply-templates/>
6297
+ </xsl:template><xsl:template match="*[local-name() = 'fn'][not(ancestor::*[(local-name() = 'table' or local-name() = 'figure') and not(ancestor::*[local-name() = 'name'])])]" priority="2" name="fn">
6298
+
6299
+ <!-- list of footnotes to calculate actual footnotes number -->
6300
+ <xsl:variable name="p_fn_">
6301
+ <xsl:choose>
6302
+ <xsl:when test="@current_fn_number"> <!-- for BSI, footnote reference number calculated already -->
6303
+ <fn gen_id="{generate-id(.)}">
6304
+ <xsl:copy-of select="@*"/>
6305
+ <xsl:copy-of select="node()"/>
6306
+ </fn>
6307
+ </xsl:when>
6308
+ <xsl:otherwise>
6309
+ <!-- itetation for:
6310
+ footnotes in bibdata/title
6311
+ footnotes in bibliography
6312
+ footnotes in document's body (except table's head/body/foot and figure text)
6313
+ -->
6314
+ <xsl:for-each select="ancestor::*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']/*[local-name() = 'note'][@type='title-footnote']">
6315
+ <fn gen_id="{generate-id(.)}">
6316
+ <xsl:copy-of select="@*"/>
6317
+ <xsl:copy-of select="node()"/>
6318
+ </fn>
6319
+ </xsl:for-each>
6320
+ <xsl:for-each select="ancestor::*[contains(local-name(), '-standard')]/*[local-name()='preface']/* | ancestor::*[contains(local-name(), '-standard')]/*[local-name()='sections']/* | ancestor::*[contains(local-name(), '-standard')]/*[local-name()='annex'] | ancestor::*[contains(local-name(), '-standard')]/*[local-name()='bibliography']/*">
6321
+ <xsl:sort select="@displayorder" data-type="number"/>
6322
+ <xsl:for-each select=".//*[local-name() = 'bibitem'][ancestor::*[local-name() = 'references']]/*[local-name() = 'note'] | .//*[local-name() = 'fn'][not(ancestor::*[(local-name() = 'table' or local-name() = 'figure') and not(ancestor::*[local-name() = 'name'])])][generate-id(.)=generate-id(key('kfn',@reference)[1])]">
6323
+ <!-- copy unique fn -->
6324
+ <fn gen_id="{generate-id(.)}">
6325
+ <xsl:copy-of select="@*"/>
6326
+ <xsl:copy-of select="node()"/>
6327
+ </fn>
6328
+ </xsl:for-each>
6329
+ </xsl:for-each>
6330
+ </xsl:otherwise>
6331
+ </xsl:choose>
6332
+ </xsl:variable>
6333
+ <xsl:variable name="p_fn" select="xalan:nodeset($p_fn_)"/>
6334
+
6335
+ <xsl:variable name="gen_id" select="generate-id(.)"/>
6336
+ <xsl:variable name="lang" select="ancestor::*[contains(local-name(), '-standard')]/*[local-name()='bibdata']//*[local-name()='language'][@current = 'true']"/>
6337
+ <xsl:variable name="reference" select="@reference"/>
6338
+ <!-- fn sequence number in document -->
6339
+ <xsl:variable name="current_fn_number">
6340
+ <xsl:choose>
6341
+ <xsl:when test="@current_fn_number"><xsl:value-of select="@current_fn_number"/></xsl:when> <!-- for BSI -->
6342
+ <xsl:otherwise>
6343
+ <xsl:value-of select="count($p_fn//fn[@reference = $reference]/preceding-sibling::fn) + 1"/>
6344
+ </xsl:otherwise>
6345
+ </xsl:choose>
6346
+ </xsl:variable>
6347
+ <xsl:variable name="current_fn_number_text">
6348
+ <xsl:value-of select="$current_fn_number"/>
6349
+
6350
+
6351
+ </xsl:variable>
6352
+
6353
+ <xsl:variable name="ref_id" select="concat('footnote_', $lang, '_', $reference, '_', $current_fn_number)"/>
6354
+ <xsl:variable name="footnote_inline">
6355
+ <fo:inline xsl:use-attribute-sets="fn-num-style">
6356
+
6357
+ <fo:basic-link internal-destination="{$ref_id}" fox:alt-text="footnote {$current_fn_number}">
6358
+ <xsl:value-of select="$current_fn_number_text"/>
6359
+ </fo:basic-link>
6360
+ </fo:inline>
6361
+ </xsl:variable>
6362
+ <!-- DEBUG: p_fn=<xsl:copy-of select="$p_fn"/>
6363
+ gen_id=<xsl:value-of select="$gen_id"/> -->
6364
+ <xsl:choose>
6365
+ <xsl:when test="normalize-space(@skip_footnote_body) = 'true'">
6366
+ <xsl:copy-of select="$footnote_inline"/>
6367
+ </xsl:when>
6368
+ <xsl:when test="$p_fn//fn[@gen_id = $gen_id] or normalize-space(@skip_footnote_body) = 'false'">
6369
+ <fo:footnote xsl:use-attribute-sets="fn-style">
6370
+ <xsl:copy-of select="$footnote_inline"/>
6371
+ <fo:footnote-body>
6372
+
6373
+ <fo:block-container text-indent="0" start-indent="0">
6374
+
6375
+
6376
+ <fo:block xsl:use-attribute-sets="fn-body-style">
6377
+
6378
+
6379
+ <fo:inline id="{$ref_id}" xsl:use-attribute-sets="fn-body-num-style">
6380
+
6381
+ <xsl:value-of select="$current_fn_number_text"/>
6382
+ </fo:inline>
6383
+ <xsl:apply-templates/>
6384
+ </fo:block>
6385
+ </fo:block-container>
6386
+ </fo:footnote-body>
6387
+ </fo:footnote>
6388
+ </xsl:when>
6389
+ <xsl:otherwise>
6390
+ <xsl:copy-of select="$footnote_inline"/>
6391
+ </xsl:otherwise>
6392
+ </xsl:choose>
6250
6393
  </xsl:template><xsl:template name="fn_display">
6251
6394
  <xsl:variable name="references">
6252
6395
 
@@ -6457,6 +6600,8 @@
6457
6600
 
6458
6601
  </fo:basic-link>
6459
6602
  </fo:inline>
6603
+ </xsl:template><xsl:template match="*[local-name()='fn']/text()[normalize-space() != '']">
6604
+ <fo:inline><xsl:value-of select="."/></fo:inline>
6460
6605
  </xsl:template><xsl:template match="*[local-name()='fn']/*[local-name()='p']">
6461
6606
  <fo:inline>
6462
6607
  <xsl:apply-templates/>
@@ -7482,22 +7627,6 @@
7482
7627
  <xsl:if test="not(preceding-sibling::*[local-name() = 'p'])"><xsl:value-of select="$callout"/></xsl:if>
7483
7628
  <xsl:apply-templates/>
7484
7629
  </fo:inline>
7485
- </xsl:template><xsl:template match="*[local-name() = 'modification']">
7486
- <xsl:variable name="title-modified">
7487
-
7488
-
7489
- <xsl:call-template name="getTitle">
7490
- <xsl:with-param name="name" select="'title-modified'"/>
7491
- </xsl:call-template>
7492
-
7493
- </xsl:variable>
7494
-
7495
- <xsl:variable name="text"><xsl:apply-templates/></xsl:variable>
7496
- <xsl:choose>
7497
- <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>
7498
- <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>
7499
- </xsl:choose>
7500
- <xsl:apply-templates/>
7501
7630
  </xsl:template><xsl:template match="*[local-name() = 'xref']">
7502
7631
  <fo:basic-link internal-destination="{@target}" fox:alt-text="{@target}" xsl:use-attribute-sets="xref-style">
7503
7632
 
@@ -8763,60 +8892,69 @@
8763
8892
  <xsl:variable name="termsource_text">
8764
8893
  <xsl:apply-templates/>
8765
8894
  </xsl:variable>
8766
-
8767
- <xsl:choose>
8895
+ <xsl:copy-of select="$termsource_text"/>
8896
+ <!-- <xsl:choose>
8768
8897
  <xsl:when test="starts-with(normalize-space($termsource_text), '[')">
8769
- <!-- <xsl:apply-templates /> -->
8770
8898
  <xsl:copy-of select="$termsource_text"/>
8771
8899
  </xsl:when>
8772
8900
  <xsl:otherwise>
8773
-
8774
-
8901
+ <xsl:if test="$namespace = 'bsi'">
8902
+ <xsl:choose>
8903
+ <xsl:when test="$document_type = 'PAS' and starts-with(*[local-name() = 'origin']/@citeas, '[')"><xsl:text>{</xsl:text></xsl:when>
8904
+ <xsl:otherwise><xsl:text>[</xsl:text></xsl:otherwise>
8905
+ </xsl:choose>
8906
+ </xsl:if>
8907
+ <xsl:if test="$namespace = 'gb' or $namespace = 'iso' or $namespace = 'iec' or $namespace = 'itu' or $namespace = 'unece' or $namespace = 'unece-rec' or $namespace = 'nist-cswp' or $namespace = 'nist-sp' or $namespace = 'ogc-white-paper' or $namespace = 'csa' or $namespace = 'csd' or $namespace = 'm3d' or $namespace = 'iho' or $namespace = 'bipm' or $namespace = 'jcgm'">
8775
8908
  <xsl:text>[</xsl:text>
8776
-
8777
- <!-- <xsl:apply-templates /> -->
8909
+ </xsl:if>
8778
8910
  <xsl:copy-of select="$termsource_text"/>
8779
-
8780
-
8911
+ <xsl:if test="$namespace = 'bsi'">
8912
+ <xsl:choose>
8913
+ <xsl:when test="$document_type = 'PAS' and starts-with(*[local-name() = 'origin']/@citeas, '[')"><xsl:text>}</xsl:text></xsl:when>
8914
+ <xsl:otherwise><xsl:text>]</xsl:text></xsl:otherwise>
8915
+ </xsl:choose>
8916
+ </xsl:if>
8917
+ <xsl:if test="$namespace = 'gb' or $namespace = 'iso' or $namespace = 'iec' or $namespace = 'itu' or $namespace = 'unece' or $namespace = 'unece-rec' or $namespace = 'nist-cswp' or $namespace = 'nist-sp' or $namespace = 'ogc-white-paper' or $namespace = 'csa' or $namespace = 'csd' or $namespace = 'm3d' or $namespace = 'iho' or $namespace = 'bipm' or $namespace = 'jcgm'">
8781
8918
  <xsl:text>]</xsl:text>
8782
-
8919
+ </xsl:if>
8783
8920
  </xsl:otherwise>
8784
- </xsl:choose>
8921
+ </xsl:choose> -->
8785
8922
  </fo:block>
8786
8923
  </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()">
8787
8924
  <xsl:if test="normalize-space() != ''">
8788
8925
  <xsl:value-of select="."/>
8789
8926
  </xsl:if>
8790
- </xsl:template><xsl:variable name="localized.source">
8791
- <xsl:call-template name="getLocalizedString">
8792
- <xsl:with-param name="key">source</xsl:with-param>
8793
- </xsl:call-template>
8794
- </xsl:variable><xsl:template match="*[local-name() = 'origin']">
8927
+ </xsl:template><xsl:template match="*[local-name() = 'termsource']/*[local-name() = 'strong'][1][following-sibling::*[1][local-name() = 'origin']]/text()">
8928
+ <fo:inline>
8929
+
8930
+
8931
+ <xsl:value-of select="."/>
8932
+ </fo:inline>
8933
+ </xsl:template><xsl:template match="*[local-name() = 'origin']">
8795
8934
  <fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}">
8796
8935
  <xsl:if test="normalize-space(@citeas) = ''">
8797
8936
  <xsl:attribute name="fox:alt-text"><xsl:value-of select="@bibitemid"/></xsl:attribute>
8798
8937
  </xsl:if>
8799
-
8800
-
8801
- <fo:inline>
8802
-
8803
-
8804
-
8805
-
8806
-
8807
-
8808
- <xsl:value-of select="$localized.source"/>
8809
- <xsl:text> </xsl:text>
8810
-
8811
-
8812
-
8813
- </fo:inline>
8814
-
8815
8938
  <fo:inline xsl:use-attribute-sets="origin-style">
8816
8939
  <xsl:apply-templates/>
8817
8940
  </fo:inline>
8941
+ </fo:basic-link>
8942
+ </xsl:template><xsl:template match="*[local-name() = 'modification']">
8943
+ <xsl:variable name="title-modified">
8818
8944
 
8819
- </fo:basic-link>
8945
+
8946
+ <xsl:call-template name="getTitle">
8947
+ <xsl:with-param name="name" select="'title-modified'"/>
8948
+ </xsl:call-template>
8949
+
8950
+ </xsl:variable>
8951
+
8952
+ <xsl:variable name="text"><xsl:apply-templates/></xsl:variable>
8953
+ <xsl:choose>
8954
+ <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>
8955
+ <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>
8956
+ </xsl:choose>
8957
+ <xsl:apply-templates/>
8820
8958
  </xsl:template><xsl:template match="*[local-name() = 'modification']/*[local-name() = 'p']">
8821
8959
  <fo:inline><xsl:apply-templates/></fo:inline>
8822
8960
  </xsl:template><xsl:template match="*[local-name() = 'modification']/text()">
@@ -9456,7 +9594,31 @@
9456
9594
  <fo:block-container border="1pt solid black" width="50%">
9457
9595
  <fo:block> </fo:block>
9458
9596
  </fo:block-container>
9459
- </xsl:template><xsl:template match="*[local-name() = 'toc']">
9597
+ </xsl:template><xsl:variable name="toc_level">
9598
+ <xsl:choose>
9599
+ <xsl:when test="1 = 2"/> <!-- to do https://github.com/metanorma/mn-native-pdf/issues/337: if there is value in xml -->
9600
+ <xsl:otherwise><!-- default value -->
9601
+ 3
9602
+
9603
+
9604
+
9605
+
9606
+
9607
+
9608
+
9609
+
9610
+
9611
+
9612
+
9613
+
9614
+
9615
+
9616
+
9617
+
9618
+
9619
+ </xsl:otherwise>
9620
+ </xsl:choose>
9621
+ </xsl:variable><xsl:template match="*[local-name() = 'toc']">
9460
9622
  <xsl:param name="colwidths"/>
9461
9623
  <xsl:variable name="colwidths_">
9462
9624
  <xsl:choose>
@@ -10096,4 +10258,14 @@
10096
10258
  </xsl:otherwise>
10097
10259
  </xsl:choose>
10098
10260
  </xsl:if>
10261
+ </xsl:template><xsl:template name="setAltText">
10262
+ <xsl:param name="value"/>
10263
+ <xsl:attribute name="fox:alt-text">
10264
+ <xsl:choose>
10265
+ <xsl:when test="normalize-space($value) != ''">
10266
+ <xsl:value-of select="$value"/>
10267
+ </xsl:when>
10268
+ <xsl:otherwise>_</xsl:otherwise>
10269
+ </xsl:choose>
10270
+ </xsl:attribute>
10099
10271
  </xsl:template></xsl:stylesheet>