metanorma-ogc 1.3.7 → 1.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/lib/asciidoctor/ogc/boilerplate.xml +6 -6
  3. data/lib/asciidoctor/ogc/cleanup.rb +145 -0
  4. data/lib/asciidoctor/ogc/converter.rb +52 -64
  5. data/lib/asciidoctor/ogc/front.rb +1 -1
  6. data/lib/asciidoctor/ogc/isodoc.rng +52 -11
  7. data/lib/asciidoctor/ogc/ogc.rng +13 -13
  8. data/lib/asciidoctor/ogc/reqt.rng +15 -4
  9. data/lib/asciidoctor/ogc/validate.rb +35 -20
  10. data/lib/isodoc/ogc/base_convert.rb +47 -10
  11. data/lib/isodoc/ogc/biblio.rb +57 -51
  12. data/lib/isodoc/ogc/html/htmlstyle.css +10 -0
  13. data/lib/isodoc/ogc/html/htmlstyle.scss +12 -0
  14. data/lib/isodoc/ogc/html/ogc.css +4 -0
  15. data/lib/isodoc/ogc/html/ogc.scss +4 -0
  16. data/lib/isodoc/ogc/i18n-en.yaml +24 -8
  17. data/lib/isodoc/ogc/metadata.rb +1 -1
  18. data/lib/isodoc/ogc/ogc.abstract-specification-topic.xsl +398 -143
  19. data/lib/isodoc/ogc/ogc.best-practice.xsl +398 -143
  20. data/lib/isodoc/ogc/ogc.change-request-supporting-document.xsl +398 -143
  21. data/lib/isodoc/ogc/ogc.community-practice.xsl +398 -143
  22. data/lib/isodoc/ogc/ogc.community-standard.xsl +398 -143
  23. data/lib/isodoc/ogc/ogc.discussion-paper.xsl +398 -143
  24. data/lib/isodoc/ogc/ogc.engineering-report.xsl +398 -143
  25. data/lib/isodoc/ogc/ogc.other.xsl +398 -143
  26. data/lib/isodoc/ogc/ogc.policy.xsl +398 -143
  27. data/lib/isodoc/ogc/ogc.reference-model.xsl +398 -143
  28. data/lib/isodoc/ogc/ogc.release-notes.xsl +398 -143
  29. data/lib/isodoc/ogc/ogc.standard.xsl +398 -143
  30. data/lib/isodoc/ogc/ogc.test-suite.xsl +398 -143
  31. data/lib/isodoc/ogc/ogc.user-guide.xsl +398 -143
  32. data/lib/isodoc/ogc/ogc.white-paper.xsl +330 -98
  33. data/lib/isodoc/ogc/presentation_xml_convert.rb +58 -48
  34. data/lib/isodoc/ogc/reqt.rb +99 -38
  35. data/lib/isodoc/ogc/xref.rb +59 -43
  36. data/lib/metanorma/ogc/processor.rb +2 -1
  37. data/lib/metanorma/ogc/version.rb +1 -1
  38. metadata +3 -2
@@ -62,6 +62,19 @@
62
62
  </optional>
63
63
  </element>
64
64
  </define>
65
+ <define name="DocumentSubtype">
66
+ <choice>
67
+ <value>conceptual-model</value>
68
+ <value>conceptual-model-and-encoding</value>
69
+ <value>conceptual-model-and-implementation</value>
70
+ <value>encoding</value>
71
+ <value>extension</value>
72
+ <value>implementation</value>
73
+ <value>profile</value>
74
+ <value>profile-with-extension</value>
75
+ <value>general</value>
76
+ </choice>
77
+ </define>
65
78
  </include>
66
79
  <define name="TextElement" combine="choice">
67
80
  <ref name="hi"/>
@@ -79,19 +92,6 @@
79
92
  </zeroOrMore>
80
93
  </element>
81
94
  </define>
82
- <define name="DocumentSubtype">
83
- <choice>
84
- <value>conceptual-model</value>
85
- <value>conceptual-model-and-encoding</value>
86
- <value>conceptual-model-and-implementation</value>
87
- <value>encoding</value>
88
- <value>extension</value>
89
- <value>implementation</value>
90
- <value>profile</value>
91
- <value>profile-with-extension</value>
92
- <value>general</value>
93
- </choice>
94
- </define>
95
95
  <define name="submitters">
96
96
  <element name="submitters">
97
97
  <ref name="Basic-Section"/>
@@ -64,9 +64,9 @@
64
64
  <optional>
65
65
  <ref name="label"/>
66
66
  </optional>
67
- <optional>
67
+ <zeroOrMore>
68
68
  <ref name="subject"/>
69
- </optional>
69
+ </zeroOrMore>
70
70
  <zeroOrMore>
71
71
  <ref name="reqinherit"/>
72
72
  </zeroOrMore>
@@ -80,6 +80,7 @@
80
80
  <ref name="verification"/>
81
81
  <ref name="import"/>
82
82
  <ref name="description"/>
83
+ <ref name="component"/>
83
84
  </choice>
84
85
  </zeroOrMore>
85
86
  <optional>
@@ -105,12 +106,16 @@
105
106
  </define>
106
107
  <define name="subject">
107
108
  <element name="subject">
108
- <text/>
109
+ <oneOrMore>
110
+ <ref name="TextElement"/>
111
+ </oneOrMore>
109
112
  </element>
110
113
  </define>
111
114
  <define name="reqinherit">
112
115
  <element name="inherit">
113
- <text/>
116
+ <oneOrMore>
117
+ <ref name="TextElement"/>
118
+ </oneOrMore>
114
119
  </element>
115
120
  </define>
116
121
  <define name="measurementtarget">
@@ -138,6 +143,12 @@
138
143
  <ref name="RequirementSubpart"/>
139
144
  </element>
140
145
  </define>
146
+ <define name="component">
147
+ <element name="component">
148
+ <attribute name="class"/>
149
+ <ref name="RequirementSubpart"/>
150
+ </element>
151
+ </define>
141
152
  <define name="reqt_references">
142
153
  <element name="references">
143
154
  <oneOrMore>
@@ -1,7 +1,13 @@
1
1
  module Asciidoctor
2
2
  module Ogc
3
3
  class Converter < Standoc::Converter
4
- def title_validate(root)
4
+ def validate(doc)
5
+ content_validate(doc)
6
+ schema_validate(formattedstr_strip(doc.dup),
7
+ File.join(File.dirname(__FILE__), "ogc.rng"))
8
+ end
9
+
10
+ def title_validate(_root)
5
11
  nil
6
12
  end
7
13
 
@@ -18,8 +24,9 @@ module Asciidoctor
18
24
  def stage_validate(xmldoc)
19
25
  stage = xmldoc&.at("//bibdata/status/stage")&.text
20
26
  %w(swg-draft oab-review public-rfc tc-vote
21
- approved deprecated retired).include? stage or
22
- @log.add("Document Attributes", nil, "#{stage} is not a recognised status")
27
+ approved deprecated retired).include? stage or
28
+ @log.add("Document Attributes", nil,
29
+ "#{stage} is not a recognised status")
23
30
  end
24
31
 
25
32
  def version_validate(xmldoc)
@@ -27,10 +34,12 @@ module Asciidoctor
27
34
  doctype = xmldoc&.at("//bibdata/ext/doctype")&.text
28
35
  if %w(engineering-report discussion-paper).include? doctype
29
36
  version.nil? or
30
- @log.add("Document Attributes", nil, "Version not permitted for #{doctype}")
37
+ @log.add("Document Attributes", nil,
38
+ "Version not permitted for #{doctype}")
31
39
  else
32
40
  version.nil? and
33
- @log.add("Document Attributes", nil, "Version required for #{doctype}")
41
+ @log.add("Document Attributes", nil,
42
+ "Version required for #{doctype}")
34
43
  end
35
44
  end
36
45
 
@@ -41,7 +50,7 @@ module Asciidoctor
41
50
  end
42
51
 
43
52
  STANDARDTYPE = %w{standard standard-with-suite abstract-specification
44
- community-standard profile}.freeze
53
+ community-standard profile}.freeze
45
54
 
46
55
  # spec of permissible section sequence
47
56
  # we skip normative references, it goes to end of list
@@ -49,24 +58,25 @@ module Asciidoctor
49
58
  [
50
59
  {
51
60
  msg: "Prefatory material must be followed by (clause) Scope",
52
- val: ["./self::clause[@type = 'scope']" ]
61
+ val: ["./self::clause[@type = 'scope']"],
53
62
  },
54
63
  {
55
64
  msg: "Scope must be followed by Conformance",
56
- val: ["./self::clause[@type = 'conformance']" ]
65
+ val: ["./self::clause[@type = 'conformance']"],
57
66
  },
58
67
  {
59
68
  msg: "Normative References must be followed by "\
60
- "Terms and Definitions",
61
- val: ["./self::terms | .//terms"]
69
+ "Terms and Definitions",
70
+ val: ["./self::terms | .//terms"],
62
71
  },
63
- ].freeze
72
+ ].freeze
64
73
 
65
74
  def seqcheck(names, msg, accepted)
66
75
  n = names.shift
67
76
  return [] if n.nil?
77
+
68
78
  test = accepted.map { |a| n.at(a) }
69
- if test.all? { |a| a.nil? }
79
+ if test.all?(&:nil?)
70
80
  @log.add("Style", nil, msg)
71
81
  end
72
82
  names
@@ -74,7 +84,9 @@ module Asciidoctor
74
84
 
75
85
  def sections_sequence_validate(root)
76
86
  return unless STANDARDTYPE.include?(
77
- root&.at("//bibdata/ext/doctype")&.text)
87
+ root&.at("//bibdata/ext/doctype")&.text,
88
+ )
89
+
78
90
  names = root.xpath("//sections/* | //bibliography/*")
79
91
  names = seqcheck(names, SEQ[0][:msg], SEQ[0][:val])
80
92
  names = seqcheck(names, SEQ[1][:msg], SEQ[1][:val])
@@ -84,25 +96,28 @@ module Asciidoctor
84
96
  n = names.shift
85
97
  end
86
98
  if n.nil? || n.name != "clause"
87
- @log.add("Style", nil, "Document must contain at least one clause")
99
+ @log.add("Style", nil,
100
+ "Document must contain at least one clause")
88
101
  return
89
102
  end
90
103
  root.at("//references | //clause[descendant::references]"\
91
104
  "[not(parent::clause)]") or
92
- @log.add("Style", nil, "Normative References are mandatory")
105
+ @log.add("Style", nil, "Normative References are mandatory")
93
106
  end
94
107
 
95
108
  def preface_sequence_validate(root)
96
- root.at("//preface/abstract") or @log.add("Style", nil, "Abstract is missing!")
109
+ root.at("//preface/abstract") or @log.add("Style", nil,
110
+ "Abstract is missing!")
97
111
  root.at("//bibdata/keyword | //bibdata/ext/keyword") or
98
112
  @log.add("Style", nil, "Keywords are missing!")
99
- root.at("//foreword") or @log.add("Style", nil, "Preface is missing!")
113
+ root.at("//foreword") or @log.add("Style", nil,
114
+ "Preface is missing!")
100
115
  root.at("//bibdata/contributor[role/@type = 'author']/organization/"\
101
116
  "name") or
102
- @log.add("Style", nil, "Submitting Organizations is missing!")
103
- root.at("//submitters") or @log.add("Style", nil, "Submitters is missing!")
117
+ @log.add("Style", nil, "Submitting Organizations is missing!")
118
+ root.at("//submitters") or @log.add("Style", nil,
119
+ "Submitters is missing!")
104
120
  end
105
121
  end
106
122
  end
107
123
  end
108
-
@@ -15,7 +15,7 @@ module IsoDoc
15
15
  end
16
16
 
17
17
  def hi_parse(node, out)
18
- out.span **{class: "hi"} do |e|
18
+ out.span **{ class: "hi" } do |e|
19
19
  node.children.each { |n| parse(n, e) }
20
20
  end
21
21
  end
@@ -27,23 +27,58 @@ module IsoDoc
27
27
 
28
28
  def term_cleanup(docxml)
29
29
  docxml.xpath("//p[@class = 'Terms']").each do |d|
30
- h2 = d.at("./preceding-sibling::*[@class = 'TermNum'][1]")
31
- h2.add_child("&nbsp;")
32
- h2.add_child(d.remove)
30
+ term_cleanup_merge_termnum(d)
31
+ term_cleanup_merge_admitted(d)
33
32
  end
34
33
  docxml
35
34
  end
36
35
 
36
+ def term_cleanup_merge_termnum(term)
37
+ h2 = term.at("./preceding-sibling::*[@class = 'TermNum'][1]")
38
+ term["class"] = h2["class"]
39
+ term["id"] = h2["id"]
40
+ term.children.first.previous = "&#xa0;"
41
+ term.children.first.previous = h2.remove.children
42
+ end
43
+
44
+ def term_cleanup_merge_admitted(term)
45
+ term.xpath("./following-sibling::p[@class = 'AltTerms' or "\
46
+ "@class = 'DeprecatedTerms']").each do |a|
47
+ term << " "
48
+ term << a.children
49
+ a.remove
50
+ end
51
+ end
52
+
53
+ def deprecated_term_parse(node, out)
54
+ out.p **{ class: "DeprecatedTerms" } do |p|
55
+ node.children.each { |c| parse(c, p) }
56
+ p << "&#xa0;"
57
+ p.span **{ class: "AdmittedLabel" } do |s|
58
+ s << l10n(@i18n.deprecated)
59
+ end
60
+ end
61
+ end
62
+
63
+ def admitted_term_parse(node, out)
64
+ out.p **{ class: "AltTerms" } do |p|
65
+ node.children.each { |c| parse(c, p) }
66
+ p << "&#xa0;"
67
+ p.span **{ class: "AdmittedLabel" } do |s|
68
+ s << l10n(@i18n.admitted)
69
+ end
70
+ end
71
+ end
72
+
37
73
  def example_parse(node, out)
38
74
  name = node.at(ns("./name"))
39
- example_name_parse(node, out, name) #if name
75
+ example_name_parse(node, out, name) # if name
40
76
  super
41
77
  end
42
78
 
43
- def example_label(node, div, name)
44
- end
79
+ def example_label(node, div, name); end
45
80
 
46
- def example_name_parse(node, div, name)
81
+ def example_name_parse(_node, div, name)
47
82
  div.p **{ class: "SourceTitle", style: "text-align:center;" } do |p|
48
83
  name&.children&.each { |n| parse(n, p) }
49
84
  end
@@ -56,6 +91,7 @@ module IsoDoc
56
91
 
57
92
  def is_clause?(name)
58
93
  return true if name == "submitters"
94
+
59
95
  super
60
96
  end
61
97
 
@@ -84,8 +120,8 @@ module IsoDoc
84
120
  def make_tr_attr(td, row, totalrows, header)
85
121
  ret = super
86
122
  if td.at("./ancestor::xmlns:table[@class = 'recommendation'] | "\
87
- "./ancestor::xmlns:table[@class = 'requirement'] | "\
88
- "./ancestor::xmlns:table[@class = 'permission']")
123
+ "./ancestor::xmlns:table[@class = 'requirement'] | "\
124
+ "./ancestor::xmlns:table[@class = 'permission']")
89
125
  ret[:style] = "vertical-align:top;"
90
126
  ret[:class] = "recommend"
91
127
  end
@@ -94,6 +130,7 @@ module IsoDoc
94
130
 
95
131
  def para_class(node)
96
132
  return node["class"] if node["class"]
133
+
97
134
  super
98
135
  end
99
136
  end
@@ -1,31 +1,31 @@
1
1
  module IsoDoc
2
2
  module Ogc
3
3
  module BaseConvert
4
- def std_bibitem_entry(list, b, ordinal, biblio)
5
- list.p **attr_code(iso_bibitem_entry_attrs(b, biblio)) do |ref|
4
+ def std_bibitem_entry(list, bib, ordinal, biblio)
5
+ list.p **attr_code(iso_bibitem_entry_attrs(bib, biblio)) do |ref|
6
6
  prefix_bracketed_ref(ref, "[#{ordinal}]") if biblio
7
- standard_citation(ref, b)
7
+ standard_citation(ref, bib)
8
8
  end
9
9
  end
10
10
 
11
- def nonstd_bibitem(list, b, ordinal, bibliography)
12
- list.p **attr_code(iso_bibitem_entry_attrs(b, bibliography)) do |r|
13
- id = bibitem_ref_code(b)
11
+ def nonstd_bibitem(list, bib, ordinal, bibliography)
12
+ list.p **attr_code(iso_bibitem_entry_attrs(bib, bibliography)) do |r|
13
+ id = bibitem_ref_code(bib)
14
14
  identifier = render_identifier(id)
15
15
  identifier[1] = nil
16
16
  if bibliography
17
17
  ref_entry_code(r, ordinal, identifier, id)
18
18
  end
19
- reference_format(b, r)
19
+ reference_format(bib, r)
20
20
  end
21
21
  end
22
22
 
23
- def reference_format(b, r)
24
- if ftitle = b.at(ns("./formattedref"))
25
- ftitle&.children&.each { |n| parse(n, r) }
23
+ def reference_format(bib, ref)
24
+ if ftitle = bib.at(ns("./formattedref"))
25
+ ftitle&.children&.each { |n| parse(n, ref) }
26
26
  else
27
27
  # eventually will be full LNCS reference
28
- standard_citation(r, b)
28
+ standard_citation(ref, bib)
29
29
  end
30
30
  end
31
31
 
@@ -34,97 +34,101 @@ module IsoDoc
34
34
  end
35
35
 
36
36
  def multiplenames_and(names)
37
- return "" if names.length == 0
37
+ return "" if names.empty?
38
38
  return names[0] if names.length == 1
39
39
  return "#{names[0]} and #{names[1]}" if names.length == 2
40
+
40
41
  names[0..-2].join(", ") + " and #{names[-1]}"
41
42
  end
42
43
 
43
- def nodes_to_span(n)
44
+ def nodes_to_span(node)
44
45
  noko do |xml|
45
46
  xml.span do |s|
46
- n&.children&.each { |x| parse(x, s) }
47
+ node&.children&.each { |x| parse(x, s) }
47
48
  end
48
- end.join("")
49
+ end.join
49
50
  end
50
51
 
51
- def extract_publisher(b)
52
- c = b.xpath(ns("./contributor[role/@type = 'publisher'][organization]"))
52
+ def extract_publisher(bib)
53
53
  abbrs = []
54
54
  names = []
55
- c&.each do |c1|
55
+ bib.xpath(ns("./contributor[role/@type = 'publisher']"\
56
+ "[organization]"))&.each do |c1|
56
57
  n = c1.at(ns("./organization/name")) or next
57
58
  abbrs << (c1.at(ns("./organization/abbreviation")) || n)
58
59
  names << nodes_to_span(n)
59
60
  end
60
61
  return [nil, nil] if names.empty?
61
- return [multiplenames_and(names), (abbrs.map { |x| x.text }).join("/")]
62
+
63
+ [multiplenames_and(names), abbrs.map(&:text).join("/")]
62
64
  end
63
65
 
64
- def extract_author(b)
65
- c = b.xpath(ns("./contributor[role/@type = 'author']"))
66
- c = b.xpath(ns("./contributor[role/@type = 'editor']")) if c.empty?
66
+ def extract_author(bib)
67
+ c = bib.xpath(ns("./contributor[role/@type = 'author']"))
68
+ c = bib.xpath(ns("./contributor[role/@type = 'editor']")) if c.empty?
67
69
  return nil if c.empty?
70
+
68
71
  c.map do |c1|
69
72
  c1&.at(ns("./organization/name"))&.text || extract_person_name(c1)
70
73
  end.reject { |e| e.nil? || e.empty? }.join(", ")
71
74
  end
72
75
 
73
- def extract_person_name(b)
74
- p = b.at(ns("./person/name")) or return
76
+ def extract_person_name(bib)
77
+ p = bib.at(ns("./person/name")) or return
75
78
  c = p.at(ns("./completename")) and return c.text
76
79
  s = p&.at(ns("./surname"))&.text or return
77
80
  i = p.xpath(ns("./initial")) and
78
- front = i.map { |e| e.text.gsub(/[^[:upper:]]/, "") }.join("")
81
+ front = i.map { |e| e.text.gsub(/[^[:upper:]]/, "") }.join
79
82
  i.empty? and f = p.xpath(ns("./forename")) and
80
- front = f.map { |e| e.text[0].upcase }.join("")
83
+ front = f.map { |e| e.text[0].upcase }.join
81
84
  front ? "#{s} #{front}" : s
82
85
  end
83
86
 
84
-
85
87
  def date_render(date)
86
88
  return nil if date.nil?
89
+
87
90
  on = date&.at(ns("./on"))&.text
88
91
  from = date&.at(ns("./from"))&.text
89
92
  to = date&.at(ns("./to"))&.text
90
93
  return on if on && !on.empty?
91
94
  return "#{from}&ndash;#{to}" if from && !from.empty?
95
+
92
96
  nil
93
97
  end
94
98
 
95
- def extract_year(b)
96
- d = b.at(ns("./date[@type = 'published']")) ||
97
- b.at(ns("./date[@type = 'issued']")) ||
98
- b.at(ns("./date[@type = 'circulated']")) ||
99
- b.at(ns("./date"))
99
+ def extract_year(bib)
100
+ d = bib.at(ns("./date[@type = 'published']")) ||
101
+ bib.at(ns("./date[@type = 'issued']")) ||
102
+ bib.at(ns("./date[@type = 'circulated']")) ||
103
+ bib.at(ns("./date"))
100
104
  date_render(d)
101
105
  end
102
106
 
103
- def extract_city(b)
104
- b.at(ns("./place"))
107
+ def extract_city(bib)
108
+ bib.at(ns("./place"))
105
109
  end
106
110
 
107
- def extract_uri(b)
108
- b.at(ns("./uri"))
111
+ def extract_uri(bib)
112
+ bib.at(ns("./uri"))
109
113
  end
110
114
 
111
115
  # {author}: {document identifier}, {title}. {publisher}, {city} ({year})
112
- def standard_citation(out, b)
113
- if ftitle = b.at(ns("./formattedref"))
116
+ def standard_citation(out, bib)
117
+ if ftitle = bib.at(ns("./formattedref"))
114
118
  ftitle&.children&.each { |n| parse(n, out) }
115
119
  else
116
- pub, pub_abbrev = extract_publisher(b)
117
- author = extract_author(b)
118
- c = extract_city(b)
119
- y = extract_year(b)
120
- u = extract_uri(b)
120
+ pub, pub_abbrev = extract_publisher(bib)
121
+ author = extract_author(bib)
122
+ c = extract_city(bib)
123
+ y = extract_year(bib)
124
+ u = extract_uri(bib)
121
125
  out << "#{author || pub_abbrev}: " if author || pub_abbrev
122
- id = render_identifier(inline_bibitem_ref_code(b))
126
+ id = render_identifier(inline_bibitem_ref_code(bib))
123
127
  out << id[1] if id[1]
124
- out << " (Draft)" if ogc_draft_ref?(b)
128
+ out << " (Draft)" if ogc_draft_ref?(bib)
125
129
  out << ", "
126
130
  out.i do |i|
127
- iso_title(b)&.children&.each { |n| parse(n, i) }
131
+ iso_title(bib)&.children&.each { |n| parse(n, i) }
128
132
  end
129
133
  out << ". "
130
134
  out << pub if pub
@@ -136,12 +140,14 @@ module IsoDoc
136
140
  end
137
141
  end
138
142
 
139
- def inline_bibitem_ref_code(b)
140
- id = b.at(ns("./docidentifier[not(@type = 'DOI' or @type = 'metanorma' "\
141
- "or @type = 'ISSN' or @type = 'ISBN' or @type = 'rfc-anchor')]"))
142
- id ||= b.at(ns("./docidentifier[not(@type = 'metanorma')]"))
143
+ def inline_bibitem_ref_code(bib)
144
+ id = bib.at(ns("./docidentifier[not(@type = 'DOI' "\
145
+ "or @type = 'metanorma' or @type = 'ISSN' "\
146
+ "or @type = 'ISBN' or @type = 'rfc-anchor')]"))
147
+ id ||= bib.at(ns("./docidentifier[not(@type = 'metanorma')]"))
143
148
  return [nil, id, nil] if id
144
- id = Nokogiri::XML::Node.new("docidentifier", b.document)
149
+
150
+ id = Nokogiri::XML::Node.new("docidentifier", bib.document)
145
151
  id << "(NO ID)"
146
152
  [nil, id, nil]
147
153
  end