metanorma-iho 1.4.10 → 1.4.12

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: 0f0eb6194ad58902b72b622a70c364a6c8b1f21aaadf4b49b72dc0443cd6a53a
4
- data.tar.gz: 2ce2393d5ccaa00cb3735a9ac2ab3637abb3081a1528e7e16e48ef47dea31aaf
3
+ metadata.gz: cc25a4bd27a28d5ee6580b2190d2c3b39c777aba9dd904ab549254284afd4e2f
4
+ data.tar.gz: ed6e8be974227a903e9fa2925f7bfe5028d0fa9af422c8544e654626a8a49af8
5
5
  SHA512:
6
- metadata.gz: f24588b9fd29907800e9218e1e1792c173b79c1e6971acf49944e408bc7494afd724a943f5f6d6e9b763ee1f1f54353795795f1c66a1257bf12d9d93ac73e053
7
- data.tar.gz: 5ff763a111a676d0b9eb7dc9bc5b87b2ff43f250be839824c1162c6fe04d0db17c364848c3f51d18882eb7ca5880be88813cfa6dda768559423c4e605f1c9ba2
6
+ metadata.gz: '00952bb216fc6e45d35eadd803310db17d203059cc661ef49a0403e9a60910c6b9297c17aabcc01b1a3b65b94ec6feda3311c239e14e714a2295becf76395841'
7
+ data.tar.gz: b355aaf202334048ab51d98d865d9392c80e6169001234354b512d46d44d075785a3b02693490e402283cfdb5bf7cf433d23ad5b3c15246204d2fea9b860067d
data/Gemfile CHANGED
@@ -8,9 +8,13 @@ gem "pubid", "~> 2.0"
8
8
  gem "isodoc", "~> 3.7.9"
9
9
  gem "isodoc-i18n", github: "metanorma/isodoc-i18n", branch: "main"
10
10
  gem "metanorma-standoc", "~> 3.5.7"
11
- gem "metanorma-document", "~> 0.5.3"
11
+ gem "metanorma-document", "~> 0.5.15"
12
12
  gem "metanorma-core", github: "metanorma/metanorma-core", branch: "main"
13
13
  gem "metanorma-iso", github: "metanorma/metanorma-iso", branch: "main"
14
14
  gem "metanorma-generic", github: "metanorma/metanorma-generic", branch: "main"
15
15
  gem "metanorma-utils", "~> 2.0"
16
16
  gem "metanorma-plugin-lutaml", github: "metanorma/metanorma-plugin-lutaml", branch: "main"
17
+
18
+ # kaleidl loads the LADL label-style profile carried as data under lib/
19
+ # (metanorma-document#215 item 5); dev-bundle test dependency only
20
+ gem "kaleidl", "~> 0.1"
@@ -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:variable name="debug">false</xsl:variable>
10
11
 
@@ -19,23 +20,30 @@
19
20
  <xsl:for-each select="xalan:nodeset($current_document)">
20
21
  <mnx:doc num="{$num}">
21
22
 
22
- <xsl:variable name="title-en"><xsl:apply-templates select="/mn:metanorma/mn:bibdata/mn:title[@language = 'en']/node()"/></xsl:variable>
23
- <xsl:variable name="title-main"><xsl:apply-templates select="/mn:metanorma/mn:bibdata/mn:title[@type = 'main']/node()"/></xsl:variable>
23
+ <xsl:variable name="contextNode" select="xalan:evaluate($bibdataContextNode)"/>
24
+ <xsl:copy-of select="$contextNode"/>
25
+
26
+ <metanorma_bibdata>
27
+ <xsl:copy-of select="/mn:metanorma/mn:bibdata"/>
28
+ </metanorma_bibdata>
29
+
30
+ <xsl:variable name="title-en"><xsl:apply-templates select="$contextNode/mn:title[@language = 'en']/node()"/></xsl:variable>
31
+ <xsl:variable name="title-main"><xsl:apply-templates select="$contextNode/mn:title[@type = 'main']/node()"/></xsl:variable>
24
32
 
25
33
  <title_header>
26
34
  <xsl:copy-of select="$title-main"/>
27
35
  <xsl:if test="normalize-space($title-main) = ''"><xsl:copy-of select="$title-en"/></xsl:if>
28
36
  </title_header>
29
37
 
30
- <xsl:variable name="docidentifier_parent" select="normalize-space(/mn:metanorma/mn:bibdata/mn:docidentifier[@type = 'IHO-parent-document'])"/>
38
+ <xsl:variable name="docidentifier_parent" select="normalize-space($contextNode/mn:docidentifier[@type = 'IHO-parent-document'])"/>
31
39
  <docidentifier>
32
40
  <xsl:value-of select="$docidentifier_parent"/>
33
- <xsl:if test="$docidentifier_parent = ''"><xsl:value-of select="/mn:metanorma/mn:bibdata/mn:docidentifier[@type = 'IHO']"/></xsl:if>
41
+ <xsl:if test="$docidentifier_parent = ''"><xsl:value-of select="$contextNode/mn:docidentifier[@type = 'IHO']"/></xsl:if>
34
42
  </docidentifier>
35
43
 
36
- <edition><xsl:apply-templates select="/mn:metanorma/mn:bibdata/mn:edition[normalize-space(@language) = '']"/></edition>
44
+ <edition><xsl:apply-templates select="$contextNode/mn:edition[normalize-space(@language) = '']"/></edition>
37
45
 
38
- <month_year><xsl:apply-templates select="/mn:metanorma/mn:bibdata/mn:date[@type = 'published']"/></month_year>
46
+ <month_year><xsl:apply-templates select="$contextNode/mn:date[@type = 'published']"/></month_year>
39
47
 
40
48
  </mnx:doc>
41
49
  </xsl:for-each>
@@ -247,7 +255,9 @@
247
255
 
248
256
  <xsl:for-each select="xalan:nodeset($current_document)">
249
257
 
250
- <xsl:call-template name="cover-pages"/>
258
+ <xsl:call-template name="cover-pages">
259
+ <xsl:with-param name="num" select="$num"/>
260
+ </xsl:call-template>
251
261
 
252
262
  <xsl:call-template name="inner-cover-page"/>
253
263
 
@@ -419,15 +429,16 @@
419
429
  </xsl:template>
420
430
 
421
431
  <xsl:template name="cover-page">
422
- <xsl:variable name="num" select="number(java:org.metanorma.fop.global.Variables.getVariable('num'))"/>
432
+ <xsl:param name="num"/>
423
433
 
424
- <xsl:variable name="title-en"><xsl:apply-templates select="/mn:metanorma/mn:bibdata/mn:title[@language = 'en']/node()"/></xsl:variable>
425
- <xsl:variable name="title-main_"><xsl:apply-templates select="/mn:metanorma/mn:bibdata/mn:title[@type = 'main']/node()"/></xsl:variable>
426
- <xsl:variable name="title-main"><xsl:apply-templates select="/mn:metanorma/mn:bibdata/mn:title[@type = 'title-main']/node()"/></xsl:variable>
427
- <xsl:variable name="title-appendix"><xsl:apply-templates select="/mn:metanorma/mn:bibdata/mn:title[@type = 'title-appendix']/node()"/></xsl:variable>
428
- <xsl:variable name="title-annex"><xsl:apply-templates select="/mn:metanorma/mn:bibdata/mn:title[@type = 'title-annex']/node()"/></xsl:variable>
429
- <xsl:variable name="title-part"><xsl:apply-templates select="/mn:metanorma/mn:bibdata/mn:title[@type = 'title-part']/node()"/></xsl:variable>
430
- <xsl:variable name="title-supplement"><xsl:apply-templates select="/mn:metanorma/mn:bibdata/mn:title[@type = 'title-supplement']/node()"/></xsl:variable>
434
+ <xsl:variable name="contextNode" select="xalan:evaluate($bibdataContextNode)"/>
435
+ <xsl:variable name="title-en"><xsl:apply-templates select="$contextNode/mn:title[@language = 'en']/node()"/></xsl:variable>
436
+ <xsl:variable name="title-main_"><xsl:apply-templates select="$contextNode/mn:title[@type = 'main']/node()"/></xsl:variable>
437
+ <xsl:variable name="title-main"><xsl:apply-templates select="$contextNode/mn:title[@type = 'title-main']/node()"/></xsl:variable>
438
+ <xsl:variable name="title-appendix"><xsl:apply-templates select="$contextNode/mn:title[@type = 'title-appendix']/node()"/></xsl:variable>
439
+ <xsl:variable name="title-annex"><xsl:apply-templates select="$contextNode/mn:title[@type = 'title-annex']/node()"/></xsl:variable>
440
+ <xsl:variable name="title-part"><xsl:apply-templates select="$contextNode/mn:title[@type = 'title-part']/node()"/></xsl:variable>
441
+ <xsl:variable name="title-supplement"><xsl:apply-templates select="$contextNode/mn:title[@type = 'title-supplement']/node()"/></xsl:variable>
431
442
 
432
443
  <!-- =========================== -->
433
444
  <!-- Cover Page -->
@@ -487,7 +498,7 @@
487
498
  <fo:table-row>
488
499
  <fo:table-cell display-align="after" text-align="right">
489
500
  <fo:block font-size="1">
490
- <xsl:apply-templates select="/mn:metanorma/mn:bibdata/mn:contributor/mn:organization/mn:logo[@type = 'mark']"/>
501
+ <xsl:apply-templates select="$contextNode/mn:contributor/mn:organization/mn:logo[@type = 'mark']"/>
491
502
  </fo:block>
492
503
  </fo:table-cell>
493
504
 
@@ -563,12 +574,12 @@
563
574
  <fo:table-row>
564
575
  <fo:table-cell>
565
576
  <fo:block font-size="1">
566
- <xsl:apply-templates select="/mn:metanorma/mn:bibdata/mn:contributor/mn:organization/mn:logo[@type = 'sign']"/>
577
+ <xsl:apply-templates select="$contextNode/mn:contributor/mn:organization/mn:logo[@type = 'sign']"/>
567
578
  </fo:block>
568
579
  </fo:table-cell>
569
580
  <fo:table-cell>
570
581
  <fo:block font-size="1">
571
- <xsl:apply-templates select="/mn:metanorma/mn:bibdata/mn:contributor/mn:organization/mn:logo[@type = 'desc']"/>
582
+ <xsl:apply-templates select="$contextNode/mn:contributor/mn:organization/mn:logo[@type = 'desc']"/>
572
583
  </fo:block>
573
584
  </fo:table-cell>
574
585
  <fo:table-cell number-rows-spanned="2">
@@ -585,7 +596,7 @@
585
596
  <fo:table-cell number-columns-spanned="2" padding-top="2mm">
586
597
  <fo:block-container width="51.5mm">
587
598
  <fo:block>
588
- <xsl:for-each select="/mn:metanorma/mn:bibdata/mn:contributor[mn:role/@type = 'publisher']/mn:organization[not(mn:abbreviation = 'IHO')]">
599
+ <xsl:for-each select="$contextNode/mn:contributor[mn:role/@type = 'publisher']/mn:organization[not(mn:abbreviation = 'IHO')]">
589
600
  <xsl:apply-templates select="mn:logo/mn:image">
590
601
  <xsl:with-param name="logo_width">25.8mm</xsl:with-param>
591
602
  </xsl:apply-templates>
@@ -976,7 +987,7 @@
976
987
  <fo:inline><xsl:copy-of select="@id"/><xsl:apply-templates/></fo:inline>
977
988
  </xsl:template>
978
989
 
979
- <xsl:template match="mn:metanorma/mn:bibdata/mn:edition">
990
+ <xsl:template match="mn:metanorma/mn:bibdata/mn:edition | mn:bibdata//mn:relation/mn:bibitem/mn:edition">
980
991
  <xsl:call-template name="capitalize">
981
992
  <xsl:with-param name="str">
982
993
  <xsl:call-template name="getLocalizedString">
@@ -988,7 +999,7 @@
988
999
  <xsl:apply-templates/>
989
1000
  </xsl:template>
990
1001
 
991
- <xsl:template match="mn:metanorma/mn:bibdata/mn:date[@type = 'published']">
1002
+ <xsl:template match="mn:metanorma/mn:bibdata/mn:date[@type = 'published'] | mn:bibdata//mn:relation/mn:bibitem/mn:date[@type = 'published']">
992
1003
  <xsl:call-template name="convertDate">
993
1004
  <xsl:with-param name="date" select="."/>
994
1005
  <xsl:with-param name="format" select="'short'"/>
@@ -2188,8 +2199,24 @@
2188
2199
  <xsl:if test="$docnum != '1'">_<xsl:value-of select="$docnum"/></xsl:if>
2189
2200
  </xsl:variable>
2190
2201
  <xsl:variable name="named_dest_doc" select="normalize-space($named_dest_doc_)"/>
2191
- <xsl:if test="not(key('kid', $named_dest_doc))"> <!-- if element with id '$named_dest_doc' doesn't exist in the document -->
2192
- <xsl:attribute name="named_dest"><xsl:value-of select="normalize-space($named_dest_doc)"/></xsl:attribute>
2202
+ <xsl:variable name="named_dest_unique_">
2203
+ <xsl:choose>
2204
+ <xsl:when test="normalize-space($caption_label) != '' and self::mn:fmt-name and count(key('kname_caption_label', $caption_label)) &gt; 1">
2205
+ <!-- duplicate caption numbers across clauses (e.g. two "Table 1" in front matter): qualify with the owner element id so fo ids stay unique -->
2206
+ <xsl:value-of select="concat(normalize-space($named_dest_doc), '_', ancestor::*[@id][1]/@id)"/>
2207
+ </xsl:when>
2208
+ <xsl:when test="normalize-space($caption_label) != '' and self::mn:fmt-title and count(key('ktitle_caption_label', $caption_label)) &gt; 1">
2209
+ <!-- duplicate clauses's caption numbers: qualify with the owner element id so fo ids stay unique -->
2210
+ <xsl:value-of select="concat(normalize-space($named_dest_doc), '_', ancestor::*[@id][1]/@id)"/>
2211
+ </xsl:when>
2212
+ <xsl:otherwise>
2213
+ <xsl:value-of select="normalize-space($named_dest_doc)"/>
2214
+ </xsl:otherwise>
2215
+ </xsl:choose>
2216
+ </xsl:variable>
2217
+ <xsl:variable name="named_dest_unique" select="normalize-space($named_dest_unique_)"/>
2218
+ <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 -->
2219
+ <xsl:attribute name="named_dest"><xsl:value-of select="$named_dest_unique"/></xsl:attribute>
2193
2220
  </xsl:if>
2194
2221
  </xsl:if>
2195
2222
  </xsl:template>
@@ -10284,8 +10311,30 @@
10284
10311
  <xsl:choose>
10285
10312
  <xsl:when test=".//*[local-name() = 'a'][*[local-name() = 'rect'] or *[local-name() = 'polygon'] or *[local-name() = 'circle'] or *[local-name() = 'ellipse']]">
10286
10313
  <fo:block>
10287
- <xsl:variable name="width" select="@width"/>
10288
- <xsl:variable name="height" select="@height"/>
10314
+ <!-- fallback for a size that is not a positive finite px number (missing, %, em, NaN, negative, huge):
10315
+ the svg_update default, i.e. the viewBox dimension, else 400 -->
10316
+ <xsl:variable name="vb" select="normalize-space(@viewBox)"/>
10317
+ <xsl:variable name="vb_width" select="number(substring-before(concat(substring-after(substring-after($vb, ' '), ' '), ' '), ' '))"/>
10318
+ <xsl:variable name="vb_height" select="number(substring-before(concat(substring-after(substring-after(substring-after($vb, ' '), ' '), ' '), ' '), ' '))"/>
10319
+
10320
+ <!-- strip a case-insensitive px suffix, trim NBSP, accept only a positive finite number -->
10321
+ <xsl:variable name="width_num" select="number(normalize-space(java:replaceAll(java:java.lang.String.new(normalize-space(translate(@width, ' ', ' '))), '(?i)px$', '')))"/>
10322
+ <xsl:variable name="height_num" select="number(normalize-space(java:replaceAll(java:java.lang.String.new(normalize-space(translate(@height, ' ', ' '))), '(?i)px$', '')))"/>
10323
+
10324
+ <xsl:variable name="width">
10325
+ <xsl:choose>
10326
+ <xsl:when test="$width_num &gt; 0 and $width_num - $width_num = 0"><xsl:value-of select="$width_num"/></xsl:when>
10327
+ <xsl:when test="$vb_width &gt; 0 and $vb_width - $vb_width = 0"><xsl:value-of select="round($vb_width)"/></xsl:when>
10328
+ <xsl:otherwise>400</xsl:otherwise>
10329
+ </xsl:choose>
10330
+ </xsl:variable>
10331
+ <xsl:variable name="height">
10332
+ <xsl:choose>
10333
+ <xsl:when test="$height_num &gt; 0 and $height_num - $height_num = 0"><xsl:value-of select="$height_num"/></xsl:when>
10334
+ <xsl:when test="$vb_height &gt; 0 and $vb_height - $vb_height = 0"><xsl:value-of select="round($vb_height)"/></xsl:when>
10335
+ <xsl:otherwise>400</xsl:otherwise>
10336
+ </xsl:choose>
10337
+ </xsl:variable>
10289
10338
 
10290
10339
  <xsl:variable name="scale_x">
10291
10340
  <xsl:choose>
@@ -10533,13 +10582,26 @@
10533
10582
  </xsl:copy>
10534
10583
  </xsl:template>
10535
10584
 
10585
+ <!-- embedded svg length: keep a valid unitless or lowercase px value as written; write a positive finite
10586
+ px value without its unit (no NBSP/case/space residue); otherwise the svg_update default 400 (Batik rejects raw px/%/NBSP/negative) -->
10587
+ <xsl:template name="svg_length">
10588
+ <xsl:variable name="raw" select="normalize-space(translate(., ' ', ' '))"/>
10589
+ <xsl:variable name="num" select="number(normalize-space(java:replaceAll(java:java.lang.String.new($raw), '(?i)px$', '')))"/>
10590
+ <xsl:choose>
10591
+ <xsl:when test="number($raw) &gt; 0 and number($raw) - number($raw) = 0"><xsl:value-of select="$raw"/></xsl:when>
10592
+ <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>
10593
+ <xsl:when test="$num &gt; 0 and $num - $num = 0"><xsl:value-of select="$num"/></xsl:when>
10594
+ <xsl:otherwise>400</xsl:otherwise>
10595
+ </xsl:choose>
10596
+ </xsl:template>
10597
+
10536
10598
  <xsl:template match="*[local-name() = 'svg']/@width" mode="svg_update">
10537
10599
  <!-- image[@width]/svg -->
10538
10600
  <xsl:variable name="parent_image_width" select="normalize-space(ancestor::*[2][self::mn:image]/@width)"/>
10539
10601
  <xsl:attribute name="width">
10540
10602
  <xsl:choose>
10541
10603
  <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>
10542
- <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
10604
+ <xsl:otherwise><xsl:call-template name="svg_length"/></xsl:otherwise>
10543
10605
  </xsl:choose>
10544
10606
  </xsl:attribute>
10545
10607
  </xsl:template>
@@ -10550,7 +10612,7 @@
10550
10612
  <xsl:attribute name="height">
10551
10613
  <xsl:choose>
10552
10614
  <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>
10553
- <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
10615
+ <xsl:otherwise><xsl:call-template name="svg_length"/></xsl:otherwise>
10554
10616
  </xsl:choose>
10555
10617
  </xsl:attribute>
10556
10618
  </xsl:template>
@@ -15862,7 +15924,8 @@
15862
15924
  </xsl:template>
15863
15925
 
15864
15926
  <xsl:template name="getDoctypeTitle">
15865
- <xsl:variable name="doctype_i18n" select="normalize-space(/mn:metanorma/mn:bibdata/mn:ext/mn:doctype[@language = $lang])"/>
15927
+ <xsl:variable name="contextNode" select="xalan:evaluate($bibdataContextNode)"/>
15928
+ <xsl:variable name="doctype_i18n" select="normalize-space($contextNode/mn:ext/mn:doctype[@language = $lang])"/>
15866
15929
  <xsl:value-of select="$doctype_i18n"/>
15867
15930
  <xsl:if test="$doctype_i18n = ''">
15868
15931
  <xsl:variable name="doctype"><xsl:call-template name="getDoctype"/></xsl:variable>
@@ -15927,13 +15990,23 @@
15927
15990
  <xsl:param name="letter-spacing" select="'0.15'"/>
15928
15991
  <xsl:if test="string-length($text) &gt; 0">
15929
15992
  <xsl:variable name="char" select="substring($text, 1, 1)"/>
15930
- <fo:inline padding-right="{$letter-spacing}mm">
15931
- <xsl:if test="$char = '®'">
15932
- <xsl:attribute name="font-size">58%</xsl:attribute>
15933
- <xsl:attribute name="baseline-shift">30%</xsl:attribute>
15934
- </xsl:if>
15935
- <xsl:value-of select="$char"/>
15936
- </fo:inline>
15993
+ <xsl:choose>
15994
+ <xsl:when test="contains($letter-spacing, 'em') or contains($letter-spacing, 'mm')">
15995
+ <!-- for negative letter spacing (in em) -->
15996
+ <fo:inline letter-spacing="{$letter-spacing}">
15997
+ <xsl:value-of select="$char"/>
15998
+ </fo:inline>
15999
+ </xsl:when>
16000
+ <xsl:otherwise>
16001
+ <fo:inline padding-right="{$letter-spacing}mm">
16002
+ <xsl:if test="$char = '®'">
16003
+ <xsl:attribute name="font-size">58%</xsl:attribute>
16004
+ <xsl:attribute name="baseline-shift">30%</xsl:attribute>
16005
+ </xsl:if>
16006
+ <xsl:value-of select="$char"/>
16007
+ </fo:inline>
16008
+ </xsl:otherwise>
16009
+ </xsl:choose>
15937
16010
  <xsl:call-template name="add-letter-spacing">
15938
16011
  <xsl:with-param name="text" select="substring($text, 2)"/>
15939
16012
  <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:variable name="debug">false</xsl:variable>
10
11
 
@@ -19,23 +20,30 @@
19
20
  <xsl:for-each select="xalan:nodeset($current_document)">
20
21
  <mnx:doc num="{$num}">
21
22
 
22
- <xsl:variable name="title-en"><xsl:apply-templates select="/mn:metanorma/mn:bibdata/mn:title[@language = 'en']/node()"/></xsl:variable>
23
- <xsl:variable name="title-main"><xsl:apply-templates select="/mn:metanorma/mn:bibdata/mn:title[@type = 'main']/node()"/></xsl:variable>
23
+ <xsl:variable name="contextNode" select="xalan:evaluate($bibdataContextNode)"/>
24
+ <xsl:copy-of select="$contextNode"/>
25
+
26
+ <metanorma_bibdata>
27
+ <xsl:copy-of select="/mn:metanorma/mn:bibdata"/>
28
+ </metanorma_bibdata>
29
+
30
+ <xsl:variable name="title-en"><xsl:apply-templates select="$contextNode/mn:title[@language = 'en']/node()"/></xsl:variable>
31
+ <xsl:variable name="title-main"><xsl:apply-templates select="$contextNode/mn:title[@type = 'main']/node()"/></xsl:variable>
24
32
 
25
33
  <title_header>
26
34
  <xsl:copy-of select="$title-main"/>
27
35
  <xsl:if test="normalize-space($title-main) = ''"><xsl:copy-of select="$title-en"/></xsl:if>
28
36
  </title_header>
29
37
 
30
- <xsl:variable name="docidentifier_parent" select="normalize-space(/mn:metanorma/mn:bibdata/mn:docidentifier[@type = 'IHO-parent-document'])"/>
38
+ <xsl:variable name="docidentifier_parent" select="normalize-space($contextNode/mn:docidentifier[@type = 'IHO-parent-document'])"/>
31
39
  <docidentifier>
32
40
  <xsl:value-of select="$docidentifier_parent"/>
33
- <xsl:if test="$docidentifier_parent = ''"><xsl:value-of select="/mn:metanorma/mn:bibdata/mn:docidentifier[@type = 'IHO']"/></xsl:if>
41
+ <xsl:if test="$docidentifier_parent = ''"><xsl:value-of select="$contextNode/mn:docidentifier[@type = 'IHO']"/></xsl:if>
34
42
  </docidentifier>
35
43
 
36
- <edition><xsl:apply-templates select="/mn:metanorma/mn:bibdata/mn:edition[normalize-space(@language) = '']"/></edition>
44
+ <edition><xsl:apply-templates select="$contextNode/mn:edition[normalize-space(@language) = '']"/></edition>
37
45
 
38
- <month_year><xsl:apply-templates select="/mn:metanorma/mn:bibdata/mn:date[@type = 'published']"/></month_year>
46
+ <month_year><xsl:apply-templates select="$contextNode/mn:date[@type = 'published']"/></month_year>
39
47
 
40
48
  </mnx:doc>
41
49
  </xsl:for-each>
@@ -247,7 +255,9 @@
247
255
 
248
256
  <xsl:for-each select="xalan:nodeset($current_document)">
249
257
 
250
- <xsl:call-template name="cover-pages"/>
258
+ <xsl:call-template name="cover-pages">
259
+ <xsl:with-param name="num" select="$num"/>
260
+ </xsl:call-template>
251
261
 
252
262
  <xsl:call-template name="inner-cover-page"/>
253
263
 
@@ -419,15 +429,16 @@
419
429
  </xsl:template>
420
430
 
421
431
  <xsl:template name="cover-page">
422
- <xsl:variable name="num" select="number(java:org.metanorma.fop.global.Variables.getVariable('num'))"/>
432
+ <xsl:param name="num"/>
423
433
 
424
- <xsl:variable name="title-en"><xsl:apply-templates select="/mn:metanorma/mn:bibdata/mn:title[@language = 'en']/node()"/></xsl:variable>
425
- <xsl:variable name="title-main_"><xsl:apply-templates select="/mn:metanorma/mn:bibdata/mn:title[@type = 'main']/node()"/></xsl:variable>
426
- <xsl:variable name="title-main"><xsl:apply-templates select="/mn:metanorma/mn:bibdata/mn:title[@type = 'title-main']/node()"/></xsl:variable>
427
- <xsl:variable name="title-appendix"><xsl:apply-templates select="/mn:metanorma/mn:bibdata/mn:title[@type = 'title-appendix']/node()"/></xsl:variable>
428
- <xsl:variable name="title-annex"><xsl:apply-templates select="/mn:metanorma/mn:bibdata/mn:title[@type = 'title-annex']/node()"/></xsl:variable>
429
- <xsl:variable name="title-part"><xsl:apply-templates select="/mn:metanorma/mn:bibdata/mn:title[@type = 'title-part']/node()"/></xsl:variable>
430
- <xsl:variable name="title-supplement"><xsl:apply-templates select="/mn:metanorma/mn:bibdata/mn:title[@type = 'title-supplement']/node()"/></xsl:variable>
434
+ <xsl:variable name="contextNode" select="xalan:evaluate($bibdataContextNode)"/>
435
+ <xsl:variable name="title-en"><xsl:apply-templates select="$contextNode/mn:title[@language = 'en']/node()"/></xsl:variable>
436
+ <xsl:variable name="title-main_"><xsl:apply-templates select="$contextNode/mn:title[@type = 'main']/node()"/></xsl:variable>
437
+ <xsl:variable name="title-main"><xsl:apply-templates select="$contextNode/mn:title[@type = 'title-main']/node()"/></xsl:variable>
438
+ <xsl:variable name="title-appendix"><xsl:apply-templates select="$contextNode/mn:title[@type = 'title-appendix']/node()"/></xsl:variable>
439
+ <xsl:variable name="title-annex"><xsl:apply-templates select="$contextNode/mn:title[@type = 'title-annex']/node()"/></xsl:variable>
440
+ <xsl:variable name="title-part"><xsl:apply-templates select="$contextNode/mn:title[@type = 'title-part']/node()"/></xsl:variable>
441
+ <xsl:variable name="title-supplement"><xsl:apply-templates select="$contextNode/mn:title[@type = 'title-supplement']/node()"/></xsl:variable>
431
442
 
432
443
  <!-- =========================== -->
433
444
  <!-- Cover Page -->
@@ -487,7 +498,7 @@
487
498
  <fo:table-row>
488
499
  <fo:table-cell display-align="after" text-align="right">
489
500
  <fo:block font-size="1">
490
- <xsl:apply-templates select="/mn:metanorma/mn:bibdata/mn:contributor/mn:organization/mn:logo[@type = 'mark']"/>
501
+ <xsl:apply-templates select="$contextNode/mn:contributor/mn:organization/mn:logo[@type = 'mark']"/>
491
502
  </fo:block>
492
503
  </fo:table-cell>
493
504
 
@@ -563,12 +574,12 @@
563
574
  <fo:table-row>
564
575
  <fo:table-cell>
565
576
  <fo:block font-size="1">
566
- <xsl:apply-templates select="/mn:metanorma/mn:bibdata/mn:contributor/mn:organization/mn:logo[@type = 'sign']"/>
577
+ <xsl:apply-templates select="$contextNode/mn:contributor/mn:organization/mn:logo[@type = 'sign']"/>
567
578
  </fo:block>
568
579
  </fo:table-cell>
569
580
  <fo:table-cell>
570
581
  <fo:block font-size="1">
571
- <xsl:apply-templates select="/mn:metanorma/mn:bibdata/mn:contributor/mn:organization/mn:logo[@type = 'desc']"/>
582
+ <xsl:apply-templates select="$contextNode/mn:contributor/mn:organization/mn:logo[@type = 'desc']"/>
572
583
  </fo:block>
573
584
  </fo:table-cell>
574
585
  <fo:table-cell number-rows-spanned="2">
@@ -585,7 +596,7 @@
585
596
  <fo:table-cell number-columns-spanned="2" padding-top="2mm">
586
597
  <fo:block-container width="51.5mm">
587
598
  <fo:block>
588
- <xsl:for-each select="/mn:metanorma/mn:bibdata/mn:contributor[mn:role/@type = 'publisher']/mn:organization[not(mn:abbreviation = 'IHO')]">
599
+ <xsl:for-each select="$contextNode/mn:contributor[mn:role/@type = 'publisher']/mn:organization[not(mn:abbreviation = 'IHO')]">
589
600
  <xsl:apply-templates select="mn:logo/mn:image">
590
601
  <xsl:with-param name="logo_width">25.8mm</xsl:with-param>
591
602
  </xsl:apply-templates>
@@ -976,7 +987,7 @@
976
987
  <fo:inline><xsl:copy-of select="@id"/><xsl:apply-templates/></fo:inline>
977
988
  </xsl:template>
978
989
 
979
- <xsl:template match="mn:metanorma/mn:bibdata/mn:edition">
990
+ <xsl:template match="mn:metanorma/mn:bibdata/mn:edition | mn:bibdata//mn:relation/mn:bibitem/mn:edition">
980
991
  <xsl:call-template name="capitalize">
981
992
  <xsl:with-param name="str">
982
993
  <xsl:call-template name="getLocalizedString">
@@ -988,7 +999,7 @@
988
999
  <xsl:apply-templates/>
989
1000
  </xsl:template>
990
1001
 
991
- <xsl:template match="mn:metanorma/mn:bibdata/mn:date[@type = 'published']">
1002
+ <xsl:template match="mn:metanorma/mn:bibdata/mn:date[@type = 'published'] | mn:bibdata//mn:relation/mn:bibitem/mn:date[@type = 'published']">
992
1003
  <xsl:call-template name="convertDate">
993
1004
  <xsl:with-param name="date" select="."/>
994
1005
  <xsl:with-param name="format" select="'short'"/>
@@ -2188,8 +2199,24 @@
2188
2199
  <xsl:if test="$docnum != '1'">_<xsl:value-of select="$docnum"/></xsl:if>
2189
2200
  </xsl:variable>
2190
2201
  <xsl:variable name="named_dest_doc" select="normalize-space($named_dest_doc_)"/>
2191
- <xsl:if test="not(key('kid', $named_dest_doc))"> <!-- if element with id '$named_dest_doc' doesn't exist in the document -->
2192
- <xsl:attribute name="named_dest"><xsl:value-of select="normalize-space($named_dest_doc)"/></xsl:attribute>
2202
+ <xsl:variable name="named_dest_unique_">
2203
+ <xsl:choose>
2204
+ <xsl:when test="normalize-space($caption_label) != '' and self::mn:fmt-name and count(key('kname_caption_label', $caption_label)) &gt; 1">
2205
+ <!-- duplicate caption numbers across clauses (e.g. two "Table 1" in front matter): qualify with the owner element id so fo ids stay unique -->
2206
+ <xsl:value-of select="concat(normalize-space($named_dest_doc), '_', ancestor::*[@id][1]/@id)"/>
2207
+ </xsl:when>
2208
+ <xsl:when test="normalize-space($caption_label) != '' and self::mn:fmt-title and count(key('ktitle_caption_label', $caption_label)) &gt; 1">
2209
+ <!-- duplicate clauses's caption numbers: qualify with the owner element id so fo ids stay unique -->
2210
+ <xsl:value-of select="concat(normalize-space($named_dest_doc), '_', ancestor::*[@id][1]/@id)"/>
2211
+ </xsl:when>
2212
+ <xsl:otherwise>
2213
+ <xsl:value-of select="normalize-space($named_dest_doc)"/>
2214
+ </xsl:otherwise>
2215
+ </xsl:choose>
2216
+ </xsl:variable>
2217
+ <xsl:variable name="named_dest_unique" select="normalize-space($named_dest_unique_)"/>
2218
+ <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 -->
2219
+ <xsl:attribute name="named_dest"><xsl:value-of select="$named_dest_unique"/></xsl:attribute>
2193
2220
  </xsl:if>
2194
2221
  </xsl:if>
2195
2222
  </xsl:template>
@@ -10284,8 +10311,30 @@
10284
10311
  <xsl:choose>
10285
10312
  <xsl:when test=".//*[local-name() = 'a'][*[local-name() = 'rect'] or *[local-name() = 'polygon'] or *[local-name() = 'circle'] or *[local-name() = 'ellipse']]">
10286
10313
  <fo:block>
10287
- <xsl:variable name="width" select="@width"/>
10288
- <xsl:variable name="height" select="@height"/>
10314
+ <!-- fallback for a size that is not a positive finite px number (missing, %, em, NaN, negative, huge):
10315
+ the svg_update default, i.e. the viewBox dimension, else 400 -->
10316
+ <xsl:variable name="vb" select="normalize-space(@viewBox)"/>
10317
+ <xsl:variable name="vb_width" select="number(substring-before(concat(substring-after(substring-after($vb, ' '), ' '), ' '), ' '))"/>
10318
+ <xsl:variable name="vb_height" select="number(substring-before(concat(substring-after(substring-after(substring-after($vb, ' '), ' '), ' '), ' '), ' '))"/>
10319
+
10320
+ <!-- strip a case-insensitive px suffix, trim NBSP, accept only a positive finite number -->
10321
+ <xsl:variable name="width_num" select="number(normalize-space(java:replaceAll(java:java.lang.String.new(normalize-space(translate(@width, ' ', ' '))), '(?i)px$', '')))"/>
10322
+ <xsl:variable name="height_num" select="number(normalize-space(java:replaceAll(java:java.lang.String.new(normalize-space(translate(@height, ' ', ' '))), '(?i)px$', '')))"/>
10323
+
10324
+ <xsl:variable name="width">
10325
+ <xsl:choose>
10326
+ <xsl:when test="$width_num &gt; 0 and $width_num - $width_num = 0"><xsl:value-of select="$width_num"/></xsl:when>
10327
+ <xsl:when test="$vb_width &gt; 0 and $vb_width - $vb_width = 0"><xsl:value-of select="round($vb_width)"/></xsl:when>
10328
+ <xsl:otherwise>400</xsl:otherwise>
10329
+ </xsl:choose>
10330
+ </xsl:variable>
10331
+ <xsl:variable name="height">
10332
+ <xsl:choose>
10333
+ <xsl:when test="$height_num &gt; 0 and $height_num - $height_num = 0"><xsl:value-of select="$height_num"/></xsl:when>
10334
+ <xsl:when test="$vb_height &gt; 0 and $vb_height - $vb_height = 0"><xsl:value-of select="round($vb_height)"/></xsl:when>
10335
+ <xsl:otherwise>400</xsl:otherwise>
10336
+ </xsl:choose>
10337
+ </xsl:variable>
10289
10338
 
10290
10339
  <xsl:variable name="scale_x">
10291
10340
  <xsl:choose>
@@ -10533,13 +10582,26 @@
10533
10582
  </xsl:copy>
10534
10583
  </xsl:template>
10535
10584
 
10585
+ <!-- embedded svg length: keep a valid unitless or lowercase px value as written; write a positive finite
10586
+ px value without its unit (no NBSP/case/space residue); otherwise the svg_update default 400 (Batik rejects raw px/%/NBSP/negative) -->
10587
+ <xsl:template name="svg_length">
10588
+ <xsl:variable name="raw" select="normalize-space(translate(., ' ', ' '))"/>
10589
+ <xsl:variable name="num" select="number(normalize-space(java:replaceAll(java:java.lang.String.new($raw), '(?i)px$', '')))"/>
10590
+ <xsl:choose>
10591
+ <xsl:when test="number($raw) &gt; 0 and number($raw) - number($raw) = 0"><xsl:value-of select="$raw"/></xsl:when>
10592
+ <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>
10593
+ <xsl:when test="$num &gt; 0 and $num - $num = 0"><xsl:value-of select="$num"/></xsl:when>
10594
+ <xsl:otherwise>400</xsl:otherwise>
10595
+ </xsl:choose>
10596
+ </xsl:template>
10597
+
10536
10598
  <xsl:template match="*[local-name() = 'svg']/@width" mode="svg_update">
10537
10599
  <!-- image[@width]/svg -->
10538
10600
  <xsl:variable name="parent_image_width" select="normalize-space(ancestor::*[2][self::mn:image]/@width)"/>
10539
10601
  <xsl:attribute name="width">
10540
10602
  <xsl:choose>
10541
10603
  <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>
10542
- <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
10604
+ <xsl:otherwise><xsl:call-template name="svg_length"/></xsl:otherwise>
10543
10605
  </xsl:choose>
10544
10606
  </xsl:attribute>
10545
10607
  </xsl:template>
@@ -10550,7 +10612,7 @@
10550
10612
  <xsl:attribute name="height">
10551
10613
  <xsl:choose>
10552
10614
  <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>
10553
- <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
10615
+ <xsl:otherwise><xsl:call-template name="svg_length"/></xsl:otherwise>
10554
10616
  </xsl:choose>
10555
10617
  </xsl:attribute>
10556
10618
  </xsl:template>
@@ -15862,7 +15924,8 @@
15862
15924
  </xsl:template>
15863
15925
 
15864
15926
  <xsl:template name="getDoctypeTitle">
15865
- <xsl:variable name="doctype_i18n" select="normalize-space(/mn:metanorma/mn:bibdata/mn:ext/mn:doctype[@language = $lang])"/>
15927
+ <xsl:variable name="contextNode" select="xalan:evaluate($bibdataContextNode)"/>
15928
+ <xsl:variable name="doctype_i18n" select="normalize-space($contextNode/mn:ext/mn:doctype[@language = $lang])"/>
15866
15929
  <xsl:value-of select="$doctype_i18n"/>
15867
15930
  <xsl:if test="$doctype_i18n = ''">
15868
15931
  <xsl:variable name="doctype"><xsl:call-template name="getDoctype"/></xsl:variable>
@@ -15927,13 +15990,23 @@
15927
15990
  <xsl:param name="letter-spacing" select="'0.15'"/>
15928
15991
  <xsl:if test="string-length($text) &gt; 0">
15929
15992
  <xsl:variable name="char" select="substring($text, 1, 1)"/>
15930
- <fo:inline padding-right="{$letter-spacing}mm">
15931
- <xsl:if test="$char = '®'">
15932
- <xsl:attribute name="font-size">58%</xsl:attribute>
15933
- <xsl:attribute name="baseline-shift">30%</xsl:attribute>
15934
- </xsl:if>
15935
- <xsl:value-of select="$char"/>
15936
- </fo:inline>
15993
+ <xsl:choose>
15994
+ <xsl:when test="contains($letter-spacing, 'em') or contains($letter-spacing, 'mm')">
15995
+ <!-- for negative letter spacing (in em) -->
15996
+ <fo:inline letter-spacing="{$letter-spacing}">
15997
+ <xsl:value-of select="$char"/>
15998
+ </fo:inline>
15999
+ </xsl:when>
16000
+ <xsl:otherwise>
16001
+ <fo:inline padding-right="{$letter-spacing}mm">
16002
+ <xsl:if test="$char = '®'">
16003
+ <xsl:attribute name="font-size">58%</xsl:attribute>
16004
+ <xsl:attribute name="baseline-shift">30%</xsl:attribute>
16005
+ </xsl:if>
16006
+ <xsl:value-of select="$char"/>
16007
+ </fo:inline>
16008
+ </xsl:otherwise>
16009
+ </xsl:choose>
15937
16010
  <xsl:call-template name="add-letter-spacing">
15938
16011
  <xsl:with-param name="text" select="substring($text, 2)"/>
15939
16012
  <xsl:with-param name="letter-spacing" select="$letter-spacing"/>
@@ -0,0 +1,651 @@
1
+ // ISO/IEC Label Style Definition in LutaML
2
+ // Based on LADL specification in document.adoc
3
+
4
+ // Main label style instance for ISO/IEC
5
+ instance IhoLabelStyle < LabelStyle {
6
+ name = "Iho Label Style"
7
+ definition {
8
+ The Iho label style inherits the IHO labeling conventions
9
+ * the ISO/IEC Directives, Part 2 as realized by the shared engine defaults
10
+ * the ISO House Style.
11
+
12
+ This style defines the labeling scheme used by Iho deliverables.
13
+ }
14
+
15
+ // References to all labellers defined in this style
16
+
17
+ // EXTRACTION GAPS (engine/profile support needed):
18
+ // * IHO annexes switch between "Annex" and "Appendix" (xref annexlbl, obligation-driven) — same obligation-condition gap as ITU
19
+
20
+ labellers = [
21
+ "id:clause_labeller",
22
+ "id:subclause_labeller",
23
+ "id:annex_labeller",
24
+ "id:annex_clause_labeller",
25
+ "id:annex_subclause_labeller",
26
+ "id:annex_note_labeller",
27
+ "id:annex_example_labeller",
28
+ "id:subclause_note_labeller",
29
+ "id:subclause_example_labeller",
30
+ "id:figure_labeller",
31
+ "id:annex_figure_labeller",
32
+ "id:subfigure_labeller",
33
+ "id:table_labeller",
34
+ "id:annex_table_labeller",
35
+ "id:note_labeller",
36
+ "id:example_labeller",
37
+ "id:formula_labeller",
38
+ "id:annex_formula_labeller",
39
+ "id:list_labeller",
40
+ "id:annex_list_labeller",
41
+ "id:unordered_list_item_labeller",
42
+ "id:ordered_list_item_level1_labeller",
43
+ "id:ordered_list_item_level2_labeller",
44
+ "id:ordered_list_item_level3_labeller",
45
+ "id:ordered_list_item_level4_labeller"
46
+ ]
47
+
48
+ // References to all sequences used in this style
49
+ sequences = [
50
+ DecimalNumericSequence,
51
+ AlphaLowerNumericSequence,
52
+ AlphaUpperNumericSequence,
53
+ RomanLowerNumericSequence
54
+ ]
55
+
56
+ // References to all templates used in this style
57
+ templates = [
58
+ ClauseLabelTemplate,
59
+ ClauseGlobalLabelTemplate,
60
+ SubclauseLabelTemplate,
61
+ SubclauseGlobalLabelTemplate,
62
+ AnnexLabelTemplate,
63
+ AnnexGlobalLabelTemplate,
64
+ AnnexClauseLabelTemplate,
65
+ AnnexClauseGlobalLabelTemplate,
66
+ AnnexSubclauseLabelTemplate,
67
+ AnnexSubclauseGlobalLabelTemplate,
68
+ FigureLabelTemplate,
69
+ FigureGlobalLabelTemplate,
70
+ AnnexFigureLabelTemplate,
71
+ AnnexFigureGlobalLabelTemplate,
72
+ SubfigureLabelTemplate,
73
+ SubfigureGlobalLabelTemplate,
74
+ TableLabelTemplate,
75
+ TableGlobalLabelTemplate,
76
+ AnnexTableLabelTemplate,
77
+ AnnexTableGlobalLabelTemplate,
78
+ NoteSingleLabelTemplate,
79
+ NoteMultipleLabelTemplate,
80
+ NoteSingleGlobalLabelTemplate,
81
+ NoteMultipleGlobalLabelTemplate,
82
+ ExampleSingleLabelTemplate,
83
+ ExampleMultipleLabelTemplate,
84
+ ExampleSingleGlobalLabelTemplate,
85
+ ExampleMultipleGlobalLabelTemplate,
86
+ FormulaLabelTemplate,
87
+ FormulaGlobalLabelTemplate,
88
+ AnnexFormulaLabelTemplate,
89
+ AnnexFormulaGlobalLabelTemplate,
90
+ ListLabelTemplate,
91
+ ListGlobalLabelTemplate,
92
+ AnnexListLabelTemplate,
93
+ AnnexListGlobalLabelTemplate,
94
+ UnorderedListItemLabelTemplate,
95
+ OrderedListItemLevel1LabelTemplate,
96
+ OrderedListItemLevel2LabelTemplate,
97
+ OrderedListItemLevel3LabelTemplate,
98
+ OrderedListItemLevel4LabelTemplate
99
+ ]
100
+
101
+ // References to all contexts used in this style
102
+ contexts = [
103
+ DocumentContext,
104
+ ClauseContext,
105
+ SubclauseContext,
106
+ AnnexContext,
107
+ AnnexClauseContext,
108
+ ListContext
109
+ ]
110
+ }
111
+
112
+ // Define the document context
113
+ instance DocumentContext < LabelContext {
114
+ name = "document"
115
+ definition "Top-level document context for ISO/IEC documents"
116
+ }
117
+
118
+ // Clause labeling
119
+ instance ClauseContext < LabelContext {
120
+ name = "clause"
121
+ parent = DocumentContext
122
+ definition "Context for clauses within the main document"
123
+ }
124
+
125
+ instance SubclauseContext < LabelContext {
126
+ name = "subclause"
127
+ parent = ClauseContext
128
+ definition "Context for subclauses within clauses"
129
+ }
130
+
131
+ // Clause templates
132
+ instance ClauseLabelTemplate < LabelTemplate {
133
+ pattern = "{clause} %n"
134
+ definition "Template for local clause references"
135
+ }
136
+
137
+ instance ClauseGlobalLabelTemplate < LabelTemplate {
138
+ pattern = "{clause} %n"
139
+ definition "Template for global clause references"
140
+ }
141
+
142
+ instance ClauseLabeller < Labeller {
143
+ id = "clause_labeller"
144
+ sequence = DecimalNumericSequence
145
+ context = DocumentContext
146
+ type = "clause"
147
+ template = ClauseLabelTemplate
148
+ global_template = ClauseGlobalLabelTemplate
149
+ definition "Labeller for clauses in the main document"
150
+ }
151
+
152
+ // Subclause templates
153
+ instance SubclauseLabelTemplate < LabelTemplate {
154
+ pattern = "%pn.%n"
155
+ definition "Template for local subclause references"
156
+ }
157
+
158
+ instance SubclauseGlobalLabelTemplate < LabelTemplate {
159
+ pattern = "%pn.%n"
160
+ definition "Template for global subclause references"
161
+ }
162
+
163
+ instance SubclauseLabeller < Labeller {
164
+ id = "subclause_labeller"
165
+ sequence = DecimalNumericSequence
166
+ context = ClauseContext
167
+ parent = ClauseLabeller
168
+ type = "subclause"
169
+ template = SubclauseLabelTemplate
170
+ global_template = SubclauseGlobalLabelTemplate
171
+ definition "Labeller for subclauses within clauses"
172
+ }
173
+
174
+ // Annex labeling
175
+ instance AnnexContext < LabelContext {
176
+ name = "annex"
177
+ parent = DocumentContext
178
+ definition "Context for annexes within the document"
179
+ }
180
+
181
+ instance AnnexClauseContext < LabelContext {
182
+ name = "annex_clause"
183
+ parent = AnnexContext
184
+ definition "Context for clauses within annexes"
185
+ }
186
+
187
+ instance AnnexLabelTemplate < LabelTemplate {
188
+ pattern = "{annex} %n"
189
+ definition "Template for local annex references"
190
+ }
191
+
192
+ instance AnnexGlobalLabelTemplate < LabelTemplate {
193
+ pattern = "{annex} %n"
194
+ definition "Template for global annex references"
195
+ }
196
+
197
+ instance AnnexLabeller < Labeller {
198
+ id = "annex_labeller"
199
+ sequence = AlphaUpperNumericSequence
200
+ context = DocumentContext
201
+ type = "annex"
202
+ template = AnnexLabelTemplate
203
+ global_template = AnnexGlobalLabelTemplate
204
+ definition "Labeller for annexes in the document"
205
+ }
206
+
207
+ instance AnnexClauseLabelTemplate < LabelTemplate {
208
+ pattern = "%pn.%n"
209
+ definition "Template for local annex clause references"
210
+ }
211
+
212
+ instance AnnexClauseGlobalLabelTemplate < LabelTemplate {
213
+ pattern = "%pn.%n"
214
+ definition "Template for global annex clause references"
215
+ }
216
+
217
+ instance AnnexClauseLabeller < Labeller {
218
+ id = "annex_clause_labeller"
219
+ sequence = DecimalNumericSequence
220
+ context = AnnexContext
221
+ parent = AnnexLabeller
222
+ type = "clause"
223
+ template = AnnexClauseLabelTemplate
224
+ global_template = AnnexClauseGlobalLabelTemplate
225
+ definition "Labeller for clauses within annexes"
226
+ }
227
+
228
+ // Annex subclauses: ISO/IEC documents label clause descendants inside
229
+ // annexes hierarchically (A.1.1, A.1.1.1), per the current ISO engine
230
+ // (isodoc annex_names recursion) and the ISO/IEC Directives Part 2.
231
+ instance AnnexSubclauseLabelTemplate < LabelTemplate {
232
+ pattern = "%pn.%n"
233
+ definition "Template for local annex subclause references"
234
+ }
235
+
236
+ instance AnnexSubclauseGlobalLabelTemplate < LabelTemplate {
237
+ pattern = "%pn.%n"
238
+ definition "Template for global annex subclause references"
239
+ }
240
+
241
+ instance AnnexSubclauseLabeller < Labeller {
242
+ id = "annex_subclause_labeller"
243
+ sequence = DecimalNumericSequence
244
+ context = AnnexClauseContext
245
+ parent = AnnexClauseLabeller
246
+ type = "subclause"
247
+ template = AnnexSubclauseLabelTemplate
248
+ global_template = AnnexSubclauseGlobalLabelTemplate
249
+ definition "Labeller for subclauses within annex clauses"
250
+ }
251
+
252
+ // Notes and examples inside annexes: bound to the annex clause context
253
+ // so they label (and restart per annex clause) instead of falling
254
+ // through to the main-document labellers.
255
+ instance AnnexNoteLabeller < Labeller {
256
+ id = "annex_note_labeller"
257
+ sequence = DecimalNumericSequence
258
+ context = AnnexClauseContext
259
+ type = "note"
260
+ template = [NoteSingleLabelTemplate, NoteMultipleLabelTemplate]
261
+ global_template = [NoteSingleGlobalLabelTemplate, NoteMultipleGlobalLabelTemplate]
262
+ definition "Labeller for notes within annex clauses"
263
+ }
264
+
265
+ instance AnnexExampleLabeller < Labeller {
266
+ id = "annex_example_labeller"
267
+ sequence = DecimalNumericSequence
268
+ context = AnnexClauseContext
269
+ type = "example"
270
+ template = [ExampleSingleLabelTemplate, ExampleMultipleLabelTemplate]
271
+ global_template = [ExampleSingleGlobalLabelTemplate, ExampleMultipleGlobalLabelTemplate]
272
+ definition "Labeller for examples within annex clauses"
273
+ }
274
+
275
+ // Figure labeling
276
+ instance FigureLabelTemplate < LabelTemplate {
277
+ pattern = "{figure} %n"
278
+ definition "Template for local figure references in the main document"
279
+ }
280
+
281
+ instance FigureGlobalLabelTemplate < LabelTemplate {
282
+ pattern = "{figure} %n"
283
+ definition "Template for global figure references in the main document"
284
+ }
285
+
286
+ instance FigureLabeller < Labeller {
287
+ id = "figure_labeller"
288
+ sequence = DecimalNumericSequence
289
+ context = DocumentContext
290
+ type = "figure"
291
+ template = FigureLabelTemplate
292
+ global_template = FigureGlobalLabelTemplate
293
+ definition "Labeller for figures in the main document"
294
+ }
295
+
296
+ instance AnnexFigureLabelTemplate < LabelTemplate {
297
+ pattern = "{figure} %pn.%n"
298
+ definition "Template for local figure references in annexes"
299
+ }
300
+
301
+ instance AnnexFigureGlobalLabelTemplate < LabelTemplate {
302
+ pattern = "{figure} %pn.%n"
303
+ definition "Template for global figure references in annexes"
304
+ }
305
+
306
+ instance AnnexFigureLabeller < Labeller {
307
+ id = "annex_figure_labeller"
308
+ sequence = DecimalNumericSequence
309
+ context = AnnexContext
310
+ parent = AnnexLabeller
311
+ type = "figure"
312
+ template = AnnexFigureLabelTemplate
313
+ global_template = AnnexFigureGlobalLabelTemplate
314
+ definition "Labeller for figures in annexes"
315
+ }
316
+
317
+ // Subfigure labeling
318
+ instance SubfigureLabelTemplate < LabelTemplate {
319
+ pattern = "{figure} %pn %n)"
320
+ definition "Template for local subfigure references"
321
+ }
322
+
323
+ instance SubfigureGlobalLabelTemplate < LabelTemplate {
324
+ pattern = "{figure} %pn %n)"
325
+ definition "Template for global subfigure references"
326
+ }
327
+
328
+ instance SubfigureLabeller < Labeller {
329
+ id = "subfigure_labeller"
330
+ sequence = AlphaLowerNumericSequence
331
+ context = DocumentContext
332
+ parent = FigureLabeller
333
+ type = "subfigure"
334
+ template = SubfigureLabelTemplate
335
+ global_template = SubfigureGlobalLabelTemplate
336
+ definition "Labeller for subfigures in the document"
337
+ }
338
+
339
+ // Table labeling
340
+ instance TableLabelTemplate < LabelTemplate {
341
+ pattern = "{table} %n"
342
+ definition "Template for local table references in the main document"
343
+ }
344
+
345
+ instance TableGlobalLabelTemplate < LabelTemplate {
346
+ pattern = "{table} %n"
347
+ definition "Template for global table references in the main document"
348
+ }
349
+
350
+ instance TableLabeller < Labeller {
351
+ id = "table_labeller"
352
+ sequence = DecimalNumericSequence
353
+ context = DocumentContext
354
+ type = "table"
355
+ template = TableLabelTemplate
356
+ global_template = TableGlobalLabelTemplate
357
+ definition "Labeller for tables in the main document"
358
+ }
359
+
360
+ instance AnnexTableLabelTemplate < LabelTemplate {
361
+ pattern = "{table} %pn.%n"
362
+ definition "Template for local table references in annexes"
363
+ }
364
+
365
+ instance AnnexTableGlobalLabelTemplate < LabelTemplate {
366
+ pattern = "{table} %pn.%n"
367
+ definition "Template for global table references in annexes"
368
+ }
369
+
370
+ instance AnnexTableLabeller < Labeller {
371
+ id = "annex_table_labeller"
372
+ sequence = DecimalNumericSequence
373
+ context = AnnexContext
374
+ parent = AnnexLabeller
375
+ type = "table"
376
+ template = AnnexTableLabelTemplate
377
+ global_template = AnnexTableGlobalLabelTemplate
378
+ definition "Labeller for tables in annexes"
379
+ }
380
+
381
+ // Note labeling
382
+ instance NoteSingleLabelTemplate < LabelTemplate {
383
+ pattern = "{note}"
384
+ definition "Template for single note references"
385
+ }
386
+
387
+ instance NoteMultipleLabelTemplate < LabelTemplate {
388
+ pattern = "{note} %n"
389
+ definition "Template for multiple note references"
390
+ condition = {
391
+ type = "element_count_gt"
392
+ threshold = 1
393
+ }
394
+ }
395
+
396
+ instance NoteSingleGlobalLabelTemplate < LabelTemplate {
397
+ pattern = "%parent, {note}"
398
+ definition "Template for global single note references"
399
+ }
400
+
401
+ instance NoteMultipleGlobalLabelTemplate < LabelTemplate {
402
+ pattern = "%parent, {note} %n"
403
+ definition "Template for global multiple note references"
404
+ condition = {
405
+ type = "element_count_gt"
406
+ threshold = 1
407
+ }
408
+ }
409
+
410
+ instance NoteLabeller < Labeller {
411
+ id = "note_labeller"
412
+ sequence = DecimalNumericSequence
413
+ context = ClauseContext
414
+ type = "note"
415
+ template = [NoteSingleLabelTemplate, NoteMultipleLabelTemplate]
416
+ global_template = [NoteSingleGlobalLabelTemplate, NoteMultipleGlobalLabelTemplate]
417
+ definition "Labeller for notes in clauses with conditional templates based on note count"
418
+ }
419
+
420
+ // Notes count per section in ISO/IEC documents: the current ISO engine
421
+ // (isodoc note_anchor_names) restarts the counter for every clause and
422
+ // subclause, so notes inside subclauses bind to SubclauseContext rather
423
+ // than continuing the enclosing clause's counter.
424
+ instance SubclauseNoteLabeller < Labeller {
425
+ id = "subclause_note_labeller"
426
+ sequence = DecimalNumericSequence
427
+ context = SubclauseContext
428
+ type = "note"
429
+ template = [NoteSingleLabelTemplate, NoteMultipleLabelTemplate]
430
+ global_template = [NoteSingleGlobalLabelTemplate, NoteMultipleGlobalLabelTemplate]
431
+ definition "Labeller for notes within subclauses (counter restarts per subclause)"
432
+ }
433
+
434
+ // Example labeling
435
+ instance ExampleSingleLabelTemplate < LabelTemplate {
436
+ pattern = "{example}"
437
+ definition "Template for single example references"
438
+ }
439
+
440
+ instance ExampleMultipleLabelTemplate < LabelTemplate {
441
+ pattern = "{example} %n"
442
+ definition "Template for multiple example references"
443
+ condition = {
444
+ type = "element_count_gt"
445
+ threshold = 1
446
+ }
447
+ }
448
+
449
+ instance ExampleSingleGlobalLabelTemplate < LabelTemplate {
450
+ pattern = "%parent, EXAMPLE"
451
+ definition "Template for global single example references"
452
+ }
453
+
454
+ instance ExampleMultipleGlobalLabelTemplate < LabelTemplate {
455
+ pattern = "%parent, EXAMPLE %n"
456
+ definition "Template for global multiple example references"
457
+ condition = {
458
+ type = "element_count_gt"
459
+ threshold = 1
460
+ }
461
+ }
462
+
463
+ instance ExampleLabeller < Labeller {
464
+ id = "example_labeller"
465
+ sequence = DecimalNumericSequence
466
+ context = ClauseContext
467
+ type = "example"
468
+ template = [ExampleSingleLabelTemplate, ExampleMultipleLabelTemplate]
469
+ global_template = [ExampleSingleGlobalLabelTemplate, ExampleMultipleGlobalLabelTemplate]
470
+ definition "Labeller for examples in clauses with conditional templates based on example count"
471
+ }
472
+
473
+ // Examples count per section in ISO/IEC documents, like notes (isodoc
474
+ // example_anchor_names restarts the counter per clause and subclause).
475
+ instance SubclauseExampleLabeller < Labeller {
476
+ id = "subclause_example_labeller"
477
+ sequence = DecimalNumericSequence
478
+ context = SubclauseContext
479
+ type = "example"
480
+ template = [ExampleSingleLabelTemplate, ExampleMultipleLabelTemplate]
481
+ global_template = [ExampleSingleGlobalLabelTemplate, ExampleMultipleGlobalLabelTemplate]
482
+ definition "Labeller for examples within subclauses (counter restarts per subclause)"
483
+ }
484
+
485
+ // Formula labeling
486
+ instance FormulaLabelTemplate < LabelTemplate {
487
+ pattern = "(%n)"
488
+ definition "Template for local formula references in the main document"
489
+ }
490
+
491
+ instance FormulaGlobalLabelTemplate < LabelTemplate {
492
+ pattern = "Formula (%n)"
493
+ definition "Template for global formula references in the main document"
494
+ }
495
+
496
+ instance FormulaLabeller < Labeller {
497
+ id = "formula_labeller"
498
+ sequence = DecimalNumericSequence
499
+ context = DocumentContext
500
+ type = "formula"
501
+ template = FormulaLabelTemplate
502
+ global_template = FormulaGlobalLabelTemplate
503
+ definition "Labeller for formulas in the main document"
504
+ }
505
+
506
+ instance AnnexFormulaLabelTemplate < LabelTemplate {
507
+ pattern = "(%pn.%n)"
508
+ definition "Template for local formula references in annexes"
509
+ }
510
+
511
+ instance AnnexFormulaGlobalLabelTemplate < LabelTemplate {
512
+ pattern = "Formula (%pn.%n)"
513
+ definition "Template for global formula references in annexes"
514
+ }
515
+
516
+ instance AnnexFormulaLabeller < Labeller {
517
+ id = "annex_formula_labeller"
518
+ sequence = DecimalNumericSequence
519
+ context = AnnexContext
520
+ parent = AnnexLabeller
521
+ type = "formula"
522
+ template = AnnexFormulaLabelTemplate
523
+ global_template = AnnexFormulaGlobalLabelTemplate
524
+ definition "Labeller for formulas in annexes"
525
+ }
526
+
527
+ // List labeling
528
+ instance ListContext < LabelContext {
529
+ name = "list"
530
+ parent = ClauseContext
531
+ definition "Context for lists within clauses"
532
+ }
533
+
534
+ instance ListLabelTemplate < LabelTemplate {
535
+ pattern = "List %n"
536
+ definition "Template for local list references in the main document"
537
+ }
538
+
539
+ instance ListGlobalLabelTemplate < LabelTemplate {
540
+ pattern = "List %n"
541
+ definition "Template for global list references in the main document"
542
+ }
543
+
544
+ instance ListLabeller < Labeller {
545
+ id = "list_labeller"
546
+ sequence = DecimalNumericSequence
547
+ context = ClauseContext
548
+ type = "list"
549
+ template = ListLabelTemplate
550
+ global_template = ListGlobalLabelTemplate
551
+ definition "Labeller for lists in the main document"
552
+ }
553
+
554
+ instance AnnexListLabelTemplate < LabelTemplate {
555
+ pattern = "List %pn.%n"
556
+ definition "Template for local list references in annexes"
557
+ }
558
+
559
+ instance AnnexListGlobalLabelTemplate < LabelTemplate {
560
+ pattern = "List %pn.%n"
561
+ definition "Template for global list references in annexes"
562
+ }
563
+
564
+ instance AnnexListLabeller < Labeller {
565
+ id = "annex_list_labeller"
566
+ sequence = DecimalNumericSequence
567
+ context = AnnexContext
568
+ parent = AnnexLabeller
569
+ type = "list"
570
+ template = AnnexListLabelTemplate
571
+ global_template = AnnexListGlobalLabelTemplate
572
+ definition "Labeller for lists in annexes"
573
+ }
574
+
575
+ // List item labeling - unordered
576
+ instance UnorderedListItemLabelTemplate < LabelTemplate {
577
+ pattern = "—"
578
+ definition "Template for unordered list items at all levels"
579
+ }
580
+
581
+ instance UnorderedListItemLabeller < Labeller {
582
+ id = "unordered_list_item_labeller"
583
+ sequence = DecimalNumericSequence // Not used but required
584
+ context = ListContext
585
+ type = "list_item_unordered"
586
+ template = UnorderedListItemLabelTemplate
587
+ definition "Labeller for unordered list items"
588
+ }
589
+
590
+ // List item labeling - ordered, level 1 (a), b), c)...)
591
+ instance OrderedListItemLevel1LabelTemplate < LabelTemplate {
592
+ pattern = "%n)"
593
+ definition "Template for first level ordered list items"
594
+ }
595
+
596
+ instance OrderedListItemLevel1Labeller < Labeller {
597
+ id = "ordered_list_item_level1_labeller"
598
+ sequence = AlphaLowerNumericSequence
599
+ context = ListContext
600
+ type = "list_item_ordered_level1"
601
+ template = OrderedListItemLevel1LabelTemplate
602
+ definition "Labeller for first level ordered list items"
603
+ }
604
+
605
+ // List item labeling - ordered, level 2 (1), 2), 3)...)
606
+ instance OrderedListItemLevel2LabelTemplate < LabelTemplate {
607
+ pattern = "%n)"
608
+ definition "Template for second level ordered list items"
609
+ }
610
+
611
+ instance OrderedListItemLevel2Labeller < Labeller {
612
+ id = "ordered_list_item_level2_labeller"
613
+ sequence = DecimalNumericSequence
614
+ context = ListContext
615
+ parent = OrderedListItemLevel1Labeller
616
+ type = "list_item_ordered_level2"
617
+ template = OrderedListItemLevel2LabelTemplate
618
+ definition "Labeller for second level ordered list items"
619
+ }
620
+
621
+ // List item labeling - ordered, level 3 (i), ii), iii)...)
622
+ instance OrderedListItemLevel3LabelTemplate < LabelTemplate {
623
+ pattern = "%n)"
624
+ definition "Template for third level ordered list items"
625
+ }
626
+
627
+ instance OrderedListItemLevel3Labeller < Labeller {
628
+ id = "ordered_list_item_level3_labeller"
629
+ sequence = RomanLowerNumericSequence
630
+ context = ListContext
631
+ parent = OrderedListItemLevel2Labeller
632
+ type = "list_item_ordered_level3"
633
+ template = OrderedListItemLevel3LabelTemplate
634
+ definition "Labeller for third level ordered list items"
635
+ }
636
+
637
+ // List item labeling - ordered, level 4 (a), b), c)... - repeats first level)
638
+ instance OrderedListItemLevel4LabelTemplate < LabelTemplate {
639
+ pattern = "%n)"
640
+ definition "Template for fourth level ordered list items"
641
+ }
642
+
643
+ instance OrderedListItemLevel4Labeller < Labeller {
644
+ id = "ordered_list_item_level4_labeller"
645
+ sequence = AlphaLowerNumericSequence
646
+ context = ListContext
647
+ parent = OrderedListItemLevel3Labeller
648
+ type = "list_item_ordered_level4"
649
+ template = OrderedListItemLevel4LabelTemplate
650
+ definition "Labeller for fourth level ordered list items"
651
+ }
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Iho
3
- VERSION = "1.4.10".freeze
3
+ VERSION = "1.4.12".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-iho
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.10
4
+ version: 1.4.12
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-25 00:00:00.000000000 Z
11
+ date: 2026-11-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pubid
@@ -273,6 +273,7 @@ files:
273
273
  - lib/metanorma/iho/html/renderer.rb
274
274
  - lib/metanorma/iho/iho-style.yml
275
275
  - lib/metanorma/iho/iho.rng
276
+ - lib/metanorma/iho/label_style.lml
276
277
  - lib/metanorma/iho/log.rb
277
278
  - lib/metanorma/iho/m3_stages.rb
278
279
  - lib/metanorma/iho/mathml4-content.rng