metanorma-bipm 2.6.2 → 2.6.4

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.
@@ -5263,6 +5263,8 @@
5263
5263
 
5264
5264
  <xsl:template name="setTableRowAttributes">
5265
5265
 
5266
+ <xsl:call-template name="setColors"/>
5267
+
5266
5268
  </xsl:template> <!-- setTableRowAttributes -->
5267
5269
  <!-- ===================== -->
5268
5270
  <!-- END Table's row processing -->
@@ -5314,6 +5316,7 @@
5314
5316
  </xsl:attribute>
5315
5317
  </xsl:if>
5316
5318
  <xsl:call-template name="display-align"/>
5319
+ <xsl:call-template name="setColors"/>
5317
5320
  </xsl:template>
5318
5321
 
5319
5322
  <xsl:template name="display-align">
@@ -5329,6 +5332,29 @@
5329
5332
  </xsl:if>
5330
5333
  </xsl:template>
5331
5334
 
5335
+ <xsl:template name="setColors">
5336
+ <xsl:variable name="styles__">
5337
+ <xsl:call-template name="split">
5338
+ <xsl:with-param name="pText" select="concat(@style,';')"/>
5339
+ <xsl:with-param name="sep" select="';'"/>
5340
+ </xsl:call-template>
5341
+ </xsl:variable>
5342
+ <xsl:variable name="quot">"</xsl:variable>
5343
+ <xsl:variable name="styles_">
5344
+ <xsl:for-each select="xalan:nodeset($styles__)/item">
5345
+ <xsl:variable name="key" select="normalize-space(substring-before(., ':'))"/>
5346
+ <xsl:variable name="value" select="normalize-space(substring-after(translate(.,$quot,''), ':'))"/>
5347
+ <xsl:if test="$key = 'color' or $key = 'background-color'">
5348
+ <style name="{$key}"><xsl:value-of select="$value"/></style>
5349
+ </xsl:if>
5350
+ </xsl:for-each>
5351
+ </xsl:variable>
5352
+ <xsl:variable name="styles" select="xalan:nodeset($styles_)"/>
5353
+ <xsl:for-each select="$styles/style">
5354
+ <xsl:attribute name="{@name}"><xsl:value-of select="."/></xsl:attribute>
5355
+ </xsl:for-each>
5356
+ </xsl:template>
5357
+
5332
5358
  <!-- cell in table body, footer -->
5333
5359
  <xsl:template match="*[local-name()='td']" name="td">
5334
5360
  <fo:table-cell xsl:use-attribute-sets="table-cell-style"> <!-- text-align="{@align}" -->
@@ -5340,12 +5366,12 @@
5340
5366
 
5341
5367
  <xsl:call-template name="refine_table-cell-style"/>
5342
5368
 
5369
+ <xsl:call-template name="setTableCellAttributes"/>
5370
+
5343
5371
  <xsl:if test=".//*[local-name() = 'table']"> <!-- if there is nested table -->
5344
5372
  <xsl:attribute name="padding-right">1mm</xsl:attribute>
5345
5373
  </xsl:if>
5346
5374
 
5347
- <xsl:call-template name="setTableCellAttributes"/>
5348
-
5349
5375
  <xsl:if test="$isGenerateTableIF = 'true'">
5350
5376
  <xsl:attribute name="border">1pt solid black</xsl:attribute> <!-- border is mandatory, to determine page width -->
5351
5377
  <xsl:attribute name="text-align">left</xsl:attribute>
@@ -7144,7 +7170,7 @@
7144
7170
  <xsl:choose>
7145
7171
  <xsl:when test="ancestor::*[local-name() = 'table']"><xsl:apply-templates/></xsl:when>
7146
7172
  <xsl:when test="following-sibling::*[2][local-name() = 'span'][@class = 'stdpublisher' or @class = 'stddocNumber' or @class = 'stddocPartNumber' or @class = 'stdyear']">
7147
- <fo:inline keep-with-next.within-line="always"><xsl:apply-templates/></fo:inline>
7173
+ <fo:inline keep-with-next.within-line="always" role="SKIP"><xsl:apply-templates/></fo:inline>
7148
7174
  </xsl:when>
7149
7175
  <xsl:otherwise>
7150
7176
  <xsl:apply-templates/>
@@ -7152,7 +7178,7 @@
7152
7178
  </xsl:choose>
7153
7179
  </xsl:template>
7154
7180
  <xsl:template match="text()[not(ancestor::*[local-name() = 'table']) and preceding-sibling::*[1][local-name() = 'span'][@class = 'stdpublisher' or @class = 'stddocNumber' or @class = 'stddocPartNumber' or @class = 'stdyear'] and following-sibling::*[1][local-name() = 'span'][@class = 'stdpublisher' or @class = 'stddocNumber' or @class = 'stddocPartNumber' or @class = 'stdyear']]" priority="2">
7155
- <fo:inline keep-with-next.within-line="always"><xsl:value-of select="."/></fo:inline>
7181
+ <fo:inline keep-with-next.within-line="always" role="SKIP"><xsl:value-of select="."/></fo:inline>
7156
7182
  </xsl:template>
7157
7183
 
7158
7184
  <xsl:template match="*[local-name() = 'span'][contains(@style, 'text-transform:none')]//text()" priority="5">
@@ -8192,24 +8218,26 @@
8192
8218
  <xsl:apply-templates select="." mode="mathml"/>
8193
8219
  </xsl:variable>
8194
8220
 
8195
- <fo:instream-foreign-object fox:alt-text="Math">
8221
+ <fo:instream-foreign-object fox:alt-text="Math" fox:actual-text="Math">
8196
8222
 
8197
8223
  <xsl:call-template name="refine_mathml_insteam_object_style"/>
8198
8224
 
8199
- <!-- put MathML in Actual Text -->
8200
- <!-- DEBUG: mathml_content=<xsl:value-of select="$mathml_content"/> -->
8201
- <xsl:attribute name="fox:actual-text">
8202
- <xsl:value-of select="$mathml_content"/>
8203
- </xsl:attribute>
8204
-
8205
- <!-- <xsl:if test="$add_math_as_text = 'true'"> -->
8206
- <xsl:if test="normalize-space($asciimath_text_) != ''">
8207
- <!-- put Mathin Alternate Text -->
8208
- <xsl:attribute name="fox:alt-text">
8209
- <xsl:value-of select="$asciimath_text_"/>
8225
+ <xsl:if test="$isGenerateTableIF = 'false'">
8226
+ <!-- put MathML in Actual Text -->
8227
+ <!-- DEBUG: mathml_content=<xsl:value-of select="$mathml_content"/> -->
8228
+ <xsl:attribute name="fox:actual-text">
8229
+ <xsl:value-of select="$mathml_content"/>
8210
8230
  </xsl:attribute>
8231
+
8232
+ <!-- <xsl:if test="$add_math_as_text = 'true'"> -->
8233
+ <xsl:if test="normalize-space($asciimath_text_) != ''">
8234
+ <!-- put Mathin Alternate Text -->
8235
+ <xsl:attribute name="fox:alt-text">
8236
+ <xsl:value-of select="$asciimath_text_"/>
8237
+ </xsl:attribute>
8238
+ </xsl:if>
8239
+ <!-- </xsl:if> -->
8211
8240
  </xsl:if>
8212
- <!-- </xsl:if> -->
8213
8241
 
8214
8242
  <xsl:copy-of select="xalan:nodeset($mathml)"/>
8215
8243
 
@@ -9972,6 +10000,8 @@
9972
10000
  <xsl:template match="*[local-name() = 'origin']" mode="contents"/>
9973
10001
  <xsl:template match="*[local-name() = 'erefstack ']" mode="contents"/>
9974
10002
 
10003
+ <xsl:template match="*[local-name() = 'requirement'] | *[local-name() = 'recommendation'] | *[local-name() = 'permission']" mode="contents" priority="3"/>
10004
+
9975
10005
  <xsl:template match="*[local-name() = 'stem']" mode="bookmarks"/>
9976
10006
  <xsl:template match="*[local-name() = 'fmt-stem']" mode="bookmarks">
9977
10007
  <xsl:apply-templates mode="bookmarks"/>
@@ -9993,6 +10023,8 @@
9993
10023
  <xsl:template match="*[local-name() = 'origin']" mode="bookmarks"/>
9994
10024
  <xsl:template match="*[local-name() = 'erefstack ']" mode="bookmarks"/>
9995
10025
 
10026
+ <xsl:template match="*[local-name() = 'requirement'] | *[local-name() = 'recommendation'] | *[local-name() = 'permission']" mode="bookmarks" priority="3"/>
10027
+
9996
10028
  <!-- Bookmarks -->
9997
10029
  <xsl:template name="addBookmarks">
9998
10030
  <xsl:param name="contents"/>
@@ -11876,21 +11908,32 @@
11876
11908
  <!-- ========== -->
11877
11909
 
11878
11910
  <xsl:variable name="reviews_">
11879
- <xsl:for-each select="//*[local-name() = 'review'][@from]">
11911
+ <xsl:for-each select="//*[local-name() = 'review'][not(parent::*[local-name() = 'review-container'])][@from]">
11880
11912
  <xsl:copy>
11881
11913
  <xsl:copy-of select="@from"/>
11882
11914
  <xsl:copy-of select="@id"/>
11883
11915
  </xsl:copy>
11884
11916
  </xsl:for-each>
11917
+ <xsl:for-each select="//*[local-name() = 'fmt-review-start'][@source]">
11918
+ <xsl:copy>
11919
+ <xsl:copy-of select="@source"/>
11920
+ <xsl:copy-of select="@id"/>
11921
+ </xsl:copy>
11922
+ </xsl:for-each>
11885
11923
  </xsl:variable>
11886
11924
  <xsl:variable name="reviews" select="xalan:nodeset($reviews_)"/>
11887
11925
 
11888
11926
  <xsl:template name="addReviewHelper">
11889
- <!-- if there is review with from="...", then add small helper block for Annot tag adding, see 'review' template -->
11890
- <xsl:variable name="curr_id" select="@id"/>
11891
- <xsl:variable name="review_id" select="normalize-space($reviews//*[local-name() = 'review'][@from = $curr_id]/@id)"/>
11892
- <xsl:if test="$review_id != ''"> <!-- i.e. if review found -->
11893
- <fo:block keep-with-next="always" line-height="0.1" id="{$review_id}" font-size="1pt" role="SKIP"><xsl:value-of select="$hair_space"/><fo:basic-link internal-destination="{$review_id}" fox:alt-text="Annot___{$review_id}" role="Annot"><xsl:value-of select="$hair_space"/></fo:basic-link></fo:block>
11927
+ <xsl:if test="$isGenerateTableIF = 'false'">
11928
+ <!-- if there is review with from="...", then add small helper block for Annot tag adding, see 'review' template -->
11929
+ <xsl:variable name="curr_id" select="@id"/>
11930
+ <!-- <xsl:variable name="review_id" select="normalize-space(/@id)"/> -->
11931
+ <xsl:for-each select="$reviews//*[local-name() = 'review'][@from = $curr_id]"> <!-- $reviews//*[local-name() = 'fmt-review-start'][@source = $curr_id] -->
11932
+ <xsl:variable name="review_id" select="normalize-space(@id)"/>
11933
+ <xsl:if test="$review_id != ''"> <!-- i.e. if review found -->
11934
+ <fo:block keep-with-next="always" line-height="0.1" id="{$review_id}" font-size="1pt" role="SKIP"><xsl:value-of select="$hair_space"/><fo:basic-link internal-destination="{$review_id}" fox:alt-text="Annot___{$review_id}" role="Annot"><xsl:value-of select="$hair_space"/></fo:basic-link></fo:block>
11935
+ </xsl:if>
11936
+ </xsl:for-each>
11894
11937
  </xsl:if>
11895
11938
  <!-- <fo:block>
11896
11939
  <curr_id><xsl:value-of select="$curr_id"/></curr_id>
@@ -12034,14 +12077,61 @@
12034
12077
 
12035
12078
  </xsl:template>
12036
12079
 
12037
- <xsl:template match="*[local-name() = 'review']"> <!-- 'review' will be processed in mn2pdf/review.xsl -->
12080
+ <!-- document text (not figures, or tables) footnotes -->
12081
+ <xsl:variable name="reviews_container_">
12082
+ <xsl:for-each select="//*[local-name() = 'review-container']/*[local-name() = 'fmt-review-body']">
12083
+ <xsl:variable name="update_xml_step1">
12084
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
12085
+ </xsl:variable>
12086
+ <xsl:apply-templates select="xalan:nodeset($update_xml_step1)" mode="update_xml_enclose_keep-together_within-line"/>
12087
+ </xsl:for-each>
12088
+ </xsl:variable>
12089
+ <xsl:variable name="reviews_container" select="xalan:nodeset($reviews_container_)"/>
12090
+
12091
+ <xsl:template match="*[local-name() = 'review-container']"/>
12092
+
12093
+ <!-- for old Presentation XML (before https://github.com/metanorma/isodoc/issues/670) -->
12094
+ <xsl:template match="*[local-name() = 'review'][not(parent::*[local-name() = 'review-container'])]"> <!-- 'review' will be processed in mn2pdf/review.xsl -->
12095
+ <xsl:variable name="id_from" select="normalize-space(current()/@from)"/>
12096
+ <xsl:if test="$isGenerateTableIF = 'false'">
12097
+ <xsl:choose>
12098
+ <!-- if there isn't the attribute '@from', then -->
12099
+ <xsl:when test="$id_from = ''">
12100
+ <fo:block id="{@id}" font-size="1pt" role="SKIP"><xsl:value-of select="$hair_space"/><fo:basic-link internal-destination="{@id}" fox:alt-text="Annot___{@id}" role="Annot"><xsl:value-of select="$hair_space"/></fo:basic-link></fo:block>
12101
+ </xsl:when>
12102
+ <!-- if there isn't element with id 'from', then create 'bookmark' here -->
12103
+ <xsl:when test="ancestor::*[local-name() = 'metanorma'] and not(ancestor::*[local-name() = 'metanorma']//*[@id = $id_from])">
12104
+ <fo:block id="{@from}" font-size="1pt" role="SKIP"><xsl:value-of select="$hair_space"/><fo:basic-link internal-destination="{@from}" fox:alt-text="Annot___{@id}" role="Annot"><xsl:value-of select="$hair_space"/></fo:basic-link></fo:block>
12105
+ </xsl:when>
12106
+ <xsl:when test="not(/*[@id = $id_from]) and not(/*//*[@id = $id_from]) and not(preceding-sibling::*[@id = $id_from])">
12107
+ <fo:block id="{@from}" font-size="1pt" role="SKIP"><xsl:value-of select="$hair_space"/><fo:basic-link internal-destination="{@from}" fox:alt-text="Annot___{@id}" role="Annot"><xsl:value-of select="$hair_space"/></fo:basic-link></fo:block>
12108
+ </xsl:when>
12109
+ </xsl:choose>
12110
+ </xsl:if>
12111
+ </xsl:template>
12112
+
12113
+ <!-- for new Presentation XML (https://github.com/metanorma/isodoc/issues/670) -->
12114
+ <xsl:template match="*[local-name() = 'fmt-review-start']" name="fmt-review-start"> <!-- 'review' will be processed in mn2pdf/review.xsl -->
12038
12115
  <!-- comment 2019-11-29 -->
12039
12116
  <!-- <fo:block font-weight="bold">Review:</fo:block>
12040
12117
  <xsl:apply-templates /> -->
12041
12118
 
12042
- <xsl:variable name="id_from" select="normalize-space(current()/@from)"/>
12119
+ <xsl:variable name="id_from" select="normalize-space(current()/@source)"/>
12043
12120
 
12044
- <xsl:if test="1 = 1">
12121
+ <xsl:variable name="source" select="normalize-space(@source)"/>
12122
+
12123
+ <xsl:if test="$isGenerateTableIF = 'false'">
12124
+ <!-- <xsl:variable name="id_from" select="normalize-space(current()/@from)"/> -->
12125
+
12126
+ <!-- <xsl:if test="@source = @end"> -->
12127
+ <!-- following-sibling::node()[1][local-name() = 'bookmark'][@id = $source] and
12128
+ following-sibling::node()[2][local-name() = 'fmt-review-end'][@source = $source] -->
12129
+ <!-- <fo:block id="{$source}" font-size="1pt" role="SKIP"><xsl:value-of select="$hair_space"/><fo:basic-link internal-destination="{$source}" fox:alt-text="Annot___{$source}" role="Annot"><xsl:value-of select="$hair_space"/></fo:basic-link></fo:block> -->
12130
+ <fo:block id="{@id}" font-size="1pt" role="SKIP" keep-with-next="always" line-height="0.1"><xsl:value-of select="$hair_space"/><fo:basic-link internal-destination="{@id}" fox:alt-text="Annot___{@id}" role="Annot"><xsl:value-of select="$hair_space"/></fo:basic-link></fo:block>
12131
+ <!-- </xsl:if> -->
12132
+ </xsl:if>
12133
+
12134
+ <xsl:if test="1 = 2">
12045
12135
  <xsl:choose>
12046
12136
  <!-- if there isn't the attribute '@from', then -->
12047
12137
  <xsl:when test="$id_from = ''">
@@ -12049,10 +12139,10 @@
12049
12139
  </xsl:when>
12050
12140
  <!-- if there isn't element with id 'from', then create 'bookmark' here -->
12051
12141
  <xsl:when test="ancestor::*[local-name() = 'metanorma'] and not(ancestor::*[local-name() = 'metanorma']//*[@id = $id_from])">
12052
- <fo:block id="{@from}" font-size="1pt" role="SKIP"><xsl:value-of select="$hair_space"/><fo:basic-link internal-destination="{@from}" fox:alt-text="Annot___{@id}" role="Annot"><xsl:value-of select="$hair_space"/></fo:basic-link></fo:block>
12142
+ <fo:block id="{$id_from}" font-size="1pt" role="SKIP"><xsl:value-of select="$hair_space"/><fo:basic-link internal-destination="{$id_from}" fox:alt-text="Annot___{@id}" role="Annot"><xsl:value-of select="$hair_space"/></fo:basic-link></fo:block>
12053
12143
  </xsl:when>
12054
12144
  <xsl:when test="not(/*[@id = $id_from]) and not(/*//*[@id = $id_from]) and not(preceding-sibling::*[@id = $id_from])">
12055
- <fo:block id="{@from}" font-size="1pt" role="SKIP"><xsl:value-of select="$hair_space"/><fo:basic-link internal-destination="{@from}" fox:alt-text="Annot___{@id}" role="Annot"><xsl:value-of select="$hair_space"/></fo:basic-link></fo:block>
12145
+ <fo:block id="{$id_from}" font-size="1pt" role="SKIP"><xsl:value-of select="$hair_space"/><fo:basic-link internal-destination="{$id_from}" fox:alt-text="Annot___{@id}" role="Annot"><xsl:value-of select="$hair_space"/></fo:basic-link></fo:block>
12056
12146
  </xsl:when>
12057
12147
  </xsl:choose>
12058
12148
  </xsl:if>
@@ -12103,16 +12193,21 @@
12103
12193
  <xsl:variable name="list_level">
12104
12194
  <xsl:choose>
12105
12195
  <xsl:when test="$list_level_ &lt;= 3"><xsl:value-of select="$list_level_"/></xsl:when>
12106
- <xsl:otherwise><xsl:value-of select="$list_level_ mod 3"/></xsl:otherwise>
12196
+ <xsl:when test="$ul_labels/label[@level = 3]"><xsl:value-of select="$list_level_ mod 3"/></xsl:when>
12197
+ <xsl:when test="$list_level_ mod 2 = 0">2</xsl:when>
12198
+ <xsl:otherwise><xsl:value-of select="$list_level_ mod 2"/></xsl:otherwise>
12107
12199
  </xsl:choose>
12108
12200
  </xsl:variable>
12109
12201
  <xsl:choose>
12110
12202
  <xsl:when test="$ul_labels/label[not(@level)]"> <!-- one label for all levels -->
12111
12203
  <xsl:apply-templates select="$ul_labels/label[not(@level)]" mode="ul_labels"/>
12112
12204
  </xsl:when>
12113
- <xsl:when test="$list_level mod 3 = 0">
12205
+ <xsl:when test="$list_level mod 3 = 0 and $ul_labels/label[@level = 3]">
12114
12206
  <xsl:apply-templates select="$ul_labels/label[@level = 3]" mode="ul_labels"/>
12115
12207
  </xsl:when>
12208
+ <xsl:when test="$list_level mod 3 = 0">
12209
+ <xsl:apply-templates select="$ul_labels/label[@level = 1]" mode="ul_labels"/>
12210
+ </xsl:when>
12116
12211
  <xsl:when test="$list_level mod 2 = 0">
12117
12212
  <xsl:apply-templates select="$ul_labels/label[@level = 2]" mode="ul_labels"/>
12118
12213
  </xsl:when>
@@ -12655,10 +12750,22 @@
12655
12750
  <xsl:template match="*[local-name() = 'table']/*[local-name() = 'bookmark']" priority="2"/>
12656
12751
 
12657
12752
  <xsl:template match="*[local-name() = 'bookmark']" name="bookmark">
12658
- <!-- <fo:inline id="{@id}" font-size="1pt"/> -->
12659
- <fo:inline id="{@id}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:inline>
12660
- <!-- we need to add zero-width space, otherwise this fo:inline is missing in IF xml -->
12661
- <xsl:if test="not(following-sibling::node()[normalize-space() != ''])"><fo:inline font-size="1pt"> </fo:inline></xsl:if>
12753
+ <xsl:variable name="bookmark_id" select="@id"/>
12754
+ <xsl:choose>
12755
+ <!-- Example:
12756
+ <fmt-review-start id="_7ef81cf7-3f6c-4ed4-9c1f-1ba092052bbd" source="_dda23915-8574-ef1e-29a1-822d465a5b97" target="_ecfb2210-3b1b-46a2-b63a-8b8505be6686" end="_dda23915-8574-ef1e-29a1-822d465a5b97" author="" date="2025-03-24T00:00:00Z"/>
12757
+ <bookmark id="_dda23915-8574-ef1e-29a1-822d465a5b97"/>
12758
+ <fmt-review-end id="_f336a8d0-08a8-4b7f-a1aa-b04688ed40c1" source="_dda23915-8574-ef1e-29a1-822d465a5b97" target="_ecfb2210-3b1b-46a2-b63a-8b8505be6686" start="_dda23915-8574-ef1e-29a1-822d465a5b97" author="" date="2025-03-24T00:00:00Z"/> -->
12759
+ <xsl:when test="1 = 2 and preceding-sibling::node()[local-name() = 'fmt-review-start'][@source = $bookmark_id] and following-sibling::node()[local-name() = 'fmt-review-end'][@source = $bookmark_id]">
12760
+ <!-- skip here, see the template 'fmt-review-start' -->
12761
+ </xsl:when>
12762
+ <xsl:otherwise>
12763
+ <!-- <fo:inline id="{@id}" font-size="1pt"/> -->
12764
+ <fo:inline id="{@id}" font-size="1pt"><xsl:if test="preceding-sibling::node()[local-name() = 'fmt-review-start'][@source = $bookmark_id] and following-sibling::node()[local-name() = 'fmt-review-end'][@source = $bookmark_id]"><xsl:attribute name="line-height">0.1</xsl:attribute></xsl:if><xsl:value-of select="$hair_space"/></fo:inline>
12765
+ <!-- we need to add zero-width space, otherwise this fo:inline is missing in IF xml -->
12766
+ <xsl:if test="not(following-sibling::node()[normalize-space() != ''])"><fo:inline font-size="1pt"> </fo:inline></xsl:if>
12767
+ </xsl:otherwise>
12768
+ </xsl:choose>
12662
12769
  </xsl:template>
12663
12770
  <!-- =================== -->
12664
12771
  <!-- End of Index processing -->
@@ -14015,6 +14122,9 @@
14015
14122
  <xsl:template match="*[local-name() = 'svgmap']" mode="update_xml_step1"/>
14016
14123
  <xsl:template match="*[local-name() = 'svgmap']" mode="update_xml_pres"/>
14017
14124
 
14125
+ <xsl:template match="*[local-name() = 'review-container']" mode="update_xml_step1"/>
14126
+ <xsl:template match="*[local-name() = 'review-container']" mode="update_xml_pres"/>
14127
+
14018
14128
  <!-- END: update new Presentation XML -->
14019
14129
 
14020
14130
  <!-- =========================================================================== -->
@@ -6,15 +6,6 @@ module IsoDoc
6
6
  @iso.middle_title(docxml)
7
7
  end
8
8
 
9
- # KILL
10
- def table1x(elem)
11
- table_fn(elem)
12
- labelled_ancestor(elem) || elem["unnumbered"] and return
13
- n = @xrefs.anchor(elem["id"], :label, false)
14
- prefix_name(elem, ".<tab/>",
15
- l10n("#{@i18n.table.capitalize} #{n}"), "name")
16
- end
17
-
18
9
  def table_delim
19
10
  l10n("x.<tab/>").sub("x", "") # force French " .</tab>"
20
11
  end
@@ -46,6 +37,34 @@ module IsoDoc
46
37
  else @i18n.prefacenote
47
38
  end
48
39
  end
40
+
41
+ def termsource_label(elem, sources)
42
+ elem.replace(l10n("[#{termsource_adapt(elem['status'])} #{sources}]"))
43
+ end
44
+
45
+ def termsource_adapt(status)
46
+ case status
47
+ when "adapted" then @i18n.adapted_from
48
+ when "modified" then @i18n.modified_from
49
+ else ""
50
+ end
51
+ end
52
+
53
+ def termsource(docxml)
54
+ termsource_insert_empty_modification(docxml)
55
+ super
56
+ end
57
+
58
+ def termsource_insert_empty_modification(docxml)
59
+ docxml.xpath("//xmlns:termsource[@status = 'modified']" \
60
+ "[not(xmlns:modification)]").each do |f|
61
+ f << "<modification/>"
62
+ end
63
+ end
64
+
65
+ def termsource_modification(elem)
66
+ termsource_add_modification_text(elem.at(ns("./modification")))
67
+ end
49
68
  end
50
69
  end
51
70
  end
@@ -0,0 +1,112 @@
1
+ module IsoDoc
2
+ module Bipm
3
+ class PresentationXMLConvert < IsoDoc::Generic::PresentationXMLConvert
4
+ def fn_label_brackets(fnote)
5
+ "<sup><span class='fmt-label-delim'>(</span>" \
6
+ "#{fn_label(fnote)}" \
7
+ "<span class='fmt-label-delim'>)</span></sup>"
8
+ end
9
+
10
+ def fn_ref_label(fnote)
11
+ if @jcgm then iso_fn_ref_label(fnote)
12
+ else fn_label_brackets(fnote)
13
+ end
14
+ end
15
+
16
+ # copied from ISO
17
+ def iso_fn_ref_label(fnote)
18
+ if fnote.ancestors("table, figure").empty? ||
19
+ !fnote.ancestors("name, fmt-name").empty?
20
+ "<sup>#{fn_label(fnote)}" \
21
+ "<span class='fmt-label-delim'>)</span></sup>"
22
+ else
23
+ "<sup>#{fn_label(fnote)}</sup>"
24
+ end
25
+ end
26
+
27
+ def fn_body_label(fnote)
28
+ if @jcgm then super
29
+ else fn_label_brackets(fnote)
30
+ end
31
+ end
32
+
33
+ # explode out all the subclauses into separate entries
34
+ # assume no hanging clauses
35
+ def sort_footnote_sections(docxml)
36
+ ret = super
37
+ ret.flat_map do |x|
38
+ explode_subclauses(x)
39
+ end
40
+ end
41
+
42
+ def explode_subclauses(clause)
43
+ clause.at(ns(".//clause")) or return [clause]
44
+ (clause.xpath(ns(".//clause")) - clause.xpath(ns(".//clause//clause")))
45
+ .map { |x| explode_subclauses(x) }
46
+ .flatten.unshift(clause)
47
+ end
48
+
49
+ # quote/table/fn references are not unique within quote
50
+ # if there are multiple tables
51
+ def renumber_document_footnote_key(fnote)
52
+ key = fnote["reference"]
53
+ !@jcgm && (t = fnote.at("./ancestor::xmlns:table")) and
54
+ key = "#{t['id']} #{key}"
55
+ key
56
+ end
57
+
58
+ def renumber_document_footnote(fnote, idx, seen)
59
+ fnote["original-reference"] = fnote["reference"]
60
+ key = renumber_document_footnote_key(fnote)
61
+ if seen[key]
62
+ fnote["reference"] = seen[fnote["reference"]]
63
+ else
64
+ seen[key] = idx
65
+ fnote["reference"] = idx
66
+ idx += 1
67
+ end
68
+ idx
69
+ end
70
+
71
+ def document_footnotes(docxml)
72
+ @jcgm and return super
73
+ sects = sort_footnote_sections(docxml)
74
+ excl = non_document_footnotes(docxml)
75
+ fns = filter_document_footnotes(sects, excl)
76
+ sects.each_with_index do |s, i|
77
+ ret = footnote_collect(renumber_document_footnotes(fns[i], 1))
78
+ f = footnote_container(fns[i], ret) and s << f
79
+ end
80
+ end
81
+
82
+ def filter_document_footnotes(sects, excl)
83
+ sects.each_with_object([]) do |s, m|
84
+ docfns = s.xpath(ns(".//fn")) - excl - s.xpath(ns(".//clause//fn"))
85
+ m << docfns
86
+ end
87
+ end
88
+
89
+ def renumber_document_footnotes(fns, idx)
90
+ @jcgm and return super
91
+ fns.each_with_object({}) do |f, seen|
92
+ idx = renumber_document_footnote(f, idx, seen)
93
+ end
94
+ fns
95
+ end
96
+
97
+ def table_fn(elem)
98
+ !@jcgm && !elem.ancestors("quote").empty? and return
99
+ super
100
+ end
101
+
102
+ def non_document_footnotes(docxml)
103
+ table_fns = docxml.xpath(ns("//table//fn")) -
104
+ docxml.xpath(ns("//table/name//fn"))
105
+ @jcgm or table_fns -= docxml.xpath(ns("//quote//table//fn"))
106
+ fig_fns = docxml.xpath(ns("//figure//fn")) -
107
+ docxml.xpath(ns("//figure/name//fn"))
108
+ table_fns + fig_fns
109
+ end
110
+ end
111
+ end
112
+ end
@@ -6,6 +6,7 @@ require_relative "doccontrol"
6
6
  require_relative "../../relaton/render/general"
7
7
  require_relative "presentation_blocks"
8
8
  require_relative "presentation_biblio"
9
+ require_relative "presentation_footnotes"
9
10
 
10
11
  module IsoDoc
11
12
  module Bipm
@@ -107,12 +108,6 @@ module IsoDoc
107
108
  jcgm_eref(docxml, "//fmt-origin[not(.//termref)]")
108
109
  end
109
110
 
110
- # KILL
111
- def quotesourcex(docxml)
112
- super
113
- jcgm_eref(docxml, "//quote//source")
114
- end
115
-
116
111
  def jcgm_eref(docxml, xpath)
117
112
  @jcgm or return
118
113
  docxml.xpath(ns(xpath)).each { |x| extract_brackets(x) }
@@ -145,48 +140,6 @@ module IsoDoc
145
140
  end
146
141
  end
147
142
 
148
- # KILL
149
- def termsource1_xx(elem)
150
- # elem["status"] == "modified" and return super
151
- while elem&.next_element&.name == "termsource"
152
- elem << "; #{to_xml(elem.next_element.remove.children)}"
153
- end
154
- elem.children = l10n("[#{termsource_adapt(elem['status'])}" \
155
- "#{to_xml(elem.children).strip}]")
156
- end
157
-
158
- def termsource_label(elem, sources)
159
- elem.replace(l10n("[#{termsource_adapt(elem['status'])} #{sources}]"))
160
- end
161
-
162
- def termsource_adapt(status)
163
- case status
164
- when "adapted" then @i18n.adapted_from
165
- when "modified" then @i18n.modified_from
166
- else ""
167
- end
168
- end
169
-
170
- def termsource(docxml)
171
- termsource_insert_empty_modification(docxml)
172
- super
173
- end
174
-
175
- def termsource_insert_empty_modification(docxml)
176
- docxml.xpath("//xmlns:termsource[@status = 'modified']" \
177
- "[not(xmlns:modification)]").each do |f|
178
- f << "<modification/>"
179
- end
180
- end
181
-
182
- def termsource_modification(elem)
183
- # if elem["status"] == "modified"
184
- # origin = elem.at(ns("./origin"))
185
- # s = termsource_status(elem["status"]) and origin.next = l10n(", #{s}")
186
- # end
187
- termsource_add_modification_text(elem.at(ns("./modification")))
188
- end
189
-
190
143
  def enable_indexsect
191
144
  true
192
145
  end
@@ -205,35 +158,6 @@ module IsoDoc
205
158
  @xrefs.bookmark_anchor_names(docxml)
206
159
  end
207
160
 
208
- def fn_label_brackets(fnote)
209
- "<sup><span class='fmt-label-delim'>(</span>" \
210
- "#{fn_label(fnote)}" \
211
- "<span class='fmt-label-delim'>)</span></sup>"
212
- end
213
-
214
- def fn_ref_label(fnote)
215
- if @jcgm then iso_fn_ref_label(fnote)
216
- else fn_label_brackets(fnote)
217
- end
218
- end
219
-
220
- # copied from ISO
221
- def iso_fn_ref_label(fnote)
222
- if fnote.ancestors("table, figure").empty? ||
223
- !fnote.ancestors("name, fmt-name").empty?
224
- "<sup>#{fn_label(fnote)}" \
225
- "<span class='fmt-label-delim'>)</span></sup>"
226
- else
227
- "<sup>#{fn_label(fnote)}</sup>"
228
- end
229
- end
230
-
231
- def fn_body_label(fnote)
232
- if @jcgm then super
233
- else fn_label_brackets(fnote)
234
- end
235
- end
236
-
237
161
  include Init
238
162
  end
239
163
  end