score:1
Accepted answer
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 in raptor_parser_parse_start()
.
if you know a real base uri is not needed, you can supply a dummy uri such as .
instead:
librdf_uri *baseuri = librdf_new_uri(world, (const unsigned char *)".");
to enable better error reports, you should register a logger with librdf_world_set_logger()
- the default logger just spits to stderr
. return non-0 from the logger function to signal you handler the message yourself. example:
#include <librdf.h>
int customlogger(void *user_data, librdf_log_message *message) {
fputs("mad custom logger: ", stderr);
fputs(message->message, stderr);
fputs("\n", stderr);
return 1;
}
int main() {
librdf_world *world = librdf_new_world();
librdf_world_set_logger(world, /*user_data=*/ 0, customlogger);
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);
}
running this will result in
mad custom logger: missing base uri for turtle parser
(for a real program, add some cleanup etc.)
Source: stackoverflow.com
Related Query
- Why does the compiler issue : warning: assignment makes integer from pointer without a cast
- Why does the compiler issue "warning: assignment makes integer from pointer without a cast"?
- In C, why does reading from a socket cause printw to give a segmentation fault?
- Why does a small, particular change in this loop's range cause such a massive change in execution time - from 15ms to infinity?
- Why does malloc(0) cause a major memory leak on Windows?
- Why does printing to stderr cause segmentation fault when dealing with ucontext?
- Why does the output comes after sleep without newline?
- Why does implicit casting from float to double return a nonsense number in my program?
- Why does 33791st prime (399137) cause Segmentation Fault?
- Why does optimization cause my loop to run indefinitely with an int iterator and stop condition at 2.7 billion?
- why does jpeg_decompress_create crash without error message?
- I expected the loop to copy null character or something but it copies the char from the beginning again. Why is that? How does this loop work?
- Why does my user-defined function work without a return statement?
- Why does a function print the value of a local auto variable from a function called earlier?
- Why does this use of fscanf cause the application to crash?
- Why does freeing a pointer cause program to abort?
- Why can't I send an int from java to C without waiting?
- why my x64 process base address not start from 0x400000?
- Why does printing from this struct give a segmentation fault?
- Why does adding a critical section cause a segmentation fault?
- Why does a high-value input prevent an array from using the actual input value in C?
- Why does this code beat rint() and how to I protect it from -ffast-math and friends?
- Why does reading from a pipe give garbage values?
- When scanning input from a file to a struct, and then saving the changes, why does it always write to the first line and erases everything else?
- Why does modifying a string literal cause a segmentation fault?
- Why does use of stdbool.h cause warning when combined with -Wtraditional-conversion
- What does "assignment makes pointer from integer without a cast" mean?
- Why does the returned array differ from the array that uses the return value in my program?
- Why does Dart FFI generate an opaque class from this C struct?
- Why does wc command in execvp() return the wrong results when taking input from a pipe in my shell?
More Query from same tag
- Parallel implementation of Gauss Elimination with pthreads
- python use ctypes to pass 2-d array into c function
- Cannot set GPIO pins in FT230X in Centos
- Segmentation fault (core dumped) in qt C++ command line code
- Force operating system to run a program with no other programs in the background
- C - OpenSSL encryption using CBC (Cipher Block Chaining) mode
- Sending Packet with VLAN tag using C Socket
- Refactoring with the ternary operator in C
- Trouble with mod C
- Missing array data in C
- Converting edgelist to compressed sparse row in C
- Error When Compiling a Simple C Program File in Windows 10 CMD Prompt Using MinGW (gcc: error: No such file or directory)
- Not getting an output for OpenGL to print line using mouse click
- How to tell the compiler to unroll this loop
- How do you correctly pass a pointer between calls with Python C-API
- passing a function vs calling a function
- How do on-disk databases handle file reading and writing on a file system level?
- Showing an image with SDL (Simple Directmedia Layer)
- How to modify values within an array sequentially
- C - Segfault when accessing member of non null pointer struct
- Programming in C: How to avoid Type mismatches (expected 'signed char ', given 'signed char*')
- Putting spaces in file directory string
- Reinterpretation of memory
- cJSON error while compiling and printing file
- Pointers are NULL after returning from a function
- how to predict the behaviour of a direct-mapped cache with alternating loads from two 512 byte arrays
- Binary Search Tree node insertion not working properly
- Porting Python/Matlab to C and to fixed-point DSP processor - should C be in fixed-point too?
- vectormath library and matrix operations
- Can't understand OpenMP sections