metanorma-bipm 2.4.0 → 2.4.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1737,6 +1737,8 @@
1737
1737
  <xsl:param name="svg_images"/> <!-- svg images array -->
1738
1738
  <xsl:variable name="images" select="document($svg_images)"/>
1739
1739
  <xsl:param name="basepath"/> <!-- base path for images -->
1740
+ <xsl:param name="inputxml_basepath"/> <!-- input xml file path -->
1741
+ <xsl:param name="inputxml_filename"/> <!-- input xml file name -->
1740
1742
  <xsl:param name="external_index"/><!-- path to index xml, generated on 1st pass, based on FOP Intermediate Format -->
1741
1743
  <xsl:param name="syntax-highlight">false</xsl:param> <!-- syntax highlighting feature, default - off -->
1742
1744
  <xsl:param name="add_math_as_text">true</xsl:param> <!-- add math in text behind svg formula, to copy-paste formula from PDF as text -->
@@ -1789,6 +1791,20 @@
1789
1791
  <xsl:call-template name="getLang"/>
1790
1792
  </xsl:variable>
1791
1793
 
1794
+ <xsl:variable name="inputxml_filename_prefix">
1795
+ <xsl:choose>
1796
+ <xsl:when test="contains($inputxml_filename, '.presentation.xml')">
1797
+ <xsl:value-of select="substring-before($inputxml_filename, '.presentation.xml')"/>
1798
+ </xsl:when>
1799
+ <xsl:when test="contains($inputxml_filename, '.xml')">
1800
+ <xsl:value-of select="substring-before($inputxml_filename, '.xml')"/>
1801
+ </xsl:when>
1802
+ <xsl:otherwise>
1803
+ <xsl:value-of select="$inputxml_filename"/>
1804
+ </xsl:otherwise>
1805
+ </xsl:choose>
1806
+ </xsl:variable>
1807
+
1792
1808
  <!-- Note 1: Each xslt has declated variable `namespace` that allows to set some properties, processing logic, etc. for concrete xslt.
1793
1809
  You can put such conditions by using xslt construction `xsl:if test="..."` or <xsl:choose><xsl:when test=""></xsl:when><xsl:otherwiste></xsl:otherwiste></xsl:choose>,
1794
1810
  BUT DON'T put any another conditions together with $namespace = '...' (such conditions will be ignored). For another conditions, please use nested xsl:if or xsl:choose -->
@@ -2246,6 +2262,10 @@
2246
2262
 
2247
2263
  </xsl:attribute-set>
2248
2264
 
2265
+ <xsl:template name="refine_termexample-style">
2266
+
2267
+ </xsl:template>
2268
+
2249
2269
  <xsl:attribute-set name="example-style">
2250
2270
 
2251
2271
  <xsl:attribute name="font-size">10pt</xsl:attribute>
@@ -2735,6 +2755,10 @@
2735
2755
 
2736
2756
  </xsl:attribute-set>
2737
2757
 
2758
+ <xsl:template name="refine_figure-block-style">
2759
+
2760
+ </xsl:template>
2761
+
2738
2762
  <xsl:attribute-set name="figure-style">
2739
2763
 
2740
2764
  </xsl:attribute-set>
@@ -3397,6 +3421,36 @@
3397
3421
  </xsl:for-each>
3398
3422
  </xsl:template>
3399
3423
 
3424
+ <xsl:template name="processMainSectionsDefault_flatxml">
3425
+ <xsl:for-each select="/*/*[local-name()='sections']/* | /*/*[local-name()='bibliography']/*[local-name()='references'][@normative='true']">
3426
+ <xsl:sort select="@displayorder" data-type="number"/>
3427
+ <xsl:variable name="flatxml">
3428
+ <xsl:apply-templates select="." mode="flatxml"/>
3429
+ </xsl:variable>
3430
+ <!-- debug_flatxml='<xsl:copy-of select="$flatxml"/>' -->
3431
+ <xsl:apply-templates select="xalan:nodeset($flatxml)/*"/>
3432
+
3433
+ </xsl:for-each>
3434
+
3435
+ <xsl:for-each select="/*/*[local-name()='annex']">
3436
+ <xsl:sort select="@displayorder" data-type="number"/>
3437
+ <xsl:variable name="flatxml">
3438
+ <xsl:apply-templates select="." mode="flatxml"/>
3439
+ </xsl:variable>
3440
+ <!-- debug_flatxml='<xsl:copy-of select="$flatxml"/>' -->
3441
+ <xsl:apply-templates select="xalan:nodeset($flatxml)/*"/>
3442
+ </xsl:for-each>
3443
+
3444
+ <xsl:for-each select="/*/*[local-name()='bibliography']/*[not(@normative='true')] | /*/*[local-name()='bibliography']/*[local-name()='clause'][*[local-name()='references'][not(@normative='true')]]">
3445
+ <xsl:sort select="@displayorder" data-type="number"/>
3446
+ <xsl:variable name="flatxml">
3447
+ <xsl:apply-templates select="." mode="flatxml"/>
3448
+ </xsl:variable>
3449
+ <!-- debug_flatxml='<xsl:copy-of select="$flatxml"/>' -->
3450
+ <xsl:apply-templates select="xalan:nodeset($flatxml)/*"/>
3451
+ </xsl:for-each>
3452
+ </xsl:template>
3453
+
3400
3454
  <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
3401
3455
  <xsl:variable name="tag_fo_inline_keep-together_within-line_open">###fo:inline keep-together_within-line###</xsl:variable>
3402
3456
  <xsl:variable name="tag_fo_inline_keep-together_within-line_close">###/fo:inline keep-together_within-line###</xsl:variable>
@@ -3523,7 +3577,9 @@
3523
3577
  </xsl:template> <!-- license-statement/p -->
3524
3578
 
3525
3579
  <xsl:template match="*[local-name()='legal-statement']">
3580
+ <xsl:param name="isLegacy">false</xsl:param>
3526
3581
  <fo:block xsl:use-attribute-sets="legal-statement-style">
3582
+
3527
3583
  <xsl:apply-templates/>
3528
3584
  </fo:block>
3529
3585
  </xsl:template> <!-- legal-statement -->
@@ -3618,7 +3674,7 @@
3618
3674
  <xsl:variable name="cols-count" select="count(xalan:nodeset($simple-table)/*/tr[1]/td)"/>
3619
3675
 
3620
3676
  <xsl:variable name="colwidths">
3621
- <xsl:if test="not(*[local-name()='colgroup']/*[local-name()='col'])">
3677
+ <xsl:if test="not(*[local-name()='colgroup']/*[local-name()='col']) and not(@class = 'dl')">
3622
3678
  <xsl:call-template name="calculate-column-widths">
3623
3679
  <xsl:with-param name="cols-count" select="$cols-count"/>
3624
3680
  <xsl:with-param name="table" select="$simple-table"/>
@@ -3730,6 +3786,11 @@
3730
3786
  <fo:table-column column-width="{@width}"/>
3731
3787
  </xsl:for-each>
3732
3788
  </xsl:when>
3789
+ <xsl:when test="@class = 'dl'">
3790
+ <xsl:for-each select=".//*[local-name()='tr'][1]/*">
3791
+ <fo:table-column column-width="{@width}"/>
3792
+ </xsl:for-each>
3793
+ </xsl:when>
3733
3794
  <xsl:otherwise>
3734
3795
  <xsl:call-template name="insertTableColumnWidth">
3735
3796
  <xsl:with-param name="colwidths" select="$colwidths"/>
@@ -5061,6 +5122,7 @@
5061
5122
  <!-- ===================== -->
5062
5123
  <!-- Definition List -->
5063
5124
  <!-- ===================== -->
5125
+
5064
5126
  <xsl:template match="*[local-name()='dl']">
5065
5127
  <xsl:variable name="isAdded" select="@added"/>
5066
5128
  <xsl:variable name="isDeleted" select="@deleted"/>
@@ -5277,10 +5339,21 @@
5277
5339
  </xsl:variable>
5278
5340
 
5279
5341
  <xsl:variable name="colwidths">
5280
- <xsl:call-template name="calculate-column-widths">
5281
- <xsl:with-param name="cols-count" select="2"/>
5282
- <xsl:with-param name="table" select="$simple-table"/>
5283
- </xsl:call-template>
5342
+ <xsl:choose>
5343
+ <!-- dl from table[@class='dl'] -->
5344
+ <xsl:when test="*[local-name() = 'colgroup']">
5345
+ <autolayout/>
5346
+ <xsl:for-each select="*[local-name() = 'colgroup']/*[local-name() = 'col']">
5347
+ <column><xsl:value-of select="translate(@width,'%m','')"/></column>
5348
+ </xsl:for-each>
5349
+ </xsl:when>
5350
+ <xsl:otherwise>
5351
+ <xsl:call-template name="calculate-column-widths">
5352
+ <xsl:with-param name="cols-count" select="2"/>
5353
+ <xsl:with-param name="table" select="$simple-table"/>
5354
+ </xsl:call-template>
5355
+ </xsl:otherwise>
5356
+ </xsl:choose>
5284
5357
  </xsl:variable>
5285
5358
 
5286
5359
  <!-- <xsl:text disable-output-escaping="yes">&lt;!- -</xsl:text>
@@ -5536,13 +5609,13 @@
5536
5609
  <tr>
5537
5610
  <td>
5538
5611
  <xsl:attribute name="id">
5539
- <xsl:value-of select="concat($id,'_',$row_number,'_1')"/>
5612
+ <xsl:value-of select="concat($id,'@',$row_number,'_1')"/>
5540
5613
  </xsl:attribute>
5541
5614
  <xsl:apply-templates/>
5542
5615
  </td>
5543
5616
  <td>
5544
5617
  <xsl:attribute name="id">
5545
- <xsl:value-of select="concat($id,'_',$row_number,'_2')"/>
5618
+ <xsl:value-of select="concat($id,'@',$row_number,'_2')"/>
5546
5619
  </xsl:attribute>
5547
5620
 
5548
5621
  <xsl:apply-templates select="following-sibling::*[local-name()='dd'][1]">
@@ -5854,13 +5927,14 @@
5854
5927
  <!-- ================= -->
5855
5928
  <!-- Added,deleted text -->
5856
5929
  <!-- ================= -->
5857
- <xsl:template match="*[local-name()='add']" name="tag_add">
5930
+ <xsl:template match="*[local-name()='add'] | *[local-name() = 'change-open-tag'] | *[local-name() = 'change-close-tag']" name="tag_add">
5858
5931
  <xsl:param name="skip">true</xsl:param>
5859
5932
  <xsl:param name="block">false</xsl:param>
5860
5933
  <xsl:param name="type"/>
5861
5934
  <xsl:param name="text-align"/>
5862
5935
  <xsl:choose>
5863
- <xsl:when test="starts-with(., $ace_tag)"> <!-- examples: ace-tag_A1_start, ace-tag_A2_end, C1_start, AC_start -->
5936
+ <xsl:when test="starts-with(., $ace_tag) or local-name() = 'change-open-tag' or local-name() = 'change-close-tag'"> <!-- examples: ace-tag_A1_start, ace-tag_A2_end, C1_start, AC_start, or
5937
+ <change-open-tag>A<sub>1</sub></change-open-tag>, <change-close-tag>A<sub>1</sub></change-close-tag> -->
5864
5938
  <xsl:choose>
5865
5939
  <xsl:when test="$skip = 'true' and ((local-name(../..) = 'note' and not(preceding-sibling::node())) or (local-name(..) = 'title' and preceding-sibling::node()[1][local-name() = 'tab']) or local-name(..) = 'formattedref' and not(preceding-sibling::node())) and ../node()[last()][local-name() = 'add'][starts-with(text(), $ace_tag)]"><!-- start tag displayed in template name="note" and title --></xsl:when>
5866
5940
  <xsl:otherwise>
@@ -5868,12 +5942,32 @@
5868
5942
  <xsl:call-template name="insertTag">
5869
5943
  <xsl:with-param name="type">
5870
5944
  <xsl:choose>
5945
+ <xsl:when test="local-name() = 'change-open-tag'">start</xsl:when>
5946
+ <xsl:when test="local-name() = 'change-close-tag'">end</xsl:when>
5871
5947
  <xsl:when test="$type = ''"><xsl:value-of select="substring-after(substring-after(., $ace_tag), '_')"/> <!-- start or end --></xsl:when>
5872
5948
  <xsl:otherwise><xsl:value-of select="$type"/></xsl:otherwise>
5873
5949
  </xsl:choose>
5874
5950
  </xsl:with-param>
5875
- <xsl:with-param name="kind" select="substring(substring-before(substring-after(., $ace_tag), '_'), 1, 1)"/> <!-- A or C -->
5876
- <xsl:with-param name="value" select="substring(substring-before(substring-after(., $ace_tag), '_'), 2)"/> <!-- 1, 2, C -->
5951
+ <xsl:with-param name="kind">
5952
+ <xsl:choose>
5953
+ <xsl:when test="local-name() = 'change-open-tag' or local-name() = 'change-close-tag'">
5954
+ <xsl:value-of select="text()"/>
5955
+ </xsl:when>
5956
+ <xsl:otherwise>
5957
+ <xsl:value-of select="substring(substring-before(substring-after(., $ace_tag), '_'), 1, 1)"/> <!-- A or C -->
5958
+ </xsl:otherwise>
5959
+ </xsl:choose>
5960
+ </xsl:with-param>
5961
+ <xsl:with-param name="value">
5962
+ <xsl:choose>
5963
+ <xsl:when test="local-name() = 'change-open-tag' or local-name() = 'change-close-tag'">
5964
+ <xsl:value-of select="*[local-name() = 'sub']"/>
5965
+ </xsl:when>
5966
+ <xsl:otherwise>
5967
+ <xsl:value-of select="substring(substring-before(substring-after(., $ace_tag), '_'), 2)"/> <!-- 1, 2, C -->
5968
+ </xsl:otherwise>
5969
+ </xsl:choose>
5970
+ </xsl:with-param>
5877
5971
  </xsl:call-template>
5878
5972
  </xsl:variable>
5879
5973
  <xsl:choose>
@@ -6133,6 +6227,10 @@
6133
6227
  <fo:inline keep-with-next.within-line="always"><xsl:value-of select="."/></fo:inline>
6134
6228
  </xsl:template>
6135
6229
 
6230
+ <xsl:template match="*[local-name() = 'span'][contains(@style, 'text-transform:none')]//text()" priority="5">
6231
+ <xsl:value-of select="."/>
6232
+ </xsl:template>
6233
+
6136
6234
  <!-- ========================= -->
6137
6235
  <!-- END Rich text formatting -->
6138
6236
  <!-- ========================= -->
@@ -6763,7 +6861,7 @@
6763
6861
  </xsl:choose>
6764
6862
  </xsl:variable>
6765
6863
  <xsl:attribute name="id">
6766
- <xsl:value-of select="concat($id,'_',$row_number,'_',$col_number,'_',$divide)"/>
6864
+ <xsl:value-of select="concat($id,'@',$row_number,'_',$col_number,'_',$divide)"/>
6767
6865
  </xsl:attribute>
6768
6866
 
6769
6867
  <xsl:for-each select="*[local-name() = 'p']">
@@ -6771,7 +6869,7 @@
6771
6869
  <xsl:copy-of select="@*"/>
6772
6870
  <xsl:variable name="p_num" select="count(preceding-sibling::*[local-name() = 'p']) + 1"/>
6773
6871
  <xsl:attribute name="id">
6774
- <xsl:value-of select="concat($id,'_',$row_number,'_',$col_number,'_p_',$p_num,'_',$divide)"/>
6872
+ <xsl:value-of select="concat($id,'@',$row_number,'_',$col_number,'_p_',$p_num,'_',$divide)"/>
6775
6873
  </xsl:attribute>
6776
6874
 
6777
6875
  <!-- <xsl:copy-of select="node()" /> -->
@@ -6835,7 +6933,7 @@
6835
6933
  <xsl:variable name="num" select="count(preceding-sibling::word) + 1"/>
6836
6934
  <xsl:copy>
6837
6935
  <xsl:attribute name="id">
6838
- <xsl:value-of select="concat($id,'_',$row_number,'_',$col_number,'_word_',$num,'_',$divide)"/>
6936
+ <xsl:value-of select="concat($id,'@',$row_number,'_',$col_number,'_word_',$num,'_',$divide)"/>
6839
6937
  </xsl:attribute>
6840
6938
  <xsl:copy-of select="node()"/>
6841
6939
  </xsl:copy>
@@ -7369,6 +7467,12 @@
7369
7467
  <xsl:when test="@updatetype = 'true'">
7370
7468
  <xsl:value-of select="concat(normalize-space(@target), '.pdf')"/>
7371
7469
  </xsl:when>
7470
+ <xsl:when test="contains(@target, concat('_', $inputxml_filename_prefix, '_attachments'))">
7471
+ <!-- link to the PDF attachment -->
7472
+ <xsl:variable name="target_" select="translate(@target, '\', '/')"/>
7473
+ <xsl:variable name="target__" select="substring-after($target_, concat('_', $inputxml_filename_prefix, '_attachments', '/'))"/>
7474
+ <xsl:value-of select="concat('url(embedded-file:', $target__, ')')"/>
7475
+ </xsl:when>
7372
7476
  <xsl:otherwise>
7373
7477
  <xsl:value-of select="normalize-space(@target)"/>
7374
7478
  </xsl:otherwise>
@@ -7776,6 +7880,7 @@
7776
7880
  <xsl:variable name="isAdded" select="@added"/>
7777
7881
  <xsl:variable name="isDeleted" select="@deleted"/>
7778
7882
  <fo:block-container id="{@id}" xsl:use-attribute-sets="figure-block-style">
7883
+ <xsl:call-template name="refine_figure-block-style"/>
7779
7884
 
7780
7885
  <xsl:call-template name="setTrackChangesStyles">
7781
7886
  <xsl:with-param name="isAdded" select="$isAdded"/>
@@ -8086,11 +8191,17 @@
8086
8191
  </xsl:when>
8087
8192
  <xsl:otherwise>
8088
8193
 
8194
+ <xsl:variable name="image_class" select="ancestor::*[local-name() = 'image']/@class"/>
8195
+ <xsl:variable name="ancestor_table_cell" select="normalize-space(ancestor::*[local-name() = 'td'] or ancestor::*[local-name() = 'th'])"/>
8196
+
8089
8197
  <xsl:variable name="element">
8090
8198
  <xsl:choose>
8091
8199
  <xsl:when test="ancestor::*[local-name() = 'tr'] and $isGenerateTableIF = 'true'">
8092
8200
  <fo:inline xsl:use-attribute-sets="image-style" text-align="left"/>
8093
8201
  </xsl:when>
8202
+ <xsl:when test="not(ancestor::*[local-name() = 'figure'])">
8203
+ <fo:inline xsl:use-attribute-sets="image-style" text-align="left"/>
8204
+ </xsl:when>
8094
8205
  <xsl:otherwise>
8095
8206
  <fo:block xsl:use-attribute-sets="image-style">
8096
8207
  <xsl:if test="ancestor::*[local-name() = 'dt']">
@@ -8106,10 +8217,24 @@
8106
8217
  <xsl:copy-of select="@*"/>
8107
8218
  <!-- <fo:block xsl:use-attribute-sets="image-style"> -->
8108
8219
  <fo:instream-foreign-object fox:alt-text="{$alt-text}">
8109
- <xsl:if test="$isGenerateTableIF = 'false'">
8110
- <xsl:attribute name="width">100%</xsl:attribute>
8111
- </xsl:if>
8112
- <xsl:attribute name="content-height">100%</xsl:attribute>
8220
+
8221
+ <xsl:choose>
8222
+ <xsl:when test="$image_class = 'corrigenda-tag'">
8223
+ <xsl:attribute name="fox:alt-text">CorrigendaTag</xsl:attribute>
8224
+ <xsl:attribute name="baseline-shift">-10%</xsl:attribute>
8225
+ <xsl:if test="$ancestor_table_cell = 'true'">
8226
+ <xsl:attribute name="baseline-shift">-25%</xsl:attribute>
8227
+ </xsl:if>
8228
+ <xsl:attribute name="height">3.5mm</xsl:attribute>
8229
+ </xsl:when>
8230
+ <xsl:otherwise>
8231
+ <xsl:if test="$isGenerateTableIF = 'false'">
8232
+ <xsl:attribute name="width">100%</xsl:attribute>
8233
+ </xsl:if>
8234
+ <xsl:attribute name="content-height">100%</xsl:attribute>
8235
+ </xsl:otherwise>
8236
+ </xsl:choose>
8237
+
8113
8238
  <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
8114
8239
  <xsl:variable name="svg_width" select="xalan:nodeset($svg_content)/*/@width"/>
8115
8240
  <xsl:variable name="svg_height" select="xalan:nodeset($svg_content)/*/@height"/>
@@ -9624,7 +9749,7 @@
9624
9749
  <!-- ====== -->
9625
9750
  <xsl:template match="*[local-name() = 'termexample']">
9626
9751
  <fo:block id="{@id}" xsl:use-attribute-sets="termexample-style">
9627
-
9752
+ <xsl:call-template name="refine_termexample-style"/>
9628
9753
  <xsl:call-template name="setBlockSpanAll"/>
9629
9754
 
9630
9755
  <xsl:apply-templates select="*[local-name()='name']"/>
@@ -10323,13 +10448,19 @@
10323
10448
  <fo:block id="{@id}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block>
10324
10449
  </xsl:when>
10325
10450
  <!-- if there isn't element with id 'from', then create 'bookmark' here -->
10326
- <xsl:when test="not(ancestor::*[contains(local-name(), '-standard')]//*[@id = $id_from])">
10451
+ <xsl:when test="ancestor::*[contains(local-name(), '-standard')] and not(ancestor::*[contains(local-name(), '-standard')]//*[@id = $id_from])">
10452
+ <fo:block id="{@from}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block>
10453
+ </xsl:when>
10454
+ <xsl:when test="not(//*[@id = $id_from]) and not(preceding-sibling::*[@id = $id_from])">
10327
10455
  <fo:block id="{@from}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block>
10328
10456
  </xsl:when>
10329
10457
  </xsl:choose>
10330
10458
 
10331
10459
  </xsl:template>
10332
10460
 
10461
+ <!-- https://github.com/metanorma/mn-samples-bsi/issues/312 -->
10462
+ <xsl:template match="*[local-name() = 'review'][@type = 'other']"/>
10463
+
10333
10464
  <xsl:template match="*[local-name() = 'name']/text()">
10334
10465
  <!-- 0xA0 to space replacement -->
10335
10466
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),' ',' ')"/>
@@ -11944,6 +12075,7 @@
11944
12075
  <xsl:template name="printEdition">
11945
12076
  <xsl:variable name="edition_i18n" select="normalize-space((//*[contains(local-name(), '-standard')])[1]/*[local-name() = 'bibdata']/*[local-name() = 'edition'][normalize-space(@language) != ''])"/>
11946
12077
  <xsl:text> </xsl:text>
12078
+
11947
12079
  <xsl:choose>
11948
12080
  <xsl:when test="$edition_i18n != ''">
11949
12081
  <!-- Example: <edition language="fr">deuxième édition</edition> -->
@@ -12127,10 +12259,10 @@
12127
12259
 
12128
12260
  <xsl:template name="addPDFUAmeta">
12129
12261
  <pdf:catalog xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf">
12130
- <pdf:dictionary type="normal" key="ViewerPreferences">
12131
- <pdf:boolean key="DisplayDocTitle">true</pdf:boolean>
12132
- </pdf:dictionary>
12133
- </pdf:catalog>
12262
+ <pdf:dictionary type="normal" key="ViewerPreferences">
12263
+ <pdf:boolean key="DisplayDocTitle">true</pdf:boolean>
12264
+ </pdf:dictionary>
12265
+ </pdf:catalog>
12134
12266
  <x:xmpmeta xmlns:x="adobe:ns:meta/">
12135
12267
  <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
12136
12268
  <rdf:Description xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:pdf="http://ns.adobe.com/pdf/1.3/" rdf:about="">
@@ -12179,6 +12311,19 @@
12179
12311
  </rdf:Description>
12180
12312
  </rdf:RDF>
12181
12313
  </x:xmpmeta>
12314
+ <!-- add attachments -->
12315
+ <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
12316
+ <xsl:choose>
12317
+ <xsl:when test="normalize-space() != ''">
12318
+ <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" src="{.}" filename="{@name}"/>
12319
+ </xsl:when>
12320
+ <xsl:otherwise>
12321
+ <!-- _{filename}_attachments -->
12322
+ <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, '_', $inputxml_filename_prefix, '_attachments', '/', @name, ')')"/>
12323
+ <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" src="{$url}" filename="{@name}"/>
12324
+ </xsl:otherwise>
12325
+ </xsl:choose>
12326
+ </xsl:for-each>
12182
12327
  </xsl:template> <!-- addPDFUAmeta -->
12183
12328
 
12184
12329
  <xsl:template name="getId">
@@ -22,26 +22,25 @@ module IsoDoc
22
22
  set(:si_aspect_paths, si_paths)
23
23
  end
24
24
 
25
- TITLE = "//bibdata/title".freeze
25
+ def title1(xml, type, lang)
26
+ xml.at(ns("//bibdata/title[@type='title-#{type}']" \
27
+ "[@language='#{lang}']"))
28
+ &.children&.to_xml || ""
29
+ end
26
30
 
27
31
  def title(isoxml, _out)
28
32
  lang1, lang2 = @lang == "fr" ? %w(fr en) : %w(en fr)
29
- set(:doctitle, @c.encode(isoxml.at(
30
- ns("#{TITLE}[@type='title-main'][@language='#{lang1}']"))&.text || ""))
31
- set(:docsubtitle, @c.encode(isoxml.at(
32
- ns("#{TITLE}[@type='title-main'][@language='#{lang2}']"))&.text || ""))
33
+ set(:doctitle, title1(isoxml, "main", lang1))
34
+ set(:docsubtitle, title1(isoxml, "main", lang2))
33
35
  %w(appendix annex part subtitle provenance).each do |e|
34
- set("#{e}title".to_sym, @c.encode(isoxml.at(
35
- ns("#{TITLE}[@type='title-#{e}'][@language='#{lang1}']"))&.text || ""))
36
- set("#{e}subtitle".to_sym, @c.encode(isoxml.at(
37
- ns("#{TITLE}[@type='title-#{e}'][@language='#{lang2}']"))&.text || ""))
36
+ set("#{e}title".to_sym, title1(isoxml, e, lang1))
37
+ set("#{e}subtitle".to_sym, title1(isoxml, e, lang2))
38
38
  end
39
39
  end
40
40
 
41
41
  def status_print(status)
42
- return "Procès-Verbal" if status == "procès-verbal"
43
- return "CIPM-MRA" if status == "cipm-mra"
44
-
42
+ status == "procès-verbal" and return "Procès-Verbal"
43
+ status == "cipm-mra" and return "CIPM-MRA"
45
44
  status.split(/[- ]/).map.with_index do |s, i|
46
45
  %w(en de).include?(s) && i.positive? ? s : s.capitalize
47
46
  end.join(" ")
@@ -49,31 +48,45 @@ module IsoDoc
49
48
 
50
49
  def docid(isoxml, _out)
51
50
  super
52
- label1, label2 = @lang == "fr" ? %w(Annexe Appendix) : %w(Appendix Annexe)
53
- dn = isoxml.at(ns("//bibdata/ext/structuredidentifier/appendix"))
54
- dn and set(:appendixid, @i18n.l10n("#{label1} #{dn.text}"))
55
- dn and set(:appendixid_alt, @i18n.l10n("#{label2} #{dn.text}"))
56
- label1, label2 = @lang == "fr" ? %w(Appendice Annex) : %w(Annex Appendice)
57
- dn = isoxml.at(ns("//bibdata/ext/structuredidentifier/annexid"))
58
- dn and set(:annexid, @i18n.l10n("#{label1} #{dn.text}"))
59
- dn and set(:annexid_alt, @i18n.l10n("#{label2} #{dn.text}"))
60
- label1, label2 = @lang == "fr" ? %w(Partie Part) : %w(Part Partie)
61
- dn = isoxml.at(ns("//bibdata/ext/structuredidentifier/part"))
62
- dn and set(:partid, @i18n.l10n("#{label1} #{dn.text}"))
63
- dn and set(:partid_alt, @i18n.l10n("#{label2} #{dn.text}"))
51
+ docid_part(isoxml, %w(Appendix Annexe), "appendix", :appendixid)
52
+ docid_part(isoxml, %w(Annex Appendice), "annexid", :annexid)
53
+ docid_part(isoxml, %w(Part Partie), "part", :partid)
64
54
  set(:org_abbrev,
65
55
  isoxml.at(ns("//bibdata/ext/editorialgroup/committee"\
66
56
  "[@acronym = 'JCGM']")) ? "JCGM" : "BIPM")
67
57
  end
68
58
 
59
+ def docid_part(isoxml, labels, elem, key)
60
+ @lang == "fr" and labels.reverse!
61
+ label1, label2 = labels
62
+ dn = isoxml.at(ns("//bibdata/ext/structuredidentifier/#{elem}"))
63
+ dn and set(key, @i18n.l10n("#{label1} #{dn.text}"))
64
+ dn and set("#{key}_alt".to_sym, @i18n.l10n("#{label2} #{dn.text}"))
65
+ end
66
+
69
67
  def extract_person_names_affiliations(authors)
70
68
  extract_person_affiliations(authors)
71
69
  end
72
70
 
73
71
  def bibdate(isoxml, _out)
74
- pubdate = isoxml.at(ns("//bibdata/date[not(@format)][@type = 'published']"))
72
+ pubdate = isoxml
73
+ .at(ns("//bibdata/date[not(@format)][@type = 'published']"))
75
74
  pubdate and set(:pubdate_monthyear, monthyr(pubdate.text))
76
75
  end
76
+
77
+ def author(xml, _out)
78
+ super
79
+ authorizer(xml)
80
+ end
81
+
82
+ def authorizer(xml)
83
+ ret = xml.xpath(ns("//bibdata/contributor[xmlns:role/@type = " \
84
+ "'authorizer']/organization"))
85
+ .each_with_object([]) do |org, m|
86
+ m << extract_variant(org.at(ns("./name")))
87
+ end
88
+ ret.empty? or set(:authorizer, ret)
89
+ end
77
90
  end
78
91
  end
79
92
  end
@@ -75,13 +75,16 @@ module IsoDoc
75
75
  end
76
76
 
77
77
  def twitter_cldr_localiser_symbols
78
- { group: "&#xA0;", fraction_group: "&#xA0;", fraction_group_digits: 3 }
78
+ { group: "&#xA0;", fraction_group: "&#xA0;",
79
+ fraction_group_digits: 3 }
79
80
  end
80
81
 
81
82
  def localized_number(num, locale, precision)
82
- g = Regexp.quote(twitter_cldr_localiser_symbols[:group])
83
- f = Regexp.quote(twitter_cldr_localiser_symbols[:fraction_group])
84
- super.sub(/^(\d)#{g}(\d)/, "\\1\\2").sub(/(\d)#{f}(\d)$/, "\\1\\2")
83
+ g = Regexp.quote(@twitter_cldr_reader[:group])
84
+ f = Regexp.quote(@twitter_cldr_reader[:fraction_group])
85
+ d = Regexp.quote(@twitter_cldr_reader[:decimal])
86
+ super.sub(/^(\d)#{g}(\d) (?= \d\d$ | \d\d#{d} )/x, "\\1\\2")
87
+ .sub(/(?<= ^\d\d | #{d}\d\d ) (\d)#{f}(\d) $/x, "\\1\\2")
85
88
  end
86
89
 
87
90
  def mathml1(elem, locale)
@@ -97,8 +100,7 @@ module IsoDoc
97
100
 
98
101
  def bibdata_dates(bibdata)
99
102
  pubdate = bibdata.at(ns("./date[not(@format)][@type = 'published']"))
100
- return unless pubdate
101
-
103
+ pubdate or return
102
104
  meta = metadata_init(@lang, @script, @locale, @i18n)
103
105
  pubdate.next = pubdate.dup
104
106
  pubdate.next["format"] = "ddMMMyyyy"
@@ -193,23 +195,23 @@ module IsoDoc
193
195
  end
194
196
 
195
197
  def termsource_modification(elem)
196
- if elem["status"] == "modified"
197
- origin = elem.at(ns("./origin"))
198
- # s = termsource_status(elem["status"]) and origin.next = l10n(", #{s}")
199
- end
198
+ # if elem["status"] == "modified"
199
+ # origin = elem.at(ns("./origin"))
200
+ # s = termsource_status(elem["status"]) and origin.next = l10n(", #{s}")
201
+ # end
200
202
  termsource_add_modification_text(elem.at(ns("./modification")))
201
203
  end
202
204
 
203
205
  def norm_ref_entry_code(_ordinal, identifiers, _ids, _standard, datefn,
204
206
  _bib)
205
- ret = (identifiers[0] || identifiers[1])
207
+ ret = identifiers[0] || identifiers[1]
206
208
  ret += " #{identifiers[1]}" if identifiers[0] && identifiers[1]
207
209
  "#{ret}#{datefn} "
208
210
  end
209
211
 
210
212
  def biblio_ref_entry_code(ordinal, ids, _id, _standard, datefn, _bib)
211
213
  # standard and id = nil
212
- ret = (ids[:ordinal] || ids[:metanorma] || "[#{ordinal}]")
214
+ ret = ids[:ordinal] || ids[:metanorma] || "[#{ordinal}]"
213
215
  if ids[:sdo]
214
216
  ret = prefix_bracketed_ref(ret)
215
217
  ret += "#{ids[:sdo]}#{datefn} "
@@ -219,10 +221,6 @@ _bib)
219
221
  ret
220
222
  end
221
223
 
222
- def bibrenderer
223
- ::Relaton::Render::BIPM::General.new(language: @lang)
224
- end
225
-
226
224
  include Init
227
225
  end
228
226
  end
@@ -244,6 +244,9 @@
244
244
  <data type="ID"/>
245
245
  </attribute>
246
246
  <attribute name="reviewer"/>
247
+ <optional>
248
+ <attribute name="type"/>
249
+ </optional>
247
250
  <optional>
248
251
  <attribute name="date">
249
252
  <data type="dateTime"/>
@@ -338,29 +338,32 @@
338
338
  </define>
339
339
  <define name="organization">
340
340
  <element name="organization">
341
- <oneOrMore>
342
- <ref name="orgname"/>
343
- </oneOrMore>
344
- <zeroOrMore>
345
- <ref name="subdivision"/>
346
- </zeroOrMore>
347
- <optional>
348
- <ref name="abbreviation"/>
349
- </optional>
350
- <zeroOrMore>
351
- <ref name="uri"/>
352
- </zeroOrMore>
353
- <zeroOrMore>
354
- <ref name="org-identifier"/>
355
- </zeroOrMore>
356
- <zeroOrMore>
357
- <ref name="contact"/>
358
- </zeroOrMore>
359
- <optional>
360
- <ref name="logo"/>
361
- </optional>
341
+ <ref name="OrganizationType"/>
362
342
  </element>
363
343
  </define>
344
+ <define name="OrganizationType">
345
+ <oneOrMore>
346
+ <ref name="orgname"/>
347
+ </oneOrMore>
348
+ <zeroOrMore>
349
+ <ref name="subdivision"/>
350
+ </zeroOrMore>
351
+ <optional>
352
+ <ref name="abbreviation"/>
353
+ </optional>
354
+ <zeroOrMore>
355
+ <ref name="uri"/>
356
+ </zeroOrMore>
357
+ <zeroOrMore>
358
+ <ref name="org-identifier"/>
359
+ </zeroOrMore>
360
+ <zeroOrMore>
361
+ <ref name="contact"/>
362
+ </zeroOrMore>
363
+ <optional>
364
+ <ref name="logo"/>
365
+ </optional>
366
+ </define>
364
367
  <define name="orgname">
365
368
  <element name="name">
366
369
  <choice>
@@ -371,10 +374,10 @@
371
374
  </define>
372
375
  <define name="subdivision">
373
376
  <element name="subdivision">
374
- <choice>
375
- <ref name="LocalizedString"/>
376
- <ref name="NameWithVariants"/>
377
- </choice>
377
+ <optional>
378
+ <attribute name="type"/>
379
+ </optional>
380
+ <ref name="OrganizationType"/>
378
381
  </element>
379
382
  </define>
380
383
  <define name="logo">