Do not output relative IRIs in RDF datasets.
This commit is contained in:
parent
944e9ee886
commit
d1501c7c08
23
jsonld.php
23
jsonld.php
|
@ -1184,8 +1184,11 @@ class JsonLdProcessor {
|
||||||
sort($graph_names);
|
sort($graph_names);
|
||||||
foreach($graph_names as $graph_name) {
|
foreach($graph_names as $graph_name) {
|
||||||
$graph = $node_map->{$graph_name};
|
$graph = $node_map->{$graph_name};
|
||||||
|
// skip relative IRIs
|
||||||
|
if($graph_name === '@default' || self::_isAbsoluteIri($graph_name)) {
|
||||||
$dataset->{$graph_name} = $this->_graphToRDF($graph, $namer, $options);
|
$dataset->{$graph_name} = $this->_graphToRDF($graph, $namer, $options);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$rval = $dataset;
|
$rval = $dataset;
|
||||||
|
|
||||||
|
@ -3159,6 +3162,11 @@ class JsonLdProcessor {
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($items as $item) {
|
foreach($items as $item) {
|
||||||
|
// skip relative IRI subjects and predicates
|
||||||
|
if(!(self::_isAbsoluteIri($id) && self::_isAbsoluteIri($property))) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// RDF subject
|
// RDF subject
|
||||||
$subject = new stdClass();
|
$subject = new stdClass();
|
||||||
$subject->type = (strpos($id, '_:') === 0) ? 'blank node' : 'IRI';
|
$subject->type = (strpos($id, '_:') === 0) ? 'blank node' : 'IRI';
|
||||||
|
@ -3184,6 +3192,8 @@ class JsonLdProcessor {
|
||||||
// convert value or node object to triple
|
// convert value or node object to triple
|
||||||
else {
|
else {
|
||||||
$object = $this->_objectToRDF($item);
|
$object = $this->_objectToRDF($item);
|
||||||
|
// skip null objects (they are relative IRIs)
|
||||||
|
if($object) {
|
||||||
$rval[] = (object)array(
|
$rval[] = (object)array(
|
||||||
'subject' => $subject,
|
'subject' => $subject,
|
||||||
'predicate' => $predicate,
|
'predicate' => $predicate,
|
||||||
|
@ -3192,6 +3202,7 @@ class JsonLdProcessor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $rval;
|
return $rval;
|
||||||
}
|
}
|
||||||
|
@ -3223,8 +3234,13 @@ class JsonLdProcessor {
|
||||||
$subject = $blank_node;
|
$subject = $blank_node;
|
||||||
$predicate = $first;
|
$predicate = $first;
|
||||||
$object = $this->_objectToRDF($item);
|
$object = $this->_objectToRDF($item);
|
||||||
|
// skip null objects (they are relative IRIs)
|
||||||
|
if($object) {
|
||||||
$triples[] = (object)array(
|
$triples[] = (object)array(
|
||||||
'subject' => $subject, 'predicate' => $predicate, 'object' => $object);
|
'subject' => $subject,
|
||||||
|
'predicate' => $predicate,
|
||||||
|
'object' => $object);
|
||||||
|
}
|
||||||
|
|
||||||
$predicate = $rest;
|
$predicate = $rest;
|
||||||
}
|
}
|
||||||
|
@ -3281,6 +3297,11 @@ class JsonLdProcessor {
|
||||||
$object->value = $id;
|
$object->value = $id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// skip relative IRIs
|
||||||
|
if($object->type === 'IRI' && !self::_isAbsoluteIri($object->value)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return $object;
|
return $object;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue