relaton-render 1.4.0.pre.alpha.3 → 1.4.0.pre.alpha.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f944c1a5f1a26e1ec5c4d1cceae37ea7420257034c87b31eaa6ea0c8e46269e6
4
- data.tar.gz: 5bcd504fbf58c890f778d4f492d70bbabe9b8a974837c838752fbf367129c67c
3
+ metadata.gz: 50d68785ac0e26c28b114b0080e9d2057f701801d641baf0fa955819edaaa7f3
4
+ data.tar.gz: 2c150fa61c2c5a073c372ab8492f897a25294f02f104cc5a442b17cd8efe4104
5
5
  SHA512:
6
- metadata.gz: 0032e8464f6d1731e4aef47a69dfca0e646df0d6c52d85dfa16b72194357f5a5b01f513ffe65498b08e5b6ae4f3e83ef8f6819c6e87e6d1b5a361787a1ce7495
7
- data.tar.gz: ab3af5ef2028428f712fca4727fe126cf56cccfb33fac0d523190536b237616d0207d2363aa2f422fc48e2c3fa78e4a9922ade6f7ad6df6c5738e1be8dc02098
6
+ metadata.gz: 2206dd123a1cab3a5ae0602e4de1cc71b71aaaac67f1a68474db7c367b10a29a52d08dc477770770295b48d89cfbae263bd314818d9cf5bcb1f722576a479f7c
7
+ data.tar.gz: 7270b105580e34e9637172aa3953d50b6bf9bdb51a9d9d9dfe55f6438bb9d026cf2d891b2c6f3b74add5b9bca73b4c8916fd6d33369e972b9ae87207398d33b1
@@ -95,6 +95,15 @@ module Relaton
95
95
  Relaton::Bib::Item
96
96
  end
97
97
 
98
+ # 1.x Parse#authoritative_identifier semantics: the
99
+ # primary/language cascade, the excluded types (URN, DOI, ISBN...)
100
+ # dropped, and scoped ids (biblio-tag duplicates, IEEE trademark)
101
+ # demoted within their type group. isodoc hands the live bibitem
102
+ # node with the document's default namespace still attached, so the
103
+ # element queries must be namespace-agnostic.
104
+ EXCLUDED_ID_TYPES = %w(METANORMA METANORMA-ORDINAL AUTHOR-DATE TITLE
105
+ URN ISO-REFERENCE ISSN ISBN DOI).freeze
106
+
98
107
  def facade_docids(doc)
99
108
  node = doc
100
109
  unless node.respond_to?(:xpath)
@@ -103,7 +112,37 @@ module Relaton
103
112
  end
104
113
  return [] unless node
105
114
 
106
- node.xpath("./docidentifier").map(&:text)
115
+ ids = node.xpath("./*[local-name() = 'docidentifier']")
116
+ ids = facade_scope_filter(ids)
117
+ out = nil
118
+ [
119
+ ->(x) { x["language"] == @lang && x["primary"] },
120
+ ->(x) { x["primary"] },
121
+ ->(x) { x["language"] == @lang },
122
+ ->(_x) { true },
123
+ ].each do |p|
124
+ out = ids.select do |x|
125
+ p.call(x) && !EXCLUDED_ID_TYPES.include?(facade_id_type(x))
126
+ end
127
+ out.empty? or break
128
+ end
129
+ out.map { |x| x.text.strip }
130
+ end
131
+
132
+ def facade_id_type(id)
133
+ t = id["type"] or return nil
134
+ m = /\A(ISBN|ISSN)\..*/i.match(t) or return t.upcase
135
+ m[1].upcase
136
+ end
137
+
138
+ def facade_scope_filter(ids)
139
+ ids.detect { |i| i["scope"] } or return ids
140
+ ids.group_by { |i| i["type"] }.flat_map do |type, group|
141
+ grouped = group.group_by { |i| i["scope"] }
142
+ if type == "IEEE" then grouped["trademark"] || grouped[nil] || []
143
+ else grouped[nil] || []
144
+ end
145
+ end
107
146
  end
108
147
 
109
148
  def warn_general_config
@@ -1,5 +1,5 @@
1
1
  module Relaton
2
2
  module Render
3
- VERSION = "1.4.0.pre.alpha.3".freeze
3
+ VERSION = "1.4.0.pre.alpha.4".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-render
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0.pre.alpha.3
4
+ version: 1.4.0.pre.alpha.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-10-03 00:00:00.000000000 Z
11
+ date: 2026-10-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lutaml-model