int rdfa_parse_start(rdfacontext* context) { /* create the buffers and expat parser */ int rval = RDFA_PARSE_SUCCESS; context->wb_allocated = sizeof(char) * READ_BUFFER_SIZE; /* +1 for NUL at end, to allow strstr() etc. to work * malloc - only the first char needs to be NUL */ context->working_buffer = (char*)malloc(context->wb_allocated + 1); *context->working_buffer = '\0'; context->done = 0; context->context_stack = rdfa_create_list(32); /* initialize the context stack */ rdfa_push_item(context->context_stack, context, RDFALIST_FLAG_CONTEXT); #ifdef LIBRDFA_IN_RAPTOR context->sax2 = raptor_new_sax2(context->world, context->locator, context); #else /* init libxml2 */ xmlInitParser(); #endif /* set up the context stack */ #ifdef LIBRDFA_IN_RAPTOR raptor_sax2_set_start_element_handler(context->sax2, raptor_rdfa_start_element); raptor_sax2_set_end_element_handler(context->sax2, raptor_rdfa_end_element); raptor_sax2_set_characters_handler(context->sax2, raptor_rdfa_character_data); raptor_sax2_set_namespace_handler(context->sax2, raptor_rdfa_namespace_handler); #endif rdfa_init_context(context); #ifdef LIBRDFA_IN_RAPTOR context->base_uri = raptor_new_uri(context->sax2->world, (const unsigned char*)context->base); raptor_sax2_parse_start(context->sax2, context->base_uri); #endif return rval; }
/* * rasqal_query_results_getrowsource_sparql_xml: * @world: rasqal world object * @iostr: #raptor_iostream to read the query results from * @base_uri: #raptor_uri base URI of the input format * * Read the fourth version of the SPARQL XML query results format from an * iostream in a format returning a rwosurce - INTERNAL. * * Return value: a new rasqal_rowsource or NULL on failure **/ static rasqal_rowsource* rasqal_query_results_get_rowsource_sparql_xml(rasqal_query_results_formatter* formatter, rasqal_world *world, rasqal_variables_table* vars_table, raptor_iostream *iostr, raptor_uri *base_uri) { rasqal_rowsource_sparql_xml_context* con; con=(rasqal_rowsource_sparql_xml_context*)RASQAL_CALLOC(rasqal_rowsource_sparql_xml_context, 1, sizeof(rasqal_rowsource_sparql_xml_context)); if(!con) return NULL; con->world=world; con->base_uri = base_uri ? raptor_uri_copy(base_uri) : NULL; con->iostr=iostr; con->locator.uri=base_uri; con->sax2 = raptor_new_sax2(world->raptor_world_ptr, &con->locator, con); if(!con->sax2) return NULL; raptor_sax2_set_start_element_handler(con->sax2, rasqal_sparql_xml_sax2_start_element_handler); raptor_sax2_set_characters_handler(con->sax2, rasqal_sparql_xml_sax2_characters_handler); raptor_sax2_set_end_element_handler(con->sax2, rasqal_sparql_xml_sax2_end_element_handler); con->results_sequence = raptor_new_sequence((raptor_data_free_handler)rasqal_free_row, (raptor_data_print_handler)rasqal_row_print); con->vars_table = rasqal_new_variables_table_from_variables_table(vars_table); return rasqal_new_rowsource_from_handler(world, NULL, con, &rasqal_rowsource_sparql_xml_handler, con->vars_table, 0); }