Remove term definition inheritance.
This commit is contained in:
parent
6e2b78c722
commit
d7bb4b3cba
52
jsonld.php
52
jsonld.php
|
@ -4041,18 +4041,6 @@ class JsonLdProcessor {
|
|||
// now defining term
|
||||
$defined->{$term} = false;
|
||||
|
||||
// if term has a prefix, define it first
|
||||
$colon = strpos($term, ':');
|
||||
$prefix = null;
|
||||
if($colon !== false) {
|
||||
$prefix = substr($term, 0, $colon);
|
||||
if(property_exists($local_ctx, $prefix)) {
|
||||
// define parent prefix
|
||||
$this->_createTermDefinition(
|
||||
$active_ctx, $local_ctx, $prefix, $defined);
|
||||
}
|
||||
}
|
||||
|
||||
if(self::_isKeyword($term)) {
|
||||
throw new JsonLdException(
|
||||
'Invalid JSON-LD syntax; keywords cannot be overridden.',
|
||||
|
@ -4120,13 +4108,6 @@ class JsonLdProcessor {
|
|||
$mapping = new stdClass();
|
||||
$mapping->propertyGenerator = false;
|
||||
|
||||
// merge onto parent mapping if one exists for a prefix
|
||||
if($prefix !== null &&
|
||||
property_exists($active_ctx->mappings, $prefix) &&
|
||||
$active_ctx->mappings->{$prefix} !== null) {
|
||||
$mapping = self::copy($active_ctx->mappings->{$prefix});
|
||||
}
|
||||
|
||||
if(property_exists($value, '@id')) {
|
||||
$id = $value->{'@id'};
|
||||
// handle property generator
|
||||
|
@ -4171,7 +4152,29 @@ class JsonLdProcessor {
|
|||
}
|
||||
}
|
||||
else {
|
||||
if($prefix === null) {
|
||||
// see if the term has a prefix
|
||||
$colon = strpos($term, ':');
|
||||
if($colon !== false) {
|
||||
$prefix = substr($term, 0, $colon);
|
||||
if(property_exists($local_ctx, $prefix)) {
|
||||
// define parent prefix
|
||||
$this->_createTermDefinition(
|
||||
$active_ctx, $local_ctx, $prefix, $defined);
|
||||
}
|
||||
|
||||
// set @id based on prefix parent
|
||||
if(property_exists($active_ctx->mappings, $prefix) &&
|
||||
$active_ctx->mappings->{$prefix}) {
|
||||
$suffix = substr($term, $colon + 1);
|
||||
$mapping->{'@id'} = $active_ctx->mappings->{$prefix}->{'@id'} .
|
||||
$suffix;
|
||||
}
|
||||
// term is an absolute IRI
|
||||
else {
|
||||
$mapping->{'@id'} = $term;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// non-IRIs *must* define @ids if @vocab is not available
|
||||
if(!property_exists($active_ctx, '@vocab')) {
|
||||
throw new JsonLdException(
|
||||
|
@ -4182,15 +4185,6 @@ class JsonLdProcessor {
|
|||
// prepend vocab to term
|
||||
$mapping->{'@id'} = $active_ctx->{'@vocab'} . $term;
|
||||
}
|
||||
// set @id based on prefix parent
|
||||
else if(property_exists($active_ctx->mappings, $prefix)) {
|
||||
$suffix = substr($term, $colon + 1);
|
||||
$mapping->{'@id'} = $active_ctx->mappings->{$prefix}->{'@id'} . $suffix;
|
||||
}
|
||||
// term is an absolute IRI
|
||||
else {
|
||||
$mapping->{'@id'} = $term;
|
||||
}
|
||||
}
|
||||
|
||||
if(property_exists($value, '@type')) {
|
||||
|
|
Loading…
Reference in a new issue