Synopsis
#include <liblod.h>
LODINSTANCE *
lod_resolve
(LODCONTEXT *context
, const char *uri
);
Description
lod_resolve
attempts to
resolve a Linked Open Data URI: that is,
perform one or more HTTP requests in order to obtain data describing
the subject identified by uri
.
In contrast to lod_fetch
(which will attempt
a network fetch regardless of the existing contents of the context’s
model), and lod_locate
(which will never attempt
a network fetch), the behaviour of lod_resolve
is conditional depending upon whether uri
is
the subject of a triple within the context’s model.
If such a triple is present, lod_resolve
behaves
as lod_locate
, returning an instance whose subject
is uri
.
If no such triple could be found, lod_resolve
behaves as though lod_fetch
had been called
instead.
Return value
Upon success, lod_resolve
returns a new
LODINSTANCE
, which should be later freed using
lod_instance_destroy
.
If an error occurs, or uri
was not
a subject of any triple in the data after the fetch completes,
lod_resolve
returns NULL
.
Use lod_error
to determine whether an error
occurred, or whether the subject does not exist in the data. If an
error does occur, you can use lod_errmsg
to
obtain a description of the error condition.
Example
LODCONTEXT *ctx;
LODINSTANCE *inst;
ctx = lod_create();
inst = lod_resolve(ctx, "http://www.dbpedialite.org/things/22308#id");
if(!inst)
{
if(lod_error(ctx))
{
/* An error occurred */
}
else
{
/* No error, but the subject wasn't present */
}
}
else
{
/* Triples found */
lod_instance_destroy(inst);
}
lod_destroy(ctx);
See also
liblod, lod_create, lod_error, lod_errmsg, lod_locate, lod_fetch, lod_instance_destroy, lod_instance_stream, librdf_parser_create.