metanorma-itu 2.4.4 → 2.4.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/lib/isodoc/itu/html/header.html +68 -0
  3. data/lib/isodoc/itu/html/itu.css +4 -1
  4. data/lib/isodoc/itu/html/itu.scss +4 -1
  5. data/lib/isodoc/itu/html/logo-small.png +0 -0
  6. data/lib/isodoc/itu/html/word_itu_intro.html +2 -0
  7. data/lib/isodoc/itu/html/wordstyle.css +2 -0
  8. data/lib/isodoc/itu/html/wordstyle.scss +2 -0
  9. data/lib/isodoc/itu/html_convert.rb +10 -0
  10. data/lib/isodoc/itu/i18n-ar.yaml +10 -0
  11. data/lib/isodoc/itu/i18n-de.yaml +10 -0
  12. data/lib/isodoc/itu/i18n-en.yaml +10 -0
  13. data/lib/isodoc/itu/i18n-es.yaml +10 -0
  14. data/lib/isodoc/itu/i18n-fr.yaml +10 -0
  15. data/lib/isodoc/itu/i18n-ru.yaml +10 -0
  16. data/lib/isodoc/itu/i18n-zh-Hans.yaml +10 -0
  17. data/lib/isodoc/itu/itu.implementers-guide.xsl +109 -110
  18. data/lib/isodoc/itu/itu.in-force.xsl +109 -110
  19. data/lib/isodoc/itu/itu.recommendation-annex.xsl +109 -110
  20. data/lib/isodoc/itu/itu.recommendation-supplement.xsl +109 -110
  21. data/lib/isodoc/itu/itu.recommendation.xsl +109 -110
  22. data/lib/isodoc/itu/itu.resolution.xsl +109 -110
  23. data/lib/isodoc/itu/itu.service-publication.xsl +109 -110
  24. data/lib/isodoc/itu/itu.technical-paper.xsl +109 -110
  25. data/lib/isodoc/itu/itu.technical-report.xsl +109 -110
  26. data/lib/isodoc/itu/metadata.rb +50 -18
  27. data/lib/isodoc/itu/presentation_preface.rb +110 -9
  28. data/lib/isodoc/itu/presentation_xml_convert.rb +13 -15
  29. data/lib/isodoc/itu/word_cleanup.rb +4 -4
  30. data/lib/isodoc/itu/word_convert.rb +21 -2
  31. data/lib/metanorma/itu/biblio.rng +24 -8
  32. data/lib/metanorma/itu/cleanup_section.rb +1 -1
  33. data/lib/metanorma/itu/front.rb +39 -13
  34. data/lib/metanorma/itu/front_id.rb +17 -6
  35. data/lib/metanorma/itu/isodoc.rng +67 -55
  36. data/lib/metanorma/itu/relaton-itu.rng +43 -7
  37. data/lib/metanorma/itu/validate.rb +4 -4
  38. data/lib/metanorma/itu/version.rb +1 -1
  39. metadata +3 -2
@@ -1,4 +1,3 @@
1
- require "isodoc"
2
1
  require "twitter_cldr"
3
2
 
4
3
  module IsoDoc
@@ -11,6 +10,7 @@ module IsoDoc
11
10
  set(:logo_comb, fileloc("itu-document-comb.png"))
12
11
  set(:logo_word, fileloc(n))
13
12
  set(:logo_sp, fileloc("logo-sp.png"))
13
+ set(:logo_small, fileloc("logo-small.png"))
14
14
  @isodoc = IsoDoc::ITU::HtmlConvert.new({})
15
15
  end
16
16
 
@@ -19,13 +19,13 @@ module IsoDoc
19
19
  File.expand_path(File.join(here, "html", file))
20
20
  end
21
21
 
22
- def title(isoxml, _out)
23
- { doctitle: "//bibdata/title[@language='#{@lang}'][@type = 'main']",
24
- docsubtitle: "//bibdata/title[@language='#{@lang}']" \
22
+ TITLE_XPATHS =
23
+ { doctitle: "//bibdata/title[@language='@_lang'][@type = 'main']",
24
+ docsubtitle: "//bibdata/title[@language='@_lang']" \
25
25
  "[@type = 'subtitle']",
26
- amendmenttitle: "//bibdata/title[@language='#{@lang}']" \
26
+ amendmenttitle: "//bibdata/title[@language='@_lang']" \
27
27
  "[@type = 'amendment']",
28
- corrigendumtitle: "//bibdata/title[@language='#{@lang}']" \
28
+ corrigendumtitle: "//bibdata/title[@language='@_lang']" \
29
29
  "[@type = 'corrigendum']",
30
30
  series: "//bibdata/series[@type='main']/title",
31
31
  series1: "//bibdata/series[@type='secondary']/title",
@@ -33,9 +33,16 @@ module IsoDoc
33
33
  annextitle: "//bibdata/title[@type='annex']",
34
34
  collectiontitle: "//bibdata/title[@type='collection']",
35
35
  slogantitle: "//bibdata/title[@type='slogan']",
36
- positiontitle: "//bibdata/title[@type='position-sp']" }.each do |k, v|
37
- titleset(isoxml, k, v)
36
+ positiontitle: "//bibdata/title[@type='position-sp']" }.freeze
37
+
38
+ def title(isoxml, _out)
39
+ TITLE_XPATHS.each do |k, v|
40
+ titleset(isoxml, k, v.sub("@_lang", @lang))
38
41
  end
42
+ titleset(isoxml, :doctitle_en,
43
+ "//bibdata/title[@language='en'][@type = 'main']") or
44
+ titleset(isoxml, :doctitle_en,
45
+ "//bibdata/title[@language='#{@lang}'][@type = 'main']")
39
46
  end
40
47
 
41
48
  def titleset(isoxml, key, xpath)
@@ -46,6 +53,7 @@ module IsoDoc
46
53
  end
47
54
  end.join
48
55
  set(key, out.sub(%r{^<span>}, "").sub(%r{</span>$}, ""))
56
+ true
49
57
  end
50
58
 
51
59
  def subtitle(_isoxml, _out)
@@ -55,12 +63,19 @@ module IsoDoc
55
63
  def author(xml, _out)
56
64
  sector = xml.at(ns("//bibdata/ext/editorialgroup/sector"))
57
65
  set(:sector, sector.text) if sector
58
- bureau = xml.at(ns("//bibdata/ext/editorialgroup/bureau"))
59
- set(:bureau, bureau.text) if bureau
66
+ bureau(xml)
60
67
  tc = xml.at(ns("//bibdata/ext/editorialgroup/committee"))
61
68
  set(:tc, tc.text) if tc
62
69
  tc = xml.at(ns("//bibdata/ext/editorialgroup/group/name"))
63
70
  set(:group, tc.text) if tc
71
+ tc = xml.at(ns("//bibdata/ext/editorialgroup/group/acronym"))
72
+ set(:group_acronym, tc.text) if tc
73
+ start1 = xml.at(ns("//bibdata/ext/editorialgroup/group/period/start"))
74
+ end1 = xml.at(ns("//bibdata/ext/editorialgroup/group/period/end"))
75
+ if start1
76
+ set(:study_group_period,
77
+ @i18n.l10n("#{start1.text}–#{end1.text}"))
78
+ end
64
79
  tc = xml.at(ns("//bibdata/ext/editorialgroup/subgroup/name"))
65
80
  set(:subgroup, tc.text) if tc
66
81
  tc = xml.at(ns("//bibdata/ext/editorialgroup/workgroup/name"))
@@ -71,20 +86,34 @@ module IsoDoc
71
86
  person_attributes(authors) unless authors.empty?
72
87
  end
73
88
 
89
+ def bureau(xml)
90
+ if bureau = xml.at(ns("//bibdata/ext/editorialgroup/bureau"))
91
+ set(:bureau, bureau.text)
92
+ case bureau.text
93
+ when "T" then set(:bureau_full, @i18n.tsb_full)
94
+ when "D" then set(:bureau_full, @i18n.bdt_full)
95
+ when "R" then set(:bureau_full, @i18n.br_full)
96
+ end
97
+ end
98
+ end
99
+
74
100
  def append(key, value)
75
101
  @metadata[key] << value
76
102
  end
77
103
 
104
+ PERSON_ATTRS = { affiliations: "./affiliation/organization/name",
105
+ addresses: "./affiliation/organization/address/" \
106
+ "formattedAddress",
107
+ emails: "./email",
108
+ faxes: "./phone[@type = 'fax']",
109
+ phones: "./phone[not(@type = 'fax')]" }.freeze
110
+
78
111
  def person_attributes(authors)
79
- %i(affiliations addresses emails faxes phones).each { |i| set(i, []) }
112
+ PERSON_ATTRS.each_key { |k| set(k, []) }
80
113
  authors.each do |a|
81
- append(:affiliations,
82
- a.at(ns("./affiliation/organization/name"))&.text)
83
- append(:addresses, a.at(ns("./affiliation/organization/address/" \
84
- "formattedAddress"))&.text)
85
- append(:emails, a.at(ns("./email"))&.text)
86
- append(:faxes, a.at(ns("./phone[@type = 'fax']"))&.text)
87
- append(:phones, a.at(ns("./phone[not(@type = 'fax')]"))&.text)
114
+ PERSON_ATTRS.each do |k, v|
115
+ append(k, a.at(ns(v))&.text)
116
+ end
88
117
  end
89
118
  end
90
119
 
@@ -134,6 +163,9 @@ module IsoDoc
134
163
  def keywords(isoxml, _out)
135
164
  super
136
165
  set(:keywords, get[:keywords].sort)
166
+ q = isoxml.xpath(ns("//bibdata/ext/question/identifier"))
167
+ q.empty? or set(:questions,
168
+ q.map { |x| x.text.sub(/^Q/, "") }.join(", "))
137
169
  end
138
170
 
139
171
  def doctype(isoxml, _out)
@@ -2,8 +2,13 @@ module IsoDoc
2
2
  module ITU
3
3
  class PresentationXMLConvert < IsoDoc::PresentationXMLConvert
4
4
  def insert_preface_sections(docxml)
5
- x = insert_editors_clause(docxml) and
6
- editors_insert_pt(docxml).next = x
5
+ if @doctype == "contribution"
6
+ x = contribution_table(docxml) and
7
+ contribution_table_insert_pt(docxml).next = x
8
+ else
9
+ x = insert_editors_clause(docxml) and
10
+ editors_insert_pt(docxml).next = x
11
+ end
7
12
  end
8
13
 
9
14
  def editors_insert_pt(docxml)
@@ -13,6 +18,74 @@ module IsoDoc
13
18
  docxml.at(ns("//preface")).children[-1]
14
19
  end
15
20
 
21
+ def contribution_table_insert_pt(docxml)
22
+ docxml.at(ns("//preface")) || docxml.at(ns("//sections"))
23
+ .add_previous_sibling("<preface> </preface>").first
24
+ docxml.at(ns("//preface")).children.first.before(" ").previous
25
+ end
26
+
27
+ def contribution_table(_doc)
28
+ @doctype == "contribution" or return
29
+ bureau = bold_and_upcase(@meta.get[:bureau_full])
30
+ <<~TABLE
31
+ <clause unnumbered="true" type="contribution-metadata">
32
+ <table class="contribution-metadata" unnumbered="true" width="100%">
33
+ <colgroup><col width="11.8%"/><col width="41.2%"/><col width="47.0%"/></colgroup>
34
+ <thead>
35
+ <tr><th rowspan="3"><image height="56" width="56" src="#{@meta.get[:logo_small]}"/></th>
36
+ <td rowspan="3"><p style="font-size:8pt;margin-top:6pt;margin-bottom:0pt;">#{@i18n.international_telecommunication_union.upcase}</p>
37
+ <p class="bureau_big" style="font-size:13pt;margin-top:6pt;margin-bottom:0pt;">#{bureau}</p>
38
+ <p style="font-size:10pt;margin-top:6pt;margin-bottom:0pt;">#{@i18n.studyperiod.sub('%', @meta.get[:study_group_period]).upcase}</p></th>
39
+ <th align="right"><p style="font-size:16pt;">#{@meta.get[:docnumber]}</p></th></tr>
40
+ <tr><th align="right"><p style="font-size:14pt;">#{@meta.get[:group].upcase}</p></th></tr>
41
+ <tr>
42
+ <th align="right"><p style="font-size:14pt;">#{@i18n.l10n("#{@i18n.original}: #{@i18n.current_language}")}</p></th>
43
+ </tr></thead>
44
+ <tbody>
45
+ <tr><th align="left" width="95">#{colon_i18n(@i18n.questions)}</th><td>#{@meta.get[:questions]}</td>
46
+ <td align="right">#{@i18n.l10n("#{@meta.get[:meeting_place]}, #{@meta.get[:meeting_date]}")}</td></tr>
47
+ <tr><th align="center" colspan="3">#{@i18n.get['doctype_dict']['contribution'].upcase}</th></tr>
48
+ <tr><th align="left" width="95">#{colon_i18n(@i18n.document_source)}</th><td colspan="2">#{@meta.get[:source]}</td></tr>
49
+ <tr><th align="left" width="95">#{colon_i18n(@i18n.title)}</th><td colspan="2">#{@meta.get[:doctitle_en]}</td></tr>
50
+ #{contribution_table_contacts}
51
+ </tbody></table>
52
+ </clause>
53
+ TABLE
54
+ end
55
+
56
+ def colon_i18n(text)
57
+ @i18n.l10n("#{text}:")
58
+ end
59
+
60
+ def bold_and_upcase(xml)
61
+ x = Nokogiri::XML("<root>#{xml}</root>")
62
+ x.traverse do |e|
63
+ e.text? or next
64
+ e.replace("<strong>#{e.text.upcase}</strong>")
65
+ end
66
+ x.root.children.to_xml
67
+ end
68
+
69
+ def contribution_table_contacts
70
+ n = (0..@meta.get[:authors]&.size).each_with_object([]) do |i, ret|
71
+ ret << contribution_table_contact(i)
72
+ end
73
+ n.map do |x|
74
+ lbl = colon_i18n(@i18n.contact)
75
+ "<tr><th align='left' width='95'>#{lbl}</th>#{x}</tr>"
76
+ end.join("\n")
77
+ end
78
+
79
+ def contribution_table_contact(idx)
80
+ <<~CELL
81
+ <td>#{@meta.get[:authors][idx]}<br/>
82
+ #{@meta.get[:affiliations][idx]}<br/>
83
+ #{@meta.get[:addresses][idx]}</td>
84
+ <td>#{@i18n.tel_abbrev}<tab/>#{@meta.get[:phones][idx]}<br/>
85
+ #{@i18n.email}<tab/>#{@meta.get[:emails][idx]}</td>
86
+ CELL
87
+ end
88
+
16
89
  def insert_editors_clause(doc)
17
90
  ret = extract_editors(doc) or return
18
91
  eds = ret[:names].each_with_object([]).with_index do |(_x, acc), i|
@@ -57,19 +130,47 @@ module IsoDoc
57
130
 
58
131
  def rearrange_clauses(docxml)
59
132
  super
60
- k = keywords(docxml) or return
61
- if a = docxml.at(ns("//preface/abstract"))
62
- a.next = k
63
- elsif a = docxml.at(ns("//preface"))
64
- a.children.first.previous = k
133
+ insert_preface_sections(docxml)
134
+ a = docxml.at(ns("//preface/abstract"))
135
+ keywords_abstract_swap(a, keywords(docxml), docxml)
136
+ c = docxml.at(ns("//preface/clause[@type='contribution-metadata']")) and
137
+ a and c.next = a
138
+ abstract_render(a)
139
+ end
140
+
141
+ def keywords_abstract_swap(abstract, keywords, docxml)
142
+ @doctype == "contribution" and return
143
+ keywords or return
144
+ if abstract then abstract.next = keywords
145
+ else
146
+ p = contribution_table_insert_pt(docxml)
147
+ p.next = keywords
65
148
  end
66
149
  end
67
150
 
151
+ def abstract_render(abstract)
152
+ @doctype == "contribution" or return
153
+ abstract.at(ns("./title"))&.remove
154
+ abstract.children = <<~TABLE
155
+ <table class="abstract" unnumbered="true" width="100%">
156
+ <colgroup><col width="11.8%"/><col width="78.2%"/></colgroup>
157
+ <tbody>
158
+ <tr><th align="left" width="95"><p>#{colon_i18n(@i18n.abstract)}</p></th>
159
+ <td>#{abstract.children.to_xml}</td></tr>
160
+ </tbody></table>
161
+ TABLE
162
+ end
163
+
68
164
  def keywords(_docxml)
69
165
  kw = @meta.get[:keywords]
70
- kw.nil? || kw.empty? and return
166
+ kw.nil? || kw.empty? || @doctype == "contribution" and return
71
167
  "<clause type='keyword'><title>#{@i18n.keywords}</title>" \
72
- "<p>#{kw.join(', ')}.</p>"
168
+ "<p>#{@i18n.l10n(kw.join(', '))}.</p>"
169
+ end
170
+
171
+ def toc_title(docxml)
172
+ %w(resolution contribution).include?(@doctype) and return
173
+ super
73
174
  end
74
175
 
75
176
  include Init
@@ -25,11 +25,6 @@ module IsoDoc
25
25
  super
26
26
  end
27
27
 
28
- def convert1(docxml, filename, dir)
29
- insert_preface_sections(docxml)
30
- super
31
- end
32
-
33
28
  def eref(docxml)
34
29
  docxml.xpath(ns("//eref")).each { |f| eref1(f) }
35
30
  end
@@ -92,8 +87,7 @@ module IsoDoc
92
87
  end
93
88
 
94
89
  def clause1(elem)
95
- @doctype == "resolution" or return super
96
- %w(sections bibliography).include? elem.parent.name or return super
90
+ clause1_super?(elem) and return super
97
91
  @suppressheadingnumbers || elem["unnumbered"] and return
98
92
  t = elem.at(ns("./title")) and t["depth"] = "1"
99
93
  lbl = @xrefs.anchor(elem["id"], :label, false) or return
@@ -102,6 +96,11 @@ module IsoDoc
102
96
  "#{@i18n.get['section'].upcase} #{lbl}</p>"
103
97
  end
104
98
 
99
+ def clause1_super?(elem)
100
+ @doctype != "resolution" ||
101
+ !%w(sections bibliography).include?(elem.parent.name)
102
+ end
103
+
105
104
  def annex1(elem)
106
105
  @doctype == "resolution" or return super
107
106
  elem.elements.first.previous = annex1_supertitle(elem)
@@ -134,16 +133,13 @@ module IsoDoc
134
133
  super
135
134
  end
136
135
 
137
- def toc_title(docxml)
138
- @doctype == "resolution" and return
139
- super
140
- end
141
-
142
136
  def middle_title(isoxml)
143
137
  s = isoxml.at(ns("//sections")) or return
144
138
  titfn = isoxml.at(ns("//note[@type = 'title-footnote']"))
145
- if @meta.get[:doctype] == "Resolution"
139
+ case @doctype
140
+ when "resolution"
146
141
  middle_title_resolution(isoxml, s.children.first)
142
+ when "contribution"
147
143
  else
148
144
  middle_title_recommendation(isoxml, s.children.first)
149
145
  end
@@ -151,7 +147,8 @@ module IsoDoc
151
147
  end
152
148
 
153
149
  def renumber_footnotes(isoxml)
154
- (isoxml.xpath(ns("//fn")) - isoxml.xpath(ns("//table//fn | //figure//fn")))
150
+ (isoxml.xpath(ns("//fn")) -
151
+ isoxml.xpath(ns("//table//fn | //figure//fn")))
155
152
  .each_with_index do |fn, i|
156
153
  fn["reference"] = (i + 1).to_s
157
154
  end
@@ -212,7 +209,8 @@ module IsoDoc
212
209
 
213
210
  def dl1(dlist)
214
211
  ins = dlist.at(ns("./dt"))
215
- ins.previous = '<colgroup><col width="20%"/><col width="80%"/></colgroup>'
212
+ ins.previous =
213
+ '<colgroup><col width="20%"/><col width="80%"/></colgroup>'
216
214
  end
217
215
 
218
216
  include Init
@@ -32,11 +32,11 @@ module IsoDoc
32
32
 
33
33
  def word_title_cleanup(docxml)
34
34
  docxml.xpath("//p[@class = 'annex_obligation']").each do |h|
35
- h&.next_element&.name == "p" or next
35
+ h.next_element&.name == "p" or next
36
36
  h.next_element["class"] ||= "Normalaftertitle"
37
37
  end
38
38
  docxml.xpath("//p[@class = 'FigureTitle']").each do |h|
39
- h&.parent&.next_element&.name == "p" or next
39
+ h.parent&.next_element&.name == "p" or next
40
40
  h.parent.next_element["class"] ||= "Normalaftertitle"
41
41
  end
42
42
  end
@@ -103,8 +103,8 @@ module IsoDoc
103
103
 
104
104
  def authority_hdr_cleanup2(docxml)
105
105
  %w(copyright license legal).each do |t|
106
- docxml&.xpath("//div[@class = 'boilerplate-#{t}']")&.each do |d|
107
- para = d&.at("./descendant::h1[2]") and
106
+ docxml.xpath("//div[@class = 'boilerplate-#{t}']")&.each do |d|
107
+ para = d.at("./descendant::h1[2]") and
108
108
  para.previous = "<p>&#xa0;</p><p>&#xa0;</p><p>&#xa0;</p>"
109
109
  d.xpath(".//h1 | .//h2").each do |p|
110
110
  p.name = "p"
@@ -21,9 +21,24 @@ module IsoDoc
21
21
  end
22
22
  end
23
23
 
24
+ def make_body1(body, _docxml)
25
+ @wordcoverpage or return
26
+ super
27
+ end
28
+
29
+ def make_body2(body, docxml)
30
+ body.div class: "WordSection2" do |div2|
31
+ boilerplate docxml, div2
32
+ content(div2, docxml, ns("//preface/*[@displayorder]"))
33
+ div2.p { |p| p << "&#xa0;" } # placeholder
34
+ end
35
+ @doctype == "contribution" or section_break(body)
36
+ end
37
+
24
38
  def abstract(clause, out)
25
39
  out.div **attr_code(id: clause["id"], class: "Abstract") do |s|
26
- clause_name(clause, "Summary", s, class: "AbstractTitle")
40
+ @doctype == "contribution" or
41
+ clause_name(clause, "Summary", s, class: "AbstractTitle")
27
42
  clause.elements.each { |e| parse(e, s) unless e.name == "title" }
28
43
  end
29
44
  end
@@ -42,10 +57,14 @@ module IsoDoc
42
57
  end
43
58
 
44
59
  def convert1(docxml, filename, dir)
45
- if @doctype == "service-publication"
60
+ case @doctype
61
+ when "service-publication"
46
62
  @wordcoverpage = html_doc_path("word_itu_titlepage_sp.html")
47
63
  options[:bodyfont] = "Arial"
48
64
  options[:headerfont] = "Arial"
65
+ when "contribution"
66
+ @wordcoverpage = nil
67
+ @wordintropage = nil
49
68
  end
50
69
  super
51
70
  end
@@ -208,7 +208,9 @@
208
208
  </define>
209
209
  <define name="roledescription">
210
210
  <element name="description">
211
- <ref name="FormattedString"/>
211
+ <oneOrMore>
212
+ <ref name="TextElement"/>
213
+ </oneOrMore>
212
214
  </element>
213
215
  </define>
214
216
  <define name="person">
@@ -333,7 +335,9 @@
333
335
  </define>
334
336
  <define name="affiliationdescription">
335
337
  <element name="description">
336
- <ref name="FormattedString"/>
338
+ <oneOrMore>
339
+ <ref name="TextElement"/>
340
+ </oneOrMore>
337
341
  </element>
338
342
  </define>
339
343
  <define name="organization">
@@ -897,7 +901,9 @@
897
901
  </define>
898
902
  <define name="formattedref">
899
903
  <element name="formattedref">
900
- <ref name="FormattedString"/>
904
+ <oneOrMore>
905
+ <ref name="TextElement"/>
906
+ </oneOrMore>
901
907
  </element>
902
908
  </define>
903
909
  <define name="license">
@@ -942,7 +948,9 @@
942
948
  <optional>
943
949
  <attribute name="type"/>
944
950
  </optional>
945
- <ref name="FormattedString"/>
951
+ <zeroOrMore>
952
+ <ref name="TextElement"/>
953
+ </zeroOrMore>
946
954
  </define>
947
955
  <!-- TitleType = ( "alternative" | "original" | "unofficial" | "subtitle" | "main" ) -->
948
956
  <define name="TypedUri">
@@ -1042,7 +1050,9 @@
1042
1050
  <optional>
1043
1051
  <attribute name="script"/>
1044
1052
  </optional>
1045
- <text/>
1053
+ <oneOrMore>
1054
+ <ref name="TextElement"/>
1055
+ </oneOrMore>
1046
1056
  </element>
1047
1057
  </define>
1048
1058
  <define name="docnumber">
@@ -1267,12 +1277,16 @@
1267
1277
  <optional>
1268
1278
  <attribute name="type"/>
1269
1279
  </optional>
1270
- <ref name="FormattedString"/>
1280
+ <oneOrMore>
1281
+ <ref name="TextElement"/>
1282
+ </oneOrMore>
1271
1283
  </element>
1272
1284
  </define>
1273
1285
  <define name="bibabstract">
1274
1286
  <element name="abstract">
1275
- <ref name="FormattedString"/>
1287
+ <oneOrMore>
1288
+ <ref name="TextElement"/>
1289
+ </oneOrMore>
1276
1290
  </element>
1277
1291
  </define>
1278
1292
  <define name="copyright">
@@ -1377,7 +1391,9 @@
1377
1391
  </attribute>
1378
1392
  <optional>
1379
1393
  <element name="description">
1380
- <ref name="FormattedString"/>
1394
+ <oneOrMore>
1395
+ <ref name="TextElement"/>
1396
+ </oneOrMore>
1381
1397
  </element>
1382
1398
  </optional>
1383
1399
  <element name="bibitem">
@@ -139,7 +139,7 @@ module Metanorma
139
139
  sym.next = "<p>#{@i18n.symbols_boilerplate}</p>"
140
140
  end
141
141
 
142
- def sections_names_cleanup(xml)
142
+ def sections_names_pref_cleanup(xml)
143
143
  super
144
144
  t = xml.at("//preface//abstract") or return
145
145
  t["id"] == "_summary" and
@@ -1,5 +1,3 @@
1
- require "asciidoctor"
2
- require "metanorma/standoc/converter"
3
1
  require "fileutils"
4
2
  require_relative "./front_id"
5
3
 
@@ -86,6 +84,7 @@ module Metanorma
86
84
  end
87
85
 
88
86
  def metadata_committee(node, xml)
87
+ hyphenate_node_attributes(node)
89
88
  metadata_sector(node, xml)
90
89
  metadata_committee1(node, xml, "")
91
90
  suffix = 2
@@ -93,6 +92,17 @@ module Metanorma
93
92
  metadata_committee1(node, xml, "_#{suffix}")
94
93
  suffix += 1
95
94
  end
95
+ metadata_question(node, xml)
96
+ end
97
+
98
+ def hyphenate_node_attributes(node)
99
+ a = node.attributes.dup
100
+ a.each do |k, v|
101
+ /group(type|acronym)/.match?(k) and
102
+ node.set_attr(k.sub(/group(type|acronym)/, "group-\\1"), v)
103
+ /group(yearstart|yearend)/.match?(k) and
104
+ node.set_attr(k.sub(/groupyear(start|end)/, "group-year-\\1"), v)
105
+ end
96
106
  end
97
107
 
98
108
  def metadata_sector(node, xml)
@@ -102,13 +112,25 @@ module Metanorma
102
112
  end
103
113
  end
104
114
 
115
+ def metadata_question(node, xml)
116
+ vals = csv_split(node.attr("question"), ",").map do |s1|
117
+ t, v = s1.split(":", 2).map(&:strip)
118
+ { id: t, value: v }
119
+ end
120
+ vals.each do |v|
121
+ xml.question do |q|
122
+ a = v[:id] and q.identifier a
123
+ a = v[:value] and q.name a
124
+ end
125
+ end
126
+ end
127
+
105
128
  def metadata_committee1(node, xml, suffix)
106
129
  xml.editorialgroup do |a|
107
130
  a.bureau ( node.attr("bureau#{suffix}") || "T")
108
131
  ["", "sub", "work"].each do |p|
109
- next unless node.attr("#{p}group#{suffix}")
110
-
111
- type = node.attr("#{p}grouptype#{suffix}")
132
+ node.attr("#{p}group#{suffix}") or next
133
+ type = node.attr("#{p}group-type#{suffix}")
112
134
  a.send "#{p}group", **attr_code(type: type) do |g|
113
135
  metadata_committee2(node, g, suffix, p)
114
136
  end
@@ -118,17 +140,21 @@ module Metanorma
118
140
 
119
141
  def metadata_committee2(node, group, suffix, prefix)
120
142
  group.name node.attr("#{prefix}group#{suffix}")
121
- node.attr("#{prefix}groupacronym#{suffix}") and
122
- group.acronym node.attr("#{prefix}groupacronym#{suffix}")
123
- if node.attr("#{prefix}groupyearstart#{suffix}")
124
- group.period do |p|
125
- p.start node.attr("#{prefix}groupyearstart#{suffix}")
126
- node.attr("#{prefix}groupacronym#{suffix}") and
127
- p.end node.attr("#{prefix}groupyearend#{suffix}")
128
- end
143
+ a = node.attr("#{prefix}group-acronym#{suffix}") and group.acronym a
144
+ s, e = group_period(node, prefix, suffix)
145
+ group.period do |p|
146
+ p.start s
147
+ p.end e
129
148
  end
130
149
  end
131
150
 
151
+ def group_period(node, prefix, suffix)
152
+ s = node.attr("#{prefix}group-year-start#{suffix}") ||
153
+ Date.today.year - (Date.today.year % 2)
154
+ e = node.attr("#{prefix}group-year-end#{suffix}") || s.to_i + 2
155
+ [s, e]
156
+ end
157
+
132
158
  def metadata_series(node, xml)
133
159
  { series: "main", series1: "secondary", series2: "tertiary" }
134
160
  .each do |k, v|
@@ -27,19 +27,30 @@ module Metanorma
27
27
 
28
28
  def itu_id1(node, lang)
29
29
  bureau = node.attr("bureau") || "T"
30
- id = if doctype(node) == "service-publication"
31
- @i18n.annex_to_itu_ob_abbrev.sub(/%/,
32
- node.attr("docnumber"))
30
+ id = case doctype(node)
31
+ when "service-publication"
32
+ itu_service_pub_id(node)
33
+ when "contribution"
34
+ itu_contrib_id(node)
33
35
  else
34
36
  "ITU-#{bureau} #{node.attr('docnumber')}"
35
37
  end
36
38
  id + (lang ? "-#{ITULANG[@lang]}" : "")
37
39
  end
38
40
 
39
- def itu_id(node, xml)
40
- return unless node.attr("docnumber") || node.attr("docidentifier")
41
+ def itu_service_pub_id(node)
42
+ @i18n.annex_to_itu_ob_abbrev.sub(/%/, node.attr("docnumber"))
43
+ end
41
44
 
42
- xml.docidentifier type: "ITU" do |i|
45
+ def itu_contrib_id(node)
46
+ group = node.attr("group-acronym") ||
47
+ node.attr("group").sub("Study Group ", "SG")
48
+ "#{group}-C#{node.attr('docnumber')}"
49
+ end
50
+
51
+ def itu_id(node, xml)
52
+ node.attr("docnumber") || node.attr("docidentifier") or return
53
+ xml.docidentifier type: "ITU", primary: "true" do |i|
43
54
  i << (node.attr("docidentifier") || itu_id1(node, false))
44
55
  end
45
56
  xml.docidentifier type: "ITU-lang" do |i|