1 #include <stdio.h> 2 #include <raptor.h> 3 #include <stdlib.h> 4 5 /* rdfserialize.c: serialize 1 triple to RDF/XML-Abbrev */ 6 7 int main(int argc,char * argv[])8main(int argc, char *argv[]) 9 { 10 raptor_serializer* rdf_serializer=NULL; 11 unsigned char *uri_string; 12 raptor_uri *base_uri; 13 raptor_statement* triple; 14 15 raptor_init(); 16 17 uri_string=raptor_uri_filename_to_uri_string(argv[1]); 18 base_uri=raptor_new_uri(uri_string); 19 20 rdf_serializer=raptor_new_serializer("rdfxml-abbrev"); 21 raptor_serialize_start_to_file_handle(rdf_serializer, base_uri, stdout); 22 23 /* Make a triple with URI subject, URI predicate, literal object */ 24 triple=(raptor_statement*)calloc(1, sizeof(raptor_statement)); 25 triple->subject=(void*)raptor_new_uri((const unsigned char*)"http://example.org/subject"); 26 triple->subject_type=RAPTOR_IDENTIFIER_TYPE_RESOURCE; 27 triple->predicate=(void*)raptor_new_uri((const unsigned char*)"http://example.org/predicate"); 28 triple->predicate_type=RAPTOR_IDENTIFIER_TYPE_RESOURCE; 29 triple->object="An example literal"; 30 triple->object_type=RAPTOR_IDENTIFIER_TYPE_LITERAL; 31 triple->object_literal_language=(const unsigned char*)"en"; 32 33 /* Write the triple */ 34 raptor_serialize_statement(rdf_serializer, triple); 35 36 /* Delete the triple */ 37 raptor_free_uri((raptor_uri*)triple->subject); 38 raptor_free_uri((raptor_uri*)triple->predicate); 39 free(triple); 40 41 raptor_serialize_end(rdf_serializer); 42 raptor_free_serializer(rdf_serializer); 43 44 raptor_free_uri(base_uri); 45 raptor_free_memory(uri_string); 46 47 raptor_finish(); 48 return 0; 49 } 50