metanorma-ogc 2.4.0 → 2.4.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.
@@ -1822,11 +1822,26 @@
1822
1822
  <xsl:value-of select="$font_extended"/><xsl:text>, </xsl:text>
1823
1823
  </xsl:if>
1824
1824
 
1825
- <xsl:value-of select="."/>
1825
+ <xsl:variable name="font_family" select="."/>
1826
1826
 
1827
- <xsl:if test="$additional_fonts != ''">
1828
- <xsl:text>, </xsl:text><xsl:value-of select="$additional_fonts"/>
1829
- </xsl:if>
1827
+ <xsl:choose>
1828
+ <xsl:when test="$additional_fonts = ''">
1829
+ <xsl:value-of select="$font_family"/>
1830
+ </xsl:when>
1831
+ <xsl:otherwise> <!-- $additional_fonts != '' -->
1832
+ <xsl:choose>
1833
+ <xsl:when test="contains($font_family, ',')">
1834
+ <xsl:value-of select="substring-before($font_family, ',')"/>
1835
+ <xsl:text>, </xsl:text><xsl:value-of select="$additional_fonts"/>
1836
+ <xsl:text>, </xsl:text><xsl:value-of select="substring-after($font_family, ',')"/>
1837
+ </xsl:when>
1838
+ <xsl:otherwise>
1839
+ <xsl:value-of select="$font_family"/>
1840
+ <xsl:text>, </xsl:text><xsl:value-of select="$additional_fonts"/>
1841
+ </xsl:otherwise>
1842
+ </xsl:choose>
1843
+ </xsl:otherwise>
1844
+ </xsl:choose>
1830
1845
  </xsl:attribute>
1831
1846
  </xsl:when>
1832
1847
  <xsl:otherwise>
@@ -4480,21 +4495,21 @@
4480
4495
 
4481
4496
  <xsl:template match="*[local-name()='table']/*[local-name()='note' or local-name() = 'example']" priority="2">
4482
4497
 
4483
- <fo:block xsl:use-attribute-sets="table-note-style">
4498
+ <fo:block xsl:use-attribute-sets="table-note-style">
4484
4499
 
4485
- <xsl:call-template name="refine_table-note-style"/>
4500
+ <xsl:call-template name="refine_table-note-style"/>
4486
4501
 
4487
- <!-- Table's note/example name (NOTE, for example) -->
4488
- <fo:inline xsl:use-attribute-sets="table-note-name-style">
4502
+ <!-- Table's note/example name (NOTE, for example) -->
4503
+ <fo:inline xsl:use-attribute-sets="table-note-name-style">
4489
4504
 
4490
- <xsl:call-template name="refine_table-note-name-style"/>
4505
+ <xsl:call-template name="refine_table-note-name-style"/>
4491
4506
 
4492
- <xsl:apply-templates select="*[local-name() = 'name']"/>
4507
+ <xsl:apply-templates select="*[local-name() = 'name']"/>
4493
4508
 
4494
- </fo:inline>
4509
+ </fo:inline>
4495
4510
 
4496
- <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
4497
- </fo:block>
4511
+ <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
4512
+ </fo:block>
4498
4513
 
4499
4514
  </xsl:template> <!-- table/note -->
4500
4515
 
@@ -7637,8 +7652,12 @@
7637
7652
  <xsl:variable name="isAdded" select="../@added"/>
7638
7653
  <xsl:variable name="isDeleted" select="../@deleted"/>
7639
7654
  <xsl:choose>
7640
- <xsl:when test="ancestor::*[local-name() = 'title']">
7655
+ <xsl:when test="ancestor::*[local-name() = 'title'] or not(parent::*[local-name() = 'figure']) or parent::*[local-name() = 'p']">
7641
7656
  <fo:inline padding-left="1mm" padding-right="1mm">
7657
+ <xsl:if test="not(parent::*[local-name() = 'figure']) or parent::*[local-name() = 'p']">
7658
+ <xsl:attribute name="padding-left">0mm</xsl:attribute>
7659
+ <xsl:attribute name="padding-right">0mm</xsl:attribute>
7660
+ </xsl:if>
7642
7661
  <xsl:variable name="src">
7643
7662
  <xsl:call-template name="image_src"/>
7644
7663
  </xsl:variable>
@@ -7671,7 +7690,7 @@
7671
7690
  <fo:external-graphic src="{$src}" fox:alt-text="Image {@alt}" xsl:use-attribute-sets="image-graphic-style">
7672
7691
  <xsl:if test="not(@mimetype = 'image/svg+xml') and ../*[local-name() = 'name'] and not(ancestor::*[local-name() = 'table'])">
7673
7692
 
7674
- <xsl:if test="@width != '' and @width != 'auto'">
7693
+ <xsl:if test="@width != '' and @width != 'auto' and @width != 'text-width' and @width != 'full-page-width' and @width != 'narrow'">
7675
7694
  <xsl:attribute name="width">
7676
7695
  <xsl:value-of select="@width"/>
7677
7696
  </xsl:attribute>
@@ -956,11 +956,26 @@
956
956
  <xsl:value-of select="$font_extended"/><xsl:text>, </xsl:text>
957
957
  </xsl:if>
958
958
 
959
- <xsl:value-of select="."/>
959
+ <xsl:variable name="font_family" select="."/>
960
960
 
961
- <xsl:if test="$additional_fonts != ''">
962
- <xsl:text>, </xsl:text><xsl:value-of select="$additional_fonts"/>
963
- </xsl:if>
961
+ <xsl:choose>
962
+ <xsl:when test="$additional_fonts = ''">
963
+ <xsl:value-of select="$font_family"/>
964
+ </xsl:when>
965
+ <xsl:otherwise> <!-- $additional_fonts != '' -->
966
+ <xsl:choose>
967
+ <xsl:when test="contains($font_family, ',')">
968
+ <xsl:value-of select="substring-before($font_family, ',')"/>
969
+ <xsl:text>, </xsl:text><xsl:value-of select="$additional_fonts"/>
970
+ <xsl:text>, </xsl:text><xsl:value-of select="substring-after($font_family, ',')"/>
971
+ </xsl:when>
972
+ <xsl:otherwise>
973
+ <xsl:value-of select="$font_family"/>
974
+ <xsl:text>, </xsl:text><xsl:value-of select="$additional_fonts"/>
975
+ </xsl:otherwise>
976
+ </xsl:choose>
977
+ </xsl:otherwise>
978
+ </xsl:choose>
964
979
  </xsl:attribute>
965
980
  </xsl:when>
966
981
  <xsl:otherwise>
@@ -3587,21 +3602,21 @@
3587
3602
 
3588
3603
  <xsl:template match="*[local-name()='table']/*[local-name()='note' or local-name() = 'example']" priority="2">
3589
3604
 
3590
- <fo:block xsl:use-attribute-sets="table-note-style">
3605
+ <fo:block xsl:use-attribute-sets="table-note-style">
3591
3606
 
3592
- <xsl:call-template name="refine_table-note-style"/>
3607
+ <xsl:call-template name="refine_table-note-style"/>
3593
3608
 
3594
- <!-- Table's note/example name (NOTE, for example) -->
3595
- <fo:inline xsl:use-attribute-sets="table-note-name-style">
3609
+ <!-- Table's note/example name (NOTE, for example) -->
3610
+ <fo:inline xsl:use-attribute-sets="table-note-name-style">
3596
3611
 
3597
- <xsl:call-template name="refine_table-note-name-style"/>
3612
+ <xsl:call-template name="refine_table-note-name-style"/>
3598
3613
 
3599
- <xsl:apply-templates select="*[local-name() = 'name']"/>
3614
+ <xsl:apply-templates select="*[local-name() = 'name']"/>
3600
3615
 
3601
- </fo:inline>
3616
+ </fo:inline>
3602
3617
 
3603
- <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
3604
- </fo:block>
3618
+ <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
3619
+ </fo:block>
3605
3620
 
3606
3621
  </xsl:template> <!-- table/note -->
3607
3622
 
@@ -6731,8 +6746,12 @@
6731
6746
  <xsl:variable name="isAdded" select="../@added"/>
6732
6747
  <xsl:variable name="isDeleted" select="../@deleted"/>
6733
6748
  <xsl:choose>
6734
- <xsl:when test="ancestor::*[local-name() = 'title']">
6749
+ <xsl:when test="ancestor::*[local-name() = 'title'] or not(parent::*[local-name() = 'figure']) or parent::*[local-name() = 'p']">
6735
6750
  <fo:inline padding-left="1mm" padding-right="1mm">
6751
+ <xsl:if test="not(parent::*[local-name() = 'figure']) or parent::*[local-name() = 'p']">
6752
+ <xsl:attribute name="padding-left">0mm</xsl:attribute>
6753
+ <xsl:attribute name="padding-right">0mm</xsl:attribute>
6754
+ </xsl:if>
6736
6755
  <xsl:variable name="src">
6737
6756
  <xsl:call-template name="image_src"/>
6738
6757
  </xsl:variable>
@@ -6765,7 +6784,7 @@
6765
6784
  <fo:external-graphic src="{$src}" fox:alt-text="Image {@alt}" xsl:use-attribute-sets="image-graphic-style">
6766
6785
  <xsl:if test="not(@mimetype = 'image/svg+xml') and ../*[local-name() = 'name'] and not(ancestor::*[local-name() = 'table'])">
6767
6786
 
6768
- <xsl:if test="@width != '' and @width != 'auto'">
6787
+ <xsl:if test="@width != '' and @width != 'auto' and @width != 'text-width' and @width != 'full-page-width' and @width != 'narrow'">
6769
6788
  <xsl:attribute name="width">
6770
6789
  <xsl:value-of select="@width"/>
6771
6790
  </xsl:attribute>
@@ -11,14 +11,13 @@ module IsoDoc
11
11
  super
12
12
  end
13
13
 
14
- def pdf_stylesheet(docxml)
15
- doctype = docxml&.at(ns("//bibdata/ext/doctype"))&.text
14
+ def pdf_stylesheet(_docxml)
16
15
  %w(abstract-specification-topic best-practice draft-standard
17
16
  change-request-supporting-document community-practice
18
17
  community-standard discussion-paper engineering-report policy
19
18
  reference-model release-notes standard user-guide test-suite
20
- white-paper).include? doctype or doctype = "other"
21
- "ogc.#{doctype}.xsl"
19
+ white-paper).include? @doctype or @doctype = "other"
20
+ "ogc.#{@doctype}.xsl"
22
21
  end
23
22
  end
24
23
  end
@@ -195,33 +195,6 @@ module IsoDoc
195
195
  xml.children = "#{f}#{xml.xpath(ns(keep)).to_xml}"
196
196
  end
197
197
 
198
- SECT_TERMS = "//sections/terms | //sections/clause[descendant::terms]"
199
- .freeze
200
-
201
- def display_order(docxml)
202
- i = 0
203
- i = display_order_xpath(docxml, "//preface/*", i)
204
- i = display_order_at(docxml, "//clause[@type = 'scope']", i)
205
- i = display_order_at(docxml, "//clause[@type = 'conformance']", i)
206
- i = display_order_at(docxml, @xrefs.klass.norm_ref_xpath, i)
207
- i = display_order_clauses(docxml, i)
208
- i = display_order_xpath(docxml, "//annex", i)
209
- i = display_order_xpath(docxml, @xrefs.klass.bibliography_xpath, i)
210
- display_order_xpath(docxml, "//indexsect", i)
211
- end
212
-
213
- def display_order_clauses(docxml, idx)
214
- if docxml.at(ns("//bibdata/ext/doctype"))&.text == "engineering-report"
215
- xpath = "#{SECT_TERMS} | //sections/definitions | " +
216
- @xrefs.klass.middle_clause(docxml)
217
- return display_order_xpath(docxml, xpath, idx)
218
- end
219
- idx = display_order_at(docxml, SECT_TERMS, idx)
220
- idx = display_order_at(docxml, "//sections/definitions", idx)
221
- display_order_xpath(docxml, @xrefs.klass.middle_clause(docxml),
222
- idx)
223
- end
224
-
225
198
  def norm_ref_entry_code(_ordinal, _idents, _ids, _standard, _datefn, _bib)
226
199
  ""
227
200
  end
@@ -40,13 +40,12 @@ module IsoDoc
40
40
  end
41
41
 
42
42
  def convert1(docxml, filename, dir)
43
- if docxml&.at(ns("//bibdata/ext/doctype"))&.text == "white-paper"
43
+ if @doctype == "white-paper"
44
44
  @wordstylesheet_name = html_doc_path("wordstyle_wp.scss")
45
45
  @standardstylesheet_name = html_doc_path("ogc_wp.scss")
46
46
  @wordcoverpage = html_doc_path("word_ogc_titlepage_wp.html")
47
47
  @wordintropage = html_doc_path("word_ogc_intro_wp.html")
48
48
  @header = html_doc_path("header_wp.html")
49
- @doctype = "white-paper"
50
49
  options[:bodyfont] = '"Arial",sans-serif'
51
50
  options[:headerfont] = '"Lato",sans-serif'
52
51
  options[:normalfontsize] = "11.0pt"
@@ -4,52 +4,22 @@ module IsoDoc
4
4
  end
5
5
 
6
6
  class Xref < IsoDoc::Xref
7
- def initial_anchor_names(doc)
8
- if @parse_settings.empty? || @parse_settings[:clauses]
9
- preface_anchor_names(doc)
10
- n = Counter.new
11
- n = section_names(doc.at(ns("//clause[@type = 'scope']")), n, 1)
12
- n = section_names(doc.at(ns("//clause[@type = 'conformance']")), n, 1)
13
- n = section_names(doc.at(ns(@klass.norm_ref_xpath)), n, 1)
14
- initial_anchor_names_middle(doc, n,
15
- doc.at(ns("//bibdata/ext/doctype"))&.text)
16
- end
17
- end
18
-
19
- TERMS_SECT = "//sections/terms | //sections/clause[descendant::terms]"
20
- .freeze
21
-
22
- def initial_anchor_names_middle(doc, num, doctype)
23
- if doctype == "engineering-report"
24
- doc.xpath(ns(@klass.middle_clause(doc)) +
25
- " | #{ns(TERMS_SECT)} | " + ns("//sections/definitions"))
26
- .each_with_index { |c, _i| section_names(c, num, 1) }
27
- else
28
- num = section_names(doc.at(ns(TERMS_SECT)), num, 1)
29
- num = section_names(doc.at(ns("//sections/definitions")), num, 1)
30
- clause_names(doc, num)
31
- end
7
+ def clause_order_main(docxml)
8
+ ret = [{ path: "//clause[@type = 'scope']" },
9
+ { path: "//clause[@type = 'conformance']" },
10
+ { path: @klass.norm_ref_xpath }]
11
+ a = ["//sections/terms | //sections/clause[descendant::terms]",
12
+ "//sections/definitions | " \
13
+ "//sections/clause[descendant::definitions][not(descendant::terms)]",
14
+ @klass.middle_clause(docxml)]
15
+ ret + if @doctype == "engineering-report"
16
+ [{ path: a.join(" | "), multi: true }]
17
+ else
18
+ [{ path: a[0] }, { path: a[1] }, { path: a[2], multi: true }]
19
+ end
32
20
  end
33
21
 
34
- def preface_anchor_names(doc)
35
- @prefacenum = 0
36
- ["//preface/abstract", "//preface/clause[@type = 'executivesummary']",
37
- "//preface/clause[@type = 'keywords']",
38
- "//foreword", "//preface/clause[@type = 'security']",
39
- "//preface/clause[@type = 'submitting_orgs']", "//submitters",
40
- "//introduction"].each do |path|
41
- preface_names_numbered(doc.at(ns(path)))
42
- end
43
- doc.xpath(ns("//preface/clause[not(@type = 'keywords' or " \
44
- "@type = 'submitting_orgs' or @type = 'security' or " \
45
- "@type = 'executivesummary' or @type = 'toc')]"))
46
- .each { |c| preface_names_numbered(c) }
47
- preface_names_numbered(doc.at(ns("//acknowledgements")))
48
- sequential_asset_names(
49
- doc.xpath(ns("//preface/abstract | //foreword | //introduction | " \
50
- "//submitters | //acknowledgements | //preface/clause")),
51
- )
52
- end
22
+ # ["//preface/abstract", "//preface/clause[@type = 'executivesummary']", "//preface/clause[@type = 'keywords']", "//foreword", "//preface/clause[@type = 'security']", "//preface/clause[@type = 'submitting_orgs']", "//submitters", "//introduction"]
53
23
 
54
24
  def middle_section_asset_names(doc)
55
25
  middle_sections =
@@ -61,9 +31,14 @@ module IsoDoc
61
31
  sequential_asset_names(doc.xpath(ns(middle_sections)))
62
32
  end
63
33
 
64
- def preface_names_numbered(clause)
65
- return if clause.nil?
34
+ def preface_anchor_names(xml)
35
+ @prefacenum = 0
36
+ super
37
+ end
66
38
 
39
+ def preface_names(clause)
40
+ clause.nil? and return
41
+ clause["type"] == "toc" and return
67
42
  @prefacenum += 1
68
43
  pref = preface_number(@prefacenum, 1)
69
44
  @anchors[clause["id"]] =
@@ -34,16 +34,32 @@ module Metanorma
34
34
  def insert_security(xml, sect)
35
35
  description = "document"
36
36
  description = "standard" if %w(standard community-standard)
37
- .include?(sect.at("//bibdata/ext/doctype")&.text)
37
+ .include?(@doctype)
38
+ @doctype == "engineering-report" and return remove_security(xml)
38
39
  preface = sect.at("//preface") ||
39
40
  sect.add_previous_sibling("<preface/>").first
40
41
  sect = xml.at("//clause[@type = 'security']")&.remove ||
41
- "<clause type='security' #{add_id}>" \
42
- "<title>Security considerations</title>" \
43
- "<p>#{@i18n.security_empty.sub(/%/, description)}</p></clause>"
42
+ create_security_clause(xml)
44
43
  preface.add_child sect
45
44
  end
46
45
 
46
+ def remove_security(xml)
47
+ a = xml.at("//clause[@type = 'security']") and
48
+ a.delete("type")
49
+ end
50
+
51
+ def create_security_clause(xml)
52
+ doctype = xml.at("//bibdata/ext/doctype")&.text
53
+ description = "document"
54
+ description = "standard" if %w(standard community-standard)
55
+ .include?(doctype)
56
+ <<~CLAUSE
57
+ <clause type='security' #{add_id}>
58
+ <title>Security considerations</title>
59
+ <p>#{@i18n.security_empty.sub('%', description)}</p></clause>
60
+ CLAUSE
61
+ end
62
+
47
63
  def insert_submitters(xml, sect)
48
64
  if xml.at("//submitters")
49
65
  preface = sect.at("//preface") ||
@@ -62,9 +78,11 @@ module Metanorma
62
78
  super
63
79
  a = xmldoc.at("//bibdata/status/stage")
64
80
  a.text == "published" and a.children = "approved"
65
- doctype = xmldoc.at("//bibdata/ext/doctype")
66
- doctype.text == "technical-paper" and
81
+ if @doctype == "technical-paper"
82
+ doctype = xmldoc.at("//bibdata/ext/doctype")
67
83
  doctype.children = "white-paper"
84
+ @doctype = "white-paper"
85
+ end
68
86
  end
69
87
 
70
88
  def section_names_terms_cleanup(xml)
@@ -17,7 +17,7 @@
17
17
  these elements; we just want one namespace for any child grammars
18
18
  of this.
19
19
  -->
20
- <!-- VERSION v1.2.3 -->
20
+ <!-- VERSION v1.2.4 -->
21
21
  <grammar xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
22
22
  <include href="reqt.rng"/>
23
23
  <include href="basicdoc.rng">
@@ -2068,6 +2068,9 @@
2068
2068
  </define>
2069
2069
  <define name="termdefinition">
2070
2070
  <element name="definition">
2071
+ <optional>
2072
+ <attribute name="type"/>
2073
+ </optional>
2071
2074
  <choice>
2072
2075
  <ref name="verbaldefinition"/>
2073
2076
  <ref name="nonverbalrep"/>
@@ -2,7 +2,6 @@ module Metanorma
2
2
  module Ogc
3
3
  class Converter < Standoc::Converter
4
4
  def validate(doc)
5
- @doctype = doc.at("//bibdata/ext/doctype")&.text
6
5
  content_validate(doc)
7
6
  schema_validate(formattedstr_strip(doc.dup),
8
7
  File.join(File.dirname(__FILE__), "ogc.rng"))
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Ogc
3
- VERSION = "2.4.0".freeze
3
+ VERSION = "2.4.2".freeze
4
4
  end
5
5
  end
@@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
26
26
  spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
27
27
 
28
28
  spec.add_dependency "iso-639"
29
- spec.add_dependency "metanorma-standoc", "~> 2.5.0"
29
+ spec.add_dependency "metanorma-standoc", "~> 2.6.0"
30
30
 
31
31
  spec.add_development_dependency "debug"
32
32
  spec.add_development_dependency "equivalent-xml", "~> 0.6"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-ogc
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0
4
+ version: 2.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-08-07 00:00:00.000000000 Z
11
+ date: 2023-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: iso-639
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 2.5.0
33
+ version: 2.6.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 2.5.0
40
+ version: 2.6.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: debug
43
43
  requirement: !ruby/object:Gem::Requirement