@@ -60,18 +60,12 @@ def create_node_map(element, graph_map,
60
60
# note: active_subject will not be nil.
61
61
if annotation = element . delete ( '@annotation' )
62
62
# rdfstar being true is implicit, as it is checked in expansion
63
- as = if node_reference? ( active_subject )
64
- active_subject [ '@id' ]
65
- else
66
- active_subject
67
- end
68
-
69
- reification = { '@id' => as , active_property => [ element ] }
63
+ reification = { '@id' => active_subject , active_property => [ element ] }
70
64
71
65
# Note that annotation is an array, make the reified subject the id of each member of that array.
72
66
annotation . each do |a |
73
- # XXX may be zero or more reifiers; use bnode for now.
74
- reifier = namer . get_name
67
+ # Use an provided reifier before allocating a fresh blank node
68
+ reifier = a . fetch ( '@id' , namer . get_name )
75
69
a = a . merge ( '@id' => reifier , '@reifies' => reification )
76
70
77
71
# Invoke recursively using annotation.
@@ -97,13 +91,28 @@ def create_node_map(element, graph_map,
97
91
list [ '@list' ] << result
98
92
end
99
93
elsif triple_term? ( element )
100
- # Add just the @triple member from element as the value of the property in the subject node.
101
- # FIXME: if a triple term can have other properties, the triple term would need to be its own entry in the node mode.
102
- add_value ( subject_node , active_property , element . dup . delete_if { |k , v | k != '@triple' } , allow_duplicate : false )
103
- if element . keys . length != 1
94
+ unless ( element . keys - %w( @triple @annotation ) ) . empty?
104
95
raise "Expected triple term to not have other properties, got #{ element . inspect } "
105
96
end
106
- else
97
+
98
+ if annotation = element . delete ( '@annotation' )
99
+ # rdfstar being true is implicit, as it is checked in expansion
100
+ reification = { '@id' => active_subject , active_property => [ element ] }
101
+
102
+ # Note that annotation is an array, make the reified subject the id of each member of that array.
103
+ annotation . each do |a |
104
+ # Use an provided reifier before allocating a fresh blank node
105
+ reifier = a . fetch ( '@id' , namer . get_name )
106
+ a = a . merge ( '@id' => reifier , '@reifies' => reification )
107
+
108
+ # Invoke recursively using annotation.
109
+ create_node_map ( a , graph_map , active_graph : active_graph , active_subject : reifier )
110
+ end
111
+ end
112
+
113
+ # Add just the @triple member from element as the value of the property in the subject node.
114
+ add_value ( subject_node , active_property , element . dup . delete_if { |k , v | k != '@triple' } , allow_duplicate : false )
115
+ else
107
116
# Element is a node object
108
117
id = element . delete ( '@id' )
109
118
id = namer . get_name ( id ) if blank_node? ( id )
@@ -127,7 +136,7 @@ def create_node_map(element, graph_map,
127
136
if annotation = element . delete ( '@annotation' )
128
137
# rdfstar being true is implicit, as it is checked in expansion
129
138
if node_reference? ( active_subject )
130
- # If this is a node reference, then we're processing a revers relationship
139
+ # If this is a node reference, then we're processing a reverse relationship
131
140
as = active_subject [ '@id' ]
132
141
reification = { '@id' => node [ '@id' ] , active_property => [ { '@id' => as } ] }
133
142
else
0 commit comments