metanorma-iso 2.2.0 → 2.2.2

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 (35) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/automerge.yml +31 -0
  3. data/lib/isodoc/iso/html/style-human.css +1 -1
  4. data/lib/isodoc/iso/html/style-iso.css +1 -1
  5. data/lib/isodoc/iso/i18n-en.yaml +9 -2
  6. data/lib/isodoc/iso/i18n-fr.yaml +9 -2
  7. data/lib/isodoc/iso/i18n-ru.yaml +9 -2
  8. data/lib/isodoc/iso/i18n-zh-Hans.yaml +1 -2
  9. data/lib/isodoc/iso/iso.amendment.xsl +54 -4
  10. data/lib/isodoc/iso/iso.international-standard.xsl +54 -4
  11. data/lib/isodoc/iso/presentation_xref.rb +10 -7
  12. data/lib/isodoc/iso/sections.rb +1 -1
  13. data/lib/isodoc/iso/xref.rb +37 -88
  14. data/lib/isodoc/iso/xref_section.rb +79 -0
  15. data/lib/metanorma/iso/basicdoc.rng +0 -27
  16. data/lib/metanorma/iso/biblio-standoc.rng +164 -0
  17. data/lib/metanorma/iso/biblio.rng +45 -18
  18. data/lib/metanorma/iso/isodoc.rng +31 -194
  19. data/lib/metanorma/iso/isostandard-amd.rng +3 -54
  20. data/lib/metanorma/iso/isostandard-compile.rng +7 -0
  21. data/lib/metanorma/iso/isostandard.rng +1 -192
  22. data/lib/metanorma/iso/relaton-iso.rng +225 -0
  23. data/lib/metanorma/iso/validate.rb +7 -7
  24. data/lib/metanorma/iso/version.rb +1 -1
  25. data/lib/metanorma/requirements/modspec.rb +26 -39
  26. data/spec/isodoc/inline_spec.rb +1 -1
  27. data/spec/metanorma/base_spec.rb +3 -3
  28. data/spec/metanorma/refs_spec.rb +7 -7
  29. data/spec/metanorma/validate_spec.rb +55 -55
  30. data/spec/requirements/requirement_components_spec.rb +53 -65
  31. data/spec/requirements/requirements_spec.rb +178 -263
  32. data/spec/requirements/xref_spec.rb +35 -35
  33. data/spec/vcr_cassettes/docrels.yml +32 -32
  34. data/spec/vcr_cassettes/withdrawn_iso.yml +30 -30
  35. metadata +7 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0af0800e26b96ca0808ae0be76f68c3311325d2271c10a1c91cd112bc041dcc4
4
- data.tar.gz: 587c652c18c8845754062388caf26d4968b6d1f7742bb049a04fe41b88dae29a
3
+ metadata.gz: bababdaaa40b4311b1ea3b536d4033bbeb418582ef7c4b7bd8cc5dcec43dfc4c
4
+ data.tar.gz: e3a3754839ac30e66c0d35574d565bced4e951a8bd1042e56cb85c390bcaf8fd
5
5
  SHA512:
6
- metadata.gz: 9e0ad39b60566f4ddf7aee46f15c9cb68c32e44e61a1f55bf26a64b7ffbe5c65ab8015dc41f4b95afdf06e79fa2c0c46fe75b3ccd93a6d19ebbfb6747fbb4f85
7
- data.tar.gz: 695551d2e13d64d7b522634fcfb6e81a002e9f0a1c0440cc6ef1614b8bc53546f23d8c2b53159665644f5e31bd2dde43a610930e01fdf6a5850675deac68fcb7
6
+ metadata.gz: fa5cd0815b1649389973e2bfff66581386dd68450b53f31e3f5d4ae8e91c59bcebc6d5fe63691542c918dc93a6dd3a6e8392ebf32207e5b22d69785c7005852c
7
+ data.tar.gz: fdbcfc037894c4121c50eefc9eab7c26296dfeb599152409b2c46fd8f84a231051d7e21d5a6696eddf43002c6ca79cb3977972f92dab5dc2b974ed1c54a45722
@@ -0,0 +1,31 @@
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
3
+ # source: https://github.com/marketplace/actions/merge-pull-requests#usage
4
+ name: automerge
5
+ on:
6
+ pull_request:
7
+ types:
8
+ - labeled
9
+ - unlabeled
10
+ - synchronize
11
+ - opened
12
+ - edited
13
+ - ready_for_review
14
+ - reopened
15
+ - unlocked
16
+ pull_request_review:
17
+ types:
18
+ - submitted
19
+ check_suite:
20
+ types:
21
+ - completed
22
+ status: {}
23
+ jobs:
24
+ automerge:
25
+ runs-on: ubuntu-latest
26
+ steps:
27
+ - id: automerge
28
+ name: automerge
29
+ uses: "pascalgn/automerge-action@v0.15.3"
30
+ env:
31
+ GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
@@ -582,7 +582,7 @@ div.figure {
582
582
  font-weight: 700;
583
583
  font-size: 1em;
584
584
  text-align: center; }
585
- div.figure > img {
585
+ div.figure > img, div.figure > svg {
586
586
  margin-left: auto;
587
587
  margin-right: auto;
588
588
  display: block;
@@ -534,7 +534,7 @@ div.figure {
534
534
  font-weight: 700;
535
535
  font-size: 1em;
536
536
  text-align: center; }
537
- div.figure > img {
537
+ div.figure > img, div.figure > svg {
538
538
  margin-left: auto;
539
539
  margin-right: auto;
540
540
  display: block;
@@ -76,5 +76,12 @@ locality:
76
76
  appendix: Appendix
77
77
  requirements:
78
78
  modspec:
79
- description: Description
80
- provisions: Provisions
79
+ provision: Provision
80
+ conformancetest: Conformance test
81
+ inflection:
82
+ Provision:
83
+ sg: Provision
84
+ pl: Provisions
85
+ Statement:
86
+ sg: Statement
87
+ pl: Statements
@@ -70,5 +70,12 @@ locality:
70
70
  appendix: Appendice
71
71
  requirements:
72
72
  modspec:
73
- description: Description
74
- provisions: Dispositions
73
+ provision: Disposition
74
+ conformancetest: Test de conformité
75
+ inflection:
76
+ Disposition:
77
+ sg: Disposition
78
+ pl: Dispositions
79
+ Déclaration:
80
+ sg: Déclaration
81
+ pl: Déclarations
@@ -74,5 +74,12 @@ locality:
74
74
  appendix: Приложение
75
75
  requirements:
76
76
  modspec:
77
- description: Описание
78
- provisions: Условия
77
+ provision: Условие
78
+ conformancetest: Тест на соответствие
79
+ inflection:
80
+ Условие:
81
+ sg: Условие
82
+ pl: Условия
83
+ Утверждение:
84
+ sg: Утверждение
85
+ pl: Утверждения
@@ -71,5 +71,4 @@ locality:
71
71
  appendix: 附录
72
72
  requirements:
73
73
  modspec:
74
- description: 描述
75
- provisions: 条件
74
+ provision: 条件
@@ -5,6 +5,7 @@
5
5
  <xsl:key name="kfn" match="*[local-name() = 'fn'][not(ancestor::*[(local-name() = 'table' or local-name() = 'figure') and not(ancestor::*[local-name() = 'name'])])]" use="@reference"/>
6
6
 
7
7
  <xsl:key name="attachments" match="iso:eref[java:endsWith(java:java.lang.String.new(@bibitemid),'.exp')]" use="@bibitemid"/>
8
+ <xsl:key name="attachments2" match="iso:eref[contains(@bibitemid,'.exp_')]" use="@bibitemid"/>
8
9
 
9
10
  <xsl:variable name="namespace_full">https://www.metanorma.org/ns/iso</xsl:variable>
10
11
 
@@ -435,6 +436,15 @@
435
436
  <xsl:variable name="url" select="concat('url(file:',$basepath, @bibitemid, ')')"/>
436
437
  <pdf:embedded-file src="{$url}" filename="{@bibitemid}"/>
437
438
  </xsl:for-each>
439
+ <xsl:for-each select="//*[local-name() = 'eref'][generate-id(.)=generate-id(key('attachments2',@bibitemid)[1])]">
440
+ <xsl:variable name="bibitemid" select="@bibitemid"/>
441
+ <xsl:variable name="uri" select="normalize-space($bibitems/*[local-name() ='bibitem'][@hidden = 'true'][@id = $bibitemid][1]/*[local-name() = 'uri'][@type='citation'])"/>
442
+ <xsl:if test="$uri != ''">
443
+ <xsl:variable name="url" select="concat('url(file:',$basepath, $uri, ')')"/>
444
+ <xsl:variable name="filename" select="concat(substring-before($bibitemid, '.exp_'), '.exp')"/>
445
+ <pdf:embedded-file src="{$url}" filename="{$filename}"/>
446
+ </xsl:if>
447
+ </xsl:for-each>
438
448
  </fo:declarations>
439
449
 
440
450
  <xsl:call-template name="addBookmarks">
@@ -1890,6 +1900,9 @@
1890
1900
  </xsl:choose>
1891
1901
  </xsl:attribute>
1892
1902
  <xsl:attribute name="margin-bottom">8pt</xsl:attribute>
1903
+ <xsl:if test="starts-with(ancestor::*[local-name() = 'table'][1]/@type, 'recommend') and not(following-sibling::*[local-name() = 'p'])">
1904
+ <xsl:attribute name="margin-bottom">0pt</xsl:attribute>
1905
+ </xsl:if>
1893
1906
  <xsl:if test="@id">
1894
1907
  <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
1895
1908
  </xsl:if>
@@ -1948,6 +1961,28 @@
1948
1961
  </fo:inline>
1949
1962
  </xsl:template>
1950
1963
 
1964
+ <xsl:template match="*[local-name() = 'eref'][contains(@bibitemid,'.exp_')]" priority="2">
1965
+ <xsl:variable name="bibitemid" select="@bibitemid"/>
1966
+ <xsl:variable name="uri" select="normalize-space($bibitems/*[local-name() ='bibitem'][@hidden = 'true'][@id = $bibitemid][1]/*[local-name() = 'uri'][@type='citation'])"/>
1967
+ <xsl:choose>
1968
+ <xsl:when test="$uri != ''">
1969
+ <xsl:variable name="filename" select="concat(substring-before($bibitemid, '.exp_'), '.exp')"/>
1970
+ <fo:inline xsl:use-attribute-sets="eref-style">
1971
+ <xsl:variable name="url" select="concat('url(embedded-file:', $filename, ')')"/>
1972
+ <fo:basic-link external-destination="{$url}" fox:alt-text="{@citeas}">
1973
+ <xsl:if test="normalize-space(@citeas) = ''">
1974
+ <xsl:attribute name="fox:alt-text"><xsl:value-of select="."/></xsl:attribute>
1975
+ </xsl:if>
1976
+ <xsl:apply-templates/>
1977
+ </fo:basic-link>
1978
+ </fo:inline>
1979
+ </xsl:when>
1980
+ <xsl:otherwise>
1981
+ <xsl:call-template name="eref"/>
1982
+ </xsl:otherwise>
1983
+ </xsl:choose>
1984
+ </xsl:template>
1985
+
1951
1986
  <!-- =================== -->
1952
1987
  <!-- Index processing -->
1953
1988
  <!-- =================== -->
@@ -4721,6 +4756,9 @@
4721
4756
  <xsl:if test="ancestor::*[local-name() = 'tfoot']">
4722
4757
  <xsl:attribute name="border">solid black 0</xsl:attribute>
4723
4758
  </xsl:if>
4759
+ <xsl:if test="starts-with(ancestor::*[local-name() = 'table'][1]/@type, 'recommend')">
4760
+ <xsl:attribute name="display-align">before</xsl:attribute>
4761
+ </xsl:if>
4724
4762
 
4725
4763
  <xsl:if test=".//*[local-name() = 'table']"> <!-- if there is nested table -->
4726
4764
  <xsl:attribute name="padding-right">1mm</xsl:attribute>
@@ -5711,8 +5749,17 @@
5711
5749
  </fo:inline>
5712
5750
  </xsl:template> <!-- tt -->
5713
5751
 
5752
+ <xsl:variable name="regex_url_start">^(http://|https://|www\.)?(.*)</xsl:variable>
5714
5753
  <xsl:template match="*[local-name()='tt']/text()" priority="2">
5715
- <xsl:call-template name="add_spaces_to_sourcecode"/>
5754
+ <xsl:choose>
5755
+ <xsl:when test="java:replaceAll(java:java.lang.String.new(.), '$2', '') != ''">
5756
+ <!-- url -->
5757
+ <xsl:call-template name="add-zero-spaces-link-java"/>
5758
+ </xsl:when>
5759
+ <xsl:otherwise>
5760
+ <xsl:call-template name="add_spaces_to_sourcecode"/>
5761
+ </xsl:otherwise>
5762
+ </xsl:choose>
5716
5763
  </xsl:template>
5717
5764
 
5718
5765
  <xsl:template match="*[local-name()='underline']">
@@ -6068,8 +6115,11 @@
6068
6115
 
6069
6116
  <xsl:template name="add-zero-spaces-link-java">
6070
6117
  <xsl:param name="text" select="."/>
6118
+
6119
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new($text), $regex_url_start, '$1')"/> <!-- http://. https:// or www. -->
6120
+ <xsl:variable name="url_continue" select="java:replaceAll(java:java.lang.String.new($text), $regex_url_start, '$2')"/>
6071
6121
  <!-- add zero-width space (#x200B) after characters: dash, dot, colon, equal, underscore, em dash, thin space -->
6072
- <xsl:value-of select="java:replaceAll(java:java.lang.String.new($text),'(-|\.|:|=|_|—| |,)','$1​')"/>
6122
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new($url_continue),'(-|\.|:|=|_|—| |,|/)','$1​')"/>
6073
6123
  </xsl:template>
6074
6124
 
6075
6125
  <!-- add zero space after dash character (for table's entries) -->
@@ -9049,7 +9099,7 @@
9049
9099
  <!-- ====== -->
9050
9100
  <!-- eref -->
9051
9101
  <!-- ====== -->
9052
- <xsl:template match="*[local-name() = 'eref']">
9102
+ <xsl:template match="*[local-name() = 'eref']" name="eref">
9053
9103
  <xsl:variable name="current_bibitemid" select="@bibitemid"/>
9054
9104
  <!-- <xsl:variable name="external-destination" select="normalize-space(key('bibitems', $current_bibitemid)/*[local-name() = 'uri'][@type = 'citation'])"/> -->
9055
9105
  <xsl:variable name="external-destination" select="normalize-space($bibitems/*[local-name() ='bibitem'][@id = $current_bibitemid]/*[local-name() = 'uri'][@type = 'citation'])"/>
@@ -10609,7 +10659,7 @@
10609
10659
 
10610
10660
  <xsl:variable name="element_name_keep-together_within-line">keep-together_within-line</xsl:variable>
10611
10661
 
10612
- <xsl:template match="text()[not(ancestor::*[local-name() = 'bibdata'] or ancestor::*[local-name() = 'sourcecode'] or ancestor::*[local-name() = 'math'])]" name="keep_together_standard_number" mode="update_xml_enclose_keep-together_within-line">
10662
+ <xsl:template match="text()[not(ancestor::*[local-name() = 'bibdata'] or ancestor::*[local-name() = 'link'][not(contains(.,' '))] or ancestor::*[local-name() = 'sourcecode'] or ancestor::*[local-name() = 'math'] or starts-with(., 'http://') or starts-with(., 'https://') or starts-with(., 'www.') )]" name="keep_together_standard_number" mode="update_xml_enclose_keep-together_within-line">
10613
10663
 
10614
10664
  <!-- enclose standard's number into tag 'keep-together_within-line' -->
10615
10665
  <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
@@ -5,6 +5,7 @@
5
5
  <xsl:key name="kfn" match="*[local-name() = 'fn'][not(ancestor::*[(local-name() = 'table' or local-name() = 'figure') and not(ancestor::*[local-name() = 'name'])])]" use="@reference"/>
6
6
 
7
7
  <xsl:key name="attachments" match="iso:eref[java:endsWith(java:java.lang.String.new(@bibitemid),'.exp')]" use="@bibitemid"/>
8
+ <xsl:key name="attachments2" match="iso:eref[contains(@bibitemid,'.exp_')]" use="@bibitemid"/>
8
9
 
9
10
  <xsl:variable name="namespace_full">https://www.metanorma.org/ns/iso</xsl:variable>
10
11
 
@@ -435,6 +436,15 @@
435
436
  <xsl:variable name="url" select="concat('url(file:',$basepath, @bibitemid, ')')"/>
436
437
  <pdf:embedded-file src="{$url}" filename="{@bibitemid}"/>
437
438
  </xsl:for-each>
439
+ <xsl:for-each select="//*[local-name() = 'eref'][generate-id(.)=generate-id(key('attachments2',@bibitemid)[1])]">
440
+ <xsl:variable name="bibitemid" select="@bibitemid"/>
441
+ <xsl:variable name="uri" select="normalize-space($bibitems/*[local-name() ='bibitem'][@hidden = 'true'][@id = $bibitemid][1]/*[local-name() = 'uri'][@type='citation'])"/>
442
+ <xsl:if test="$uri != ''">
443
+ <xsl:variable name="url" select="concat('url(file:',$basepath, $uri, ')')"/>
444
+ <xsl:variable name="filename" select="concat(substring-before($bibitemid, '.exp_'), '.exp')"/>
445
+ <pdf:embedded-file src="{$url}" filename="{$filename}"/>
446
+ </xsl:if>
447
+ </xsl:for-each>
438
448
  </fo:declarations>
439
449
 
440
450
  <xsl:call-template name="addBookmarks">
@@ -1890,6 +1900,9 @@
1890
1900
  </xsl:choose>
1891
1901
  </xsl:attribute>
1892
1902
  <xsl:attribute name="margin-bottom">8pt</xsl:attribute>
1903
+ <xsl:if test="starts-with(ancestor::*[local-name() = 'table'][1]/@type, 'recommend') and not(following-sibling::*[local-name() = 'p'])">
1904
+ <xsl:attribute name="margin-bottom">0pt</xsl:attribute>
1905
+ </xsl:if>
1893
1906
  <xsl:if test="@id">
1894
1907
  <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
1895
1908
  </xsl:if>
@@ -1948,6 +1961,28 @@
1948
1961
  </fo:inline>
1949
1962
  </xsl:template>
1950
1963
 
1964
+ <xsl:template match="*[local-name() = 'eref'][contains(@bibitemid,'.exp_')]" priority="2">
1965
+ <xsl:variable name="bibitemid" select="@bibitemid"/>
1966
+ <xsl:variable name="uri" select="normalize-space($bibitems/*[local-name() ='bibitem'][@hidden = 'true'][@id = $bibitemid][1]/*[local-name() = 'uri'][@type='citation'])"/>
1967
+ <xsl:choose>
1968
+ <xsl:when test="$uri != ''">
1969
+ <xsl:variable name="filename" select="concat(substring-before($bibitemid, '.exp_'), '.exp')"/>
1970
+ <fo:inline xsl:use-attribute-sets="eref-style">
1971
+ <xsl:variable name="url" select="concat('url(embedded-file:', $filename, ')')"/>
1972
+ <fo:basic-link external-destination="{$url}" fox:alt-text="{@citeas}">
1973
+ <xsl:if test="normalize-space(@citeas) = ''">
1974
+ <xsl:attribute name="fox:alt-text"><xsl:value-of select="."/></xsl:attribute>
1975
+ </xsl:if>
1976
+ <xsl:apply-templates/>
1977
+ </fo:basic-link>
1978
+ </fo:inline>
1979
+ </xsl:when>
1980
+ <xsl:otherwise>
1981
+ <xsl:call-template name="eref"/>
1982
+ </xsl:otherwise>
1983
+ </xsl:choose>
1984
+ </xsl:template>
1985
+
1951
1986
  <!-- =================== -->
1952
1987
  <!-- Index processing -->
1953
1988
  <!-- =================== -->
@@ -4721,6 +4756,9 @@
4721
4756
  <xsl:if test="ancestor::*[local-name() = 'tfoot']">
4722
4757
  <xsl:attribute name="border">solid black 0</xsl:attribute>
4723
4758
  </xsl:if>
4759
+ <xsl:if test="starts-with(ancestor::*[local-name() = 'table'][1]/@type, 'recommend')">
4760
+ <xsl:attribute name="display-align">before</xsl:attribute>
4761
+ </xsl:if>
4724
4762
 
4725
4763
  <xsl:if test=".//*[local-name() = 'table']"> <!-- if there is nested table -->
4726
4764
  <xsl:attribute name="padding-right">1mm</xsl:attribute>
@@ -5711,8 +5749,17 @@
5711
5749
  </fo:inline>
5712
5750
  </xsl:template> <!-- tt -->
5713
5751
 
5752
+ <xsl:variable name="regex_url_start">^(http://|https://|www\.)?(.*)</xsl:variable>
5714
5753
  <xsl:template match="*[local-name()='tt']/text()" priority="2">
5715
- <xsl:call-template name="add_spaces_to_sourcecode"/>
5754
+ <xsl:choose>
5755
+ <xsl:when test="java:replaceAll(java:java.lang.String.new(.), '$2', '') != ''">
5756
+ <!-- url -->
5757
+ <xsl:call-template name="add-zero-spaces-link-java"/>
5758
+ </xsl:when>
5759
+ <xsl:otherwise>
5760
+ <xsl:call-template name="add_spaces_to_sourcecode"/>
5761
+ </xsl:otherwise>
5762
+ </xsl:choose>
5716
5763
  </xsl:template>
5717
5764
 
5718
5765
  <xsl:template match="*[local-name()='underline']">
@@ -6068,8 +6115,11 @@
6068
6115
 
6069
6116
  <xsl:template name="add-zero-spaces-link-java">
6070
6117
  <xsl:param name="text" select="."/>
6118
+
6119
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new($text), $regex_url_start, '$1')"/> <!-- http://. https:// or www. -->
6120
+ <xsl:variable name="url_continue" select="java:replaceAll(java:java.lang.String.new($text), $regex_url_start, '$2')"/>
6071
6121
  <!-- add zero-width space (#x200B) after characters: dash, dot, colon, equal, underscore, em dash, thin space -->
6072
- <xsl:value-of select="java:replaceAll(java:java.lang.String.new($text),'(-|\.|:|=|_|—| |,)','$1​')"/>
6122
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new($url_continue),'(-|\.|:|=|_|—| |,|/)','$1​')"/>
6073
6123
  </xsl:template>
6074
6124
 
6075
6125
  <!-- add zero space after dash character (for table's entries) -->
@@ -9049,7 +9099,7 @@
9049
9099
  <!-- ====== -->
9050
9100
  <!-- eref -->
9051
9101
  <!-- ====== -->
9052
- <xsl:template match="*[local-name() = 'eref']">
9102
+ <xsl:template match="*[local-name() = 'eref']" name="eref">
9053
9103
  <xsl:variable name="current_bibitemid" select="@bibitemid"/>
9054
9104
  <!-- <xsl:variable name="external-destination" select="normalize-space(key('bibitems', $current_bibitemid)/*[local-name() = 'uri'][@type = 'citation'])"/> -->
9055
9105
  <xsl:variable name="external-destination" select="normalize-space($bibitems/*[local-name() ='bibitem'][@id = $current_bibitemid]/*[local-name() = 'uri'][@type = 'citation'])"/>
@@ -10609,7 +10659,7 @@
10609
10659
 
10610
10660
  <xsl:variable name="element_name_keep-together_within-line">keep-together_within-line</xsl:variable>
10611
10661
 
10612
- <xsl:template match="text()[not(ancestor::*[local-name() = 'bibdata'] or ancestor::*[local-name() = 'sourcecode'] or ancestor::*[local-name() = 'math'])]" name="keep_together_standard_number" mode="update_xml_enclose_keep-together_within-line">
10662
+ <xsl:template match="text()[not(ancestor::*[local-name() = 'bibdata'] or ancestor::*[local-name() = 'link'][not(contains(.,' '))] or ancestor::*[local-name() = 'sourcecode'] or ancestor::*[local-name() = 'math'] or starts-with(., 'http://') or starts-with(., 'https://') or starts-with(., 'www.') )]" name="keep_together_standard_number" mode="update_xml_enclose_keep-together_within-line">
10613
10663
 
10614
10664
  <!-- enclose standard's number into tag 'keep-together_within-line' -->
10615
10665
  <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
@@ -104,15 +104,18 @@ module IsoDoc
104
104
  locality_span_wrap(ret, type)
105
105
  end
106
106
 
107
- def prefix_container(container, linkend, target)
107
+ def prefix_container(container, linkend, node, target)
108
108
  delim = ", "
109
- type = :xref
110
- if @xrefs.anchor(target, :type) == "listitem" &&
109
+ ref = if @xrefs.anchor(target, :type) == "listitem" &&
111
110
  !@xrefs.anchor(target, :refer_list)
112
- delim = " "
113
- type = :label # 7 a) not Clause 7 a), but Clause 7 List 1 a)
114
- end
115
- l10n(@xrefs.anchor(container, type) + delim + linkend)
111
+ delim = " "
112
+ @xrefs.anchor(container, :label)
113
+ # 7 a) : Clause 7 a), but Clause 7 List 1 a)
114
+ else
115
+ anchor_xref(node, container)
116
+ end
117
+
118
+ l10n(ref + delim + linkend)
116
119
  end
117
120
 
118
121
  def expand_citeas(text)
@@ -48,7 +48,7 @@ module IsoDoc
48
48
  end
49
49
 
50
50
  def foreword(isoxml, out)
51
- f = isoxml.at(ns("//foreword")) || return
51
+ f = isoxml.at(ns("//foreword")) or return
52
52
  @foreword = true
53
53
  page_break(out)
54
54
  out.div **attr_code(id: f["id"]) do |s|
@@ -1,3 +1,5 @@
1
+ require_relative "xref_section"
2
+
1
3
  module IsoDoc
2
4
  module Iso
3
5
  class Counter < IsoDoc::XrefGen::Counter
@@ -17,11 +19,10 @@ module IsoDoc
17
19
 
18
20
  def initial_anchor_names_amd(doc)
19
21
  if @parse_settings.empty? || @parse_settings[:clauses]
20
- doc.xpath(ns("//preface/*")).each do |c|
21
- c.element? and preface_names(c)
22
- end
23
- doc.xpath(ns("//sections/clause")).each do |c|
24
- c.element? and preface_names(c)
22
+ ["//preface/*", "//sections/clause"].each do |xpath|
23
+ doc.xpath(ns(xpath)).each do |c|
24
+ c.element? and preface_names(c)
25
+ end
25
26
  end
26
27
  end
27
28
  end
@@ -49,76 +50,6 @@ module IsoDoc
49
50
  end
50
51
  end
51
52
 
52
- # we can reference 0-number clauses in introduction
53
- def introduction_names(clause)
54
- return if clause.nil?
55
-
56
- clause.at(ns("./clause")) and
57
- @anchors[clause["id"]] = { label: "0", level: 1, type: "clause",
58
- xref: clause.at(ns("./title"))&.text }
59
- i = Counter.new
60
- clause.xpath(ns("./clause")).each do |c|
61
- i.increment(c)
62
- section_names1(c, "0.#{i.print}", 2)
63
- end
64
- end
65
-
66
- def annex_names(clause, num)
67
- appendix_names(clause, num)
68
- super
69
- end
70
-
71
- def appendix_names(clause, _num)
72
- i = Counter.new
73
- clause.xpath(ns("./appendix")).each do |c|
74
- i.increment(c)
75
- @anchors[c["id"]] =
76
- anchor_struct(i.print, nil, @labels["appendix"],
77
- "clause").merge(level: 2, subtype: "annex",
78
- container: clause["id"])
79
- j = Counter.new
80
- c.xpath(ns("./clause | ./references")).each do |c1|
81
- j.increment(c1)
82
- lbl = "#{@labels['appendix']} #{i.print}.#{j.print}"
83
- appendix_names1(c1, l10n(lbl), 3, clause["id"])
84
- end
85
- end
86
- end
87
-
88
- # subclauses are not prefixed with "Clause"
89
- # retaining subtype for the semantics
90
- def section_names1(clause, num, level)
91
- @anchors[clause["id"]] =
92
- { label: num, level: level, xref: num, subtype: "clause" }
93
- i = Counter.new
94
- clause.xpath(ns("./clause | ./terms | ./term | ./definitions | "\
95
- "./references"))
96
- .each do |c|
97
- i.increment(c)
98
- section_names1(c, "#{num}.#{i.print}", level + 1)
99
- end
100
- end
101
-
102
- def annex_names1(clause, num, level)
103
- @anchors[clause["id"]] = { label: num, xref: num, level: level,
104
- subtype: "annex" }
105
- i = Counter.new
106
- clause.xpath(ns("./clause | ./references")).each do |c|
107
- i.increment(c)
108
- annex_names1(c, "#{num}.#{i.print}", level + 1)
109
- end
110
- end
111
-
112
- def appendix_names1(clause, num, level, container)
113
- @anchors[clause["id"]] = { label: num, xref: num, level: level,
114
- container: container }
115
- i = Counter.new
116
- clause.xpath(ns("./clause | ./references")).each do |c|
117
- i.increment(c)
118
- appendix_names1(c, "#{num}.#{i.print}", level + 1, container)
119
- end
120
- end
121
-
122
53
  def hierarchical_formula_names(clause, num)
123
54
  c = IsoDoc::XrefGen::Counter.new
124
55
  clause.xpath(ns(".//formula")).each do |t|
@@ -132,10 +63,10 @@ module IsoDoc
132
63
  end
133
64
  end
134
65
 
135
- def figure_anchor(elem, sublabel, label)
66
+ def figure_anchor(elem, sublabel, label, klass)
136
67
  @anchors[elem["id"]] = anchor_struct(
137
68
  (sublabel ? "#{label} #{sublabel}" : label),
138
- nil, @labels["figure"], "figure", elem["unnumbered"]
69
+ nil, @labels[klass] || klass.capitalize, klass, elem["unnumbered"]
139
70
  )
140
71
  sublabel && elem["unnumbered"] != "true" and
141
72
  @anchors[elem["id"]][:label] = sublabel
@@ -143,27 +74,49 @@ module IsoDoc
143
74
 
144
75
  def sequential_figure_names(clause)
145
76
  j = 0
146
- clause.xpath(ns(".//figure | .//sourcecode[not(ancestor::example)]"))
77
+ clause.xpath(ns(FIGURE_NO_CLASS)).noblank
147
78
  .each_with_object(IsoDoc::XrefGen::Counter.new) do |t, c|
148
79
  j = subfigure_increment(j, c, t)
149
80
  sublabel = j.zero? ? nil : "#{(j + 96).chr})"
150
- next if blank?(t["id"])
81
+ figure_anchor(t, sublabel, c.print, "figure")
82
+ end
83
+ sequential_figure_class_names(clause)
84
+ end
151
85
 
152
- figure_anchor(t, sublabel, c.print)
86
+ def sequential_figure_class_names(clause)
87
+ c = {}
88
+ j = 0
89
+ clause.xpath(ns(".//figure[@class][not(@class = 'pseudocode')]"))
90
+ .each do |t|
91
+ c[t["class"]] ||= IsoDoc::XrefGen::Counter.new
92
+ j = subfigure_increment(j, c[t["class"]], t)
93
+ sublabel = j.zero? ? nil : "#{(j + 96).chr})"
94
+ figure_anchor(t, sublabel, c.print, t["class"])
153
95
  end
154
96
  end
155
97
 
156
98
  def hierarchical_figure_names(clause, num)
157
99
  c = IsoDoc::XrefGen::Counter.new
158
100
  j = 0
159
- clause.xpath(ns(".//figure | .//sourcecode[not(ancestor::example)]"))
160
- .each do |t|
101
+ clause.xpath(ns(FIGURE_NO_CLASS)).noblank.each do |t|
161
102
  j = subfigure_increment(j, c, t)
162
103
  label = "#{num}#{hiersep}#{c.print}"
163
104
  sublabel = j.zero? ? nil : "#{(j + 96).chr})"
164
- next if blank?(t["id"])
105
+ figure_anchor(t, sublabel, label, "figure")
106
+ end
107
+ hierarchical_figure_class_names(clause, num)
108
+ end
165
109
 
166
- figure_anchor(t, sublabel, label)
110
+ def hierarchical_figure_class_names(clause, num)
111
+ c = {}
112
+ j = 0
113
+ clause.xpath(ns(".//figure[@class][not(@class = 'pseudocode')]"))
114
+ .noblank.each do |t|
115
+ c[t["class"]] ||= IsoDoc::XrefGen::Counter.new
116
+ j = subfigure_increment(j, c[t["class"]], t)
117
+ label = "#{num}#{hiersep}#{c.print}"
118
+ sublabel = j.zero? ? nil : "#{(j + 96).chr})"
119
+ figure_anchor(t, sublabel, label, t["class"])
167
120
  end
168
121
  end
169
122
 
@@ -180,10 +133,6 @@ module IsoDoc
180
133
  end
181
134
  end
182
135
 
183
- def annex_name_lbl(clause, num)
184
- super.sub(%r{<br/>(.*)$}, "<br/><span class='obligation'>\\1</span>")
185
- end
186
-
187
136
  def list_anchor_names(sections)
188
137
  sections.each do |s|
189
138
  notes = s.xpath(ns(".//ol")) - s.xpath(ns(".//clause//ol")) -
@@ -0,0 +1,79 @@
1
+ module IsoDoc
2
+ module Iso
3
+ class Xref < IsoDoc::Xref
4
+ # we can reference 0-number clauses in introduction
5
+ def introduction_names(clause)
6
+ return if clause.nil?
7
+
8
+ clause.at(ns("./clause")) and
9
+ @anchors[clause["id"]] = { label: "0", level: 1, type: "clause",
10
+ xref: clause.at(ns("./title"))&.text }
11
+ i = Counter.new
12
+ clause.xpath(ns("./clause")).each do |c|
13
+ i.increment(c)
14
+ section_names1(c, "0.#{i.print}", 2)
15
+ end
16
+ end
17
+
18
+ def annex_names(clause, num)
19
+ appendix_names(clause, num)
20
+ super
21
+ end
22
+
23
+ def appendix_names(clause, _num)
24
+ i = Counter.new
25
+ clause.xpath(ns("./appendix")).each do |c|
26
+ i.increment(c)
27
+ @anchors[c["id"]] =
28
+ anchor_struct(i.print, nil, @labels["appendix"],
29
+ "clause").merge(level: 2, subtype: "annex",
30
+ container: clause["id"])
31
+ j = Counter.new
32
+ c.xpath(ns("./clause | ./references")).each do |c1|
33
+ j.increment(c1)
34
+ lbl = "#{@labels['appendix']} #{i.print}.#{j.print}"
35
+ appendix_names1(c1, l10n(lbl), 3, clause["id"])
36
+ end
37
+ end
38
+ end
39
+
40
+ # subclauses are not prefixed with "Clause"
41
+ # retaining subtype for the semantics
42
+ def section_names1(clause, num, level)
43
+ @anchors[clause["id"]] =
44
+ { label: num, level: level, xref: num, subtype: "clause" }
45
+ i = Counter.new
46
+ clause.xpath(ns("./clause | ./terms | ./term | ./definitions | "\
47
+ "./references"))
48
+ .each do |c|
49
+ i.increment(c)
50
+ section_names1(c, "#{num}.#{i.print}", level + 1)
51
+ end
52
+ end
53
+
54
+ def annex_names1(clause, num, level)
55
+ @anchors[clause["id"]] = { label: num, xref: num, level: level,
56
+ subtype: "annex" }
57
+ i = Counter.new
58
+ clause.xpath(ns("./clause | ./references")).each do |c|
59
+ i.increment(c)
60
+ annex_names1(c, "#{num}.#{i.print}", level + 1)
61
+ end
62
+ end
63
+
64
+ def appendix_names1(clause, num, level, container)
65
+ @anchors[clause["id"]] = { label: num, xref: num, level: level,
66
+ container: container }
67
+ i = Counter.new
68
+ clause.xpath(ns("./clause | ./references")).each do |c|
69
+ i.increment(c)
70
+ appendix_names1(c, "#{num}.#{i.print}", level + 1, container)
71
+ end
72
+ end
73
+
74
+ def annex_name_lbl(clause, num)
75
+ super.sub(%r{<br/>(.*)$}, "<br/><span class='obligation'>\\1</span>")
76
+ end
77
+ end
78
+ end
79
+ end