From: Richard C. <ri...@cy...> - 2005-09-20 18:33:46
|
Hi, There's a bug in Statement::reify. According to the Statement documentation, you can pass a blank node to the function. Test script: <?php define("RDFAPI_INCLUDE_DIR", "./rdfapi-php/api/"); include(RDFAPI_INCLUDE_DIR . "RdfAPI.php"); $a = new Resource("http://example.org/a"); $b = new Resource("http://example.org/b"); $c = new Resource("http://example.org/c"); $statement = new Statement($a, $b, $c); $model = ModelFactory::getDefaultModel(); $blank = new BlankNode($model); $reification_quad = $statement->reify($blank); echo $reification_quad->writeRdfToString(); ?> This throws a bunch of warnings and then produces this output: <rdf:RDF (snip namespaces) <rdf:Statement rdf:nodeID="Object"> <rdf:subject rdf:resource="http://example.org/a"/> <rdf:predicate rdf:resource="http://example.org/b"/> <rdf:object rdf:resource="http://example.org/c"/> </rdf:Statement> Note the rdf:nodeID="Object". It should say something like bNode1. The fix is easy. Quote from the body of Statement::reify: function & reify(&$model_or_bNodeID) { if (is_a($model_or_bNodeID, 'MemModel')) { // parameter is model $statementModel = new MemModel($model_or_bNodeID- >getBaseURI()); $thisStatement = new BlankNode($model_or_bNodeID); } else { // parameter is bNodeID $statementModel = new MemModel(); $thisStatement = new BlankNode($model_or_bNodeID); } Note the last line: $model_or_bNodeID contains a blank node, but we create a new blank node anyway, with the blank node as argument! The line should read: $thisStatement = &$model_or_bNodeID; (It's line 271 of /api/model/Statement.php) Related issue: I don't see a reason why the method is restricted to blank node arguments. Passing a URI should also be allowed. There's actually nothing in the code to make it specific to blank nodes. Passing a URI should work just fine. I suggest the method documentation and variable names be updated to also allow blank nodes. Cheers, Richard |