metanorma-jis 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8bcd50e7099ae02c6427bbca496f824f9429ba102e0d3b8df1bdb2f2fd6cb9a2
4
- data.tar.gz: 760abf62f4c69e4f73f8fa9e2bfc696e431b6fc4859b79f103e4595d6883bb3e
3
+ metadata.gz: 6bbc9bfd3ed93ebd4eb27838a31bae9b074c79c280f0eee5c476475de1239a9c
4
+ data.tar.gz: 3404f0677c547960ef888d5503ed89b942a21c33812bb3ae042c9ed7d09f5fdb
5
5
  SHA512:
6
- metadata.gz: d1128ad3d108ac316a8d4c324c69b2fa5328838b84a1ff4b59f7b01ab79464c7946839c151c1a0749c52bc4da406c5ab820f7be2aefb43a06c36464757ebf020
7
- data.tar.gz: c06c9323c1e2af9c1fe73c5b2e43c68dcb81efebb4004bc8c6f88959b2bfc43cc3989366c92242eab460873e137419e7efa83c6b5732f2a33ee71ea9f46f0168
6
+ metadata.gz: '0839e480d352f8971eda023631979408b4ac4f352b06673b17e5ee02f3280842c2e51a40b9cd1bb091494f54cc9cc4235453d8d8ee18458bad55f43fe9228ec3'
7
+ data.tar.gz: bcaf0551aa3d35711b213137019a580eb84ae83c4b13a409c76644fc2af6eb577e06d46acb65260a48699598537064a6354fb35072392137161405097bc22798
@@ -1,15 +1,15 @@
1
1
  module IsoDoc
2
2
  module JIS
3
3
  class I18n < IsoDoc::Iso::I18n
4
+ def load_file(fname)
5
+ f = File.join(File.dirname(__FILE__), fname)
6
+ File.exist?(f) ? YAML.load_file(f) : {}
7
+ end
8
+
4
9
  def load_yaml1(lang, script)
5
- y = if lang == "en"
6
- YAML.load_file(File.join(File.dirname(__FILE__), "i18n-en.yaml"))
7
- else
8
- YAML.load_file(File.join(File.dirname(__FILE__), "i18n-ja.yaml"))
9
- end
10
- super.deep_merge(y)
10
+ y = load_file("i18n-#{yaml_lang(lang, script)}.yaml")
11
+ y.empty? ? load_file("i18n-en.yaml").merge(super) : super.deep_merge(y)
11
12
  end
12
13
  end
13
14
  end
14
15
  end
15
-
@@ -205,7 +205,7 @@ module IsoDoc
205
205
  elem = s.children.first
206
206
  middle_title_hdr(elem)
207
207
  middle_title_main(elem, "zzSTDTitle1")
208
- middle_subtitle_main(elem)
208
+ middle_subtitle_main(elem, "zzSTDTitle2")
209
209
  # middle_title_amd(s.children.first)
210
210
  end
211
211
 
@@ -225,11 +225,8 @@ module IsoDoc
225
225
  def middle_title_main(out, style)
226
226
  t = @meta.get[:doctitlemain]
227
227
  (t && !t.empty?) or return
228
- ret = "<p class='#{style}'>#{@meta.get[:doctitleintro]}"
229
- ret += " &#x2014; " if @meta.get[:doctitleintro] && t
230
- ret += t
231
- ret += " &#x2014; " if t && @meta.get[:doctitlepart]
232
- ret += "</p>"
228
+ ret =
229
+ middle_title_para(style, :doctitleintro, :doctitlemain, :doctitlepart)
233
230
  if a = @meta.get[:doctitlepart]
234
231
  ret += "<p class='zzSTDTitle1'>"
235
232
  b = @meta.get[:doctitlepartlabel] and ret += "#{b}: "
@@ -238,14 +235,11 @@ module IsoDoc
238
235
  out.previous = ret
239
236
  end
240
237
 
241
- def middle_subtitle_main(out)
238
+ def middle_subtitle_main(out, style)
242
239
  t = @meta.get[:docsubtitlemain]
243
240
  (t && !t.empty?) or return
244
- ret = "<p class='zzSTDTitle2'>#{@meta.get[:docsubtitleintro]}"
245
- ret += " &#x2014; " if @meta.get[:docsubtitleintro] && t
246
- ret += @meta.get[:docsubtitlemain]
247
- ret += " &#x2014; " if t && @meta.get[:docsubtitlepart]
248
- ret += "</p>"
241
+ ret = middle_title_para(style, :docsubtitleintro, :docsubtitlemain,
242
+ :docsubtitlepart)
249
243
  if a = @meta.get[:docsubtitlepart]
250
244
  ret += "<p class='zzSTDTitle2'>"
251
245
  b = @meta.get[:docsubtitlepartlabel] and ret += "#{b}: "
@@ -254,6 +248,15 @@ module IsoDoc
254
248
  out.previous = ret
255
249
  end
256
250
 
251
+ def middle_title_para(style, intro, main, part)
252
+ ret = "<p class='#{style}'>#{@meta.get[intro]}"
253
+ ret += " &#x2014; " if @meta.get[intro] && @meta.get[main]
254
+ ret += @meta.get[main]
255
+ ret += " &#x2014; " if @meta.get[main] && @meta.get[part]
256
+ ret += "</p>"
257
+ ret
258
+ end
259
+
257
260
  include Init
258
261
  end
259
262
  end
@@ -59,11 +59,11 @@ module IsoDoc
59
59
  def back_clauses_anchor_names(xml)
60
60
  clause_order_back(xml).each do |a|
61
61
  xml.xpath(ns(a[:path])).each do |c|
62
- if c["commentary"] == "true"
63
- commentary_names(c)
64
- else
65
- preface_names(c)
62
+ if c["commentary"] == "true" then commentary_names(c)
63
+ else preface_names(c)
66
64
  end
65
+ x = Nokogiri::XML::NodeSet.new(c.document, [c])
66
+ sequential_asset_names(x, container: true)
67
67
  a[:multi] or break
68
68
  end
69
69
  end
@@ -374,6 +374,16 @@
374
374
  <ref name="image"/>
375
375
  </element>
376
376
  </define>
377
+ <define name="depiction">
378
+ <element name="depiction">
379
+ <optional>
380
+ <attribute name="scope"/>
381
+ </optional>
382
+ <zeroOrMore>
383
+ <ref name="image"/>
384
+ </zeroOrMore>
385
+ </element>
386
+ </define>
377
387
  <define name="NameWithVariants">
378
388
  <element name="primary">
379
389
  <ref name="LocalizedString"/>
@@ -760,6 +770,9 @@
760
770
  <optional>
761
771
  <ref name="validity"/>
762
772
  </optional>
773
+ <optional>
774
+ <ref name="depiction"/>
775
+ </optional>
763
776
  </define>
764
777
  <define name="ReducedBibliographicItem">
765
778
  <optional>
@@ -11,14 +11,6 @@ module Metanorma
11
11
  "JIS"
12
12
  end
13
13
 
14
- # # Like the ISO code, but multilingual
15
- # def metadata_author(node, xml)
16
- # metadata_contrib_sdo(node, xml, JIS_HASH,
17
- # { role: "author", sourcerole: "publisher" })
18
- # node.attr("doctype") == "expert-commentary" and
19
- # personal_author(node, xml)
20
- # end
21
-
22
14
  def metadata_author(node, xml)
23
15
  org_contributor(node, xml,
24
16
  { source: ["publisher", "pub"], role: "author",
@@ -27,19 +19,6 @@ module Metanorma
27
19
  personal_author(node, xml)
28
20
  end
29
21
 
30
- # def metadata_publisher(node, xml)
31
- # metadata_contrib_sdo(node, xml, JIS_HASH,
32
- # { role: "publisher", sourcerole: "publisher" })
33
- # metadata_contrib_sdo(node, xml, nil,
34
- # { role: "authorizer",
35
- # sourcerole: "investigative-organization",
36
- # desc: "Investigative organization" })
37
- # metadata_contrib_sdo(node, xml, nil,
38
- # { role: "authorizer",
39
- # sourcerole: "investigative-committee",
40
- # desc: "Investigative committee" })
41
- # end
42
-
43
22
  def metadata_publisher(node, xml)
44
23
  [{ source: ["publisher", "pub"], role: "publisher", default: JIS_HASH },
45
24
  { role: "authorizer",
@@ -57,60 +36,6 @@ module Metanorma
57
36
  JIS_HASH =
58
37
  { "ja" => "日本工業規格", "en" => "Japanese Industrial Standards" }.freeze
59
38
 
60
- # def metadata_contrib_sdo(node, xml, default_value, opt)
61
- # pub, default = metadata_contrib_extract(node, opt[:sourcerole], default_value)
62
- # metadata_contrib_sdo_build(node, xml, pub, default, opt)
63
- # end
64
- #
65
- # def metadata_contrib_sdo_build(node, xml, pub, default, opt)
66
- # pub&.each do |p|
67
- # xml.contributor do |c|
68
- # c.role type: opt[:role] do |r|
69
- # opt[:desc] and r.description opt[:desc]
70
- # end
71
- # c.organization do |a|
72
- # organization(a, p, opt[:role] == "publisher", node, default)
73
- # end
74
- # end
75
- # end
76
- # end
77
- #
78
- # def metadata_contrib_extract(node, role, default_value)
79
- # pub, default = multiling_docattr_csv(node, role, LANGS, default_value)
80
- # a = node.attr("#{role}-abbr") and abbr = a # one abbrev for all languages
81
- # [pub&.map { |p| { name: p, abbr: abbr } }, default]
82
- # end
83
- #
84
- # def multiling_docattr(node, attr, langs)
85
- # ret = node.attr(attr) and return ret
86
- # ret = langs.each_with_object({}).each do |l, m|
87
- # x = node.attr("#{attr}-#{l}") and m[l] = x
88
- # end.compact
89
- # ret.empty? and return nil
90
- # ret
91
- # end
92
- #
93
- # def multiling_docattr_csv(node, attr, langs, default)
94
- # ret = multiling_docattr(node, attr, langs)
95
- # not_found = ret.nil?
96
- # ret ||= default
97
- # ret &&= if ret.is_a?(Hash) then interleave_multiling_docattr(ret)
98
- # else csv_split(ret)
99
- # end
100
- # [ret, not_found]
101
- # end
102
- #
103
- # # TODO abort if CSV count different between different languages
104
- # def interleave_multiling_docattr(ret)
105
- # h = ret.transform_values { |v| csv_split(v) }
106
- # h.each_with_object([]) do |(k, v), m|
107
- # v.each_with_index do |v1, i|
108
- # m[i] ||= {}
109
- # m[i][k] = v1
110
- # end
111
- # end
112
- # end
113
-
114
39
  def org_organization(node, xml, org)
115
40
  organization(xml, { name: org[:name], abbr: org[:abbr] }.compact,
116
41
  node, !multiling_docattr(node, "publisher", "", LANGS))
@@ -120,9 +45,9 @@ module Metanorma
120
45
 
121
46
  def org_attrs_parse(node, opts)
122
47
  source = opts[:source]&.detect { |s| node.attr(s) }
123
- source ||= opts[:source]&.detect do |s|
124
- LANGS.detect { |l| node.attr("#{s}-#{l}") }
125
- end
48
+ source ||= opts[:source]&.detect do |s|
49
+ LANGS.detect { |l| node.attr("#{s}-#{l}") }
50
+ end
126
51
  org_attrs_simple_parse(node, opts, source) ||
127
52
  org_attrs_complex_parse(node, opts, source)
128
53
  end
@@ -140,6 +65,7 @@ module Metanorma
140
65
  end
141
66
 
142
67
  def multiling_docattr(node, attr, suffix, langs)
68
+ node.nil? and return nil
143
69
  ret = node.attr(attr + suffix) and return ret
144
70
  ret = langs.each_with_object({}).each do |l, m|
145
71
  x = node.attr("#{attr}-#{l}#{suffix}") and m[l] = x
@@ -189,28 +115,10 @@ module Metanorma
189
115
  multiling_noko_value(a, "subdivision", xml)
190
116
  abbr = org[:abbr]
191
117
  abbr ||= org_abbrev[name_str]
192
- default_org && b = node.attr("subdivision-abbr") and abbr = b
118
+ default_org && b = node&.attr("subdivision-abbr") and abbr = b
193
119
  abbr and xml.abbreviation abbr
194
120
  end
195
121
 
196
- # def metadata_copyright(node, xml)
197
- # pub, default = metadata_contrib_extract(node, "copyright-holder", nil)
198
- # if default
199
- # pub, default = metadata_contrib_extract(node, "publisher", JIS_HASH)
200
- # end
201
- #
202
- # pub&.each do |p|
203
- # xml.copyright do |c|
204
- # c.from (node.attr("copyright-year") || Date.today.year)
205
- # c.owner do |owner|
206
- # owner.organization do |o|
207
- # organization(o, p, true, node, default)
208
- # end
209
- # end
210
- # end
211
- # end
212
- # end
213
-
214
122
  def copyright_parse(node)
215
123
  opt = { source: ["copyright-holder", "publisher", "pub"],
216
124
  role: "publisher", default: JIS_HASH }
@@ -231,8 +139,6 @@ module Metanorma
231
139
  end
232
140
 
233
141
  def metadata_id(node, xml)
234
- node.attr("docidentifier") || node.attr("docnumber") or
235
- @fatalerror << "No docnumber attribute supplied"
236
142
  if id = node.attr("docidentifier")
237
143
  xml.docidentifier id.sub(/^JIS /, ""), **attr_code(type: "JIS")
238
144
  else iso_id(node, xml)
@@ -249,21 +155,8 @@ module Metanorma
249
155
  end
250
156
  end
251
157
 
252
- def iso_id(node, xml)
253
- (!@amd && node.attr("docnumber")) || (@amd && node.attr("updates")) or
254
- return
255
- params = iso_id_params(node)
256
- iso_id_out(xml, params, true)
257
- end
258
-
259
- def iso_id_params(node)
260
- params = iso_id_params_core(node)
261
- params2 = iso_id_params_add(node)
262
- if node.attr("updates")
263
- orig_id = Pubid::Jis::Identifier::Base.parse(node.attr("updates"))
264
- orig_id.edition ||= 1
265
- end
266
- iso_id_params_resolve(params, params2, node, orig_id)
158
+ def base_pubid
159
+ Pubid::Jis::Identifier
267
160
  end
268
161
 
269
162
  def iso_id_params_core(node)
@@ -290,7 +183,7 @@ module Metanorma
290
183
  end
291
184
 
292
185
  def iso_id_default(params)
293
- Pubid::Jis::Identifier.create(**params)
186
+ base_pubid.create(**params)
294
187
  rescue StandardError => e
295
188
  clean_abort("Document identifier: #{e}", xml)
296
189
  end
@@ -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.8 -->
20
+ <!-- VERSION v1.2.9 -->
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">
@@ -1958,6 +1958,16 @@
1958
1958
  <data type="boolean"/>
1959
1959
  </attribute>
1960
1960
  </optional>
1961
+ <optional>
1962
+ <attribute name="type">
1963
+ <choice>
1964
+ <value>letter</value>
1965
+ <value>symbol</value>
1966
+ <value>formula</value>
1967
+ <value>equation</value>
1968
+ </choice>
1969
+ </attribute>
1970
+ </optional>
1961
1971
  <element name="name">
1962
1972
  <oneOrMore>
1963
1973
  <choice>
@@ -1,6 +1,6 @@
1
1
  module Metanorma
2
2
  module JIS
3
- VERSION = "0.1.4".freeze
3
+ VERSION = "0.1.5".freeze
4
4
  end
5
5
  end
6
6
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-jis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-27 00:00:00.000000000 Z
11
+ date: 2023-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: metanorma-iso