[redland-dev] Setting namespace for rdf triples

Lauri Aalto laalto at gmail.com
Wed Dec 3 22:32:33 CET 2008


Hi,

On Wed, Dec 3, 2008 at 9:55 PM, Marius Erdt <marius.erdt at gmx.de> wrote:
>       predicate = librdf_new_node_from_uri_string(world, (const
> unsigned char*) ":type" ),

You probably want the full uri
"http://www.w3.org/1999/02/22-rdf-syntax-ns#type" here instead of just
":type". librdf_new_node_from_uri_string() knows nothing about uri
prefixes. librdf_new_uri_from_uri_local_name() is the function you
would use for prefixed uris but even then you need the librdf_uri
object for the prefix part.

The rdf:type uri is also pre-defined by the rdf_concepts module. You
can access it with librdf_get_concept_uri_by_index(world,
LIBRDF_MS_type).

When serializing, you can declare any namespace prefixes you want in
the serializer object using librdf_serializer_set_namespace(). For
most serializers including rdfxml, the "rdf" namespace prefix is
already declared to "http://www.w3.org/1999/02/22-rdf-syntax-ns#". For
undeclared namespaces, the rdfxml serializer will use namespaces ns0,
ns1, ns2... for turning predicate uris into XML tag names.

Lauri


More information about the redland-dev mailing list