@@ -137,7 +137,7 @@ def expand_object(input, active_property, context, output_object, ordered: false
137137 keys . each do |key |
138138 # For each key and value in element, ordered lexicographically by key:
139139 value = input [ key ]
140- expanded_property = context . expand_iri ( key , vocab : true , log_depth : @options [ :log_depth ] )
140+ expanded_property = context . expand_iri ( key , vocab : true , quiet : true )
141141
142142 # If expanded property is null or it neither contains a colon (:) nor it is a keyword, drop key by continuing to the next key.
143143 next if expanded_property . is_a? ( RDF ::URI ) && expanded_property . relative?
@@ -164,16 +164,16 @@ def expand_object(input, active_property, context, output_object, ordered: false
164164 # If expanded property is @id and value is not a string, an invalid @id value error has been detected and processing is aborted
165165 e_id = case value
166166 when String
167- context . expand_iri ( value , documentRelative : true , log_depth : @options [ :log_depth ] ) . to_s
167+ context . expand_iri ( value , documentRelative : true , quiet : true ) . to_s
168168 when Array
169169 # Framing allows an array of IRIs, and always puts values in an array
170170 raise JsonLdError ::InvalidIdValue ,
171171 "value of @id must be a string, array of string or hash if framing: #{ value . inspect } " unless framing
172- context . expand_iri ( value , documentRelative : true , log_depth : @options [ :log_depth ] ) . to_s
172+ context . expand_iri ( value , documentRelative : true , quiet : true ) . to_s
173173 value . map do |v |
174174 raise JsonLdError ::InvalidTypeValue ,
175175 "@id value must be a string or array of strings for framing: #{ v . inspect } " unless v . is_a? ( String )
176- context . expand_iri ( v , documentRelative : true , quiet : true , log_depth : @options [ :log_depth ] ) . to_s
176+ context . expand_iri ( v , documentRelative : true , quiet : true , ) . to_s
177177 end
178178 when Hash
179179 raise JsonLdError ::InvalidIdValue ,
@@ -201,10 +201,10 @@ def expand_object(input, active_property, context, output_object, ordered: false
201201 value . map do |v |
202202 raise JsonLdError ::InvalidTypeValue ,
203203 "@type value must be a string or array of strings: #{ v . inspect } " unless v . is_a? ( String )
204- context . expand_iri ( v , vocab : true , documentRelative : true , quiet : true , log_depth : @options [ :log_depth ] ) . to_s
204+ context . expand_iri ( v , vocab : true , documentRelative : true , quiet : true ) . to_s
205205 end
206206 when String
207- context . expand_iri ( value , vocab : true , documentRelative : true , quiet : true , log_depth : @options [ :log_depth ] ) . to_s
207+ context . expand_iri ( value , vocab : true , documentRelative : true , quiet : true ) . to_s
208208 when Hash
209209 # For framing
210210 raise JsonLdError ::InvalidTypeValue ,
@@ -379,11 +379,18 @@ def expand_object(input, active_property, context, output_object, ordered: false
379379 keys . each do |k |
380380 # Initialize index value to the result of using this algorithm recursively, passing active context, key as active property, and index value as element.
381381 index_value = expand ( [ value [ k ] ] . flatten , key , active_context , ordered : ordered )
382+ #require 'byebug'; byebug
382383 index_value . each do |item |
383384 case container
384- when '@id' , '@index' then item [ container ] ||= k
385- # If container is @type add the key-value pair (@type-[index]) to item, appending any existing values in item
386- when '@type' then item [ container ] = [ k ] . concat ( Array ( item [ container ] ) )
385+ when '@index' then item [ container ] ||= k
386+ when '@id'
387+ # Expand k document relative
388+ expanded_k = active_context . expand_iri ( k , documentRelative : true , quiet : true ) . to_s
389+ item [ container ] ||= expanded_k
390+ when '@type'
391+ # Expand k vocabulary relative
392+ expanded_k = active_context . expand_iri ( k , vocab : true , documentRelative : true , quiet : true ) . to_s
393+ item [ container ] = [ expanded_k ] . concat ( Array ( item [ container ] ) )
387394 end
388395
389396 # Append item to expanded value.
0 commit comments