Hi everybody.<br>I was trying to implement a webservice that serializes RDF to JSON using Redland PHP binding.<br>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.<br>
The script loads a RDF string into the model, and than serializes it into JSON, very simple. <br>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.<br>
<br>Any suggestions would be appreciated.<br>Thank you.<br><br>Luca<br><br><span style="font-family: courier new,monospace;">$dlls = array("redland.so", "php_redland.dll", "redland.dylib", "redland.bundle");</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">foreach ($dlls as $dll) {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> if(file_exists($dll)) {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> dl($dll);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> }</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">}</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">$world=librdf_php_get_world();</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">$storage=librdf_new_storage($world,'hashes','dummy',"new=yes,hash-type='memory'");</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">$model=librdf_new_model($world,$storage,null);</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">$parser=librdf_new_parser($world,'rdfxml',null,null);</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">$string = "<?xml version=\"1.0\"?>\</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"><rdf:RDF xmlns:rdf=\"<a href="http://www.w3.org/1999/02/22-rdf-syntax-ns#" target="_blank">http://www.w3.org/1999/02/22-rdf-syntax-ns#</a>\"\</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> xmlns:dc=\"<a href="http://purl.org/dc/elements/1.1/" target="_blank">http://purl.org/dc/elements/1.1/</a>\">\</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> <rdf:Description rdf:about=\"<a href="http://www.dajobe.org/" target="_blank">http://www.dajobe.org/</a>\">\</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> <dc:title>Dave Beckett's Home Page</dc:title>\</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> <dc:creator>Dave Beckett</dc:creator>\</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> <dc:description>The generic home page of Dave Beckett.</dc:description>\</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> </rdf:Description> \</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"></rdf:RDF>\</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">";</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">if(librdf_parser_parse_string_into_model($parser,$string,librdf_new_uri($world,'<a href="http://example.org/foo%27" target="_blank">http://example.org/foo'</a>),$model)){</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> echo "<br>parsing error<br>";</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">}</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">$serializer=librdf_new_serializer($world,'json',null, null);</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">$res = librdf_serializer_serialize_model_to_string($serializer,null,$model);</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">echo $res;</span><br>