[redland] Silly questions
Dave Beckett
Dave.Beckett at bristol.ac.uk
Thu Dec 5 14:19:19 GMT 2002
>>>James Michael DuPont said:
> Silly question time:
> 1. how to use some features like datayped literals
>
> from the changelog :
> >>* Added support for RDF datatyped literals in RDF/XML with
> >>rdf:datatype attribute on property elements and
> >>N-Triples with "string"^^<datatypeURIref>.
That's from the entry about the support added to the Raptor parser,
not redland. As it happens, I've added datatyped literal stuff to
Redland too, in the CVS.
> How can I create such beasts in redland?
There is a new node constructor that allows you to created typed
literal nodes; the same as before but with an extra URI argument.
The autogenerated API refererence links to it already:
http://www.redland.opensource.ac.uk/docs/api/node.html
librdf_new_node_from_typed_literal -- Constructor - create a new typed literal librdf_node object
plus new methods:
librdf_node_get_literal_value_datatype_uri -- Get the typed literal datatype URI of the literal node
librdf_node_set_typed_literal_value -- Set the node typed literal value with options
so you'd use it something like:
xsd_int_uri=librdf_new_uri(world, "http://www.w3.org/2001/XMLSchema#int");
tnode=librdf_new_node_from_typed_literal (world, "10",
NULL /* no language */,
xsd_int_uri);
and then just use it anywhere you like.
I don't guarantee that's working just yet. Wait for a release.
> Also, I would like to give datatypes on resources themselves,
> right now i use more statements like this :
>
> here is the statement about its type:
> <./nodes/node-ids#id-2910>
> <http://purl.oclc.org/NET/introspector/2002/11/24/gcc/node_fields#type
> >
> <http://purl.oclc.org/NET/introspector/2002/11/24/gcc/node_types#array
> _type>
> .
>
> and here that it is a string_cst
> <./nodes/node-ids#id-2910>
> <http://purl.oclc.org/NET/introspector/2002/11/24/gcc/node_fields#stri
> ng>
> <./nodes/node-strings#dequeue_and_dump> .
>
> <./nodes/node-ids#id-2910>
> <http://purl.oclc.org/NET/introspector/2002/11/24/gcc/node_fields#tree
> -code>
> <http://purl.oclc.org/NET/introspector/2002/11/24/gcc/node_types#strin
> g_cst>
> .
> >>* Reorganised the source into separate modules - URI, xml parser,
> >>ntriples parser, XML namespaces, XML qnames, locator.
That's more of the raptor changelog documenting internal changes.
There are no public APIs to those modules of raptor.
> How can I make the uris use these? and reference a namespace,
> for example
> <?xml version="1.0"?>
> <RDF
> xmlns:gcc="http://purl.oclc.org/NET/introspector/2002/11/24/gcc/">
> </RDF>
>
> Right now I use two functions in redland :
> this is to create a local name :
> pobject= librdf_new_node_from_uri_local_name(di->pworld,
> pobject_base,
> pstring);
The above is how to use a 'namespace' (ie a URI) and a local name to
shorten the creation of URIs. There are no qnames in RDF.
> And this to create a literal :
> pobject= librdf_new_node_from_literal(di->pworld,
> pstring,
> NULL,
> 0); // create a new node
>
> Then the predicates are added in to a statement,
>
> I use for items in my file, this base uri,
> but this is referencing a local now, that is relative to the file
> pcurrent_uri =librdf_new_uri(di->pworld,"./nodes/node-ids#");
>
> how can I now define this "./nodes/node-ids#id-2"?
> if i create a file ./nodes/node-ids and put a node in there like
>
> -----------------------------
> plocal_uri =librdf_new_uri(di->pworld,"#");
That isn't a URI (technically). But redland only deals with absolute
URI references - that's what librdf_uri is about.
> pobject= librdf_new_node_from_uri_local_name(di->pworld,
> plocal_uri,
> pstring);
>
> would that be the best way to reference a local uri?
You can't do such "local URIs", RDF deals only with absolute ones.
Make them file: or some other scheme.
> Also, I would like to group all the data together into
> "Basic Abbreviated Syntax", is this possible?
You mean write a graph in RDF/XML? I've added a simple rdf/xml
serializer to redland that should be adequate for this. It doesn't
try to make it pretty.
> Oh yes one more issue :
> What about malloc/calloc, I have tried to rename them to xmalloc and
> xcalloc for cygwin, but still have problems. In the gcc under cygwin,
> the malloc is poisoned, in gentoo as well. I cannot link the redland
> to gcc on cygwin, and on gentoo right now. If I change that to
> xmalloc, it segfaults. Any ideas?
poisoned? What the heck is that about? If malloc doesn't work,
your system is really broken.
FYI, the current redland and raptor CVS work on:
OSX 10.2 ppc with gcc 3.1
Linux Redhat 7.3/Debian sid x86 with gcc2.95 / gcc3.1 / gcc.32
Solaris 8 sparc with sun cc
FreeBSD 4.7 x86 with gcc2.95 / gcc3.2
and others build raptor for win32 under cygwin.
Dave
More information about the redland-dev
mailing list