isodoc 1.2.1 → 1.2.6

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 (48) hide show
  1. checksums.yaml +4 -4
  2. data/isodoc.gemspec +1 -0
  3. data/lib/isodoc-yaml/i18n-fr.yaml +1 -1
  4. data/lib/isodoc/base_style/all.css +1 -1
  5. data/lib/isodoc/base_style/metanorma_word.css +6 -0
  6. data/lib/isodoc/base_style/metanorma_word.scss +6 -0
  7. data/lib/isodoc/base_style/reset.css +1 -1
  8. data/lib/isodoc/base_style/reset.scss +1 -1
  9. data/lib/isodoc/convert.rb +1 -1
  10. data/lib/isodoc/function/blocks.rb +1 -0
  11. data/lib/isodoc/function/cleanup.rb +1 -1
  12. data/lib/isodoc/function/references.rb +4 -2
  13. data/lib/isodoc/function/section.rb +13 -1
  14. data/lib/isodoc/function/table.rb +1 -0
  15. data/lib/isodoc/function/to_word_html.rb +3 -0
  16. data/lib/isodoc/function/utils.rb +1 -1
  17. data/lib/isodoc/html_function/html.rb +1 -0
  18. data/lib/isodoc/i18n.rb +8 -50
  19. data/lib/isodoc/metadata.rb +49 -35
  20. data/lib/isodoc/metadata_date.rb +5 -0
  21. data/lib/isodoc/presentation_function/bibdata.rb +24 -0
  22. data/lib/isodoc/presentation_function/block.rb +14 -0
  23. data/lib/isodoc/presentation_function/inline.rb +27 -14
  24. data/lib/isodoc/presentation_xml_convert.rb +4 -0
  25. data/lib/isodoc/version.rb +1 -1
  26. data/lib/isodoc/word_function/body.rb +1 -0
  27. data/lib/isodoc/word_function/postprocess.rb +1 -1
  28. data/lib/isodoc/word_function/table.rb +3 -2
  29. data/lib/isodoc/xref.rb +1 -0
  30. data/lib/isodoc/xref/xref_anchor.rb +8 -3
  31. data/lib/isodoc/xref/xref_counter.rb +21 -7
  32. data/lib/isodoc/xref/xref_gen.rb +29 -6
  33. data/lib/isodoc/xref/xref_sect_gen.rb +1 -1
  34. data/lib/isodoc/xslfo_convert.rb +6 -1
  35. data/spec/assets/i18n.yaml +9 -0
  36. data/spec/isodoc/blocks_spec.rb +281 -13
  37. data/spec/isodoc/cleanup_spec.rb +3 -1
  38. data/spec/isodoc/i18n_spec.rb +43 -5
  39. data/spec/isodoc/inline_spec.rb +47 -5
  40. data/spec/isodoc/metadata_spec.rb +24 -15
  41. data/spec/isodoc/postproc_spec.rb +39 -3
  42. data/spec/isodoc/ref_spec.rb +4 -1
  43. data/spec/isodoc/section_spec.rb +134 -10
  44. data/spec/isodoc/table_spec.rb +306 -207
  45. data/spec/isodoc/terms_spec.rb +1 -1
  46. data/spec/isodoc/xref_spec.rb +46 -18
  47. data/spec/spec_helper.rb +4 -0
  48. metadata +17 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 41a0527fbc7f1b53775ff475d0306709ad4ffb42d5aa17ab1907124684d6a891
4
- data.tar.gz: ea38f9755d51aef103ca9d63f496a5a12d89211be9e3bd0c48bb5a21409318ca
3
+ metadata.gz: dcbc3f4f71f739273b06483080ad077fcda05b20f8eca96858300543b0fb2784
4
+ data.tar.gz: f0c4a29519de6c22dbc47af2193d8f4ee0a2c925c5d0c9f58414813be28070ef
5
5
  SHA512:
6
- metadata.gz: c54dd45f7dac502a8cb36dcf5cd6c6ec19b7accf8a03d12b7e393d5d284cbc6ed055c4f024a8b643b56fc3fe9c0344b007a491de98dfdc93eb28cc74f7079f35
7
- data.tar.gz: c626b8d0a3f08e48d62a082d0f0a33037b06918d3b1d767a8777ec2da04c507a9e16d1ee79827c9911eb8d4242c449fa46cbe1c4fc4ac387fefa1f5a363303fd
6
+ metadata.gz: 5eb17f999c954a1185f60807f5c9b4dcdde33391fd95546d51dca4a00aee8d742736155313153a5007205d06d189c5ee69b39152db57478669e54e7622fde568
7
+ data.tar.gz: e0122186b16428b61c7009d7c8560ab12de531a8ec3bac56e58e89528f4a2a0acd2e1ab4ce4453919f7ed2707e7724037175852a3dc148a53bb0eef63aa5f695
@@ -37,6 +37,7 @@ Gem::Specification.new do |spec|
37
37
  spec.add_dependency "liquid"
38
38
  spec.add_dependency "roman-numerals"
39
39
  spec.add_dependency "metanorma", "~> 1.1.0"
40
+ spec.add_dependency "relaton-cli"
40
41
 
41
42
  spec.add_development_dependency "rake", "~> 13.0"
42
43
  spec.add_development_dependency "byebug", "~> 9.1"
@@ -1,6 +1,6 @@
1
1
  term_def_boilerplate:
2
2
  scope: Domaine d'application
3
- symbolabbrev: Symboles et termes abrégés
3
+ symbolsabbrev: Symboles et termes abrégés
4
4
  abbrev: Termes abrégés
5
5
  symbols: Symboles
6
6
  table_of_contents: Sommaire
@@ -9,7 +9,7 @@ fieldset, form, label, legend,
9
9
  table, caption, tbody, tfoot, thead, tr, th, td,
10
10
  article, aside, canvas, details, embed,
11
11
  figure, figcaption, footer, header, hgroup,
12
- menu, nav, output, ruby, section, summary,
12
+ menu, output, ruby, section, summary,
13
13
  time, mark, audio, video {
14
14
  margin: 0;
15
15
  padding: 0; }
@@ -16,6 +16,12 @@ td {
16
16
  tr {
17
17
  page-break-after: avoid; }
18
18
 
19
+ table.MsoISOTableBig tr {
20
+ page-break-inside: auto; }
21
+
22
+ table.MsoISOTableBig td {
23
+ page-break-inside: auto; }
24
+
19
25
  span.stem {
20
26
  font-family: "Cambria Math",serif;
21
27
  mso-ascii-font-family: "Cambria Math";
@@ -13,6 +13,12 @@ table.MsoISOTable tr
13
13
  td { page-break-inside:avoid; }
14
14
  tr { page-break-after:avoid; }
15
15
 
16
+ table.MsoISOTableBig tr
17
+ {page-break-inside:auto;}
18
+
19
+ table.MsoISOTableBig td
20
+ {page-break-inside:auto;}
21
+
16
22
  span.stem
17
23
  {font-family:"Cambria Math",serif;
18
24
  mso-ascii-font-family:"Cambria Math";
@@ -9,7 +9,7 @@ fieldset, form, label, legend,
9
9
  table, caption, tbody, tfoot, thead, tr, th, td,
10
10
  article, aside, canvas, details, embed,
11
11
  figure, figcaption, footer, header, hgroup,
12
- menu, nav, output, ruby, section, summary,
12
+ menu, output, ruby, section, summary,
13
13
  time, mark, audio, video {
14
14
  margin: 0;
15
15
  padding: 0; }
@@ -9,7 +9,7 @@ fieldset, form, label, legend,
9
9
  table, caption, tbody, tfoot, thead, tr, th, td,
10
10
  article, aside, canvas, details, embed,
11
11
  figure, figcaption, footer, header, hgroup,
12
- menu, nav, output, ruby, section, summary,
12
+ menu, output, ruby, section, summary,
13
13
  time, mark, audio, video {
14
14
  margin: 0;
15
15
  padding: 0;
@@ -6,7 +6,7 @@ require_relative "i18n"
6
6
 
7
7
  module IsoDoc
8
8
  class Convert < ::IsoDoc::Common
9
- attr_reader :options
9
+ attr_accessor :options
10
10
  attr_accessor :i18n
11
11
 
12
12
  # htmlstylesheet: Generic stylesheet for HTML
@@ -181,6 +181,7 @@ module IsoDoc::Function
181
181
  def quote_attribution(node, out)
182
182
  author = node.at(ns("./author"))
183
183
  source = node.at(ns("./source"))
184
+ return if author.nil? && source.nil?
184
185
  out.p **{ class: "QuoteAttribution" } do |p|
185
186
  p << "&mdash; #{author.text}" if author
186
187
  p << ", " if author && source
@@ -6,9 +6,9 @@ module IsoDoc::Function
6
6
 
7
7
  def termref_cleanup(docxml)
8
8
  docxml.
9
+ gsub(/\s*\[MODIFICATION\]\s*\[\/TERMREF\]/, l10n(", #{@i18n.modified} [/TERMREF]")).
9
10
  gsub(%r{\s*\[/TERMREF\]\s*</p>\s*<p>\s*\[TERMREF\]}, "; ").
10
11
  gsub(/\[TERMREF\]\s*/, l10n("[#{@i18n.source}: ")).
11
- gsub(/\s*\[MODIFICATION\]\s*\[\/TERMREF\]/, l10n(", #{@i18n.modified} [/TERMREF]")).
12
12
  gsub(%r{\s*\[\/TERMREF\]\s*}, l10n("]")).
13
13
  gsub(/\s*\[MODIFICATION\]/, l10n(", #{@i18n.modified} &mdash; "))
14
14
  end
@@ -54,7 +54,8 @@ module IsoDoc::Function
54
54
  def bibitem_ref_code(b)
55
55
  id = b.at(ns("./docidentifier[@type = 'metanorma']"))
56
56
  id1 = pref_ref_code(b)
57
- id2 = b.at(ns("./docidentifier[@type = 'DOI' or @type = 'ISSN' or @type = 'ISBN']"))
57
+ id2 = b.at(ns("./docidentifier[@type = 'DOI' or @type = 'ISSN' or "\
58
+ "@type = 'ISBN']"))
58
59
  return [id, id1, id2] if id || id1 || id2
59
60
  id = Nokogiri::XML::Node.new("docidentifier", b.document)
60
61
  id << "(NO ID)"
@@ -193,7 +194,8 @@ module IsoDoc::Function
193
194
  def bibliography_parse(node, out)
194
195
  title = node&.at(ns("./title"))&.text || ""
195
196
  out.div do |div|
196
- clause_parse_title(node, div, node.at(ns("./title")), out, { class: "Section3" })
197
+ clause_parse_title(node, div, node.at(ns("./title")), out,
198
+ { class: "Section3" })
197
199
  biblio_list(node, div, true)
198
200
  end
199
201
  end
@@ -182,7 +182,6 @@ module IsoDoc::Function
182
182
  page_break(out)
183
183
  out.div **attr_code(id: f["id"]) do |s|
184
184
  clause_name(nil, f.at(ns("./title")), s, { class: "AbstractTitle" })
185
- #s.h1(**{ class: "AbstractTitle" }) { |h1| h1 << @i18n.abstract }
186
185
  f.elements.each { |e| parse(e, s) unless e.name == "title" }
187
186
  end
188
187
  end
@@ -201,6 +200,19 @@ module IsoDoc::Function
201
200
  end
202
201
  end
203
202
 
203
+ def is_clause?(name)
204
+ %w(clause references definitions terms foreword introduction abstract
205
+ acknowledgements).include? name
206
+ end
207
+
208
+ def preface_block(isoxml, out)
209
+ p = isoxml.at(ns("//preface")) or return
210
+ p.elements.each do |e|
211
+ next if is_clause?(e.name)
212
+ parse(e, out)
213
+ end
214
+ end
215
+
204
216
  def copyright_parse(node, out)
205
217
  out.div **{class: "boilerplate-copyright"} do |div|
206
218
  node.children.each { |n| parse(n, div) }
@@ -82,6 +82,7 @@ module IsoDoc::Function
82
82
  def make_tr_attr(td, row, totalrows, header)
83
83
  style = td.name == "th" ? "font-weight:bold;" : ""
84
84
  td["align"] and style += "text-align:#{td['align']};"
85
+ td["valign"] and style += "vertical-align:#{td['valign']};"
85
86
  rowmax = td["rowspan"] ? row + td["rowspan"].to_i - 1 : row
86
87
  style += <<~STYLE
87
88
  border-top:#{row.zero? ? "#{SW} 1.5pt;" : 'none;'}
@@ -80,6 +80,7 @@ module IsoDoc::Function
80
80
  def make_body3(body, docxml)
81
81
  body.div **{ class: "main-section" } do |div3|
82
82
  boilerplate docxml, div3
83
+ preface_block docxml, div3
83
84
  abstract docxml, div3
84
85
  foreword docxml, div3
85
86
  introduction docxml, div3
@@ -103,6 +104,7 @@ module IsoDoc::Function
103
104
  @meta.version isoxml, out
104
105
  @meta.url isoxml, out
105
106
  @meta.keywords isoxml, out
107
+ @meta.note isoxml, out
106
108
  @meta.get
107
109
  end
108
110
 
@@ -220,6 +222,7 @@ module IsoDoc::Function
220
222
  when "feedback-statement" then feedback_parse(node, out)
221
223
  when "passthrough" then passthrough_parse(node, out)
222
224
  when "variant" then variant_parse(node, out)
225
+ when "amend" then amend_parse(node, out)
223
226
  when "tab" then clausedelimspace(out) # in Presentation XML only
224
227
  else
225
228
  error_parse(node, out)
@@ -184,7 +184,7 @@ module IsoDoc::Function
184
184
 
185
185
  def labelled_ancestor(node)
186
186
  !node.ancestors('example, requirement, recommendation, permission, '\
187
- 'table, figure, sourcecode').empty?
187
+ 'note, table, figure, sourcecode').empty?
188
188
  end
189
189
  end
190
190
  end
@@ -31,6 +31,7 @@ module IsoDoc::HtmlFunction
31
31
  def make_body3(body, docxml)
32
32
  body.div **{ class: "main-section" } do |div3|
33
33
  boilerplate docxml, div3
34
+ preface_block docxml, div3
34
35
  abstract docxml, div3
35
36
  foreword docxml, div3
36
37
  introduction docxml, div3
@@ -1,6 +1,5 @@
1
1
  require "yaml"
2
2
 
3
- # TODO: Cleanup and generalize
4
3
  module IsoDoc
5
4
  class I18n
6
5
  def load_yaml(lang, script, i18nyaml = nil)
@@ -43,55 +42,6 @@ module IsoDoc
43
42
  @labels.each do |k, v|
44
43
  self.class.send(:define_method, k.downcase) { v }
45
44
  end
46
- =begin
47
- @term_def_boilerplate = y["term_def_boilerplate"]
48
- @scope_lbl = y["scope"]
49
- @symbols_lbl = y["symbols"]
50
- @table_of_contents_lbl = y["table_of_contents"]
51
- @introduction_lbl = y["introduction"]
52
- @foreword_lbl = y["foreword"]
53
- @abstract_lbl = y["abstract"]
54
- @termsdef_lbl = y["termsdef"]
55
- @termsdefsymbols_lbl = y["termsdefsymbols"]
56
- @normref_lbl = y["normref"]
57
- @bibliography_lbl = y["bibliography"]
58
- @clause_lbl = y["clause"]
59
- @annex_lbl = y["annex"]
60
- @appendix_lbl = y["appendix"]
61
- @no_terms_boilerplate = y["no_terms_boilerplate"]
62
- @internal_terms_boilerplate = y["internal_terms_boilerplate"]
63
- @norm_with_refs_pref = y["norm_with_refs_pref"]
64
- @norm_empty_pref = y["norm_empty_pref"]
65
- @external_terms_boilerplate = y["external_terms_boilerplate"]
66
- @internal_external_terms_boilerplate =
67
- y["internal_external_terms_boilerplate"]
68
- @note_lbl = y["note"]
69
- @note_xref_lbl = y["note_xref"]
70
- @termnote_lbl = y["termnote"]
71
- @figure_lbl = y["figure"]
72
- @list_lbl = y["list"]
73
- @formula_lbl = y["formula"]
74
- @inequality_lbl = y["inequality"]
75
- @table_lbl = y["table"]
76
- @key_lbl = y["key"]
77
- @example_lbl = y["example"]
78
- @example_xref_lbl = y["example_xref"]
79
- @where_lbl = y["where"]
80
- @wholeoftext_lbl = y["wholeoftext"]
81
- @draft_lbl = y["draft_label"]
82
- @inform_annex_lbl = y["inform_annex"]
83
- @norm_annex_lbl = y["norm_annex"]
84
- @modified_lbl = y["modified"]
85
- @deprecated_lbl = y["deprecated"]
86
- @source_lbl = y["source"]
87
- @and_lbl = y["and"]
88
- @all_parts_lbl = y["all_parts"]
89
- @permission_lbl = y["permission"]
90
- @recommendation_lbl = y["recommendation"]
91
- @requirement_lbl = y["requirement"]
92
- @locality = y["locality"]
93
- @admonition = y["admonition"]
94
- =end
95
45
  end
96
46
 
97
47
  def self.l10n(x, lang = @lang, script = @script)
@@ -116,6 +66,14 @@ module IsoDoc
116
66
  end
117
67
  end
118
68
 
69
+ def multiple_and(names, andword)
70
+ return '' if names.empty?
71
+ return names[0] if names.length == 1
72
+ (names.length == 2) &&
73
+ (return l10n("#{names[0]} #{andword} #{names[1]}", @lang, @script))
74
+ l10n(names[0..-2].join(', ') + " #{andword} #{names[-1]}", @lang, @script)
75
+ end
76
+
119
77
  #module_function :l10n
120
78
 
121
79
  end
@@ -4,11 +4,6 @@ require_relative './metadata_date'
4
4
 
5
5
  module IsoDoc
6
6
  class Metadata
7
- DATETYPES = %w{published accessed created implemented obsoleted confirmed
8
- updated issued received transmitted copied unchanged
9
- circulated vote-started
10
- vote-ended}.freeze
11
-
12
7
  attr_accessor :fonts_options
13
8
 
14
9
  def ns(xpath)
@@ -98,8 +93,9 @@ module IsoDoc
98
93
 
99
94
  def doctype(isoxml, _out)
100
95
  b = isoxml&.at(ns('//bibdata/ext/doctype'))&.text || return
101
- t = b.split(/[- ]/).map(&:capitalize).join(' ')
102
- set(:doctype, t)
96
+ set(:doctype, status_print(b))
97
+ b = isoxml&.at(ns('//local_bibdata/ext/doctype'))&.text || return
98
+ set(:doctype_display, status_print(b))
103
99
  end
104
100
 
105
101
  def iso?(org)
@@ -109,7 +105,7 @@ module IsoDoc
109
105
  name == 'International Organization for Standardization')
110
106
  end
111
107
 
112
- def agency(xml)
108
+ def agency1(xml)
113
109
  agency = ''
114
110
  publisher = []
115
111
  xml.xpath(ns("//bibdata/contributor[xmlns:role/@type = 'publisher']/"\
@@ -119,36 +115,48 @@ module IsoDoc
119
115
  publisher << name if name
120
116
  agency = iso?(org) ? "ISO/#{agency}" : "#{agency}#{agency1}/"
121
117
  end
118
+ [agency, publisher]
119
+ end
120
+
121
+ def agency(xml)
122
+ agency, publisher = agency1(xml)
122
123
  set(:agency, agency.sub(%r{/$}, ''))
123
- set(:publisher, multiple_and(publisher, @labels['and']))
124
+ set(:publisher, @i18n.multiple_and(publisher, @labels['and']))
125
+ agency_addr(xml)
124
126
  end
125
127
 
126
- def multiple_and(names, andword)
127
- return '' if names.empty?
128
- return names[0] if names.length == 1
129
- (names.length == 2) &&
130
- (return l10n("#{names[0]} #{andword} #{names[1]}", @lang, @script))
131
- l10n(names[0..-2].join(', ') + " #{andword} #{names[-1]}", @lang, @script)
128
+ def agency_addr(xml)
129
+ a = xml.at(ns("//bibdata/contributor[xmlns:role/@type = 'publisher'][1]/"\
130
+ "organization")) or return
131
+ n = a.at(ns("./subdivision")) and set(:subdivision, n.text)
132
+ n = a.at(ns("./address/formattedAddress")) and
133
+ set(:pub_address, n.children.to_xml)
134
+ n = a.at(ns("./phone[not(@type = 'fax')]")) and set(:pub_phone, n.text)
135
+ n = a.at(ns("./phone[@type = 'fax']")) and set(:pub_fax, n.text)
136
+ n = a.at(ns("./email")) and set(:pub_email, n.text)
137
+ n = a.at(ns("./uri")) and set(:pub_uri, n.text)
132
138
  end
133
139
 
134
140
  def docstatus(isoxml, _out)
135
- docstatus = isoxml.at(ns('//bibdata/status/stage'))
136
141
  set(:unpublished, true)
137
- if docstatus
138
- set(:stage, status_print(docstatus.text))
139
- (i = isoxml&.at(ns('//bibdata/status/substage'))&.text) &&
140
- set(:substage, i)
141
- (i = isoxml&.at(ns('//bibdata/status/iteration'))&.text) &&
142
- set(:iteration, i)
143
- set(:unpublished, unpublished(docstatus.text))
144
- unpublished(docstatus.text) &&
145
- set(:stageabbr, stage_abbr(docstatus.text))
146
- end
142
+ return unless docstatus = isoxml.at(ns('//bibdata/status/stage'))
143
+ docstatus_local = isoxml.at(ns('//local_bibdata/status/stage'))
144
+ set(:stage, status_print(docstatus.text))
145
+ docstatus_local and
146
+ set(:stage_display, status_print(docstatus_local.text))
147
+ (i = isoxml&.at(ns('//bibdata/status/substage'))&.text) &&
148
+ set(:substage, i)
149
+ (i = isoxml&.at(ns('//local_bibdata/status/substage'))&.text) &&
150
+ set(:substage_display, i)
151
+ (i = isoxml&.at(ns('//bibdata/status/iteration'))&.text) &&
152
+ set(:iteration, i)
153
+ set(:unpublished, unpublished(docstatus.text))
154
+ unpublished(docstatus.text) &&
155
+ set(:stageabbr, stage_abbr(docstatus.text))
147
156
  end
148
157
 
149
158
  def stage_abbr(docstatus)
150
- status_print(docstatus).split(/ /)
151
- .map { |s| s[0].upcase }.join('')
159
+ status_print(docstatus).split(/ /).map { |s| s[0].upcase }.join('')
152
160
  end
153
161
 
154
162
  def unpublished(status)
@@ -156,7 +164,7 @@ module IsoDoc
156
164
  end
157
165
 
158
166
  def status_print(status)
159
- status.split(/-/).map(&:capitalize).join(' ')
167
+ status.split(/[- ]/).map(&:capitalize).join(' ')
160
168
  end
161
169
 
162
170
  def docid(isoxml, _out)
@@ -170,12 +178,10 @@ module IsoDoc
170
178
  end
171
179
 
172
180
  def draftinfo(draft, revdate)
173
- draftinfo = ''
174
- if draft
175
- draftinfo = " (#{@labels['draft_label']} #{draft}"
176
- draftinfo += ", #{revdate}" if revdate
177
- draftinfo += ')'
178
- end
181
+ return "" unless draft
182
+ draftinfo = " (#{@labels['draft_label']} #{draft}"
183
+ draftinfo += ", #{revdate}" if revdate
184
+ draftinfo += ')'
179
185
  l10n(draftinfo, @lang, @script)
180
186
  end
181
187
 
@@ -231,5 +237,13 @@ module IsoDoc
231
237
  isoxml.xpath(ns('//bibdata/keyword')).each { |kw| ret << kw.text }
232
238
  set(:keywords, ret)
233
239
  end
240
+
241
+ def note(isoxml, _out)
242
+ ret = []
243
+ isoxml.xpath(ns("//bibdata/note[@type = 'title-footnote']")).each do |n|
244
+ ret << n.text
245
+ end
246
+ set(:title_footnote, ret)
247
+ end
234
248
  end
235
249
  end
@@ -1,5 +1,10 @@
1
1
  module IsoDoc
2
2
  class Metadata
3
+ DATETYPES = %w{published accessed created implemented obsoleted confirmed
4
+ updated issued received transmitted copied unchanged
5
+ circulated vote-started
6
+ vote-ended}.freeze
7
+
3
8
  def months
4
9
  {
5
10
  "01": @labels["month_january"],
@@ -0,0 +1,24 @@
1
+ module IsoDoc
2
+ class PresentationXMLConvert < ::IsoDoc::Convert
3
+ def bibdata(docxml)
4
+ a = docxml.at(ns("//bibdata")) or return
5
+ b = a.dup
6
+ b.name = "local_bibdata"
7
+ bibdata_i18n(b)
8
+ a.next = b
9
+ end
10
+
11
+ def bibdata_i18n(b)
12
+ hash_translate(b, @i18n.get["doctype_dict"], "./ext/doctype")
13
+ hash_translate(b, @i18n.get["stage_dict"], "./status/stage")
14
+ hash_translate(b, @i18n.get["substage_dict"], "./status/substage")
15
+ end
16
+
17
+ def hash_translate(bibdata, hash, xpath)
18
+ hash.is_a? Hash or return
19
+ x = bibdata.at(ns(xpath)) or return
20
+ hash[x.text] or return
21
+ x.children = hash[x.text]
22
+ end
23
+ end
24
+ end