[redland-dev] Questions about Reland
Dave Beckett
dave.beckett at bristol.ac.uk
Sun Jul 6 12:08:45 BST 2003
On Tue, 01 Jul 2003 08:50:30 +0000
Alessandro Moro <alessandromoro at hotmail.com> wrote:
> Hi,
>
> I have a couple of question about Redland.
>
> In the section API reference the function
> librdf_parser_raptor_parse_uri_into_model is documented .This fuction should
> Retrieve the RDF/XML content at URI and store it into a librdf_model. I
> serched the prototype of the function with a grep command but I didn' t find
> it.
> How can I use this function? Is there another way to retrieve the RDF/XML
> content from an URL?
That's an internal API on the implementation class of the parser interface,
for the parser called raptor.
The way to use parsing is to use the methods on the parser class:
librdf_parser_parse_into_model
librdf_parser_parse_as_stream
They either write directly into the model or give you a stream of
librdf_statement (triple) objects.
> In the example 4 the function libref_parser_parse_into_model is used: it
> works wery well with files (i.e. file:/Service.daml), but doesn' t seem to
> work with URLs (i.e. http://www.daml.org/services/daml-s/0.9/Service.daml).
URL support requires a library that does the URL retrieval. This is made
available when you have either of libxml2 or libcurl available. Only
then will redland do the URL retrieval and it should work. Otherwise
you'll need to explain a bit more about "doesn't seem to work with URLs".
The examples such as example/example4.c and nearby should give you
working code that shows how to do this.
> The second question regards the posibility to add the RDF/XML content of a
> file/URL to an existing database. In the example 4 I removed the option
> new='yes' from the option string of the function librdf_new_storage, and it
> works well. THe problem is that if I parse twice the same file, I have the
> same statements repeated twice in the database. Is there a way to add the
> XML/RDF content of a file/URL to an existing database, avoiding repetition
> of statements already in the database?
Redland allows duplicate statements in a graph, so parsing the same file
twice or different files with the same statements, will give them duplicated.
You might like to use contexts to track file/statements or some other
application level logic - if you've seen the URL before, don't parse it!
Dave
More information about the redland-dev
mailing list