Use available aliases for @value, @language when compacting.
This commit is contained in:
parent
7cf02461cc
commit
599e507bcc
28
jsonld.php
28
jsonld.php
|
@ -1160,8 +1160,10 @@ class JsonLdProcessor {
|
||||||
if(!property_exists($ctx, '@language')) {
|
if(!property_exists($ctx, '@language')) {
|
||||||
return $element->{'@value'};
|
return $element->{'@value'};
|
||||||
}
|
}
|
||||||
// return full element
|
// return full element, alias @value
|
||||||
return $element;
|
$rval = new stdClass();
|
||||||
|
$rval->{$this->_compactIri($ctx, '@value')} = $element->{'@value'};
|
||||||
|
return $rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
// get type and language context rules
|
// get type and language context rules
|
||||||
|
@ -1171,19 +1173,29 @@ class JsonLdProcessor {
|
||||||
// matching @type specified in context, compact element
|
// matching @type specified in context, compact element
|
||||||
if($type !== null &&
|
if($type !== null &&
|
||||||
property_exists($element, '@type') && $element->{'@type'} === $type) {
|
property_exists($element, '@type') && $element->{'@type'} === $type) {
|
||||||
$element = $element->{'@value'};
|
return $element->{'@value'};
|
||||||
}
|
}
|
||||||
// matching @language specified in context, compact element
|
// matching @language specified in context, compact element
|
||||||
else if($language !== null &&
|
else if($language !== null &&
|
||||||
property_exists($element, '@language') &&
|
property_exists($element, '@language') &&
|
||||||
$element->{'@language'} === $language) {
|
$element->{'@language'} === $language) {
|
||||||
$element = $element->{'@value'};
|
return $element->{'@value'};
|
||||||
}
|
}
|
||||||
// compact @type IRI
|
else {
|
||||||
else if(property_exists($element, '@type')) {
|
$rval = new stdClass();
|
||||||
$element->{'@type'} = $this->_compactIri($ctx, $element->{'@type'});
|
// compact @type IRI
|
||||||
|
if(property_exists($element, '@type')) {
|
||||||
|
$rval->{$this->_compactIri($ctx, '@type')} =
|
||||||
|
$this->_compactIri($ctx, $element->{'@type'});
|
||||||
|
}
|
||||||
|
// alias @language
|
||||||
|
else if(property_exists($element, '@language')) {
|
||||||
|
$rval->{$this->_compactIri($ctx, '@language')} =
|
||||||
|
$element->{'@language'};
|
||||||
|
}
|
||||||
|
$rval->{$this->_compactIri($ctx, '@value')} = $element->{'@value'};
|
||||||
|
return $rval;
|
||||||
}
|
}
|
||||||
return $element;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// compact subject references
|
// compact subject references
|
||||||
|
|
Loading…
Reference in a new issue