[redland-dev] librdf_model_to_string only works for rdf+xml? (repost)

Dave Beckett dave at dajobe.org
Sat Jul 14 05:29:24 BST 2007


Einar Poke wrote:
> (Sorry but my previous posting was unreadable due to
> rich formatting that my web mail doesn't allow to turn
> off, thus I'm sending it again from another
> account...)
> 
> ---
> 
> It seems function librdf_model_to_string (and
> similars) only works for converting from model as
> "rdf+xml", but it doesn't work as "rss", "atom" and
> others. Or maybe I'm doing something wrong? Please
> advise!
>  
> I have created a very simple program to isolate this
> problem:
>  
> #include <stdio.h>
> #include <string.h>
> #include <stdarg.h>
> #include <redland.h>
> int main(int argc, char *argv[]) {
>   librdf_world* world;
>   librdf_storage* storage;
>   librdf_parser* parser;
>   librdf_model* model;
>   librdf_uri *uri;
>   char *str = NULL;
>   world=librdf_new_world();
>   librdf_world_open(world);
>   uri=librdf_new_uri(world, (const unsigned
> char*)argv[1]);
>   if(!uri) { return 1; }
>   storage=librdf_new_storage(world, "memory", "test",
> NULL);
>   if(!storage) { return 1; }
>   model=librdf_new_model(world, storage, NULL);
>   if(!model) { return 1; }
>   parser=librdf_new_parser(world, "rss-tag-soup",
> NULL, NULL);
>   if(!parser) { return 1; }
>   if(librdf_parser_parse_into_model(parser, uri, uri,
> model)) {
>     fprintf(stderr, "Failed to parse RDF into
> model\n");
>     return 1;
>   }
>   str = librdf_model_to_string(model, uri, "",
> "application/rss", 0);
>   if(!str) {
>     fprintf(stderr, "Failed to convert to string\n");
>     return 1 ;
>   }
>   //...
>   fprintf(stdout, "Resulting model is: %s\n", str);
>   return 0;
> }
> 
> Running the program above with parameter
> "http://scripts.gamespy.com/rss/gamespy.all.2.0.xml"
> results in "Failed to convert to string". But if we
> change the program to use instead
> "application/rdf+xml", it works.
>  
> I have also tried initializing storage with different
> options (mainly
> "hash-type='memory',new='yes',context='yes'") but it
> made no difference.
>  
> Is there anything I'm missing? Please help!

There is no standard mime type for RSS 1.0, but it works
if you use the serializer name:

   str = librdf_model_to_string(model, uri, "rss-1.0", NULL, 0);

Cheers

Dave



More information about the redland-dev mailing list