relaton-iso-bib 1.6.pre1 → 1.8.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -38,6 +38,9 @@
38
38
  </define>
39
39
  <define name="BibDataExtensionType">
40
40
  <ref name="doctype"/>
41
+ <optional>
42
+ <ref name="horizontal"/>
43
+ </optional>
41
44
  <ref name="editorialgroup"/>
42
45
  <zeroOrMore>
43
46
  <ref name="ics"/>
@@ -76,19 +79,6 @@
76
79
  </choice>
77
80
  </element>
78
81
  </define>
79
- <define name="ul">
80
- <element name="ul">
81
- <attribute name="id">
82
- <data type="ID"/>
83
- </attribute>
84
- <oneOrMore>
85
- <ref name="ul_li"/>
86
- </oneOrMore>
87
- <zeroOrMore>
88
- <ref name="note"/>
89
- </zeroOrMore>
90
- </element>
91
- </define>
92
82
  <define name="sections">
93
83
  <element name="sections">
94
84
  <zeroOrMore>
@@ -137,22 +127,28 @@
137
127
  </choice>
138
128
  </attribute>
139
129
  </optional>
130
+ <optional>
131
+ <attribute name="type"/>
132
+ </optional>
140
133
  <optional>
141
134
  <ref name="section-title"/>
142
135
  </optional>
143
- <choice>
144
- <group>
145
- <oneOrMore>
146
- <ref name="BasicBlock"/>
147
- </oneOrMore>
148
- <zeroOrMore>
149
- <ref name="note"/>
150
- </zeroOrMore>
151
- </group>
136
+ <group>
137
+ <choice>
138
+ <group>
139
+ <oneOrMore>
140
+ <ref name="BasicBlock"/>
141
+ </oneOrMore>
142
+ <zeroOrMore>
143
+ <ref name="note"/>
144
+ </zeroOrMore>
145
+ </group>
146
+ <ref name="amend"/>
147
+ </choice>
152
148
  <oneOrMore>
153
149
  <ref name="clause-subsection"/>
154
150
  </oneOrMore>
155
- </choice>
151
+ </group>
156
152
  </define>
157
153
  <define name="term">
158
154
  <element name="term">
@@ -183,17 +179,6 @@
183
179
  </zeroOrMore>
184
180
  </element>
185
181
  </define>
186
- <define name="definition">
187
- <element name="definition">
188
- <oneOrMore>
189
- <choice>
190
- <ref name="paragraph"/>
191
- <ref name="figure"/>
192
- <ref name="formula"/>
193
- </choice>
194
- </oneOrMore>
195
- </element>
196
- </define>
197
182
  <define name="annex">
198
183
  <element name="annex">
199
184
  <optional>
@@ -271,6 +256,7 @@
271
256
  <value>guide</value>
272
257
  <value>amendment</value>
273
258
  <value>technical-corrigendum</value>
259
+ <value>directive</value>
274
260
  </choice>
275
261
  </define>
276
262
  <define name="structuredidentifier">
@@ -324,6 +310,11 @@
324
310
  <optional>
325
311
  <attribute name="script"/>
326
312
  </optional>
313
+ <optional>
314
+ <attribute name="inline-header">
315
+ <data type="boolean"/>
316
+ </attribute>
317
+ </optional>
327
318
  <optional>
328
319
  <attribute name="obligation">
329
320
  <choice>
@@ -332,6 +323,12 @@
332
323
  </choice>
333
324
  </attribute>
334
325
  </optional>
326
+ <optional>
327
+ <attribute name="number"/>
328
+ </optional>
329
+ <optional>
330
+ <attribute name="type"/>
331
+ </optional>
335
332
  <optional>
336
333
  <ref name="section-title"/>
337
334
  </optional>
@@ -349,54 +346,6 @@
349
346
  </oneOrMore>
350
347
  </choice>
351
348
  </define>
352
- <define name="table">
353
- <element name="table">
354
- <attribute name="id">
355
- <data type="ID"/>
356
- </attribute>
357
- <optional>
358
- <attribute name="width"/>
359
- </optional>
360
- <optional>
361
- <attribute name="unnumbered">
362
- <data type="boolean"/>
363
- </attribute>
364
- </optional>
365
- <optional>
366
- <attribute name="number"/>
367
- </optional>
368
- <optional>
369
- <attribute name="subsequence"/>
370
- </optional>
371
- <optional>
372
- <attribute name="alt"/>
373
- </optional>
374
- <optional>
375
- <attribute name="summary"/>
376
- </optional>
377
- <optional>
378
- <attribute name="uri">
379
- <data type="anyURI"/>
380
- </attribute>
381
- </optional>
382
- <optional>
383
- <ref name="tname"/>
384
- </optional>
385
- <optional>
386
- <ref name="thead"/>
387
- </optional>
388
- <ref name="tbody"/>
389
- <optional>
390
- <ref name="tfoot"/>
391
- </optional>
392
- <zeroOrMore>
393
- <ref name="table-note"/>
394
- </zeroOrMore>
395
- <optional>
396
- <ref name="dl"/>
397
- </optional>
398
- </element>
399
- </define>
400
349
  </include>
401
350
  <!-- end overrides -->
402
351
  <!--
@@ -416,6 +365,9 @@
416
365
  <zeroOrMore>
417
366
  <ref name="termdocsource"/>
418
367
  </zeroOrMore>
368
+ <optional>
369
+ <ref name="misccontainer"/>
370
+ </optional>
419
371
  <optional>
420
372
  <ref name="boilerplate"/>
421
373
  </optional>
@@ -427,6 +379,14 @@
427
379
  <ref name="annex"/>
428
380
  </zeroOrMore>
429
381
  <ref name="bibliography"/>
382
+ <zeroOrMore>
383
+ <ref name="indexsect"/>
384
+ </zeroOrMore>
385
+ </element>
386
+ </define>
387
+ <define name="horizontal">
388
+ <element name="horizontal">
389
+ <data type="boolean"/>
430
390
  </element>
431
391
  </define>
432
392
  <define name="documentnumber">
@@ -510,28 +470,6 @@
510
470
  <ref name="Clause-Section"/>
511
471
  </element>
512
472
  </define>
513
- <define name="ul_li">
514
- <element name="li">
515
- <optional>
516
- <attribute name="id">
517
- <data type="ID"/>
518
- </attribute>
519
- </optional>
520
- <optional>
521
- <attribute name="uncheckedcheckbox">
522
- <data type="boolean"/>
523
- </attribute>
524
- </optional>
525
- <optional>
526
- <attribute name="checkedcheckbox">
527
- <data type="boolean"/>
528
- </attribute>
529
- </optional>
530
- <oneOrMore>
531
- <ref name="BasicBlock"/>
532
- </oneOrMore>
533
- </element>
534
- </define>
535
473
  <define name="stagename">
536
474
  <element name="stagename">
537
475
  <text/>
data/grammars/reqt.rng CHANGED
@@ -30,15 +30,34 @@
30
30
  <data type="boolean"/>
31
31
  </attribute>
32
32
  </optional>
33
+ <optional>
34
+ <attribute name="number"/>
35
+ </optional>
33
36
  <optional>
34
37
  <attribute name="subsequence"/>
35
38
  </optional>
39
+ <optional>
40
+ <attribute name="keep-with-next">
41
+ <data type="boolean"/>
42
+ </attribute>
43
+ </optional>
44
+ <optional>
45
+ <attribute name="keep-lines-together">
46
+ <data type="boolean"/>
47
+ </attribute>
48
+ </optional>
36
49
  <attribute name="id">
37
50
  <data type="ID"/>
38
51
  </attribute>
39
52
  <optional>
40
53
  <attribute name="filename"/>
41
54
  </optional>
55
+ <optional>
56
+ <attribute name="model"/>
57
+ </optional>
58
+ <optional>
59
+ <attribute name="type"/>
60
+ </optional>
42
61
  <optional>
43
62
  <ref name="reqtitle"/>
44
63
  </optional>
@@ -48,9 +67,9 @@
48
67
  <optional>
49
68
  <ref name="subject"/>
50
69
  </optional>
51
- <optional>
70
+ <zeroOrMore>
52
71
  <ref name="reqinherit"/>
53
- </optional>
72
+ </zeroOrMore>
54
73
  <zeroOrMore>
55
74
  <ref name="classification"/>
56
75
  </zeroOrMore>
@@ -135,6 +154,16 @@
135
154
  <data type="boolean"/>
136
155
  </attribute>
137
156
  </optional>
157
+ <optional>
158
+ <attribute name="keep-with-next">
159
+ <data type="boolean"/>
160
+ </attribute>
161
+ </optional>
162
+ <optional>
163
+ <attribute name="keep-lines-together">
164
+ <data type="boolean"/>
165
+ </attribute>
166
+ </optional>
138
167
  <oneOrMore>
139
168
  <ref name="BasicBlock"/>
140
169
  </oneOrMore>
@@ -10,7 +10,7 @@ module RelatonIsoBib
10
10
  def self.grammar_hash
11
11
  gem_path = File.expand_path "..", __dir__
12
12
  grammars_path = File.join gem_path, "grammars", "*"
13
- grammars = Dir[grammars_path].sort.map { |gp| File.read gp }.join
13
+ grammars = Dir[grammars_path].sort.map { |gp| File.read gp, encoding: "UTF-8" }.join
14
14
  Digest::MD5.hexdigest grammars
15
15
  end
16
16
  end
@@ -35,13 +35,13 @@ module RelatonIsoBib
35
35
  # @param secretariat [String, NilClass]
36
36
  def initialize(technical_committee:, **args) # rubocop:disable Metrics/CyclomaticComplexity,Metrics/AbcSize
37
37
  @technical_committee = technical_committee.map do |tc|
38
- tc.is_a?(Hash) ? IsoSubgroup.new(tc) : tc
38
+ tc.is_a?(Hash) ? IsoSubgroup.new(**tc) : tc
39
39
  end
40
40
  @subcommittee = args.fetch(:subcommittee, []).map do |sc|
41
- sc.is_a?(Hash) ? IsoSubgroup.new(sc) : sc
41
+ sc.is_a?(Hash) ? IsoSubgroup.new(**sc) : sc
42
42
  end
43
43
  @workgroup = args.fetch(:workgroup, []).map do |wg|
44
- wg.is_a?(Hash) ? IsoSubgroup.new(wg) : wg
44
+ wg.is_a?(Hash) ? IsoSubgroup.new(**wg) : wg
45
45
  end
46
46
  @secretariat = args[:secretariat]
47
47
  end
@@ -9,7 +9,7 @@ module RelatonIsoBib
9
9
  # @param item [Hash]
10
10
  # @retirn [RelatonIsoBib::IsoBibliographicItem]
11
11
  def bib_item(item)
12
- IsoBibliographicItem.new(item)
12
+ IsoBibliographicItem.new(**item)
13
13
  end
14
14
 
15
15
  #
@@ -18,7 +18,7 @@ module RelatonIsoBib
18
18
  # @param title [Hash]
19
19
  # @return [RelatonBib::TypedTitleString]
20
20
  def typed_title_strig(title)
21
- RelatonBib::TypedTitleString.new title
21
+ RelatonBib::TypedTitleString.new **title
22
22
  end
23
23
 
24
24
  # @param ret [Hash]
@@ -45,9 +45,7 @@ module RelatonIsoBib
45
45
  def structuredidentifier_hash_to_bib(ret)
46
46
  return unless ret[:structuredidentifier]
47
47
 
48
- ret[:structuredidentifier] = RelatonIsoBib::StructuredIdentifier.new(
49
- ret[:structuredidentifier],
50
- )
48
+ ret[:structuredidentifier] = RelatonIsoBib::StructuredIdentifier.new(**ret[:structuredidentifier])
51
49
  end
52
50
  end
53
51
  end
@@ -27,6 +27,7 @@ module RelatonIsoBib
27
27
  def to_hash
28
28
  hash = {}
29
29
  hash["code"] = code if code
30
+ hash["text"] = description if description
30
31
  hash
31
32
  end
32
33
 
@@ -24,7 +24,7 @@ module RelatonIsoBib
24
24
  TYPES = %w[
25
25
  international-standard technical-specification technical-report
26
26
  publicly-available-specification international-workshop-agreement guide
27
- amendment technical-corrigendum
27
+ amendment technical-corrigendum directive
28
28
  ].freeze
29
29
 
30
30
  # @return [RelatonIsoBib::StructuredIdentifier]
@@ -36,6 +36,9 @@ module RelatonIsoBib
36
36
  # @return [String, NilClass]
37
37
  attr_reader :doctype, :stagename
38
38
 
39
+ # @return [Boolean, nil]
40
+ attr_reader :horizontal
41
+
39
42
  # @return [RelatonIsoBib::EditorialGroup]
40
43
  attr_reader :editorialgroup
41
44
 
@@ -62,6 +65,8 @@ module RelatonIsoBib
62
65
  # @param classification [RelatonBib::Classification, NilClass]
63
66
  # @param validity [RelatonBib:Validity, NilClass]
64
67
  # @param docid [Array<RelatonBib::DocumentIdentifier>]
68
+ # @param doctype [String, nil]
69
+ # @param horizontal [Boolean, nil]
65
70
  # @param structuredidentifier [RelatonIsoBib::StructuredIdentifier]
66
71
  # @param stagename [String, NilClass]
67
72
  #
@@ -131,20 +136,20 @@ module RelatonIsoBib
131
136
  copyright link fetched docid formattedref extent accesslocation
132
137
  classification validity doctype keyword].include? k
133
138
  end
134
- super super_args
139
+ super **super_args
135
140
 
136
141
  @type = args[:type] || "standard"
137
142
 
138
143
  if args[:editorialgroup]
139
144
  @editorialgroup = if args[:editorialgroup].is_a?(Hash)
140
- EditorialGroup.new(args[:editorialgroup])
145
+ EditorialGroup.new(**args[:editorialgroup])
141
146
  else args[:editorialgroup]
142
147
  end
143
148
  end
144
149
 
145
150
  @structuredidentifier = args[:structuredidentifier]
146
- # @doctype = args[:doctype] || "international-standard"
147
- @ics = args.fetch(:ics, []).map { |i| i.is_a?(Hash) ? Ics.new(i) : i }
151
+ @horizontal = args[:horizontal]
152
+ @ics = args.fetch(:ics, []).map { |i| i.is_a?(Hash) ? Ics.new(**i) : i }
148
153
  @stagename = args[:stagename]
149
154
  @id_attribute = true
150
155
  end
@@ -156,22 +161,22 @@ module RelatonIsoBib
156
161
  # @return [String] XML
157
162
  def to_xml(**opts)
158
163
  super **opts do |b|
159
- if opts[:bibdata] && (doctype || respond_to?(:committee) && committee ||
160
- editorialgroup || ics.any? || structuredidentifier || stagename ||
161
- block_given?)
164
+ if block_given? then yield b
165
+ elsif opts[:bibdata] && has_ext_attrs?
162
166
  b.ext do
163
167
  b.doctype doctype if doctype
164
- b.docsubtype docsubtype if respond_to?(:docsubtype) && docsubtype
168
+ b.horizontal horizontal unless horizontal.nil?
169
+ # b.docsubtype docsubtype if respond_to?(:docsubtype) && docsubtype
165
170
  # GB renders gbcommittee elements istead of an editorialgroup
166
- if respond_to? :committee
167
- committee&.to_xml b
168
- else
169
- editorialgroup&.to_xml b
170
- end
171
+ # if respond_to? :committee
172
+ # committee&.to_xml b
173
+ # else
174
+ editorialgroup&.to_xml b
175
+ # end
171
176
  ics.each { |i| i.to_xml b }
172
177
  structuredidentifier&.to_xml b
173
178
  b.stagename stagename if stagename
174
- yield b if block_given?
179
+ # yield b if block_given?
175
180
  end
176
181
  end
177
182
  end
@@ -183,6 +188,7 @@ module RelatonIsoBib
183
188
  # @return [Hash]
184
189
  def to_hash
185
190
  hash = super
191
+ hash["horizontal"] = horizontal unless horizontal.nil?
186
192
  hash["stagename"] = stagename if stagename
187
193
  hash
188
194
  end
@@ -190,7 +196,7 @@ module RelatonIsoBib
190
196
  # @param prefix [String]
191
197
  # @return [String]
192
198
  def to_asciibib(prefix = "")
193
- pref = prefix.empty? ? prefix : prefix + "."
199
+ pref = prefix.empty? ? prefix : "#{prefix}."
194
200
  out = super
195
201
  out += "#{pref}stagename:: #{stagename}\n" if stagename
196
202
  out
@@ -218,5 +224,13 @@ module RelatonIsoBib
218
224
  end
219
225
  idstr&.gsub(/:/, "-")&.gsub(/\s/, "")&.strip
220
226
  end
227
+
228
+ #
229
+ # @return [Boolean]
230
+ #
231
+ def has_ext_attrs? # rubocop:disable Metrics/CyclomaticComplexity
232
+ (doctype || !horizontal.nil? || editorialgroup || ics.any? ||
233
+ structuredidentifier || stagename || horizontal)
234
+ end
221
235
  end
222
236
  end