@@ -124,21 +124,21 @@ def create_node_map(element, graph_map,
124
124
125
125
# For rdfstar, if node contains an `@annotation` member ...
126
126
# note: active_subject will not be nil
127
- # XXX: what if we're reversing an annotation?
128
127
if annotation = element . delete ( '@annotation' )
129
128
# rdfstar being true is implicit, as it is checked in expansion
130
- as = if node_reference? ( active_subject )
131
- active_subject [ '@id' ]
129
+ if node_reference? ( active_subject )
130
+ # If this is a node reference, then we're processing a revers relationship
131
+ as = active_subject [ '@id' ]
132
+ reification = { '@id' => node [ '@id' ] , active_property => [ { '@id' => as } ] }
132
133
else
133
- active_subject
134
+ as = active_subject
135
+ reification = { '@id' => as , active_property => [ { '@id' => node [ '@id' ] } ] }
134
136
end
135
137
136
- reification = { '@id' => as , active_property => [ { '@id' => node [ '@id' ] } ] }
137
-
138
138
# Note that annotation is an array, make the reified subject the id of each member of that array.
139
139
annotation . each do |a |
140
- # XXX may be zero or more reifiers; use bnode for now.
141
- reifier = namer . get_name
140
+ # Use an provided reifier before allocating a fresh blank node
141
+ reifier = a . fetch ( '@id' , namer . get_name )
142
142
a = a . merge ( '@id' => reifier , '@reifies' => reification )
143
143
144
144
# Invoke recursively using annotation.
@@ -252,7 +252,8 @@ def create_annotations(node_map)
252
252
target_values . is_a? ( Array )
253
253
254
254
target_values . each do |t_value |
255
- next unless t_value == reif_value
255
+ # See if target value matches the reification value (other than a potential `@annotation`).
256
+ next unless t_value . dup . delete_if { |k , _ | %w( @annotation ) . include? ( k ) } == reif_value
256
257
257
258
# Add annotation to the identified value
258
259
t_value [ '@annotation' ] ||= [ ]
0 commit comments