Exclude blank node predicates unless producing generalized RDF.

This commit is contained in:
Dave Longley 2013-08-06 14:02:08 -04:00
parent c0280e53e4
commit 443df61b11

View file

@ -1115,7 +1115,7 @@ class JsonLdProcessor {
} }
catch(JsonLdException $e) { catch(JsonLdException $e) {
throw new JsonLdException( throw new JsonLdException(
'Could not expand input before conversion to RDF.', 'Could not expand input before serialization to RDF.',
'jsonld.RdfError', $e); 'jsonld.RdfError', $e);
} }
@ -1130,7 +1130,7 @@ 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};
$dataset->{$graph_name} = $this->_graphToRDF($graph, $namer); $dataset->{$graph_name} = $this->_graphToRDF($graph, $namer, $options);
} }
$rval = $dataset; $rval = $dataset;
@ -2636,7 +2636,7 @@ class JsonLdProcessor {
* Converts an RDF dataset to JSON-LD. * Converts an RDF dataset to JSON-LD.
* *
* @param stdClass $dataset the RDF dataset. * @param stdClass $dataset the RDF dataset.
* @param assoc $options the RDF conversion options. * @param assoc $options the RDF serialization options.
* *
* @return array the JSON-LD output. * @return array the JSON-LD output.
*/ */
@ -3110,6 +3110,12 @@ class JsonLdProcessor {
'blank node' : 'IRI'); 'blank node' : 'IRI');
$predicate->value = $property; $predicate->value = $property;
// skip bnode predicates unless producing generalized RDF
if($predicate->type === 'blank node' &&
!$options['produceGeneralizedRdf']) {
continue;
}
// convert @list to triples // convert @list to triples
if(self::_isList($item)) { if(self::_isList($item)) {
$this->_listToRDF( $this->_listToRDF(