[redland-dev] Redland PHP binding librdf_parser_parse_string_into_model
Ikoichi Yahoo
ikoichi_2112 at yahoo.it
Wed Mar 10 21:22:08 CET 2010
Hi everybody.
I was trying to implement a webservice that serializes RDF to JSON using
Redland PHP binding.
But I think that's something wrong with the
librdf_parser_parse_string_into_model function, and I can not figure out
what it is.
The script loads a RDF string into the model, and than serializes it into
JSON, very simple.
If I use librdf_parser_parse_into_model (instead of
librdf_parser_parse_string_into_model) loading the rdf from a uri,
everything goes well.
Any suggestions would be appreciated.
Thank you.
Luca
$dlls = array("redland.so", "php_redland.dll", "redland.dylib",
"redland.bundle");
foreach ($dlls as $dll) {
if(file_exists($dll)) {
dl($dll);
}
}
$world=librdf_php_get_world();
$storage=librdf_new_storage($world,'hashes','dummy',"new=yes,hash-type='memory'");
$model=librdf_new_model($world,$storage,null);
$parser=librdf_new_parser($world,'rdfxml',null,null);
$string = "<?xml version=\"1.0\"?>\
<rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\
xmlns:dc=\"http://purl.org/dc/elements/1.1/\">\
<rdf:Description rdf:about=\"http://www.dajobe.org/\">\
<dc:title>Dave Beckett's Home Page</dc:title>\
<dc:creator>Dave Beckett</dc:creator>\
<dc:description>The generic home page of Dave Beckett.</dc:description>\
</rdf:Description> \
</rdf:RDF>\
";
if(librdf_parser_parse_string_into_model($parser,$string,librdf_new_uri($world,'
http://example.org/foo' <http://example.org/foo%27>),$model)){
echo "<br>parsing error<br>";
}
$serializer=librdf_new_serializer($world,'json',null, null);
$res = librdf_serializer_serialize_model_to_string($serializer,null,$model);
echo $res;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.librdf.org/pipermail/redland-dev/attachments/20100310/5d32ce3c/attachment.htm
More information about the redland-dev
mailing list