Why does the following test produce an error? Does Redland's turtle parser insist on a base URI even if all actual URIs are absolute? (Apache Jena apparently does not.) And how could I find out more about what actually went wrong (i.e. what API call would return an error description, or similar)?
librdf_world *world = librdf_new_world();
librdf_world_open(world);
librdf_storage *storage = librdf_new_storage(world, "memory", NULL, NULL);
librdf_model *model = librdf_new_model(world, storage, NULL);
librdf_parser* parser = librdf_new_parser(world, NULL, "text/turtle", NULL);
librdf_uri *baseUri = NULL;
const char *turtle = "<http://example.com/SomeSubject> <http://example.com/SomePredicate> <http://example.com/SomeObject> .";
int error = librdf_parser_parse_string_into_model(parser, (const unsigned char *)turtle, baseUri, model);
A base URI is required because the parser says so using
RAPTOR_SYNTAX_NEED_BASE_URI
flag. It produces the error before even looking at the content inraptor_parser_parse_start()
.If you know a real base URI is not needed, you can supply a dummy URI such as
.
instead:To enable better error reports, you should register a logger with
librdf_world_set_logger()
- the default logger just spits tostderr
. Return non-0 from the logger function to signal you handler the message yourself. Example:Running this will result in
(For a real program, add some cleanup etc.)