asciidoctor-gb 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +7 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +18 -14
- data/asciidoctor-gb.gemspec +1 -0
- data/lib/asciidoctor-gb.rb +1 -0
- data/lib/asciidoctor/gb/biblio.rng +19 -3
- data/lib/asciidoctor/gb/converter.rb +3 -2
- data/lib/asciidoctor/gb/gbstandard.rng +10 -3
- data/lib/asciidoctor/gb/isodoc.rng +1 -1
- data/lib/asciidoctor/gb/isostandard.rng +63 -14
- data/lib/asciidoctor/gb/section_input.rb +2 -0
- data/lib/asciidoctor/gb/validate.rb +1 -1
- data/lib/asciidoctor/gb/version.rb +1 -1
- data/lib/isodoc/gb/agencies.rb +16 -8
- data/lib/isodoc/gb/gbcleanup.rb +6 -3
- data/lib/isodoc/gb/gbconvert.rb +22 -112
- data/lib/isodoc/gb/gbhtmlconvert.rb +73 -0
- data/lib/isodoc/gb/gbhtmlrender.rb +206 -0
- data/lib/isodoc/gb/gbwordconvert.rb +69 -6
- data/lib/isodoc/gb/gbwordrender.rb +206 -0
- data/lib/isodoc/gb/html/htmlstyle.scss +1 -1
- data/lib/isodoc/gb/metadata.rb +57 -56
- metadata +21 -7
- data/lib/isodoc/gb/block_output.rb +0 -86
- data/lib/isodoc/gb/i18n.rb +0 -20
- data/lib/isodoc/gb/section_output.rb +0 -57
- data/lib/isodoc/gb/xref_gen.rb +0 -17
@@ -1,18 +1,43 @@
|
|
1
1
|
require "isodoc"
|
2
|
-
require_relative "
|
2
|
+
require_relative "gbconvert"
|
3
|
+
require_relative "gbcleanup"
|
4
|
+
require_relative "agencies"
|
5
|
+
require_relative "metadata"
|
6
|
+
require_relative "gbwordrender"
|
3
7
|
|
4
8
|
module IsoDoc
|
5
9
|
module Gb
|
6
10
|
# A {Converter} implementation that generates GB output, and a document
|
7
11
|
# schema encapsulation of the document for validation
|
8
12
|
|
9
|
-
class WordConvert < IsoDoc::
|
10
|
-
|
13
|
+
class WordConvert < IsoDoc::WordConvert
|
14
|
+
def default_fonts(options)
|
15
|
+
script = options[:script] || "Hans"
|
16
|
+
b = options[:bodyfont] ||
|
17
|
+
(script == "Hans" ? '"SimSun",serif' :
|
18
|
+
script == "Latn" ? '"Cambria",serif' : '"SimSun",serif' )
|
19
|
+
h = options[:headerfont] ||
|
20
|
+
(script == "Hans" ? '"SimHei",sans-serif' :
|
21
|
+
script == "Latn" ? '"Calibri",sans-serif' : '"SimHei",sans-serif' )
|
22
|
+
m = options[:monospacefont] || '"Courier New",monospace'
|
23
|
+
scope = options[:scope] || "national"
|
24
|
+
t = options[:titlefont] ||
|
25
|
+
(scope == "national" ? (script != "Hans" ? '"Cambria",serif' : '"SimSun",serif' ) :
|
26
|
+
(script == "Hans" ? '"SimHei",sans-serif' : '"Calibri",sans-serif' ))
|
27
|
+
"$bodyfont: #{b};\n$headerfont: #{h};\n$monospacefont: #{m};\n$titlefont: #{t};\n"
|
28
|
+
end
|
29
|
+
|
30
|
+
def metadata_init(lang, script, labels)
|
31
|
+
@meta = Metadata.new(lang, script, labels)
|
32
|
+
@common = IsoDoc::Gb::Common.new(meta: @meta)
|
33
|
+
end
|
34
|
+
|
11
35
|
def html_doc_path(file)
|
12
36
|
File.join(File.dirname(__FILE__), File.join("html", file))
|
13
37
|
end
|
14
38
|
|
15
39
|
def initialize(options)
|
40
|
+
@common = IsoDoc::Gb::Common.new(options)
|
16
41
|
super
|
17
42
|
@wordstylesheet = generate_css(html_doc_path("wordstyle.scss"), false, default_fonts(options))
|
18
43
|
@standardstylesheet = generate_css(html_doc_path("gb.scss"), false, default_fonts(options))
|
@@ -23,6 +48,40 @@ module IsoDoc
|
|
23
48
|
@olstyle = "l10"
|
24
49
|
end
|
25
50
|
|
51
|
+
def metadata_init(lang, script, labels)
|
52
|
+
@meta = Metadata.new(lang, script, labels)
|
53
|
+
@common = IsoDoc::Gb::Common.new(meta: @meta)
|
54
|
+
end
|
55
|
+
|
56
|
+
def cleanup(docxml)
|
57
|
+
@cleanup = Cleanup.new(@script, @deprecated_lbl)
|
58
|
+
super
|
59
|
+
@cleanup.cleanup(docxml)
|
60
|
+
docxml
|
61
|
+
end
|
62
|
+
|
63
|
+
def example_cleanup(docxml)
|
64
|
+
super
|
65
|
+
@cleanup.example_cleanup(docxml)
|
66
|
+
end
|
67
|
+
|
68
|
+
def html_doc_path(file)
|
69
|
+
File.join(File.dirname(__FILE__), File.join("html", file))
|
70
|
+
end
|
71
|
+
|
72
|
+
def i18n_init(lang, script)
|
73
|
+
super
|
74
|
+
y = if lang == "en"
|
75
|
+
YAML.load_file(File.join(File.dirname(__FILE__), "i18n-en.yaml"))
|
76
|
+
elsif lang == "zh" && script == "Hans"
|
77
|
+
YAML.load_file(File.join(File.dirname(__FILE__),
|
78
|
+
"i18n-zh-Hans.yaml"))
|
79
|
+
else
|
80
|
+
YAML.load_file(File.join(File.dirname(__FILE__), "i18n-zh-Hans.yaml"))
|
81
|
+
end
|
82
|
+
@labels = @labels.merge(y)
|
83
|
+
end
|
84
|
+
|
26
85
|
ENDLINE = <<~END.freeze
|
27
86
|
<v:line id="_x0000_s1026"
|
28
87
|
alt="" style='position:absolute;left:0;text-align:left;z-index:251662848;
|
@@ -39,11 +98,11 @@ module IsoDoc
|
|
39
98
|
def generate_header(filename, dir)
|
40
99
|
return unless @header
|
41
100
|
template = Liquid::Template.parse(File.read(@header, encoding: "UTF-8"))
|
42
|
-
meta =
|
101
|
+
meta = @meta.get
|
43
102
|
meta[:filename] = filename
|
44
103
|
params = meta.map { |k, v| [k.to_s, v] }.to_h
|
45
104
|
File.open("header.html", "w") { |f| f.write(template.render(params)) }
|
46
|
-
system "cp #{fileloc(File.join('html', 'blank.png'))} blank.png"
|
105
|
+
system "cp #{@common.fileloc(File.join('html', 'blank.png'))} blank.png"
|
47
106
|
@files_to_delete << "blank.png"
|
48
107
|
@files_to_delete << "header.html"
|
49
108
|
end
|
@@ -64,7 +123,7 @@ module IsoDoc
|
|
64
123
|
def word_cleanup(docxml)
|
65
124
|
word_preface(docxml)
|
66
125
|
word_annex_cleanup(docxml)
|
67
|
-
title_cleanup(docxml.at('//div[@class="WordSection2"]'))
|
126
|
+
@cleanup.title_cleanup(docxml.at('//div[@class="WordSection2"]'))
|
68
127
|
docxml
|
69
128
|
end
|
70
129
|
|
@@ -84,6 +143,10 @@ module IsoDoc
|
|
84
143
|
liststyles: {ul: "l7", ol: "l10"})
|
85
144
|
end
|
86
145
|
=end
|
146
|
+
|
147
|
+
def html_doc_path(file)
|
148
|
+
File.join(File.dirname(__FILE__), File.join("html", file))
|
149
|
+
end
|
87
150
|
end
|
88
151
|
end
|
89
152
|
end
|
@@ -0,0 +1,206 @@
|
|
1
|
+
module IsoDoc
|
2
|
+
module Gb
|
3
|
+
# A {Converter} implementation that generates GB output, and a document
|
4
|
+
# schema encapsulation of the document for validation
|
5
|
+
class WordConvert < IsoDoc::WordConvert
|
6
|
+
def formula_parse(node, out)
|
7
|
+
out.div **attr_code(id: node["id"], class: "formula") do |div|
|
8
|
+
insert_tab(div, 1)
|
9
|
+
parse(node.at(ns("./stem")), out)
|
10
|
+
insert_tab(div, 1)
|
11
|
+
div << "(#{get_anchors[node['id']][:label]})"
|
12
|
+
end
|
13
|
+
formula_where(node.at(ns("./dl")), out)
|
14
|
+
end
|
15
|
+
|
16
|
+
def formula_where(dl, out)
|
17
|
+
return unless dl
|
18
|
+
out.p { |p| p << @where_lbl }
|
19
|
+
formula_dl_parse(dl, out)
|
20
|
+
end
|
21
|
+
|
22
|
+
def formula_dl_parse(node, out)
|
23
|
+
out.table **{ class: "dl" } do |v|
|
24
|
+
node.elements.each_slice(2) do |dt, dd|
|
25
|
+
v.tr do |tr|
|
26
|
+
tr.td **{ valign: "top", align: "left" } do |term|
|
27
|
+
dt_parse(dt, term)
|
28
|
+
end
|
29
|
+
tr.td(**{ valign: "top" }) { |td| td << "—" }
|
30
|
+
tr.td **{ valign: "top" } do |listitem|
|
31
|
+
dd.children.each { |n| parse(n, listitem) }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
EXAMPLE_TBL_ATTR =
|
39
|
+
{ valign: "top", class: "example_label",
|
40
|
+
style: "padding:2pt 2pt 2pt 2pt" }.freeze
|
41
|
+
|
42
|
+
def example_parse(node, out)
|
43
|
+
out.table **attr_code(id: node["id"], class: "example") do |t|
|
44
|
+
t.tr do |tr|
|
45
|
+
tr.td **EXAMPLE_TBL_ATTR do |td|
|
46
|
+
td << l10n(example_label(node) + ":")
|
47
|
+
end
|
48
|
+
tr.td **{ valign: "top", class: "example" } do |td|
|
49
|
+
node.children.each { |n| parse(n, td) }
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def note_parse(node, out)
|
56
|
+
@note = true
|
57
|
+
out.table **attr_code(id: node["id"], class: "Note") do |t|
|
58
|
+
t.tr do |tr|
|
59
|
+
tr.td **EXAMPLE_TBL_ATTR do |td|
|
60
|
+
td << l10n(note_label(node) + ":")
|
61
|
+
end
|
62
|
+
tr.td **{ valign: "top", class: "Note" } do |td|
|
63
|
+
node.children.each { |n| parse(n, td) }
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
@note = false
|
68
|
+
end
|
69
|
+
|
70
|
+
def termnote_parse(node, out)
|
71
|
+
@note = true
|
72
|
+
out.table **attr_code(id: node["id"], class: "Note") do |t|
|
73
|
+
t.tr do |tr|
|
74
|
+
tr.td **EXAMPLE_TBL_ATTR do |td|
|
75
|
+
td << l10n("#{get_anchors[node['id']][:label]}:")
|
76
|
+
end
|
77
|
+
tr.td **{ valign: "top", class: "Note" } do |td|
|
78
|
+
node.children.each { |n| parse(n, td) }
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
@note = false
|
83
|
+
end
|
84
|
+
|
85
|
+
def middle(isoxml, out)
|
86
|
+
super
|
87
|
+
end_line(isoxml, out)
|
88
|
+
end
|
89
|
+
|
90
|
+
def end_line(_isoxml, out)
|
91
|
+
out.hr **{ width: "25%" }
|
92
|
+
end
|
93
|
+
|
94
|
+
def error_parse(node, out)
|
95
|
+
# catch elements not defined in ISO
|
96
|
+
case node.name
|
97
|
+
when "string" then string_parse(node, out)
|
98
|
+
else
|
99
|
+
super
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def string_parse(node, out)
|
104
|
+
if node["script"] == "Hant"
|
105
|
+
out.span **{ class: "Hant" } do |s|
|
106
|
+
node.children.each { |c| parse(c, s) }
|
107
|
+
end
|
108
|
+
else
|
109
|
+
node.children.each { |c| parse(c, out) }
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
def deprecated_term_parse(node, out)
|
114
|
+
out.p **{ class: "DeprecatedTerms" } do |p|
|
115
|
+
p << l10n("#{@deprecated_lbl}: ")
|
116
|
+
node.children.each { |c| parse(c, p) }
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
def termref_render(x)
|
121
|
+
parts = x.split(%r{(\s*\[MODIFICATION\]|,)}m)
|
122
|
+
parts[1] = l10n(", #{@source_lbl}") if parts.size > 1 && parts[1] == ","
|
123
|
+
parts.map do |p|
|
124
|
+
/\s*\[MODIFICATION\]/.match?(p) ? l10n(", #{@modified_lbl} — ") : p
|
125
|
+
end.join.sub(/\A\s*/m, l10n("[")).sub(/\s*\z/m, l10n("]"))
|
126
|
+
end
|
127
|
+
|
128
|
+
def termref_resolve(docxml)
|
129
|
+
docxml.split(%r{(\[TERMREF\]|\[/TERMREF\])}).each_slice(4).
|
130
|
+
map do |a|
|
131
|
+
a.size < 3 ? a[0] : a[0] + termref_render(a[2])
|
132
|
+
end.join
|
133
|
+
end
|
134
|
+
|
135
|
+
def populate_template(docxml, format)
|
136
|
+
meta = @meta.get.merge(@labels)
|
137
|
+
logo = @common.format_logo(meta[:gbprefix], meta[:gbscope], format)
|
138
|
+
logofile = @meta.standard_logo(meta[:gbprefix])
|
139
|
+
@files_to_delete << logofile + ".gif" unless logofile.nil?
|
140
|
+
docxml = termref_resolve(docxml)
|
141
|
+
meta[:standard_agency_formatted] =
|
142
|
+
@common.format_agency(meta[:standard_agency], format)
|
143
|
+
meta[:standard_logo] = logo
|
144
|
+
template = Liquid::Template.parse(docxml)
|
145
|
+
template.render(meta.map { |k, v| [k.to_s, v] }.to_h)
|
146
|
+
end
|
147
|
+
|
148
|
+
def foreword(isoxml, out)
|
149
|
+
f = isoxml.at(ns("//foreword")) || return
|
150
|
+
page_break(out)
|
151
|
+
out.div do |s|
|
152
|
+
s.h1 **{ class: "ForewordTitle" } do |h1|
|
153
|
+
h1 << "#{@foreword_lbl} "
|
154
|
+
# insert_tab(h1, 1)
|
155
|
+
end
|
156
|
+
f.elements.each { |e| parse(e, s) unless e.name == "title" }
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
def clause_name(num, title, div, header_class)
|
161
|
+
header_class = {} if header_class.nil?
|
162
|
+
div.h1 **attr_code(header_class) do |h1|
|
163
|
+
if num
|
164
|
+
h1 << num
|
165
|
+
h1 << " "
|
166
|
+
end
|
167
|
+
h1 << title
|
168
|
+
end
|
169
|
+
div.parent.at(".//h1")
|
170
|
+
end
|
171
|
+
|
172
|
+
def clause_parse_title(node, div, c1, out)
|
173
|
+
if node["inline-header"] == "true"
|
174
|
+
inline_header_title(out, node, c1)
|
175
|
+
else
|
176
|
+
div.send "h#{get_anchors[node['id']][:level]}" do |h|
|
177
|
+
h << "#{get_anchors[node['id']][:label]}. "
|
178
|
+
c1.children.each { |c2| parse(c2, h) }
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
def annex_name(annex, name, div)
|
184
|
+
div.h1 **{ class: "Annex" } do |t|
|
185
|
+
t << "#{get_anchors[annex['id']][:label]}<br/><br/>"
|
186
|
+
t << name.text
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
def term_defs_boilerplate(div, source, term, preface)
|
191
|
+
(source.empty? && term.nil?) and div << @no_terms_boilerplate or
|
192
|
+
div << term_defs_boilerplate_cont(source, term)
|
193
|
+
div << @term_def_boilerplate unless preface
|
194
|
+
end
|
195
|
+
|
196
|
+
def reference_names(ref)
|
197
|
+
isopub = ref.at(ns(ISO_PUBLISHER_XPATH))
|
198
|
+
docid = ref.at(ns("./docidentifier"))
|
199
|
+
date = ref.at(ns("./date[@type = 'published']"))
|
200
|
+
reference = format_ref(docid.text, isopub, date)
|
201
|
+
@anchors[ref["id"]] = { xref: reference }
|
202
|
+
end
|
203
|
+
end
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
data/lib/isodoc/gb/metadata.rb
CHANGED
@@ -5,21 +5,21 @@ module IsoDoc
|
|
5
5
|
module Gb
|
6
6
|
# A {Converter} implementation that generates GB output, and a document
|
7
7
|
# schema encapsulation of the document for validation
|
8
|
-
class
|
9
|
-
def
|
8
|
+
class Metadata < IsoDoc::Metadata
|
9
|
+
def initialize(lang, script, labels)
|
10
10
|
super
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
11
|
+
set(:docmaintitlezh, "")
|
12
|
+
set(:docsubtitlezh, "XXXX")
|
13
|
+
set(:docparttitlezh, "")
|
14
|
+
set(:docmaintitleen, "")
|
15
|
+
set(:docsubtitleen, "XXXX")
|
16
|
+
set(:docparttitleen, "")
|
17
|
+
set(:gbequivalence, "")
|
18
|
+
set(:isostandard, nil)
|
19
|
+
set(:isostandardtitle, "")
|
20
|
+
set(:doctitle, "XXXX")
|
21
|
+
set(:obsoletes, nil)
|
22
|
+
set(:obsoletes_part, nil)
|
23
23
|
end
|
24
24
|
|
25
25
|
def title(isoxml, _out)
|
@@ -27,22 +27,22 @@ module IsoDoc
|
|
27
27
|
main = isoxml.at(ns("//title-main[@language='zh']"))
|
28
28
|
part = isoxml.at(ns("//title-part[@language='zh']"))
|
29
29
|
partnumber = isoxml.at(ns("//project-number/@part"))
|
30
|
-
intro.nil? ||
|
31
|
-
main.nil? ||
|
30
|
+
intro.nil? || set(:docmaintitlezh, intro.text + " ")
|
31
|
+
main.nil? || set(:docsubtitlezh, main.text)
|
32
32
|
partnum = partnumber ? "#{part_label(partnumber, 'zh')}:" : ""
|
33
|
-
part.nil? ||
|
33
|
+
part.nil? || set(:docparttitlezh,
|
34
34
|
" #{partnum}#{part.text}")
|
35
35
|
end
|
36
36
|
|
37
37
|
def set_doctitle
|
38
38
|
if @lang == "zh"
|
39
|
-
|
40
|
-
|
41
|
-
|
39
|
+
set(:doctitle, get[:docmaintitlezh] +
|
40
|
+
get[:docsubtitlezh] +
|
41
|
+
get[:docparttitlezh])
|
42
42
|
else
|
43
|
-
|
44
|
-
|
45
|
-
|
43
|
+
set(:doctitle, get[:docmaintitleen] +
|
44
|
+
get[:docsubtitleen] +
|
45
|
+
get[:docparttitleen])
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
@@ -51,17 +51,17 @@ module IsoDoc
|
|
51
51
|
main = isoxml.at(ns("//title-main[@language='en']"))
|
52
52
|
part = isoxml.at(ns("//title-part[@language='en']"))
|
53
53
|
partnumber = isoxml.at(ns("//project-number/@part"))
|
54
|
-
intro.nil? ||
|
55
|
-
main.nil? ||
|
54
|
+
intro.nil? || set(:docmaintitleen, intro.text + "—")
|
55
|
+
main.nil? || set(:docsubtitleen, main.text)
|
56
56
|
partnum = partnumber ? "#{part_label(partnumber, 'en')}: " : ""
|
57
|
-
part.nil? ||
|
57
|
+
part.nil? || set(:docparttitleen,
|
58
58
|
"—#{partnum} #{part.text}")
|
59
59
|
set_doctitle
|
60
60
|
end
|
61
61
|
|
62
62
|
def author(isoxml, _out)
|
63
63
|
gbcommittee = isoxml.at(ns("//bibdata/gbcommittee"))
|
64
|
-
|
64
|
+
set(:committee, gbcommittee&.text)
|
65
65
|
end
|
66
66
|
|
67
67
|
STAGE_ABBRS_CN = {
|
@@ -87,22 +87,22 @@ module IsoDoc
|
|
87
87
|
def docstatus(isoxml, _out)
|
88
88
|
docstatus = isoxml.at(ns("//status/stage"))
|
89
89
|
if docstatus
|
90
|
-
|
90
|
+
set(:stage, docstatus.text.to_i)
|
91
91
|
abbr = stage_abbrev_cn(docstatus.text, isoxml.at(ns("//status/iteration")),
|
92
92
|
isoxml.at(ns("//version/draft")))
|
93
|
-
|
93
|
+
set(:stageabbr, abbr)
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
97
97
|
def docid1(isoxml, _out)
|
98
98
|
dn = docnumber(isoxml)
|
99
|
-
docstatus =
|
99
|
+
docstatus = get[:stage]
|
100
100
|
if docstatus
|
101
101
|
abbr = stage_abbrev(docstatus.to_s, isoxml.at(ns("//status/iteration")),
|
102
102
|
isoxml.at(ns("//version/draft")))
|
103
103
|
(docstatus.to_i < 60) && dn = abbr + " " + dn
|
104
104
|
end
|
105
|
-
|
105
|
+
set(:docnumber, dn)
|
106
106
|
end
|
107
107
|
|
108
108
|
def docid(isoxml, _out)
|
@@ -117,14 +117,14 @@ module IsoDoc
|
|
117
117
|
|
118
118
|
def gb_equivalence(isoxml)
|
119
119
|
isostdid = isoxml.at(ns("#{ISO_STD_XPATH}/docidentifier")) || return
|
120
|
-
|
120
|
+
set(:isostandard, isostdid.text)
|
121
121
|
isostdtitle = isoxml.at(ns("#{ISO_STD_XPATH}/title"))
|
122
|
-
|
122
|
+
set(:isostandardtitle, isostdtitle.text) if isostdtitle
|
123
123
|
eq = isoxml.at(ns("//bibdata/relation/@type"))
|
124
124
|
case eq.text
|
125
|
-
when "equivalent" then
|
126
|
-
when "nonequivalent" then
|
127
|
-
when "identical" then
|
125
|
+
when "equivalent" then set(:gbequivalence, "MOD")
|
126
|
+
when "nonequivalent" then set(:gbequivalence, "NEQ")
|
127
|
+
when "identical" then set(:gbequivalence, "IDT")
|
128
128
|
end
|
129
129
|
end
|
130
130
|
|
@@ -135,19 +135,19 @@ module IsoDoc
|
|
135
135
|
}.freeze
|
136
136
|
|
137
137
|
def docidentifier(scope, prefix, mandate, docyear)
|
138
|
-
docnum =
|
138
|
+
docnum = get[:docnumber]
|
139
139
|
dn = case scope
|
140
140
|
when "local"
|
141
|
-
"#{SCOPEPFX[scope.to_sym]}#{mandate_suffix(prefix, mandate)}/"\
|
141
|
+
"#{SCOPEPFX[scope.to_sym]}#{@agencies.mandate_suffix(prefix, mandate)}/"\
|
142
142
|
"#{docnum}".gsub(%r{/([TZ])/}, "/\\1 ")
|
143
143
|
when "social-group", "enterprise"
|
144
|
-
"#{mandate_suffix(SCOPEPFX[scope.to_sym], mandate)}/"\
|
144
|
+
"#{@agencies.mandate_suffix(SCOPEPFX[scope.to_sym], mandate)}/"\
|
145
145
|
"#{prefix} #{docnum}"
|
146
146
|
else
|
147
|
-
"#{mandate_suffix(prefix, mandate)} #{docnum}"
|
147
|
+
"#{@agencies.mandate_suffix(prefix, mandate)} #{docnum}"
|
148
148
|
end
|
149
149
|
dn += "—#{docyear}" if docyear
|
150
|
-
|
150
|
+
set(:docidentifier, dn)
|
151
151
|
end
|
152
152
|
|
153
153
|
def gb_identifier(isoxml)
|
@@ -155,14 +155,15 @@ module IsoDoc
|
|
155
155
|
mandate = isoxml.at(ns("//gbmandate"))&.text || "mandatory"
|
156
156
|
prefix = isoxml.at(ns("//gbprefix"))&.text || "XXX"
|
157
157
|
docyear = isoxml&.at(ns("//copyright/from"))&.text
|
158
|
-
docidentifier(scope, prefix, mandate, docyear)
|
159
158
|
issuer = isoxml&.at(ns("//bibdata/contributor[role/@type = 'issuer']/"\
|
160
159
|
"organization/name"))&.text || "GB"
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
160
|
+
@agencies = Agencies.new(@lang, @labels, issuer)
|
161
|
+
docidentifier(scope, prefix, mandate, docyear)
|
162
|
+
set(:issuer, issuer)
|
163
|
+
set(:standard_class, @agencies.standard_class(scope, prefix, mandate))
|
164
|
+
set(:standard_agency, @agencies.standard_agency(scope, prefix, mandate))
|
165
|
+
set(:gbprefix, scope == "local" ? "DB" : prefix)
|
166
|
+
set(:gbscope, scope)
|
166
167
|
end
|
167
168
|
|
168
169
|
def standard_logo(gbprefix)
|
@@ -180,12 +181,12 @@ module IsoDoc
|
|
180
181
|
def gb_library_identifier(isoxml)
|
181
182
|
ics = []
|
182
183
|
ccs = []
|
183
|
-
isoxml.xpath(ns("//bibdata/ics")).each { |i| ics << i.text }
|
184
|
+
isoxml.xpath(ns("//bibdata/ics/code")).each { |i| ics << i.text }
|
184
185
|
isoxml.xpath(ns("//bibdata/ccs")).each { |i| ccs << i.text }
|
185
186
|
p = isoxml.at(ns("//bibdata/plannumber"))
|
186
|
-
|
187
|
-
|
188
|
-
|
187
|
+
set(:libraryid_ics, ics.empty? ? "XXX" : ics.join(", "))
|
188
|
+
set(:libraryid_ccs, ccs.empty? ? "XXX" : ccs.join(", "))
|
189
|
+
set(:libraryid_plan, p ? p.text : "XXX")
|
189
190
|
end
|
190
191
|
|
191
192
|
def part_label(partnumber, lang)
|
@@ -197,16 +198,16 @@ module IsoDoc
|
|
197
198
|
|
198
199
|
def bibdate(isoxml, _out)
|
199
200
|
super
|
200
|
-
m =
|
201
|
+
m = get
|
201
202
|
if @lang == "zh"
|
202
|
-
|
203
|
+
set(:labelled_publisheddate, m[:publisheddate] + " " +
|
203
204
|
@labels["publicationdate_lbl"])
|
204
|
-
|
205
|
+
set(:labelled_implementeddate, m[:implementeddate] + " " +
|
205
206
|
@labels["implementationdate_lbl"])
|
206
207
|
else
|
207
|
-
|
208
|
+
set(:labelled_publisheddate, @labels["publicationdate_lbl"] +
|
208
209
|
": " + m[:publisheddate])
|
209
|
-
|
210
|
+
set(:labelled_implementeddate,
|
210
211
|
@labels["implementationdate_lbl"] + ": " +
|
211
212
|
m[:implementeddate])
|
212
213
|
end
|