Declare namespaces

Raptor can use namespace prefix/URIs to abbreviate syntax in some syntaxes such as Turtle or any XML syntax including RDF/XML, RSS1.0 and Atom 1.0. These are declared with raptor_serializer_set_namespace() using a prefix and URI argument pair like this:

  const unsigned char* prefix = "ex";
  raptor_uri* uri = raptor_new_uri(world, "");

  raptor_serializer_set_namespace(rdf_serializer, prefix, uri);

or raptor_serializer_set_namespace_from_namespace() from an existing namespace. This can be useful when connected up the the namespace declarations that are generated from a parser via a namespace handler set with raptor_parser_set_namespace_handler()

like this:
  static void
  relay_namespaces(void* user_data, raptor_namespace *nspace)
    raptor_serializer_set_namespace_from_namespace(rdf_serializer, nspace);


  rdf_parser = raptor_new_parser(world, syntax_name);
  raptor_parser_set_namespace_handler(rdf_parser, rdf_serializer, relay_namespaces);

Navigation: Redland Home Page

Copyright 2000-2014 Dave Beckett