From 443df61b11fe5f56ab06f2b0fa8fbb7662709599 Mon Sep 17 00:00:00 2001 From: Dave Longley Date: Tue, 6 Aug 2013 14:02:08 -0400 Subject: [PATCH] Exclude blank node predicates unless producing generalized RDF. --- jsonld.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/jsonld.php b/jsonld.php index 2c5ccf8..3828ef8 100644 --- a/jsonld.php +++ b/jsonld.php @@ -1115,7 +1115,7 @@ class JsonLdProcessor { } catch(JsonLdException $e) { throw new JsonLdException( - 'Could not expand input before conversion to RDF.', + 'Could not expand input before serialization to RDF.', 'jsonld.RdfError', $e); } @@ -1130,7 +1130,7 @@ class JsonLdProcessor { sort($graph_names); foreach($graph_names as $graph_name) { $graph = $node_map->{$graph_name}; - $dataset->{$graph_name} = $this->_graphToRDF($graph, $namer); + $dataset->{$graph_name} = $this->_graphToRDF($graph, $namer, $options); } $rval = $dataset; @@ -2636,7 +2636,7 @@ class JsonLdProcessor { * Converts an RDF dataset to JSON-LD. * * @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. */ @@ -3110,6 +3110,12 @@ class JsonLdProcessor { 'blank node' : 'IRI'); $predicate->value = $property; + // skip bnode predicates unless producing generalized RDF + if($predicate->type === 'blank node' && + !$options['produceGeneralizedRdf']) { + continue; + } + // convert @list to triples if(self::_isList($item)) { $this->_listToRDF(