Do not output relative IRIs in RDF datasets.

This commit is contained in:
Dave Longley 2013-09-13 13:16:10 -04:00
parent 944e9ee886
commit d1501c7c08

View file

@ -1184,8 +1184,11 @@ class JsonLdProcessor {
sort($graph_names);
foreach($graph_names as $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);
}
}
$rval = $dataset;
@ -3159,6 +3162,11 @@ class JsonLdProcessor {
}
foreach($items as $item) {
// skip relative IRI subjects and predicates
if(!(self::_isAbsoluteIri($id) && self::_isAbsoluteIri($property))) {
continue;
}
// RDF subject
$subject = new stdClass();
$subject->type = (strpos($id, '_:') === 0) ? 'blank node' : 'IRI';
@ -3184,6 +3192,8 @@ class JsonLdProcessor {
// convert value or node object to triple
else {
$object = $this->_objectToRDF($item);
// skip null objects (they are relative IRIs)
if($object) {
$rval[] = (object)array(
'subject' => $subject,
'predicate' => $predicate,
@ -3192,6 +3202,7 @@ class JsonLdProcessor {
}
}
}
}
return $rval;
}
@ -3223,8 +3234,13 @@ class JsonLdProcessor {
$subject = $blank_node;
$predicate = $first;
$object = $this->_objectToRDF($item);
// skip null objects (they are relative IRIs)
if($object) {
$triples[] = (object)array(
'subject' => $subject, 'predicate' => $predicate, 'object' => $object);
'subject' => $subject,
'predicate' => $predicate,
'object' => $object);
}
$predicate = $rest;
}
@ -3281,6 +3297,11 @@ class JsonLdProcessor {
$object->value = $id;
}
// skip relative IRIs
if($object->type === 'IRI' && !self::_isAbsoluteIri($object->value)) {
return null;
}
return $object;
}