metanorma-iso 3.5.31 → 3.5.33

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.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +4 -1
  3. data/lib/isodoc/iso/iso.amendment.xsl +135 -38
  4. data/lib/isodoc/iso/iso.international-standard.xsl +135 -38
  5. data/lib/isodoc/iso/sts_convert.rb +11 -0
  6. data/lib/metanorma/iso/processor.rb +1 -0
  7. data/lib/metanorma/iso/sts/html_renderer/ruby.rb +9 -1079
  8. data/lib/metanorma/iso/sts/parity_validator/normaliser.rb +4 -84
  9. data/lib/metanorma/iso/sts/parity_validator/report.rb +3 -125
  10. data/lib/metanorma/iso/sts/profile.rb +68 -0
  11. data/lib/metanorma/iso/sts/transformer/back_transformer.rb +1 -1
  12. data/lib/metanorma/iso/sts/transformer/base.rb +5 -76
  13. data/lib/metanorma/iso/sts/transformer/block_dispatcher.rb +1 -1
  14. data/lib/metanorma/iso/sts/transformer/body_transformer.rb +1 -1
  15. data/lib/metanorma/iso/sts/transformer/context.rb +13 -37
  16. data/lib/metanorma/iso/sts/transformer/dl_transformer.rb +5 -122
  17. data/lib/metanorma/iso/sts/transformer/document_transformer.rb +1 -1
  18. data/lib/metanorma/iso/sts/transformer/figure_transformer.rb +5 -118
  19. data/lib/metanorma/iso/sts/transformer/footnote_collector.rb +1 -1
  20. data/lib/metanorma/iso/sts/transformer/formula_transformer.rb +6 -35
  21. data/lib/metanorma/iso/sts/transformer/front_transformer.rb +1 -1
  22. data/lib/metanorma/iso/sts/transformer/id_generator.rb +10 -1
  23. data/lib/metanorma/iso/sts/transformer/inline_transformer.rb +2 -1
  24. data/lib/metanorma/iso/sts/transformer/list_transformer.rb +1 -1
  25. data/lib/metanorma/iso/sts/transformer/note_transformer.rb +4 -185
  26. data/lib/metanorma/iso/sts/transformer/paragraph_transformer.rb +17 -31
  27. data/lib/metanorma/iso/sts/transformer/provision_index.rb +1 -1
  28. data/lib/metanorma/iso/sts/transformer/quote_transformer.rb +5 -41
  29. data/lib/metanorma/iso/sts/transformer/reference_transformer.rb +1 -1
  30. data/lib/metanorma/iso/sts/transformer/rendered_text_extractor.rb +1 -1
  31. data/lib/metanorma/iso/sts/transformer/requirement_transformer.rb +1 -1
  32. data/lib/metanorma/iso/sts/transformer/section_transformer.rb +5 -239
  33. data/lib/metanorma/iso/sts/transformer/source_document.rb +1 -1
  34. data/lib/metanorma/iso/sts/transformer/standard.rb +1 -1
  35. data/lib/metanorma/iso/sts/transformer/table_transformer.rb +32 -8
  36. data/lib/metanorma/iso/sts/transformer/term_transformer.rb +1 -1
  37. data/lib/metanorma/iso/sts/validation_report.rb +4 -49
  38. data/lib/metanorma/iso/sts/validator.rb +3 -1
  39. data/lib/metanorma/iso/sts.rb +20 -0
  40. data/lib/metanorma/iso/version.rb +1 -1
  41. data/metanorma-iso.gemspec +1 -1
  42. data/tasks/sts_golden.rake +39 -0
  43. metadata +6 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c02ac9f963b874679334c7bc6cccd3f686c8f835570b4e214d8ecfdd67b245c3
4
- data.tar.gz: 1ed11c5077b27d9787ef1230354f83fdcc6925aa7c5631a367ff987403bbdea7
3
+ metadata.gz: d035af43572bed99155f41b23950c39fdfe28924490639c567e7168a25330e34
4
+ data.tar.gz: ad9478a3a49eec4cec19d4eabf9254e920bd735f6931bef7530600d881a7fe03
5
5
  SHA512:
6
- metadata.gz: c62bef0620baddba7e8759dd5526d4b6aa8eebadec901f1f3d66e2335ecb434383d147197b0b33510784460a06594c3063d7cd81b6d300412af2e0abf91d6534
7
- data.tar.gz: 3895573687b2ca03d112774a3e00de4e84a8d3f5515fccf4993c69258d9c412c921ccb59687c06b1e6fbb770683873eae13c7cb542486c874e133f8ed3c172d5
6
+ metadata.gz: 9c3b5b4de58e9a600bf187fb669b4512a5ce6d059d50896624502c539c61ebbf653e1981f4c4e09d462ad75558b766f6b58ca85892219f44d39c1fc48af6caa7
7
+ data.tar.gz: 4c77d9012c9bcc309438ec1a0825767eb64cefcd6965bbadaf326c934cae866d5a8c5c4b9bfe1e7e6804019814e963efdd0db855c02dd94dd4800ac9c6127d7d
data/Gemfile CHANGED
@@ -9,7 +9,10 @@ gem "isodoc", "~> 3.7.9" # carries the relaton-render range #846
9
9
  gem "metanorma-plugin-lutaml", "~> 0.7"
10
10
  gem "metanorma-utils", "~> 2.0" # GcBudget + the array-join table cell buffer
11
11
  gem "metanorma-standoc", "~> 3.5.7" # Standoc::Document split + the pubid-dispatch refs world
12
- gem "metanorma-document", "~> 0.5.3" # relaton 3.1 line; relaton-bib retired
12
+ # Dev pin: golden capture and the engine-delegation parity runs execute
13
+ # against the released engine (metanorma-document#165); the gemspec
14
+ # floor is raised in the engine-delegation wave.
15
+ gem "metanorma-document", "~> 0.5.15"
13
16
  gem "rake"
14
17
  # relaton-bib is retired; its successors ship in the relaton 3.1 line.
15
18
  gem "rspec"
@@ -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"/>