relaton-nist 1.10.0 → 1.11.0

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: 6904cbde4499524d13afe026233d523943a7be4bd90b099c9cbf13326fea209c
4
- data.tar.gz: 952f261685119de525a3427aae8611080e4ad9cbc27f9d5a3a643b3aadbed1b0
3
+ metadata.gz: 3efd113d39aa3ae5803492db6fedb79c6c77b8e6c346f545d7e56aedf5ccb90c
4
+ data.tar.gz: 15bbf418f6ea804ccfb295fd566029bebf6e197d0d5985d5ee63f19909ce3bdc
5
5
  SHA512:
6
- metadata.gz: cce2b8ebb750f482c4eb7e74856b447179756d3d8ddd1f6927657b424fb5480caec4cdacbc86c49e8e62213df3a14b7b4916eb153ffbaadbcf2bfe3197660e06
7
- data.tar.gz: 19d173f3010316364ac1712f2b30e54221c67bd137ca691f9837cf8975d93454464f7161ad6b7bee0e290966ac9ce8ebd834d1d0d2fe8861993b3cbad5b6f0d5
6
+ metadata.gz: 69b106a55f829e861510cd4cd71eda6c11e689f0b78742cafe8333d81a0e6fcba87d708825439d85eb88543ea6a223749565b6d99469c34cf2889f87e429a88e
7
+ data.tar.gz: 00fba574ac9177d32e8af0d9fc3d09947c13c2075a6bcdcf01d3525ee296e9b993f53033f6213dee59a8c33250606cb5034201697a1c1e022bfab2daa770ef2f
@@ -173,9 +173,11 @@
173
173
  <data type="dateTime"/>
174
174
  </attribute>
175
175
  </optional>
176
- <attribute name="from">
177
- <data type="IDREF"/>
178
- </attribute>
176
+ <optional>
177
+ <attribute name="from">
178
+ <data type="IDREF"/>
179
+ </attribute>
180
+ </optional>
179
181
  <optional>
180
182
  <attribute name="to">
181
183
  <data type="IDREF"/>
@@ -624,6 +626,9 @@
624
626
  <choice>
625
627
  <ref name="PureTextElement"/>
626
628
  <ref name="stem"/>
629
+ <ref name="eref"/>
630
+ <ref name="xref"/>
631
+ <ref name="hyperlink"/>
627
632
  </choice>
628
633
  </zeroOrMore>
629
634
  </element>
@@ -634,6 +639,9 @@
634
639
  <choice>
635
640
  <ref name="PureTextElement"/>
636
641
  <ref name="stem"/>
642
+ <ref name="eref"/>
643
+ <ref name="xref"/>
644
+ <ref name="hyperlink"/>
637
645
  </choice>
638
646
  </zeroOrMore>
639
647
  </element>
@@ -641,7 +649,12 @@
641
649
  <define name="tt">
642
650
  <element name="tt">
643
651
  <zeroOrMore>
644
- <ref name="PureTextElement"/>
652
+ <choice>
653
+ <ref name="PureTextElement"/>
654
+ <ref name="eref"/>
655
+ <ref name="xref"/>
656
+ <ref name="hyperlink"/>
657
+ </choice>
645
658
  </zeroOrMore>
646
659
  </element>
647
660
  </define>
@@ -822,7 +835,9 @@
822
835
  <attribute name="alt"/>
823
836
  </optional>
824
837
  <ref name="CitationType"/>
825
- <text/>
838
+ <oneOrMore>
839
+ <ref name="PureTextElement"/>
840
+ </oneOrMore>
826
841
  </define>
827
842
  <define name="hyperlink">
828
843
  <element name="link">
@@ -835,7 +850,9 @@
835
850
  <optional>
836
851
  <attribute name="alt"/>
837
852
  </optional>
838
- <text/>
853
+ <oneOrMore>
854
+ <ref name="PureTextElement"/>
855
+ </oneOrMore>
839
856
  </element>
840
857
  </define>
841
858
  <define name="xref">
@@ -849,7 +866,9 @@
849
866
  <optional>
850
867
  <attribute name="alt"/>
851
868
  </optional>
852
- <text/>
869
+ <oneOrMore>
870
+ <ref name="PureTextElement"/>
871
+ </oneOrMore>
853
872
  </element>
854
873
  </define>
855
874
  <define name="fn">
data/grammars/biblio.rng CHANGED
@@ -209,9 +209,6 @@
209
209
  <zeroOrMore>
210
210
  <ref name="contact"/>
211
211
  </zeroOrMore>
212
- <zeroOrMore>
213
- <ref name="uri"/>
214
- </zeroOrMore>
215
212
  </element>
216
213
  </define>
217
214
  <define name="fullname">
@@ -680,6 +677,9 @@
680
677
  <zeroOrMore>
681
678
  <ref name="extent"/>
682
679
  </zeroOrMore>
680
+ <optional>
681
+ <ref name="bibliographic_size"/>
682
+ </optional>
683
683
  <zeroOrMore>
684
684
  <ref name="accesslocation"/>
685
685
  </zeroOrMore>
@@ -828,6 +828,11 @@
828
828
  <optional>
829
829
  <attribute name="scope"/>
830
830
  </optional>
831
+ <optional>
832
+ <attribute name="primary">
833
+ <data type="boolean"/>
834
+ </attribute>
835
+ </optional>
831
836
  <text/>
832
837
  </element>
833
838
  </define>
@@ -920,9 +925,29 @@
920
925
  <text/>
921
926
  </element>
922
927
  </define>
928
+ <define name="sizevalue">
929
+ <element name="value">
930
+ <attribute name="type"/>
931
+ <text/>
932
+ </element>
933
+ </define>
934
+ <define name="bibliographic_size">
935
+ <element name="size">
936
+ <oneOrMore>
937
+ <ref name="sizevalue"/>
938
+ </oneOrMore>
939
+ </element>
940
+ </define>
923
941
  <define name="extent">
924
942
  <element name="extent">
925
- <ref name="BibItemLocality"/>
943
+ <choice>
944
+ <zeroOrMore>
945
+ <ref name="locality"/>
946
+ </zeroOrMore>
947
+ <zeroOrMore>
948
+ <ref name="localityStack"/>
949
+ </zeroOrMore>
950
+ </choice>
926
951
  </element>
927
952
  </define>
928
953
  <define name="series">
data/grammars/isodoc.rng CHANGED
@@ -152,9 +152,7 @@
152
152
  <data type="boolean"/>
153
153
  </attribute>
154
154
  </optional>
155
- <oneOrMore>
156
- <ref name="PureTextElement"/>
157
- </oneOrMore>
155
+ <ref name="XrefBody"/>
158
156
  </element>
159
157
  </define>
160
158
  <define name="erefType">
@@ -188,6 +186,42 @@
188
186
  <ref name="PureTextElement"/>
189
187
  </oneOrMore>
190
188
  </define>
189
+ <define name="localityStack">
190
+ <element name="localityStack">
191
+ <optional>
192
+ <attribute name="connective">
193
+ <choice>
194
+ <value>and</value>
195
+ <value>or</value>
196
+ <value>from</value>
197
+ <value>to</value>
198
+ <value/>
199
+ </choice>
200
+ </attribute>
201
+ </optional>
202
+ <zeroOrMore>
203
+ <ref name="locality"/>
204
+ </zeroOrMore>
205
+ </element>
206
+ </define>
207
+ <define name="sourceLocalityStack">
208
+ <element name="sourceLocalityStack">
209
+ <optional>
210
+ <attribute name="connective">
211
+ <choice>
212
+ <value>and</value>
213
+ <value>or</value>
214
+ <value>from</value>
215
+ <value>to</value>
216
+ <value/>
217
+ </choice>
218
+ </attribute>
219
+ </optional>
220
+ <zeroOrMore>
221
+ <ref name="sourceLocality"/>
222
+ </zeroOrMore>
223
+ </element>
224
+ </define>
191
225
  <define name="ul">
192
226
  <element name="ul">
193
227
  <attribute name="id">
@@ -1098,6 +1132,16 @@
1098
1132
  </define>
1099
1133
  </include>
1100
1134
  <!-- end overrides -->
1135
+ <define name="image" combine="choice">
1136
+ <element name="svg">
1137
+ <oneOrMore>
1138
+ <choice>
1139
+ <text/>
1140
+ <ref name="AnyElement"/>
1141
+ </choice>
1142
+ </oneOrMore>
1143
+ </element>
1144
+ </define>
1101
1145
  <define name="MultilingualRenderingType">
1102
1146
  <choice>
1103
1147
  <value>common</value>
@@ -2631,4 +2675,30 @@
2631
2675
  </zeroOrMore>
2632
2676
  </element>
2633
2677
  </define>
2678
+ <define name="XrefBody">
2679
+ <zeroOrMore>
2680
+ <ref name="XrefTarget"/>
2681
+ </zeroOrMore>
2682
+ <oneOrMore>
2683
+ <ref name="PureTextElement"/>
2684
+ </oneOrMore>
2685
+ </define>
2686
+ <define name="XrefTarget">
2687
+ <element name="location">
2688
+ <attribute name="target">
2689
+ <data type="string">
2690
+ <param name="pattern">\i\c*|\c+#\c+</param>
2691
+ </data>
2692
+ </attribute>
2693
+ <attribute name="connective">
2694
+ <choice>
2695
+ <value>and</value>
2696
+ <value>or</value>
2697
+ <value>from</value>
2698
+ <value>to</value>
2699
+ <value/>
2700
+ </choice>
2701
+ </attribute>
2702
+ </element>
2703
+ </define>
2634
2704
  </grammar>
data/grammars/reqt.rng CHANGED
@@ -58,6 +58,14 @@
58
58
  <optional>
59
59
  <attribute name="type"/>
60
60
  </optional>
61
+ <optional>
62
+ <attribute name="tag"/>
63
+ </optional>
64
+ <optional>
65
+ <attribute name="multilingual-rendering">
66
+ <ref name="MultilingualRenderingType"/>
67
+ </attribute>
68
+ </optional>
61
69
  <optional>
62
70
  <ref name="reqtitle"/>
63
71
  </optional>
@@ -101,7 +109,9 @@
101
109
  </define>
102
110
  <define name="label">
103
111
  <element name="label">
104
- <text/>
112
+ <oneOrMore>
113
+ <ref name="TextElement"/>
114
+ </oneOrMore>
105
115
  </element>
106
116
  </define>
107
117
  <define name="subject">
@@ -175,6 +185,14 @@
175
185
  <data type="boolean"/>
176
186
  </attribute>
177
187
  </optional>
188
+ <optional>
189
+ <attribute name="tag"/>
190
+ </optional>
191
+ <optional>
192
+ <attribute name="multilingual-rendering">
193
+ <ref name="MultilingualRenderingType"/>
194
+ </attribute>
195
+ </optional>
178
196
  <oneOrMore>
179
197
  <ref name="BasicBlock"/>
180
198
  </oneOrMore>
@@ -20,6 +20,7 @@ module RelatonNist
20
20
  @output = output
21
21
  @format = format
22
22
  @ext = format.sub(/^bib/, "")
23
+ @files = []
23
24
  end
24
25
 
25
26
  def parse_docid(doc) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
@@ -32,17 +33,18 @@ module RelatonNist
32
33
  # end
33
34
  # anchor = doi.split("/")[1..-1].join "/"
34
35
  [
35
- { type: "NIST", id: pub_id(doc) },
36
- { type: "DOI", id: doi(doc) },
37
- { type: "NIST", id: anchor(doc), scope: "anchor" },
36
+ { type: "NIST", id: pub_id(doc), primary: true },
37
+ { type: "DOI", id: fetch_doi(doc) },
38
+ # { type: "NIST", id: anchor(doc), scope: "anchor" },
38
39
  ]
39
40
  end
40
41
 
41
42
  def pub_id(doc)
42
- anchor(doc).gsub(".", " ")
43
+ # anchor(doc).gsub(".", " ")
44
+ fetch_doi(doc).split("/")[1..-1].join("/").gsub(".", " ")
43
45
  end
44
46
 
45
- def doi(doc) # rubocop:disable Metrics/CyclomaticComplexity
47
+ def fetch_doi(doc) # rubocop:disable Metrics/CyclomaticComplexity
46
48
  id = doc.at("doi_data/doi").text
47
49
  case id
48
50
  when "10.6028/NBS.CIRC.e2e" then "10.6028/NBS.CIRC.2e2"
@@ -55,9 +57,9 @@ module RelatonNist
55
57
  end
56
58
  end
57
59
 
58
- def anchor(doc)
59
- doi(doc).split("/")[1..-1].join "/"
60
- end
60
+ # def anchor(doc)
61
+ # fetch_doi(doc).split("/")[1..-1].join "/"
62
+ # end
61
63
 
62
64
  # @param doc [Nokogiri::XML::Element]
63
65
  # @return [Array<RelatonBib::DocumentIdentifier>]
@@ -114,8 +116,11 @@ module RelatonNist
114
116
  # @param doc [Nokogiri::XML::Element]
115
117
  # @return [Array<RelatonBib::TypedUri>]
116
118
  def fetch_link(doc)
117
- url = doc.at("doi_data/resource").text
118
- [RelatonBib::TypedUri.new(type: "doi", content: url)]
119
+ pdf = doc.at("doi_data/resource").text
120
+ doi = "https://doi.org/#{fetch_doi(doc)}"
121
+ [{ type: "doi", content: doi }, { type: "pdf", content: pdf }].map do |l|
122
+ RelatonBib::TypedUri.new(**l)
123
+ end
119
124
  end
120
125
 
121
126
  # @param doc [Nokogiri::XML::Element]
@@ -191,17 +196,17 @@ module RelatonNist
191
196
  def write_file(bib) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
192
197
  id = bib.docidentifier[0].id.gsub(%r{[/\s:.]}, "_").upcase.sub(/^NIST_IR/, "NISTIR")
193
198
  file = File.join(@output, "#{id}.#{@ext}")
194
- if File.exist? file
199
+ if @files.include? file
195
200
  warn "File #{file} exists. Docid: #{bib.docidentifier[0].id}"
196
201
  # warn "Link: #{bib.link.detect { |l| l.type == 'src' }.content}"
197
- else
198
- output = case @format
199
- when "yaml" then bib.to_hash.to_yaml
200
- when "xml" then bib.to_xml bibdata: true
201
- else bib.send "to_#{@format}"
202
- end
203
- File.write file, output, encoding: "UTF-8"
202
+ else @files << file
204
203
  end
204
+ output = case @format
205
+ when "yaml" then bib.to_hash.to_yaml
206
+ when "xml" then bib.to_xml bibdata: true
207
+ else bib.send "to_#{@format}"
208
+ end
209
+ File.write file, output, encoding: "UTF-8"
205
210
  end
206
211
 
207
212
  #
@@ -101,5 +101,16 @@ module RelatonNist
101
101
  out += commentperiod.to_asciibib prefix if commentperiod
102
102
  out
103
103
  end
104
+
105
+ #
106
+ # Create BibXML reference attributes
107
+ #
108
+ # @return [Hash<Symbol=>String>] attributes
109
+ #
110
+ def ref_attrs
111
+ docidentifier.detect(&:primary)&.tap do |di|
112
+ return { anchor: di.id.gsub(" ", ".") }
113
+ end
114
+ end
104
115
  end
105
116
  end
@@ -15,7 +15,7 @@ module RelatonNist
15
15
  titles = fetch_titles(hit_data)
16
16
  unless /^(SP|NISTIR|FIPS) /.match? item_data[:docid][0].id
17
17
  item_data[:docid][0] = RelatonBib::DocumentIdentifier.new(
18
- id: titles[0][:content].upcase, type: "NIST",
18
+ id: titles[0][:content].upcase, type: "NIST", primary: true,
19
19
  )
20
20
  end
21
21
  item_data[:fetched] = Date.today.to_s
@@ -56,7 +56,7 @@ module RelatonNist
56
56
  item_ref = docid
57
57
  # item_ref ||= "?"
58
58
  item_ref.sub!(/\sAddendum$/, "-Add")
59
- [RelatonBib::DocumentIdentifier.new(id: item_ref, type: "NIST")]
59
+ [RelatonBib::DocumentIdentifier.new(id: item_ref, type: "NIST", primary: true)]
60
60
  end
61
61
 
62
62
  # Fetch status.
@@ -1,3 +1,3 @@
1
1
  module RelatonNist
2
- VERSION = "1.10.0".freeze
2
+ VERSION = "1.11.0".freeze
3
3
  end
data/relaton_nist.gemspec CHANGED
@@ -32,6 +32,6 @@ Gem::Specification.new do |spec|
32
32
  spec.add_development_dependency "vcr"
33
33
  spec.add_development_dependency "webmock"
34
34
 
35
- spec.add_dependency "relaton-bib", "~> 1.10.0"
35
+ spec.add_dependency "relaton-bib", "~> 1.11.0"
36
36
  spec.add_dependency "rubyzip"
37
37
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-nist
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.10.0
4
+ version: 1.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-01-30 00:00:00.000000000 Z
11
+ date: 2022-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: equivalent-xml
@@ -128,14 +128,14 @@ dependencies:
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: 1.10.0
131
+ version: 1.11.0
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: 1.10.0
138
+ version: 1.11.0
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: rubyzip
141
141
  requirement: !ruby/object:Gem::Requirement