@@ -60,18 +60,12 @@ def create_node_map(element, graph_map,
6060 # note: active_subject will not be nil.
6161 if annotation = element . delete ( '@annotation' )
6262 # 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 ] }
7064
7165 # Note that annotation is an array, make the reified subject the id of each member of that array.
7266 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 )
7569 a = a . merge ( '@id' => reifier , '@reifies' => reification )
7670
7771 # Invoke recursively using annotation.
@@ -97,13 +91,28 @@ def create_node_map(element, graph_map,
9791 list [ '@list' ] << result
9892 end
9993 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?
10495 raise "Expected triple term to not have other properties, got #{ element . inspect } "
10596 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
107116 # Element is a node object
108117 id = element . delete ( '@id' )
109118 id = namer . get_name ( id ) if blank_node? ( id )
@@ -127,7 +136,7 @@ def create_node_map(element, graph_map,
127136 if annotation = element . delete ( '@annotation' )
128137 # rdfstar being true is implicit, as it is checked in expansion
129138 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
131140 as = active_subject [ '@id' ]
132141 reification = { '@id' => node [ '@id' ] , active_property => [ { '@id' => as } ] }
133142 else
0 commit comments