metanorma-iso 3.5.32 → 3.5.34

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4cd7f51f339252af4d3357f7a016678dced9cc60cc50f228ec7e5f2aa6e945c4
4
- data.tar.gz: e052eacd1739c20d62da75d503ea87b830853fb3f461ef682c5b9a44ec87cb72
3
+ metadata.gz: d765b523da4b9198769810cdbf0120dcdf6321392f1ac9e620ade11d7d3cb973
4
+ data.tar.gz: 17e01d22e019bbc217120f8a67e1ce8d458a443ae575a816a9f188181fd63f49
5
5
  SHA512:
6
- metadata.gz: 42483b14c89ce8a2c3d64578251b7325a5187b71a3f34226f44f10997a8e46ab881ff9c85549699423fff2cee8bdf3fc92744835a5cafa6b3c2dc198bb99e9de
7
- data.tar.gz: 50afbf315e333d736e6f9efec0dfa0ee92606e6cb3d567d7cddd899813beccd043228b2132f0268e65f3efdc97605c82ddb59709160e30a95f6e873be3b2b0cb
6
+ metadata.gz: 32f668b9aa28be718844160bde3df8f935e60d95931093c1b8440457c825fdc55916bcd860e5f94a9122c8d23e915a30aa7df57658444aebce7259cb108c773c
7
+ data.tar.gz: ce741eca2f4a4f28a5e25d68dbc37c86b9386093f9b63fd11473dc844f0b41a0e4df89e1aee4dc0254c5024883bf0844be02445527d6b7645fb5e65d2ff22b1d
@@ -3,8 +3,9 @@
3
3
  <xsl:output method="xml" encoding="UTF-8" indent="no"/>
4
4
 
5
5
  <xsl:key name="kfn" match="mn:fn[not(ancestor::*[self::mn:table or self::mn:figure or self::mn:localized-strings] and not(ancestor::mn:fmt-name))]" use="@reference"/>
6
-
7
6
  <xsl:key name="kid" match="*" use="@id"/>
7
+ <xsl:key name="ktitle_caption_label" match="mn:fmt-title" use="translate(normalize-space(.//mn:span[@class = 'fmt-caption-label']), ' ()', '')"/>
8
+ <xsl:key name="kname_caption_label" match="mn:fmt-name" use="translate(normalize-space(.//mn:span[@class = 'fmt-caption-label']), ' ()', '')"/>
8
9
 
9
10
  <xsl:key name="attachments" match="mn:fmt-eref[java:endsWith(java:java.lang.String.new(@bibitemid),'.exp')]" use="@bibitemid"/>
10
11
  <xsl:key name="attachments2" match="mn:fmt-eref[contains(@bibitemid,'.exp_')]" use="@bibitemid"/>
@@ -252,12 +253,24 @@
252
253
  <xsl:variable name="doctype"><xsl:call-template name="getDoctype"/></xsl:variable>
253
254
  <doctype><xsl:value-of select="$doctype"/></doctype>
254
255
 
255
- <xsl:variable name="doctype_localized_" select="$contextNode/mn:ext/mn:doctype[@language = $lang]"/>
256
+ <xsl:variable name="doctype_localized_" select="normalize-space($contextNode/mn:ext/mn:doctype[@language = $lang])"/>
257
+ <!-- https://github.com/metanorma/mn-native-pdf/issues/1136 -->
258
+ <xsl:variable name="doctype_localized__">
259
+ <xsl:if test="$doctype_localized_ = '' and count($contextNode/mn:ext/mn:doctype) = 1 and normalize-space($contextNode/mn:ext/mn:doctype[not(@language)]) != ''">
260
+ <!-- example: <localized-string key="doctype_dict.international-standard" language="en">International Standard</localized-string> -->
261
+ <xsl:variable name="key"><xsl:value-of select="concat('doctype_dict.', $doctype)"/></xsl:variable>
262
+ <xsl:value-of select="/mn:metanorma/mn:localized-strings/mn:localized-string[@key = $key]"/>
263
+ </xsl:if>
264
+ </xsl:variable>
265
+
256
266
  <xsl:variable name="doctype_localized">
257
267
  <xsl:choose>
258
268
  <xsl:when test="$doctype_localized_ != ''">
259
269
  <xsl:value-of select="translate(normalize-space($doctype_localized_),'-',' ')"/>
260
270
  </xsl:when>
271
+ <xsl:when test="$doctype_localized__ != ''">
272
+ <xsl:value-of select="$doctype_localized__"/>
273
+ </xsl:when>
261
274
  <xsl:otherwise>
262
275
  <xsl:value-of select="translate(normalize-space($doctype),'-',' ')"/>
263
276
  </xsl:otherwise>
@@ -273,7 +286,22 @@
273
286
  <xsl:variable name="stagename_abbreviation" select="normalize-space($contextNode/mn:ext/mn:stagename/@abbreviation)"/>
274
287
  <stagename_abbreviation><xsl:value-of select="$stagename_abbreviation"/></stagename_abbreviation>
275
288
 
276
- <xsl:variable name="stagename_localized" select="normalize-space($contextNode/mn:status/mn:stage[@language = $lang])"/>
289
+ <xsl:variable name="stagename_localized_" select="normalize-space($contextNode/mn:status/mn:stage[@language = $lang])"/>
290
+ <!-- https://github.com/metanorma/mn-native-pdf/issues/1136 -->
291
+ <xsl:variable name="stagename_localized__">
292
+ <xsl:if test="$stagename_localized_ = '' and count($contextNode/mn:status/mn:stage) = 1">
293
+ <!-- example: <localized-string key="60.international-standard" language="en">International Standard</localized-string> -->
294
+ <xsl:variable name="key"><xsl:value-of select="concat(normalize-space($contextNode/mn:status/mn:stage[not(@language)]), '.', $doctype)"/></xsl:variable>
295
+ <xsl:value-of select="/mn:metanorma/mn:localized-strings/mn:localized-string[@key = $key]"/>
296
+ </xsl:if>
297
+ </xsl:variable>
298
+ <xsl:variable name="stagename_localized___">
299
+ <xsl:choose>
300
+ <xsl:when test="$stagename_localized_ != ''"><xsl:value-of select="$stagename_localized_"/></xsl:when>
301
+ <xsl:otherwise><xsl:value-of select="$stagename_localized__"/></xsl:otherwise>
302
+ </xsl:choose>
303
+ </xsl:variable>
304
+ <xsl:variable name="stagename_localized" select="normalize-space($stagename_localized___)"/>
277
305
  <stagename_localized><xsl:value-of select="$stagename_localized"/></stagename_localized>
278
306
 
279
307
  <stagename_localized_coverpage><xsl:copy-of select="$contextNode/mn:status/mn:stage[@language = $lang and @type = 'coverpage']/node()"/></stagename_localized_coverpage>
@@ -537,8 +565,6 @@
537
565
  </xsl:variable> <!-- END: contents_ -->
538
566
  <xsl:variable name="contents" select="xalan:nodeset($contents_)"/>
539
567
 
540
- <xsl:variable name="XML" select="/"/>
541
-
542
568
  <xsl:template name="layout-master-set">
543
569
  <fo:layout-master-set>
544
570
 
@@ -1108,7 +1134,7 @@
1108
1134
  </fo:inline>
1109
1135
  </fo:block>
1110
1136
 
1111
- <xsl:if test="$contextNode/mn:keyword">
1137
+ <xsl:if test="normalize-space($contextNode/mn:keyword) != ''">
1112
1138
  <fo:block margin-top="6pt">
1113
1139
  <fo:inline font-weight="bold"><xsl:value-of select="$i18n_descriptors"/> : </fo:inline>
1114
1140
  <xsl:call-template name="insertKeywords">
@@ -1204,6 +1230,7 @@
1204
1230
  <!-- Example: title-intro fr -->
1205
1231
  <xsl:call-template name="insertTitlesLangOther">
1206
1232
  <xsl:with-param name="num" select="$num"/>
1233
+ <xsl:with-param name="contextNode" select="$contextNode"/>
1207
1234
  <xsl:with-param name="lang_other" select="$lang_other_"/>
1208
1235
  </xsl:call-template>
1209
1236
  </fo:block>
@@ -1749,7 +1776,7 @@
1749
1776
  </fo:inline>
1750
1777
  </fo:block>
1751
1778
 
1752
- <xsl:if test="$contextNode/mn:keyword">
1779
+ <xsl:if test="normalize-space($contextNode/mn:keyword) != ''">
1753
1780
  <fo:block margin-top="10pt">
1754
1781
  <fo:inline font-weight="bold"><xsl:value-of select="$i18n_descriptors"/> : </fo:inline>
1755
1782
  <xsl:call-template name="insertKeywords">
@@ -1858,6 +1885,7 @@
1858
1885
  <!-- Example: title-intro fr -->
1859
1886
  <xsl:call-template name="insertTitlesLangOther">
1860
1887
  <xsl:with-param name="num" select="$num"/>
1888
+ <xsl:with-param name="contextNode" select="$contextNode"/>
1861
1889
  <xsl:with-param name="lang_other" select="$lang_other_"/>
1862
1890
  </xsl:call-template>
1863
1891
  </fo:block>
@@ -1946,6 +1974,7 @@
1946
1974
  <!-- Example: title-intro fr -->
1947
1975
  <xsl:call-template name="insertTitlesLangOther">
1948
1976
  <xsl:with-param name="num" select="$num"/>
1977
+ <xsl:with-param name="contextNode" select="$contextNode"/>
1949
1978
  <xsl:with-param name="lang_other" select="$lang_other_"/>
1950
1979
  </xsl:call-template>
1951
1980
  </fo:block>
@@ -2101,6 +2130,7 @@
2101
2130
  <fo:block-container font-family="Cambria" line-height="1.1" role="SKIP" height="110mm" id="{concat('__internal_layout__coverpage_p_title_', $num , '_', generate-id())}">
2102
2131
  <!-- for role see coment https://github.com/pdf-association/extension-brotli/issues/5#issuecomment-3931742869 -->
2103
2132
  <fo:block margin-right="3.5mm" role="P/Title"> <!-- role="SKIP" -->
2133
+
2104
2134
  <fo:block font-size="18pt" font-weight="bold" margin-top="2.5mm" role="SKIP"> <!-- role="H1" -->
2105
2135
  <xsl:call-template name="insertTitlesLangMain"><xsl:with-param name="num" select="$num"/></xsl:call-template>
2106
2136
  </fo:block>
@@ -2113,6 +2143,7 @@
2113
2143
  <!-- Example: title-intro fr -->
2114
2144
  <xsl:call-template name="insertTitlesLangOther">
2115
2145
  <xsl:with-param name="num" select="$num"/>
2146
+ <xsl:with-param name="contextNode" select="$contextNode"/>
2116
2147
  <xsl:with-param name="lang_other" select="$lang_other_"/>
2117
2148
  </xsl:call-template>
2118
2149
  </fo:block>
@@ -2161,7 +2192,7 @@
2161
2192
  <!-- </xsl:if>
2162
2193
 
2163
2194
  <xsl:if test="$doctype = 'amendment' and not($stage-abbreviation = 'FDAMD' or $stage-abbreviation = 'FDAM')"> -->
2164
- <xsl:if test="$contextNode/mn:date[@type = 'updated']">
2195
+ <xsl:if test="normalize-space($contextNode/mn:date[@type = 'updated']) != ''">
2165
2196
  <fo:block font-size="18pt" font-weight="bold" margin-bottom="3mm">
2166
2197
  <xsl:value-of select="$contextNode/mn:date[@type = 'updated']"/>
2167
2198
  </fo:block>
@@ -2555,6 +2586,7 @@
2555
2586
  <!-- Example: title-intro fr -->
2556
2587
  <xsl:call-template name="insertTitlesLangOther">
2557
2588
  <xsl:with-param name="num" select="$num"/>
2589
+ <xsl:with-param name="contextNode" select="$contextNode"/>
2558
2590
  <xsl:with-param name="lang_other" select="$lang_other_"/>
2559
2591
  </xsl:call-template>
2560
2592
  </fo:block>
@@ -2818,6 +2850,7 @@
2818
2850
  <!-- Example: title-intro fr -->
2819
2851
  <xsl:call-template name="insertTitlesLangOther">
2820
2852
  <xsl:with-param name="num" select="$num"/>
2853
+ <xsl:with-param name="contextNode" select="$contextNode"/>
2821
2854
  <xsl:with-param name="lang_other" select="$lang_other_"/>
2822
2855
  </xsl:call-template>
2823
2856
  </fo:block>
@@ -2949,6 +2982,7 @@
2949
2982
  <!-- Example: title-intro fr -->
2950
2983
  <xsl:call-template name="insertTitlesLangOther">
2951
2984
  <xsl:with-param name="num" select="$num"/>
2985
+ <xsl:with-param name="contextNode" select="$contextNode"/>
2952
2986
  <xsl:with-param name="lang_other" select="$lang_other_"/>
2953
2987
  </xsl:call-template>
2954
2988
  </fo:block>
@@ -2974,7 +3008,7 @@
2974
3008
 
2975
3009
  <fo:block-container text-align="right" role="SKIP">
2976
3010
  <xsl:choose>
2977
- <xsl:when test="$contextNode/mn:docidentifier[@type = 'iso-tc']">
3011
+ <xsl:when test="normalize-space($contextNode/mn:docidentifier[@type = 'iso-tc']) != ''">
2978
3012
  <!-- 17301 -->
2979
3013
  <fo:block font-size="14pt" font-weight="bold" margin-bottom="12pt">
2980
3014
  <xsl:value-of select="$contextNode/mn:docidentifier[@type = 'iso-tc']"/>
@@ -3026,6 +3060,7 @@
3026
3060
  <!-- Example: title-intro fr -->
3027
3061
  <xsl:call-template name="insertTitlesLangOther">
3028
3062
  <xsl:with-param name="num" select="$num"/>
3063
+ <xsl:with-param name="contextNode" select="$contextNode"/>
3029
3064
  <xsl:with-param name="lang_other" select="$lang_other_"/>
3030
3065
  </xsl:call-template>
3031
3066
  </fo:block>
@@ -3229,7 +3264,7 @@
3229
3264
  <xsl:param name="content-height"/>
3230
3265
  <xsl:variable name="contextNode" select="xalan:evaluate($bibdataContextNode)"/>
3231
3266
  <xsl:choose>
3232
- <xsl:when test="$contextNode/mn:contributor[mn:role[@type = 'author']/mn:description = 'committee']/mn:organization">
3267
+ <xsl:when test="normalize-space($contextNode/mn:contributor[mn:role[@type = 'author']/mn:description = 'committee']/mn:organization) != ''">
3233
3268
  <xsl:for-each select="$contextNode/mn:contributor[mn:role[@type = 'author']/mn:description = 'committee']/mn:organization">
3234
3269
 
3235
3270
  <xsl:variable name="items">
@@ -3337,7 +3372,7 @@
3337
3372
  <xsl:variable name="content-height">20</xsl:variable>
3338
3373
  <xsl:variable name="contextNode" select="xalan:evaluate($bibdataContextNode)"/>
3339
3374
  <xsl:choose>
3340
- <xsl:when test="$contextNode/mn:contributor[mn:role[@type = 'author']/mn:description = 'committee']/mn:organization[mn:abbreviation]">
3375
+ <xsl:when test="normalize-space($contextNode/mn:contributor[mn:role[@type = 'author']/mn:description = 'committee']/mn:organization[mn:abbreviation]) != ''">
3341
3376
  <xsl:for-each select="$contextNode/mn:contributor[mn:role[@type = 'author']/mn:description = 'committee']/mn:organization[mn:abbreviation]">
3342
3377
  <xsl:variable name="items">
3343
3378
  <xsl:call-template name="split_abbreviation"/>
@@ -3475,15 +3510,16 @@
3475
3510
 
3476
3511
  <xsl:template name="insertTitlesLangOther">
3477
3512
  <xsl:param name="num"/>
3513
+ <xsl:param name="contextNode"/>
3478
3514
  <xsl:param name="lang_other"/>
3479
- <xsl:apply-templates select="$XML/mn:metanorma/mn:bibdata/mn:title[@language = $lang_other and @type = 'title-intro']"/>
3480
- <xsl:apply-templates select="$XML/mn:metanorma/mn:bibdata/mn:title[@language = $lang_other and @type = 'title-main']"/>
3481
- <xsl:apply-templates select="$XML/mn:metanorma/mn:bibdata/mn:title[@language = $lang_other and @type = 'title-complementary']"/>
3482
- <xsl:apply-templates select="$XML/mn:metanorma/mn:bibdata/mn:title[@language = $lang_other and @type = 'title-part']">
3515
+ <xsl:apply-templates select="$contextNode/mn:title[@language = $lang_other and @type = 'title-intro']"/>
3516
+ <xsl:apply-templates select="$contextNode/mn:title[@language = $lang_other and @type = 'title-main']"/>
3517
+ <xsl:apply-templates select="$contextNode/mn:title[@language = $lang_other and @type = 'title-complementary']"/>
3518
+ <xsl:apply-templates select="$contextNode/mn:title[@language = $lang_other and @type = 'title-part']">
3483
3519
  <xsl:with-param name="num" select="$num"/>
3484
3520
  <xsl:with-param name="curr_lang" select="$lang_other"/>
3485
3521
  </xsl:apply-templates>
3486
- <xsl:apply-templates select="$XML/mn:metanorma/mn:bibdata/mn:title[@language = $lang_other and @type = 'title-amd']">
3522
+ <xsl:apply-templates select="$contextNode/mn:title[@language = $lang_other and @type = 'title-amd']">
3487
3523
  <xsl:with-param name="num" select="$num"/>
3488
3524
  <xsl:with-param name="curr_lang" select="$lang_other"/>
3489
3525
  </xsl:apply-templates>
@@ -3514,13 +3550,13 @@
3514
3550
  <xsl:value-of select="$edition"/>
3515
3551
  <xsl:variable name="date">
3516
3552
  <xsl:choose>
3517
- <xsl:when test="($stage-abbreviation = 'NWIP' or $stage-abbreviation = 'NP' or $stage-abbreviation = 'PWI' or $stage-abbreviation = 'AWI' or $stage-abbreviation = 'WD' or $stage-abbreviation = 'CD' or $stage-abbreviation = 'FDIS' or $stagename_abbreviation = 'FDIS') and $contextNode/mn:version/mn:revision-date">
3553
+ <xsl:when test="($stage-abbreviation = 'NWIP' or $stage-abbreviation = 'NP' or $stage-abbreviation = 'PWI' or $stage-abbreviation = 'AWI' or $stage-abbreviation = 'WD' or $stage-abbreviation = 'CD' or $stage-abbreviation = 'FDIS' or $stagename_abbreviation = 'FDIS') and normalize-space($contextNode/mn:version/mn:revision-date) != ''">
3518
3554
  <xsl:value-of select="$contextNode/mn:version/mn:revision-date"/>
3519
3555
  </xsl:when>
3520
- <xsl:when test="$stage-abbreviation = 'IS' and /mn:metanorma/mn:bibdata/mn:date[@type = 'published']">
3556
+ <xsl:when test="$stage-abbreviation = 'IS' and normalize-space($contextNode/mn:date[@type = 'published']) != ''">
3521
3557
  <xsl:value-of select="$contextNode/mn:date[@type = 'published']"/>
3522
3558
  </xsl:when>
3523
- <xsl:when test="($stage-abbreviation = 'IS' or $stage-abbreviation = 'D') and $contextNode/mn:date[@type = 'created']">
3559
+ <xsl:when test="($stage-abbreviation = 'IS' or $stage-abbreviation = 'D') and normalize-space($contextNode/mn:date[@type = 'created']) != ''">
3524
3560
  <xsl:value-of select="$contextNode/mn:date[@type = 'created']"/>
3525
3561
  </xsl:when>
3526
3562
  <xsl:when test="$stage-abbreviation = 'IS' or $stage-abbreviation = 'PRF' or $stage_published = 'true'">
@@ -4016,7 +4052,7 @@
4016
4052
  <!-- ==================== -->
4017
4053
  <!-- display titles -->
4018
4054
  <!-- ==================== -->
4019
- <xsl:template match="mn:bibdata/mn:title[@type = 'title-intro']">
4055
+ <xsl:template match="mn:bibdata/mn:title[@type = 'title-intro'] | mn:bibdata//mn:relation/mn:bibitem/mn:title[@type = 'title-intro']">
4020
4056
  <xsl:variable name="layoutVersion">
4021
4057
  <xsl:call-template name="getVariable"><xsl:with-param name="variable">layoutVersion</xsl:with-param></xsl:call-template>
4022
4058
  </xsl:variable>
@@ -4031,7 +4067,7 @@
4031
4067
  </xsl:choose>
4032
4068
  </xsl:template>
4033
4069
 
4034
- <xsl:template match="mn:bibdata/mn:title[@type = 'title-main']">
4070
+ <xsl:template match="mn:bibdata/mn:title[@type = 'title-main'] | mn:bibdata//mn:relation/mn:bibitem/mn:title[@type = 'title-main']">
4035
4071
  <xsl:param name="body">false</xsl:param>
4036
4072
  <xsl:variable name="layoutVersion">
4037
4073
  <xsl:call-template name="getVariable"><xsl:with-param name="variable">layoutVersion</xsl:with-param></xsl:call-template>
@@ -4060,13 +4096,13 @@
4060
4096
  </xsl:choose>
4061
4097
  </xsl:template>
4062
4098
 
4063
- <xsl:template match="mn:bibdata/mn:title[@type = 'title-complementary']">
4099
+ <xsl:template match="mn:bibdata/mn:title[@type = 'title-complementary'] | mn:bibdata//mn:relation/mn:bibitem/mn:title[@type = 'title-complementary']">
4064
4100
  <xsl:param name="body">false</xsl:param>
4065
4101
  <xsl:value-of select="$nonbreak_space_em_dash_space"/>
4066
4102
  <xsl:apply-templates/>
4067
4103
  </xsl:template>
4068
4104
 
4069
- <xsl:template match="mn:bibdata/mn:title[@type = 'title-part']">
4105
+ <xsl:template match="mn:bibdata/mn:title[@type = 'title-part'] | mn:bibdata//mn:relation/mn:bibitem/mn:title[@type = 'title-part']">
4070
4106
  <xsl:param name="num"/>
4071
4107
  <xsl:param name="curr_lang" select="$lang"/>
4072
4108
  <xsl:param name="isMainLang">false</xsl:param>
@@ -4154,7 +4190,7 @@
4154
4190
  </xsl:choose>
4155
4191
  </xsl:template>
4156
4192
 
4157
- <xsl:template match="mn:bibdata/mn:title[@type = 'title-amd']">
4193
+ <xsl:template match="mn:bibdata/mn:title[@type = 'title-amd'] | mn:bibdata//mn:relation/mn:bibitem/mn:title[@type = 'title-amd']">
4158
4194
  <xsl:param name="num"/>
4159
4195
  <xsl:param name="isMainLang">false</xsl:param>
4160
4196
  <xsl:param name="curr_lang" select="$lang"/>
@@ -6027,7 +6063,7 @@
6027
6063
  </xsl:choose> -->
6028
6064
  </fo:block>
6029
6065
  <xsl:variable name="font-size_footer_copyright"><xsl:call-template name="get_font-size_footer_copyright"><xsl:with-param name="num" select="$num"/></xsl:call-template></xsl:variable>
6030
- <xsl:if test="$contextNode/mn:keyword">
6066
+ <xsl:if test="normalize-space($contextNode/mn:keyword) != ''">
6031
6067
  <fo:block font-size="{$font-size_footer_copyright}" margin-bottom="6pt">
6032
6068
  <fo:inline font-weight="bold"><xsl:value-of select="$i18n_descriptors"/>: </fo:inline>
6033
6069
  <xsl:call-template name="insertKeywords">
@@ -7305,8 +7341,24 @@
7305
7341
  <xsl:if test="$docnum != '1'">_<xsl:value-of select="$docnum"/></xsl:if>
7306
7342
  </xsl:variable>
7307
7343
  <xsl:variable name="named_dest_doc" select="normalize-space($named_dest_doc_)"/>
7308
- <xsl:if test="not(key('kid', $named_dest_doc))"> <!-- if element with id '$named_dest_doc' doesn't exist in the document -->
7309
- <xsl:attribute name="named_dest"><xsl:value-of select="normalize-space($named_dest_doc)"/></xsl:attribute>
7344
+ <xsl:variable name="named_dest_unique_">
7345
+ <xsl:choose>
7346
+ <xsl:when test="normalize-space($caption_label) != '' and self::mn:fmt-name and count(key('kname_caption_label', $caption_label)) &gt; 1">
7347
+ <!-- duplicate caption numbers across clauses (e.g. two "Table 1" in front matter): qualify with the owner element id so fo ids stay unique -->
7348
+ <xsl:value-of select="concat(normalize-space($named_dest_doc), '_', ancestor::*[@id][1]/@id)"/>
7349
+ </xsl:when>
7350
+ <xsl:when test="normalize-space($caption_label) != '' and self::mn:fmt-title and count(key('ktitle_caption_label', $caption_label)) &gt; 1">
7351
+ <!-- duplicate clauses's caption numbers: qualify with the owner element id so fo ids stay unique -->
7352
+ <xsl:value-of select="concat(normalize-space($named_dest_doc), '_', ancestor::*[@id][1]/@id)"/>
7353
+ </xsl:when>
7354
+ <xsl:otherwise>
7355
+ <xsl:value-of select="normalize-space($named_dest_doc)"/>
7356
+ </xsl:otherwise>
7357
+ </xsl:choose>
7358
+ </xsl:variable>
7359
+ <xsl:variable name="named_dest_unique" select="normalize-space($named_dest_unique_)"/>
7360
+ <xsl:if test="$named_dest_unique != '' and not(key('kid', $named_dest_unique))"> <!-- if element with id '$named_dest_unique' doesn't exist in the document -->
7361
+ <xsl:attribute name="named_dest"><xsl:value-of select="$named_dest_unique"/></xsl:attribute>
7310
7362
  </xsl:if>
7311
7363
  </xsl:if>
7312
7364
  </xsl:template>
@@ -15959,8 +16011,30 @@
15959
16011
  <xsl:choose>
15960
16012
  <xsl:when test=".//*[local-name() = 'a'][*[local-name() = 'rect'] or *[local-name() = 'polygon'] or *[local-name() = 'circle'] or *[local-name() = 'ellipse']]">
15961
16013
  <fo:block>
15962
- <xsl:variable name="width" select="@width"/>
15963
- <xsl:variable name="height" select="@height"/>
16014
+ <!-- fallback for a size that is not a positive finite px number (missing, %, em, NaN, negative, huge):
16015
+ the svg_update default, i.e. the viewBox dimension, else 400 -->
16016
+ <xsl:variable name="vb" select="normalize-space(@viewBox)"/>
16017
+ <xsl:variable name="vb_width" select="number(substring-before(concat(substring-after(substring-after($vb, ' '), ' '), ' '), ' '))"/>
16018
+ <xsl:variable name="vb_height" select="number(substring-before(concat(substring-after(substring-after(substring-after($vb, ' '), ' '), ' '), ' '), ' '))"/>
16019
+
16020
+ <!-- strip a case-insensitive px suffix, trim NBSP, accept only a positive finite number -->
16021
+ <xsl:variable name="width_num" select="number(normalize-space(java:replaceAll(java:java.lang.String.new(normalize-space(translate(@width, ' ', ' '))), '(?i)px$', '')))"/>
16022
+ <xsl:variable name="height_num" select="number(normalize-space(java:replaceAll(java:java.lang.String.new(normalize-space(translate(@height, ' ', ' '))), '(?i)px$', '')))"/>
16023
+
16024
+ <xsl:variable name="width">
16025
+ <xsl:choose>
16026
+ <xsl:when test="$width_num &gt; 0 and $width_num - $width_num = 0"><xsl:value-of select="$width_num"/></xsl:when>
16027
+ <xsl:when test="$vb_width &gt; 0 and $vb_width - $vb_width = 0"><xsl:value-of select="round($vb_width)"/></xsl:when>
16028
+ <xsl:otherwise>400</xsl:otherwise>
16029
+ </xsl:choose>
16030
+ </xsl:variable>
16031
+ <xsl:variable name="height">
16032
+ <xsl:choose>
16033
+ <xsl:when test="$height_num &gt; 0 and $height_num - $height_num = 0"><xsl:value-of select="$height_num"/></xsl:when>
16034
+ <xsl:when test="$vb_height &gt; 0 and $vb_height - $vb_height = 0"><xsl:value-of select="round($vb_height)"/></xsl:when>
16035
+ <xsl:otherwise>400</xsl:otherwise>
16036
+ </xsl:choose>
16037
+ </xsl:variable>
15964
16038
 
15965
16039
  <xsl:variable name="scale_x">
15966
16040
  <xsl:choose>
@@ -16208,13 +16282,26 @@
16208
16282
  </xsl:copy>
16209
16283
  </xsl:template>
16210
16284
 
16285
+ <!-- embedded svg length: keep a valid unitless or lowercase px value as written; write a positive finite
16286
+ px value without its unit (no NBSP/case/space residue); otherwise the svg_update default 400 (Batik rejects raw px/%/NBSP/negative) -->
16287
+ <xsl:template name="svg_length">
16288
+ <xsl:variable name="raw" select="normalize-space(translate(., ' ', ' '))"/>
16289
+ <xsl:variable name="num" select="number(normalize-space(java:replaceAll(java:java.lang.String.new($raw), '(?i)px$', '')))"/>
16290
+ <xsl:choose>
16291
+ <xsl:when test="number($raw) &gt; 0 and number($raw) - number($raw) = 0"><xsl:value-of select="$raw"/></xsl:when>
16292
+ <xsl:when test="$num &gt; 0 and $num - $num = 0 and substring($raw, string-length($raw) - 1) = 'px'"><xsl:value-of select="$raw"/></xsl:when>
16293
+ <xsl:when test="$num &gt; 0 and $num - $num = 0"><xsl:value-of select="$num"/></xsl:when>
16294
+ <xsl:otherwise>400</xsl:otherwise>
16295
+ </xsl:choose>
16296
+ </xsl:template>
16297
+
16211
16298
  <xsl:template match="*[local-name() = 'svg']/@width" mode="svg_update">
16212
16299
  <!-- image[@width]/svg -->
16213
16300
  <xsl:variable name="parent_image_width" select="normalize-space(ancestor::*[2][self::mn:image]/@width)"/>
16214
16301
  <xsl:attribute name="width">
16215
16302
  <xsl:choose>
16216
16303
  <xsl:when test="$parent_image_width != '' and normalize-space(java:matches(java:java.lang.String.new($parent_image_width), $regex_starts_with_digit)) = 'true'"><xsl:value-of select="$parent_image_width"/></xsl:when>
16217
- <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
16304
+ <xsl:otherwise><xsl:call-template name="svg_length"/></xsl:otherwise>
16218
16305
  </xsl:choose>
16219
16306
  </xsl:attribute>
16220
16307
  </xsl:template>
@@ -16225,7 +16312,7 @@
16225
16312
  <xsl:attribute name="height">
16226
16313
  <xsl:choose>
16227
16314
  <xsl:when test="$parent_image_height != '' and normalize-space(java:matches(java:java.lang.String.new($parent_image_height), $regex_starts_with_digit)) = 'true'"><xsl:value-of select="$parent_image_height"/></xsl:when>
16228
- <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
16315
+ <xsl:otherwise><xsl:call-template name="svg_length"/></xsl:otherwise>
16229
16316
  </xsl:choose>
16230
16317
  </xsl:attribute>
16231
16318
  </xsl:template>
@@ -21948,13 +22035,23 @@
21948
22035
  <xsl:param name="letter-spacing" select="'0.15'"/>
21949
22036
  <xsl:if test="string-length($text) &gt; 0">
21950
22037
  <xsl:variable name="char" select="substring($text, 1, 1)"/>
21951
- <fo:inline padding-right="{$letter-spacing}mm">
21952
- <xsl:if test="$char = '®'">
21953
- <xsl:attribute name="font-size">58%</xsl:attribute>
21954
- <xsl:attribute name="baseline-shift">30%</xsl:attribute>
21955
- </xsl:if>
21956
- <xsl:value-of select="$char"/>
21957
- </fo:inline>
22038
+ <xsl:choose>
22039
+ <xsl:when test="contains($letter-spacing, 'em') or contains($letter-spacing, 'mm')">
22040
+ <!-- for negative letter spacing (in em) -->
22041
+ <fo:inline letter-spacing="{$letter-spacing}">
22042
+ <xsl:value-of select="$char"/>
22043
+ </fo:inline>
22044
+ </xsl:when>
22045
+ <xsl:otherwise>
22046
+ <fo:inline padding-right="{$letter-spacing}mm">
22047
+ <xsl:if test="$char = '®'">
22048
+ <xsl:attribute name="font-size">58%</xsl:attribute>
22049
+ <xsl:attribute name="baseline-shift">30%</xsl:attribute>
22050
+ </xsl:if>
22051
+ <xsl:value-of select="$char"/>
22052
+ </fo:inline>
22053
+ </xsl:otherwise>
22054
+ </xsl:choose>
21958
22055
  <xsl:call-template name="add-letter-spacing">
21959
22056
  <xsl:with-param name="text" select="substring($text, 2)"/>
21960
22057
  <xsl:with-param name="letter-spacing" select="$letter-spacing"/>
@@ -3,8 +3,9 @@
3
3
  <xsl:output method="xml" encoding="UTF-8" indent="no"/>
4
4
 
5
5
  <xsl:key name="kfn" match="mn:fn[not(ancestor::*[self::mn:table or self::mn:figure or self::mn:localized-strings] and not(ancestor::mn:fmt-name))]" use="@reference"/>
6
-
7
6
  <xsl:key name="kid" match="*" use="@id"/>
7
+ <xsl:key name="ktitle_caption_label" match="mn:fmt-title" use="translate(normalize-space(.//mn:span[@class = 'fmt-caption-label']), ' ()', '')"/>
8
+ <xsl:key name="kname_caption_label" match="mn:fmt-name" use="translate(normalize-space(.//mn:span[@class = 'fmt-caption-label']), ' ()', '')"/>
8
9
 
9
10
  <xsl:key name="attachments" match="mn:fmt-eref[java:endsWith(java:java.lang.String.new(@bibitemid),'.exp')]" use="@bibitemid"/>
10
11
  <xsl:key name="attachments2" match="mn:fmt-eref[contains(@bibitemid,'.exp_')]" use="@bibitemid"/>
@@ -252,12 +253,24 @@
252
253
  <xsl:variable name="doctype"><xsl:call-template name="getDoctype"/></xsl:variable>
253
254
  <doctype><xsl:value-of select="$doctype"/></doctype>
254
255
 
255
- <xsl:variable name="doctype_localized_" select="$contextNode/mn:ext/mn:doctype[@language = $lang]"/>
256
+ <xsl:variable name="doctype_localized_" select="normalize-space($contextNode/mn:ext/mn:doctype[@language = $lang])"/>
257
+ <!-- https://github.com/metanorma/mn-native-pdf/issues/1136 -->
258
+ <xsl:variable name="doctype_localized__">
259
+ <xsl:if test="$doctype_localized_ = '' and count($contextNode/mn:ext/mn:doctype) = 1 and normalize-space($contextNode/mn:ext/mn:doctype[not(@language)]) != ''">
260
+ <!-- example: <localized-string key="doctype_dict.international-standard" language="en">International Standard</localized-string> -->
261
+ <xsl:variable name="key"><xsl:value-of select="concat('doctype_dict.', $doctype)"/></xsl:variable>
262
+ <xsl:value-of select="/mn:metanorma/mn:localized-strings/mn:localized-string[@key = $key]"/>
263
+ </xsl:if>
264
+ </xsl:variable>
265
+
256
266
  <xsl:variable name="doctype_localized">
257
267
  <xsl:choose>
258
268
  <xsl:when test="$doctype_localized_ != ''">
259
269
  <xsl:value-of select="translate(normalize-space($doctype_localized_),'-',' ')"/>
260
270
  </xsl:when>
271
+ <xsl:when test="$doctype_localized__ != ''">
272
+ <xsl:value-of select="$doctype_localized__"/>
273
+ </xsl:when>
261
274
  <xsl:otherwise>
262
275
  <xsl:value-of select="translate(normalize-space($doctype),'-',' ')"/>
263
276
  </xsl:otherwise>
@@ -273,7 +286,22 @@
273
286
  <xsl:variable name="stagename_abbreviation" select="normalize-space($contextNode/mn:ext/mn:stagename/@abbreviation)"/>
274
287
  <stagename_abbreviation><xsl:value-of select="$stagename_abbreviation"/></stagename_abbreviation>
275
288
 
276
- <xsl:variable name="stagename_localized" select="normalize-space($contextNode/mn:status/mn:stage[@language = $lang])"/>
289
+ <xsl:variable name="stagename_localized_" select="normalize-space($contextNode/mn:status/mn:stage[@language = $lang])"/>
290
+ <!-- https://github.com/metanorma/mn-native-pdf/issues/1136 -->
291
+ <xsl:variable name="stagename_localized__">
292
+ <xsl:if test="$stagename_localized_ = '' and count($contextNode/mn:status/mn:stage) = 1">
293
+ <!-- example: <localized-string key="60.international-standard" language="en">International Standard</localized-string> -->
294
+ <xsl:variable name="key"><xsl:value-of select="concat(normalize-space($contextNode/mn:status/mn:stage[not(@language)]), '.', $doctype)"/></xsl:variable>
295
+ <xsl:value-of select="/mn:metanorma/mn:localized-strings/mn:localized-string[@key = $key]"/>
296
+ </xsl:if>
297
+ </xsl:variable>
298
+ <xsl:variable name="stagename_localized___">
299
+ <xsl:choose>
300
+ <xsl:when test="$stagename_localized_ != ''"><xsl:value-of select="$stagename_localized_"/></xsl:when>
301
+ <xsl:otherwise><xsl:value-of select="$stagename_localized__"/></xsl:otherwise>
302
+ </xsl:choose>
303
+ </xsl:variable>
304
+ <xsl:variable name="stagename_localized" select="normalize-space($stagename_localized___)"/>
277
305
  <stagename_localized><xsl:value-of select="$stagename_localized"/></stagename_localized>
278
306
 
279
307
  <stagename_localized_coverpage><xsl:copy-of select="$contextNode/mn:status/mn:stage[@language = $lang and @type = 'coverpage']/node()"/></stagename_localized_coverpage>
@@ -537,8 +565,6 @@
537
565
  </xsl:variable> <!-- END: contents_ -->
538
566
  <xsl:variable name="contents" select="xalan:nodeset($contents_)"/>
539
567
 
540
- <xsl:variable name="XML" select="/"/>
541
-
542
568
  <xsl:template name="layout-master-set">
543
569
  <fo:layout-master-set>
544
570
 
@@ -1108,7 +1134,7 @@
1108
1134
  </fo:inline>
1109
1135
  </fo:block>
1110
1136
 
1111
- <xsl:if test="$contextNode/mn:keyword">
1137
+ <xsl:if test="normalize-space($contextNode/mn:keyword) != ''">
1112
1138
  <fo:block margin-top="6pt">
1113
1139
  <fo:inline font-weight="bold"><xsl:value-of select="$i18n_descriptors"/> : </fo:inline>
1114
1140
  <xsl:call-template name="insertKeywords">
@@ -1204,6 +1230,7 @@
1204
1230
  <!-- Example: title-intro fr -->
1205
1231
  <xsl:call-template name="insertTitlesLangOther">
1206
1232
  <xsl:with-param name="num" select="$num"/>
1233
+ <xsl:with-param name="contextNode" select="$contextNode"/>
1207
1234
  <xsl:with-param name="lang_other" select="$lang_other_"/>
1208
1235
  </xsl:call-template>
1209
1236
  </fo:block>
@@ -1749,7 +1776,7 @@
1749
1776
  </fo:inline>
1750
1777
  </fo:block>
1751
1778
 
1752
- <xsl:if test="$contextNode/mn:keyword">
1779
+ <xsl:if test="normalize-space($contextNode/mn:keyword) != ''">
1753
1780
  <fo:block margin-top="10pt">
1754
1781
  <fo:inline font-weight="bold"><xsl:value-of select="$i18n_descriptors"/> : </fo:inline>
1755
1782
  <xsl:call-template name="insertKeywords">
@@ -1858,6 +1885,7 @@
1858
1885
  <!-- Example: title-intro fr -->
1859
1886
  <xsl:call-template name="insertTitlesLangOther">
1860
1887
  <xsl:with-param name="num" select="$num"/>
1888
+ <xsl:with-param name="contextNode" select="$contextNode"/>
1861
1889
  <xsl:with-param name="lang_other" select="$lang_other_"/>
1862
1890
  </xsl:call-template>
1863
1891
  </fo:block>
@@ -1946,6 +1974,7 @@
1946
1974
  <!-- Example: title-intro fr -->
1947
1975
  <xsl:call-template name="insertTitlesLangOther">
1948
1976
  <xsl:with-param name="num" select="$num"/>
1977
+ <xsl:with-param name="contextNode" select="$contextNode"/>
1949
1978
  <xsl:with-param name="lang_other" select="$lang_other_"/>
1950
1979
  </xsl:call-template>
1951
1980
  </fo:block>
@@ -2101,6 +2130,7 @@
2101
2130
  <fo:block-container font-family="Cambria" line-height="1.1" role="SKIP" height="110mm" id="{concat('__internal_layout__coverpage_p_title_', $num , '_', generate-id())}">
2102
2131
  <!-- for role see coment https://github.com/pdf-association/extension-brotli/issues/5#issuecomment-3931742869 -->
2103
2132
  <fo:block margin-right="3.5mm" role="P/Title"> <!-- role="SKIP" -->
2133
+
2104
2134
  <fo:block font-size="18pt" font-weight="bold" margin-top="2.5mm" role="SKIP"> <!-- role="H1" -->
2105
2135
  <xsl:call-template name="insertTitlesLangMain"><xsl:with-param name="num" select="$num"/></xsl:call-template>
2106
2136
  </fo:block>
@@ -2113,6 +2143,7 @@
2113
2143
  <!-- Example: title-intro fr -->
2114
2144
  <xsl:call-template name="insertTitlesLangOther">
2115
2145
  <xsl:with-param name="num" select="$num"/>
2146
+ <xsl:with-param name="contextNode" select="$contextNode"/>
2116
2147
  <xsl:with-param name="lang_other" select="$lang_other_"/>
2117
2148
  </xsl:call-template>
2118
2149
  </fo:block>
@@ -2161,7 +2192,7 @@
2161
2192
  <!-- </xsl:if>
2162
2193
 
2163
2194
  <xsl:if test="$doctype = 'amendment' and not($stage-abbreviation = 'FDAMD' or $stage-abbreviation = 'FDAM')"> -->
2164
- <xsl:if test="$contextNode/mn:date[@type = 'updated']">
2195
+ <xsl:if test="normalize-space($contextNode/mn:date[@type = 'updated']) != ''">
2165
2196
  <fo:block font-size="18pt" font-weight="bold" margin-bottom="3mm">
2166
2197
  <xsl:value-of select="$contextNode/mn:date[@type = 'updated']"/>
2167
2198
  </fo:block>
@@ -2555,6 +2586,7 @@
2555
2586
  <!-- Example: title-intro fr -->
2556
2587
  <xsl:call-template name="insertTitlesLangOther">
2557
2588
  <xsl:with-param name="num" select="$num"/>
2589
+ <xsl:with-param name="contextNode" select="$contextNode"/>
2558
2590
  <xsl:with-param name="lang_other" select="$lang_other_"/>
2559
2591
  </xsl:call-template>
2560
2592
  </fo:block>
@@ -2818,6 +2850,7 @@
2818
2850
  <!-- Example: title-intro fr -->
2819
2851
  <xsl:call-template name="insertTitlesLangOther">
2820
2852
  <xsl:with-param name="num" select="$num"/>
2853
+ <xsl:with-param name="contextNode" select="$contextNode"/>
2821
2854
  <xsl:with-param name="lang_other" select="$lang_other_"/>
2822
2855
  </xsl:call-template>
2823
2856
  </fo:block>
@@ -2949,6 +2982,7 @@
2949
2982
  <!-- Example: title-intro fr -->
2950
2983
  <xsl:call-template name="insertTitlesLangOther">
2951
2984
  <xsl:with-param name="num" select="$num"/>
2985
+ <xsl:with-param name="contextNode" select="$contextNode"/>
2952
2986
  <xsl:with-param name="lang_other" select="$lang_other_"/>
2953
2987
  </xsl:call-template>
2954
2988
  </fo:block>
@@ -2974,7 +3008,7 @@
2974
3008
 
2975
3009
  <fo:block-container text-align="right" role="SKIP">
2976
3010
  <xsl:choose>
2977
- <xsl:when test="$contextNode/mn:docidentifier[@type = 'iso-tc']">
3011
+ <xsl:when test="normalize-space($contextNode/mn:docidentifier[@type = 'iso-tc']) != ''">
2978
3012
  <!-- 17301 -->
2979
3013
  <fo:block font-size="14pt" font-weight="bold" margin-bottom="12pt">
2980
3014
  <xsl:value-of select="$contextNode/mn:docidentifier[@type = 'iso-tc']"/>
@@ -3026,6 +3060,7 @@
3026
3060
  <!-- Example: title-intro fr -->
3027
3061
  <xsl:call-template name="insertTitlesLangOther">
3028
3062
  <xsl:with-param name="num" select="$num"/>
3063
+ <xsl:with-param name="contextNode" select="$contextNode"/>
3029
3064
  <xsl:with-param name="lang_other" select="$lang_other_"/>
3030
3065
  </xsl:call-template>
3031
3066
  </fo:block>
@@ -3229,7 +3264,7 @@
3229
3264
  <xsl:param name="content-height"/>
3230
3265
  <xsl:variable name="contextNode" select="xalan:evaluate($bibdataContextNode)"/>
3231
3266
  <xsl:choose>
3232
- <xsl:when test="$contextNode/mn:contributor[mn:role[@type = 'author']/mn:description = 'committee']/mn:organization">
3267
+ <xsl:when test="normalize-space($contextNode/mn:contributor[mn:role[@type = 'author']/mn:description = 'committee']/mn:organization) != ''">
3233
3268
  <xsl:for-each select="$contextNode/mn:contributor[mn:role[@type = 'author']/mn:description = 'committee']/mn:organization">
3234
3269
 
3235
3270
  <xsl:variable name="items">
@@ -3337,7 +3372,7 @@
3337
3372
  <xsl:variable name="content-height">20</xsl:variable>
3338
3373
  <xsl:variable name="contextNode" select="xalan:evaluate($bibdataContextNode)"/>
3339
3374
  <xsl:choose>
3340
- <xsl:when test="$contextNode/mn:contributor[mn:role[@type = 'author']/mn:description = 'committee']/mn:organization[mn:abbreviation]">
3375
+ <xsl:when test="normalize-space($contextNode/mn:contributor[mn:role[@type = 'author']/mn:description = 'committee']/mn:organization[mn:abbreviation]) != ''">
3341
3376
  <xsl:for-each select="$contextNode/mn:contributor[mn:role[@type = 'author']/mn:description = 'committee']/mn:organization[mn:abbreviation]">
3342
3377
  <xsl:variable name="items">
3343
3378
  <xsl:call-template name="split_abbreviation"/>
@@ -3475,15 +3510,16 @@
3475
3510
 
3476
3511
  <xsl:template name="insertTitlesLangOther">
3477
3512
  <xsl:param name="num"/>
3513
+ <xsl:param name="contextNode"/>
3478
3514
  <xsl:param name="lang_other"/>
3479
- <xsl:apply-templates select="$XML/mn:metanorma/mn:bibdata/mn:title[@language = $lang_other and @type = 'title-intro']"/>
3480
- <xsl:apply-templates select="$XML/mn:metanorma/mn:bibdata/mn:title[@language = $lang_other and @type = 'title-main']"/>
3481
- <xsl:apply-templates select="$XML/mn:metanorma/mn:bibdata/mn:title[@language = $lang_other and @type = 'title-complementary']"/>
3482
- <xsl:apply-templates select="$XML/mn:metanorma/mn:bibdata/mn:title[@language = $lang_other and @type = 'title-part']">
3515
+ <xsl:apply-templates select="$contextNode/mn:title[@language = $lang_other and @type = 'title-intro']"/>
3516
+ <xsl:apply-templates select="$contextNode/mn:title[@language = $lang_other and @type = 'title-main']"/>
3517
+ <xsl:apply-templates select="$contextNode/mn:title[@language = $lang_other and @type = 'title-complementary']"/>
3518
+ <xsl:apply-templates select="$contextNode/mn:title[@language = $lang_other and @type = 'title-part']">
3483
3519
  <xsl:with-param name="num" select="$num"/>
3484
3520
  <xsl:with-param name="curr_lang" select="$lang_other"/>
3485
3521
  </xsl:apply-templates>
3486
- <xsl:apply-templates select="$XML/mn:metanorma/mn:bibdata/mn:title[@language = $lang_other and @type = 'title-amd']">
3522
+ <xsl:apply-templates select="$contextNode/mn:title[@language = $lang_other and @type = 'title-amd']">
3487
3523
  <xsl:with-param name="num" select="$num"/>
3488
3524
  <xsl:with-param name="curr_lang" select="$lang_other"/>
3489
3525
  </xsl:apply-templates>
@@ -3514,13 +3550,13 @@
3514
3550
  <xsl:value-of select="$edition"/>
3515
3551
  <xsl:variable name="date">
3516
3552
  <xsl:choose>
3517
- <xsl:when test="($stage-abbreviation = 'NWIP' or $stage-abbreviation = 'NP' or $stage-abbreviation = 'PWI' or $stage-abbreviation = 'AWI' or $stage-abbreviation = 'WD' or $stage-abbreviation = 'CD' or $stage-abbreviation = 'FDIS' or $stagename_abbreviation = 'FDIS') and $contextNode/mn:version/mn:revision-date">
3553
+ <xsl:when test="($stage-abbreviation = 'NWIP' or $stage-abbreviation = 'NP' or $stage-abbreviation = 'PWI' or $stage-abbreviation = 'AWI' or $stage-abbreviation = 'WD' or $stage-abbreviation = 'CD' or $stage-abbreviation = 'FDIS' or $stagename_abbreviation = 'FDIS') and normalize-space($contextNode/mn:version/mn:revision-date) != ''">
3518
3554
  <xsl:value-of select="$contextNode/mn:version/mn:revision-date"/>
3519
3555
  </xsl:when>
3520
- <xsl:when test="$stage-abbreviation = 'IS' and /mn:metanorma/mn:bibdata/mn:date[@type = 'published']">
3556
+ <xsl:when test="$stage-abbreviation = 'IS' and normalize-space($contextNode/mn:date[@type = 'published']) != ''">
3521
3557
  <xsl:value-of select="$contextNode/mn:date[@type = 'published']"/>
3522
3558
  </xsl:when>
3523
- <xsl:when test="($stage-abbreviation = 'IS' or $stage-abbreviation = 'D') and $contextNode/mn:date[@type = 'created']">
3559
+ <xsl:when test="($stage-abbreviation = 'IS' or $stage-abbreviation = 'D') and normalize-space($contextNode/mn:date[@type = 'created']) != ''">
3524
3560
  <xsl:value-of select="$contextNode/mn:date[@type = 'created']"/>
3525
3561
  </xsl:when>
3526
3562
  <xsl:when test="$stage-abbreviation = 'IS' or $stage-abbreviation = 'PRF' or $stage_published = 'true'">
@@ -4016,7 +4052,7 @@
4016
4052
  <!-- ==================== -->
4017
4053
  <!-- display titles -->
4018
4054
  <!-- ==================== -->
4019
- <xsl:template match="mn:bibdata/mn:title[@type = 'title-intro']">
4055
+ <xsl:template match="mn:bibdata/mn:title[@type = 'title-intro'] | mn:bibdata//mn:relation/mn:bibitem/mn:title[@type = 'title-intro']">
4020
4056
  <xsl:variable name="layoutVersion">
4021
4057
  <xsl:call-template name="getVariable"><xsl:with-param name="variable">layoutVersion</xsl:with-param></xsl:call-template>
4022
4058
  </xsl:variable>
@@ -4031,7 +4067,7 @@
4031
4067
  </xsl:choose>
4032
4068
  </xsl:template>
4033
4069
 
4034
- <xsl:template match="mn:bibdata/mn:title[@type = 'title-main']">
4070
+ <xsl:template match="mn:bibdata/mn:title[@type = 'title-main'] | mn:bibdata//mn:relation/mn:bibitem/mn:title[@type = 'title-main']">
4035
4071
  <xsl:param name="body">false</xsl:param>
4036
4072
  <xsl:variable name="layoutVersion">
4037
4073
  <xsl:call-template name="getVariable"><xsl:with-param name="variable">layoutVersion</xsl:with-param></xsl:call-template>
@@ -4060,13 +4096,13 @@
4060
4096
  </xsl:choose>
4061
4097
  </xsl:template>
4062
4098
 
4063
- <xsl:template match="mn:bibdata/mn:title[@type = 'title-complementary']">
4099
+ <xsl:template match="mn:bibdata/mn:title[@type = 'title-complementary'] | mn:bibdata//mn:relation/mn:bibitem/mn:title[@type = 'title-complementary']">
4064
4100
  <xsl:param name="body">false</xsl:param>
4065
4101
  <xsl:value-of select="$nonbreak_space_em_dash_space"/>
4066
4102
  <xsl:apply-templates/>
4067
4103
  </xsl:template>
4068
4104
 
4069
- <xsl:template match="mn:bibdata/mn:title[@type = 'title-part']">
4105
+ <xsl:template match="mn:bibdata/mn:title[@type = 'title-part'] | mn:bibdata//mn:relation/mn:bibitem/mn:title[@type = 'title-part']">
4070
4106
  <xsl:param name="num"/>
4071
4107
  <xsl:param name="curr_lang" select="$lang"/>
4072
4108
  <xsl:param name="isMainLang">false</xsl:param>
@@ -4154,7 +4190,7 @@
4154
4190
  </xsl:choose>
4155
4191
  </xsl:template>
4156
4192
 
4157
- <xsl:template match="mn:bibdata/mn:title[@type = 'title-amd']">
4193
+ <xsl:template match="mn:bibdata/mn:title[@type = 'title-amd'] | mn:bibdata//mn:relation/mn:bibitem/mn:title[@type = 'title-amd']">
4158
4194
  <xsl:param name="num"/>
4159
4195
  <xsl:param name="isMainLang">false</xsl:param>
4160
4196
  <xsl:param name="curr_lang" select="$lang"/>
@@ -6027,7 +6063,7 @@
6027
6063
  </xsl:choose> -->
6028
6064
  </fo:block>
6029
6065
  <xsl:variable name="font-size_footer_copyright"><xsl:call-template name="get_font-size_footer_copyright"><xsl:with-param name="num" select="$num"/></xsl:call-template></xsl:variable>
6030
- <xsl:if test="$contextNode/mn:keyword">
6066
+ <xsl:if test="normalize-space($contextNode/mn:keyword) != ''">
6031
6067
  <fo:block font-size="{$font-size_footer_copyright}" margin-bottom="6pt">
6032
6068
  <fo:inline font-weight="bold"><xsl:value-of select="$i18n_descriptors"/>: </fo:inline>
6033
6069
  <xsl:call-template name="insertKeywords">
@@ -7305,8 +7341,24 @@
7305
7341
  <xsl:if test="$docnum != '1'">_<xsl:value-of select="$docnum"/></xsl:if>
7306
7342
  </xsl:variable>
7307
7343
  <xsl:variable name="named_dest_doc" select="normalize-space($named_dest_doc_)"/>
7308
- <xsl:if test="not(key('kid', $named_dest_doc))"> <!-- if element with id '$named_dest_doc' doesn't exist in the document -->
7309
- <xsl:attribute name="named_dest"><xsl:value-of select="normalize-space($named_dest_doc)"/></xsl:attribute>
7344
+ <xsl:variable name="named_dest_unique_">
7345
+ <xsl:choose>
7346
+ <xsl:when test="normalize-space($caption_label) != '' and self::mn:fmt-name and count(key('kname_caption_label', $caption_label)) &gt; 1">
7347
+ <!-- duplicate caption numbers across clauses (e.g. two "Table 1" in front matter): qualify with the owner element id so fo ids stay unique -->
7348
+ <xsl:value-of select="concat(normalize-space($named_dest_doc), '_', ancestor::*[@id][1]/@id)"/>
7349
+ </xsl:when>
7350
+ <xsl:when test="normalize-space($caption_label) != '' and self::mn:fmt-title and count(key('ktitle_caption_label', $caption_label)) &gt; 1">
7351
+ <!-- duplicate clauses's caption numbers: qualify with the owner element id so fo ids stay unique -->
7352
+ <xsl:value-of select="concat(normalize-space($named_dest_doc), '_', ancestor::*[@id][1]/@id)"/>
7353
+ </xsl:when>
7354
+ <xsl:otherwise>
7355
+ <xsl:value-of select="normalize-space($named_dest_doc)"/>
7356
+ </xsl:otherwise>
7357
+ </xsl:choose>
7358
+ </xsl:variable>
7359
+ <xsl:variable name="named_dest_unique" select="normalize-space($named_dest_unique_)"/>
7360
+ <xsl:if test="$named_dest_unique != '' and not(key('kid', $named_dest_unique))"> <!-- if element with id '$named_dest_unique' doesn't exist in the document -->
7361
+ <xsl:attribute name="named_dest"><xsl:value-of select="$named_dest_unique"/></xsl:attribute>
7310
7362
  </xsl:if>
7311
7363
  </xsl:if>
7312
7364
  </xsl:template>
@@ -15959,8 +16011,30 @@
15959
16011
  <xsl:choose>
15960
16012
  <xsl:when test=".//*[local-name() = 'a'][*[local-name() = 'rect'] or *[local-name() = 'polygon'] or *[local-name() = 'circle'] or *[local-name() = 'ellipse']]">
15961
16013
  <fo:block>
15962
- <xsl:variable name="width" select="@width"/>
15963
- <xsl:variable name="height" select="@height"/>
16014
+ <!-- fallback for a size that is not a positive finite px number (missing, %, em, NaN, negative, huge):
16015
+ the svg_update default, i.e. the viewBox dimension, else 400 -->
16016
+ <xsl:variable name="vb" select="normalize-space(@viewBox)"/>
16017
+ <xsl:variable name="vb_width" select="number(substring-before(concat(substring-after(substring-after($vb, ' '), ' '), ' '), ' '))"/>
16018
+ <xsl:variable name="vb_height" select="number(substring-before(concat(substring-after(substring-after(substring-after($vb, ' '), ' '), ' '), ' '), ' '))"/>
16019
+
16020
+ <!-- strip a case-insensitive px suffix, trim NBSP, accept only a positive finite number -->
16021
+ <xsl:variable name="width_num" select="number(normalize-space(java:replaceAll(java:java.lang.String.new(normalize-space(translate(@width, ' ', ' '))), '(?i)px$', '')))"/>
16022
+ <xsl:variable name="height_num" select="number(normalize-space(java:replaceAll(java:java.lang.String.new(normalize-space(translate(@height, ' ', ' '))), '(?i)px$', '')))"/>
16023
+
16024
+ <xsl:variable name="width">
16025
+ <xsl:choose>
16026
+ <xsl:when test="$width_num &gt; 0 and $width_num - $width_num = 0"><xsl:value-of select="$width_num"/></xsl:when>
16027
+ <xsl:when test="$vb_width &gt; 0 and $vb_width - $vb_width = 0"><xsl:value-of select="round($vb_width)"/></xsl:when>
16028
+ <xsl:otherwise>400</xsl:otherwise>
16029
+ </xsl:choose>
16030
+ </xsl:variable>
16031
+ <xsl:variable name="height">
16032
+ <xsl:choose>
16033
+ <xsl:when test="$height_num &gt; 0 and $height_num - $height_num = 0"><xsl:value-of select="$height_num"/></xsl:when>
16034
+ <xsl:when test="$vb_height &gt; 0 and $vb_height - $vb_height = 0"><xsl:value-of select="round($vb_height)"/></xsl:when>
16035
+ <xsl:otherwise>400</xsl:otherwise>
16036
+ </xsl:choose>
16037
+ </xsl:variable>
15964
16038
 
15965
16039
  <xsl:variable name="scale_x">
15966
16040
  <xsl:choose>
@@ -16208,13 +16282,26 @@
16208
16282
  </xsl:copy>
16209
16283
  </xsl:template>
16210
16284
 
16285
+ <!-- embedded svg length: keep a valid unitless or lowercase px value as written; write a positive finite
16286
+ px value without its unit (no NBSP/case/space residue); otherwise the svg_update default 400 (Batik rejects raw px/%/NBSP/negative) -->
16287
+ <xsl:template name="svg_length">
16288
+ <xsl:variable name="raw" select="normalize-space(translate(., ' ', ' '))"/>
16289
+ <xsl:variable name="num" select="number(normalize-space(java:replaceAll(java:java.lang.String.new($raw), '(?i)px$', '')))"/>
16290
+ <xsl:choose>
16291
+ <xsl:when test="number($raw) &gt; 0 and number($raw) - number($raw) = 0"><xsl:value-of select="$raw"/></xsl:when>
16292
+ <xsl:when test="$num &gt; 0 and $num - $num = 0 and substring($raw, string-length($raw) - 1) = 'px'"><xsl:value-of select="$raw"/></xsl:when>
16293
+ <xsl:when test="$num &gt; 0 and $num - $num = 0"><xsl:value-of select="$num"/></xsl:when>
16294
+ <xsl:otherwise>400</xsl:otherwise>
16295
+ </xsl:choose>
16296
+ </xsl:template>
16297
+
16211
16298
  <xsl:template match="*[local-name() = 'svg']/@width" mode="svg_update">
16212
16299
  <!-- image[@width]/svg -->
16213
16300
  <xsl:variable name="parent_image_width" select="normalize-space(ancestor::*[2][self::mn:image]/@width)"/>
16214
16301
  <xsl:attribute name="width">
16215
16302
  <xsl:choose>
16216
16303
  <xsl:when test="$parent_image_width != '' and normalize-space(java:matches(java:java.lang.String.new($parent_image_width), $regex_starts_with_digit)) = 'true'"><xsl:value-of select="$parent_image_width"/></xsl:when>
16217
- <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
16304
+ <xsl:otherwise><xsl:call-template name="svg_length"/></xsl:otherwise>
16218
16305
  </xsl:choose>
16219
16306
  </xsl:attribute>
16220
16307
  </xsl:template>
@@ -16225,7 +16312,7 @@
16225
16312
  <xsl:attribute name="height">
16226
16313
  <xsl:choose>
16227
16314
  <xsl:when test="$parent_image_height != '' and normalize-space(java:matches(java:java.lang.String.new($parent_image_height), $regex_starts_with_digit)) = 'true'"><xsl:value-of select="$parent_image_height"/></xsl:when>
16228
- <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
16315
+ <xsl:otherwise><xsl:call-template name="svg_length"/></xsl:otherwise>
16229
16316
  </xsl:choose>
16230
16317
  </xsl:attribute>
16231
16318
  </xsl:template>
@@ -21948,13 +22035,23 @@
21948
22035
  <xsl:param name="letter-spacing" select="'0.15'"/>
21949
22036
  <xsl:if test="string-length($text) &gt; 0">
21950
22037
  <xsl:variable name="char" select="substring($text, 1, 1)"/>
21951
- <fo:inline padding-right="{$letter-spacing}mm">
21952
- <xsl:if test="$char = '®'">
21953
- <xsl:attribute name="font-size">58%</xsl:attribute>
21954
- <xsl:attribute name="baseline-shift">30%</xsl:attribute>
21955
- </xsl:if>
21956
- <xsl:value-of select="$char"/>
21957
- </fo:inline>
22038
+ <xsl:choose>
22039
+ <xsl:when test="contains($letter-spacing, 'em') or contains($letter-spacing, 'mm')">
22040
+ <!-- for negative letter spacing (in em) -->
22041
+ <fo:inline letter-spacing="{$letter-spacing}">
22042
+ <xsl:value-of select="$char"/>
22043
+ </fo:inline>
22044
+ </xsl:when>
22045
+ <xsl:otherwise>
22046
+ <fo:inline padding-right="{$letter-spacing}mm">
22047
+ <xsl:if test="$char = '®'">
22048
+ <xsl:attribute name="font-size">58%</xsl:attribute>
22049
+ <xsl:attribute name="baseline-shift">30%</xsl:attribute>
22050
+ </xsl:if>
22051
+ <xsl:value-of select="$char"/>
22052
+ </fo:inline>
22053
+ </xsl:otherwise>
22054
+ </xsl:choose>
21958
22055
  <xsl:call-template name="add-letter-spacing">
21959
22056
  <xsl:with-param name="text" select="substring($text, 2)"/>
21960
22057
  <xsl:with-param name="letter-spacing" select="$letter-spacing"/>
@@ -26,6 +26,7 @@ module IsoDoc
26
26
  FileUtils.rm_rf dir
27
27
  output_file = out_fname || "#{filename}.#{@suffix}"
28
28
  run_mnconvert(in_fname, output_file)
29
+ declare_processing_meta(output_file)
29
30
  # mnconvert passes Metanorma-internal constructs through verbatim;
30
31
  # repair the result into schema-valid NISO STS before delivery.
31
32
  Metanorma::Iso::Sts::OutputSanitizer.sanitize_file(output_file)
@@ -33,6 +34,16 @@ module IsoDoc
33
34
 
34
35
  private
35
36
 
37
+ # The native driver (Metanorma::Iso::Sts.convert_inner) declares the
38
+ # coding profile; mnconvert does not, so this leg adds it. Shared
39
+ # with the native driver so both emit the same declaration.
40
+ def declare_processing_meta(output_file)
41
+ xml = File.read(output_file, encoding: "utf-8")
42
+ File.write(output_file,
43
+ Metanorma::Iso::Sts.inject_processing_meta(xml),
44
+ encoding: "utf-8")
45
+ end
46
+
36
47
  # The mnconvert binary writes its output before self-validating it
37
48
  # against the NISO STS XSD, and legacy Metanorma constructs (flavor
38
49
  # build attributes, inline identifiers, generated id collisions)
@@ -56,6 +56,7 @@ module Metanorma
56
56
  Metanorma::Iso::Sts.inject_namespaces(xml)
57
57
  .then { |x| Metanorma::Iso::Sts.inject_processing_meta(x) }
58
58
  .then { |x| Metanorma::Iso::Sts.fix_lang_attribute(x) }
59
+ .then { |x| Metanorma::Iso::Sts.inject_term_entry_type(x) }
59
60
  end,
60
61
  },
61
62
  }
@@ -30,6 +30,7 @@ module Metanorma
30
30
  @kinds = {}
31
31
  @normative_refs = {}
32
32
  @entry_ids = {}
33
+ @term_entry_by_sec = {}
33
34
  @issued_ids = {}
34
35
  @annex_count = 0
35
36
  @figure_count = 0
@@ -60,6 +61,13 @@ module Metanorma
60
61
  @normative_refs[source_id]
61
62
  end
62
63
 
64
+ # The <tbx:termEntry> id of a term whose <term-sec> carries +sec_id+;
65
+ # nil when +sec_id+ is not a term section. A reference to a term
66
+ # names the entry (guidelines 9.2.6), not the section.
67
+ def term_entry_id_for(sec_id)
68
+ @term_entry_by_sec[sec_id]
69
+ end
70
+
63
71
  # Records the kind of a block that keeps its source id
64
72
  # (formula, table), so an xref to it gets the right @ref-type.
65
73
  def mark_kind(source_id, kind)
@@ -135,6 +143,7 @@ module Metanorma
135
143
  entry_id = claim("term_#{suffix}")
136
144
  register(term.id, sec_id, "clause") if term.id
137
145
  @entry_ids[term.id] = entry_id if term.id
146
+ @term_entry_by_sec[sec_id] = entry_id
138
147
  [sec_id, entry_id]
139
148
  end
140
149
 
@@ -453,25 +453,6 @@ module Metanorma
453
453
  # transformer; the result is flattened to text because
454
454
  # Sts::TbxIsoTml::Fn#p is typed as NisoSts::Paragraph (uses
455
455
  # :text, not :content) and the math roundtrip drops msub.
456
- def build_fn(fn_element)
457
- paragraphs = Array(fn_element.p).map.with_index do |p, i|
458
- build_fn_paragraph_text(p, fn_element, first: i.zero?)
459
- end
460
- return nil if paragraphs.empty?
461
-
462
- attrs = { id: fn_element.id, paragraph: paragraphs }
463
- label = fn_element.reference if fn_element.is_a?(Metanorma::Document::Components::Inline::FnElement)
464
- attrs[:label] = ::Sts::NisoSts::Label.new(content: [label]) if label && !label.to_s.empty?
465
- ::Sts::NisoSts::Fn.new(attrs)
466
- end
467
-
468
- def build_fn_paragraph_text(mn_p, fn_element, first:)
469
- text = RenderedTextExtractor.text_of(mn_p)
470
- label = fn_element.reference if fn_element.is_a?(Metanorma::Document::Components::Inline::FnElement)
471
- text = "#{label})#{text}" if first && label && !label.to_s.empty? && !text.empty?
472
- ::Sts::NisoSts::Paragraph.new(text: [text])
473
- end
474
-
475
456
  # Builds a map of stem_id → FmtStemElement mirror by scanning
476
457
  # the paragraph's descendant fmt-stem elements. Each fmt-stem's
477
458
  # inner semx carries a `source` matching the original stem's id.
@@ -604,20 +585,22 @@ module Metanorma
604
585
  # through unchanged.
605
586
  rid = id_generator.remap(rid)
606
587
 
588
+ if (entry_id = id_generator.term_entry_id_for(rid))
589
+ return term_entry_xref(node, entry_id)
590
+ end
591
+
607
592
  visible = xref_visible_text(node, rid)
608
593
  ModelBuilder.xref(rid: rid, ref_type: ref_type_for(node, rid), value: visible)
609
594
  end
610
595
 
611
- def xref_visible_text(node, rid)
596
+ # A reference to a term: ref-type "custom" aimed at the termEntry.
597
+ # The custom-type="term-entry" attribute is added in
598
+ # Metanorma::Iso::Sts.inject_term_entry_type, as the xref model
599
+ # carries no custom-type.
600
+ def term_entry_xref(node, entry_id)
612
601
  explicit = text_of(node)
613
- return explicit unless explicit.empty?
614
- raw = node.target.to_s
615
- case raw
616
- when /\Asec-(.+)\z/, /\Afig-(.+)\z/, /\Atable-(.+)\z/, /\Afn-(.+)\z/
617
- "#{Regexp.last_match(1)} "
618
- else
619
- explicit.empty? ? rid : explicit
620
- end
602
+ visible = explicit.empty? ? entry_id.delete_prefix("term_") : explicit
603
+ ModelBuilder.xref(rid: entry_id, ref_type: "custom", value: visible)
621
604
  end
622
605
 
623
606
  # @ref-type per the guidelines 10.1.1 enumeration, derived from
@@ -4,6 +4,15 @@ module Metanorma
4
4
  module Sts
5
5
  module Transformer
6
6
  class TableTransformer < Metanorma::Document::Sts::Transformer::TableTransformer
7
+ # A hyphen or en dash between digits with no spaces ("Table 1-2") marks
8
+ # a range or compound number, so a dash separates only with whitespace
9
+ # on both sides or with a non-digit directly after it.
10
+ LEGACY_DESIGNATION = /
11
+ \A((?i:table)[[:space:]]+(?:[A-Z]\.)?\d+(?:\.\d+)*)
12
+ (?:[[:space:]]+[‒-―−-][[:space:]]+|[[:space:]]*[‒-―−](?!\d))
13
+ (.+)\z
14
+ /mx
15
+
7
16
  # +opts+: provision-table overrides passed by
8
17
  # RequirementTransformer — the table-wrap id (the requirement's
9
18
  # anchor, what xrefs target), the mnconvert content-type /
@@ -32,17 +41,31 @@ module Metanorma
32
41
  source_table.id
33
42
  end
34
43
 
35
- # "Table 2" from the presentation XML autonum attribute.
44
+ # "Table 2" from the presentation XML autonum attribute; a legacy
45
+ # presentation table with no autonum names itself "Table 2 — …".
36
46
  def table_label(source_table)
37
- return nil unless source_table.autonum
47
+ return "Table #{source_table.autonum}" if source_table.autonum
38
48
 
39
- "Table #{source_table.autonum}"
49
+ legacy_split(caption_text(source_table)).first
40
50
  end
41
51
 
42
52
  # Provision-table captions prefer the fully-rendered fmt-name
43
53
  # (it carries the "Table N — Requirement M: …" composition);
44
54
  # data tables use the semantic <name>.
45
55
  def table_caption(source_table)
56
+ text = if source_table.autonum
57
+ caption_text(source_table)
58
+ else
59
+ legacy_split(caption_text(source_table)).last
60
+ end
61
+ return nil if text.nil? || text.empty?
62
+
63
+ ::Sts::NisoSts::Caption.new(
64
+ title: ::Sts::NisoSts::Title.new(content: [text.strip])
65
+ )
66
+ end
67
+
68
+ def caption_text(source_table)
46
69
  text = nil
47
70
  if source_table.fmt_name
48
71
  text = RenderedTextExtractor.text_of(source_table.fmt_name)
@@ -50,11 +73,12 @@ module Metanorma
50
73
  if (text.nil? || text.empty?) && source_table.name
51
74
  text = RenderedTextExtractor.text_of(source_table.name)
52
75
  end
53
- return nil if text.nil? || text.empty?
76
+ text
77
+ end
54
78
 
55
- ::Sts::NisoSts::Caption.new(
56
- title: ::Sts::NisoSts::Title.new(content: [text.strip])
57
- )
79
+ def legacy_split(text)
80
+ match = text&.match(LEGACY_DESIGNATION)
81
+ match ? [match[1], match[2]] : [nil, text]
58
82
  end
59
83
 
60
84
  def build_table(source_table, bold_header: false)
@@ -1,7 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "moxml"
4
+ require "pathname"
4
5
  require "set"
6
+ require "metanorma/iso/sts/validation_report"
5
7
 
6
8
  module Metanorma
7
9
  module Iso
@@ -72,6 +72,7 @@ module Metanorma
72
72
  inject_namespaces(xml)
73
73
  .then { |x| inject_processing_meta(x) }
74
74
  .then { |x| fix_lang_attribute(x) }
75
+ .then { |x| inject_term_entry_type(x) }
75
76
  .then { |x| Transformer::NbspProcessor.apply_to_text(x) }
76
77
  end
77
78
 
@@ -135,6 +136,14 @@ module Metanorma
135
136
  xml.gsub(/\slang="([a-z-]+)"/, ' xml:lang="\\1"')
136
137
  end
137
138
 
139
+ # ref-type="custom" is emitted only for references to a term (see
140
+ # ParagraphTransformer#term_entry_xref); guidelines 9.2.6 require the
141
+ # custom-type to name the term entry.
142
+ def self.inject_term_entry_type(xml)
143
+ xml.gsub('<xref ref-type="custom" ',
144
+ '<xref ref-type="custom" custom-type="term-entry" ')
145
+ end
146
+
138
147
  # Validate an ISO NISO STS XML string against the flavor constraints
139
148
  # (IEC/ISO NISO STS Coding Guidelines ed 2.1; error findings fail
140
149
  # +valid?+, warnings are report-only).
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Iso
3
- VERSION = "3.5.32".freeze
3
+ VERSION = "3.5.34".freeze
4
4
  end
5
5
  end
@@ -32,7 +32,7 @@ Gem::Specification.new do |spec|
32
32
  end
33
33
  spec.required_ruby_version = Gem::Requirement.new(">= 3.3.0")
34
34
 
35
- spec.add_dependency "metanorma-document", "~> 0.5.15" # the shared STS engine (metanorma-iso#1760)
35
+ spec.add_dependency "metanorma-document", "~> 0.5.17" # the shared STS engine; 0.5.17 = fn-spacing + xref-label fixes (metanorma-document#202)
36
36
  spec.add_dependency "metanorma-standoc", ">= 3.4.2" # relaxed until standoc#1232 releases
37
37
  spec.add_dependency "mnconvert", "~> 1.14"
38
38
  spec.add_dependency "pubid", "~> 2.0.3"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-iso
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.5.32
4
+ version: 3.5.34
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-11-26 00:00:00.000000000 Z
11
+ date: 2026-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: metanorma-document
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.5.15
19
+ version: 0.5.17
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.5.15
26
+ version: 0.5.17
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: metanorma-standoc
29
29
  requirement: !ruby/object:Gem::Requirement