diff --git a/jsonld.php b/jsonld.php index 27f4938..a3320d3 100644 --- a/jsonld.php +++ b/jsonld.php @@ -1517,30 +1517,31 @@ class JsonLdProcessor { // preserve empty arrays if(count($expanded_value) === 0) { - $active_property = $this->_compactIri( - $active_ctx, $expanded_property, null, array('vocab' => true), - $element); + $item_active_property = $this->_compactIri( + $active_ctx, $expanded_property, $expanded_value, + array('vocab' => true), $element); self::addValue( - $rval, $active_property, array(), array('propertyIsArray' => true)); + $rval, $item_active_property, array(), + array('propertyIsArray' => true)); } // recusively process array values foreach($expanded_value as $expanded_item) { // compact property and get container type - $active_property = $this->_compactIri( + $item_active_property = $this->_compactIri( $active_ctx, $expanded_property, $expanded_item, array('vocab' => true), $element); $container = self::getContextValue( - $active_ctx, $active_property, '@container'); + $active_ctx, $item_active_property, '@container'); // remove any duplicates that were (presumably) generated by a // property generator - if(property_exists($active_ctx->mappings, $active_property)) { - $mapping = $active_ctx->mappings->{$active_property}; + if(property_exists($active_ctx->mappings, $item_active_property)) { + $mapping = $active_ctx->mappings->{$item_active_property}; if($mapping && $mapping->propertyGenerator) { $this->_findPropertyGeneratorDuplicates( $active_ctx, $element, $expanded_property, $expanded_item, - $active_property, true); + $item_active_property, true); } } @@ -1553,8 +1554,8 @@ class JsonLdProcessor { // recursively compact expanded item $compacted_item = $this->_compact( - $active_ctx, $active_property, $is_list ? $list : $expanded_item, - $options); + $active_ctx, $item_active_property, + $is_list ? $list : $expanded_item, $options); // handle @list if($is_list) { @@ -1573,7 +1574,7 @@ class JsonLdProcessor { } } // can't use @list container for more than 1 list - else if(property_exists($rval, $active_property)) { + else if(property_exists($rval, $item_active_property)) { throw new JsonLdException( 'JSON-LD compact error; property has a "@list" @container ' . 'rule but there is more than a single @list that matches ' . @@ -1586,11 +1587,11 @@ class JsonLdProcessor { // handle language and index maps if($container === '@language' || $container === '@index') { // get or create the map object - if(property_exists($rval, $active_property)) { - $map_object = $rval->{$active_property}; + if(property_exists($rval, $item_active_property)) { + $map_object = $rval->{$item_active_property}; } else { - $rval->{$active_property} = $map_object = new stdClass(); + $rval->{$item_active_property} = $map_object = new stdClass(); } // if container is a language map, simplify compacted value to @@ -1614,7 +1615,7 @@ class JsonLdProcessor { // add compact value self::addValue( - $rval, $active_property, $compacted_item, + $rval, $item_active_property, $compacted_item, array('propertyIsArray' => $is_array)); } }