Skip to content

Instantly share code, notes, and snippets.

@njh
Created January 24, 2011 23:13
Show Gist options
  • Select an option

  • Save njh/794189 to your computer and use it in GitHub Desktop.

Select an option

Save njh/794189 to your computer and use it in GitHub Desktop.
diff --git a/src/rdf_serializer_raptor.c b/src/rdf_serializer_raptor.c
index 849e378..f41e4e8 100644
--- a/src/rdf_serializer_raptor.c
+++ b/src/rdf_serializer_raptor.c
@@ -169,7 +169,8 @@ librdf_serializer_raptor_set_namespace(void* context,
static int
librdf_serializer_raptor_serialize_statement(raptor_serializer *rserializer,
- librdf_statement* statement)
+ librdf_statement* statement,
+ librdf_node* graph)
{
int rc = 1;
raptor_statement rstatement;
@@ -224,7 +225,21 @@ librdf_serializer_raptor_serialize_statement(raptor_serializer *rserializer,
goto exit;
}
- rstatement.graph = NULL;
+ if (graph) {
+ if(librdf_node_is_blank(graph)) {
+ rstatement.graph = raptor_new_term_from_blank(raptor_serializer_get_world(rserializer),
+ librdf_node_get_blank_identifier(graph));
+ } else if(librdf_node_is_resource(subject)) {
+ rstatement.graph = raptor_new_term_from_uri(raptor_serializer_get_world(rserializer),
+ (raptor_uri*)librdf_node_get_uri(graph));
+ } else {
+ /* FIXME - what to log here if anything? */
+ goto exit;
+ }
+ } else {
+ rstatement.graph = NULL;
+ }
+
rc = raptor_serializer_serialize_statement(rserializer, &rstatement);
exit:
@@ -260,8 +275,9 @@ librdf_serializer_raptor_serialize_stream_to_file_handle(void *context,
rc=0;
while(!librdf_stream_end(stream)) {
librdf_statement *statement=librdf_stream_get_object(stream);
+ librdf_node *graph=librdf_stream_get_context2(stream);
rc=librdf_serializer_raptor_serialize_statement(scontext->rdf_serializer,
- statement);
+ statement, graph);
if(rc)
break;
librdf_stream_next(stream);
@@ -334,8 +350,9 @@ librdf_serializer_raptor_serialize_stream_to_counted_string(void *context,
rc=0;
while(!librdf_stream_end(stream)) {
librdf_statement *statement=librdf_stream_get_object(stream);
+ librdf_node *graph=librdf_stream_get_context2(stream);
rc=librdf_serializer_raptor_serialize_statement(scontext->rdf_serializer,
- statement);
+ statement, graph);
if(rc)
break;
librdf_stream_next(stream);
@@ -412,8 +429,9 @@ librdf_serializer_raptor_serialize_stream_to_iostream(void *context,
rc=0;
while(!librdf_stream_end(stream)) {
librdf_statement *statement=librdf_stream_get_object(stream);
+ librdf_node *graph=librdf_stream_get_context2(stream);
rc=librdf_serializer_raptor_serialize_statement(scontext->rdf_serializer,
- statement);
+ statement, graph);
if(rc)
break;
librdf_stream_next(stream);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment