From 65ba48bced126ed278c706bdcbc29a6ceff3abd2 Mon Sep 17 00:00:00 2001 From: Dave Beckett Date: Wed, 6 Jan 2010 18:04:06 -0800 Subject: raptor_identifier_type loses the RAPTOR_IDENTIFIER_TYPE_ORDINAL value. raptor_identifier loses ordinal field. Consequent removal of RAPTOR_IDENTIFIER_TYPE_ORDINAL from cases especially handling predicates. (raptor_rdfxml_end_element_grammar, raptor_rdfxml_generate_statement, raptor_rdfxml_process_property_attributes, raptor_rdfxml_serialize_statement): Most changes were made here to generate a URI instead of the ordinal integers from the various rdf:li element forms. Multiple serializers are now simpler in not having to check for predicate (or even subject/object) ordinals. Several if ordinal {ordinal handling } .. else {uri handling} were removed. rdfdiff lost several checks for ordinal/resource alternatives. (rdfdiff_ordinal_equals_resource): Deleted. --- src/raptor.h | 4 -- src/raptor_abbrev.c | 20 +-------- src/raptor_identifier.c | 3 -- src/raptor_rdfxml.c | 71 ++++++++++++------------------- src/raptor_serialize_dot.c | 13 +----- src/raptor_serialize_json.c | 4 -- src/raptor_serialize_ntriples.c | 9 ---- src/raptor_serialize_rdfxml.c | 51 +++++++---------------- src/raptor_serialize_rdfxmla.c | 76 +++++----------------------------- src/raptor_serialize_rss.c | 15 ++++--- src/raptor_serialize_simple.c | 18 ++------ src/raptor_serialize_turtle.c | 66 ++--------------------------- src/raptor_statement.c | 43 +++---------------- utils/rdfdiff.c | 92 ++++++++--------------------------------- 14 files changed, 95 insertions(+), 390 deletions(-) diff --git a/src/raptor.h b/src/raptor.h index b8b5497e..4f884812 100644 --- a/src/raptor.h +++ b/src/raptor.h @@ -233,7 +233,6 @@ typedef struct raptor_sax2_s raptor_sax2; * raptor_identifier_type: * @RAPTOR_IDENTIFIER_TYPE_RESOURCE: Resource URI (e.g. rdf:about) * @RAPTOR_IDENTIFIER_TYPE_ANONYMOUS: _:foo N-Triples, or generated - * @RAPTOR_IDENTIFIER_TYPE_ORDINAL: rdf:li, rdf:_n. No longer generated in any parser in Raptor 1.4.10+, instead a #RAPTOR_IDENTIFIER_TYPE_RESOURCE is returned. * @RAPTOR_IDENTIFIER_TYPE_LITERAL: regular literal * @RAPTOR_IDENTIFIER_TYPE_XML_LITERAL: rdf:parseType="Literal". No longer generated by any parser in Raptor 1.4.8+, instead a #RAPTOR_IDENTIFIER_TYPE_LITERAL is returned with a datatype of rdf:XMLLiteral. * @RAPTOR_IDENTIFIER_TYPE_UNKNOWN: Internal @@ -245,7 +244,6 @@ typedef enum { RAPTOR_IDENTIFIER_TYPE_UNKNOWN, RAPTOR_IDENTIFIER_TYPE_RESOURCE, RAPTOR_IDENTIFIER_TYPE_ANONYMOUS, - RAPTOR_IDENTIFIER_TYPE_ORDINAL, RAPTOR_IDENTIFIER_TYPE_LITERAL, RAPTOR_IDENTIFIER_TYPE_XML_LITERAL } raptor_identifier_type; @@ -426,7 +424,6 @@ typedef enum { * @uri: URI of identifier for types %RAPTOR_IDENTIFIER_TYPE_RESOURCE * @uri_source: where the identifier (URI or blank node) came from * @id: blank node identifier for type %RAPTOR_IDENTIFIER_TYPE_ANONYMOUS - * @ordinal: integer ordinal for type %RAPTOR_IDENTIFIER_TYPE_ORDINAL * @is_malloced: internal * @literal: literal string for types %RAPTOR_IDENTIFIER_TYPE_LITERAL and * %RAPTOR_IDENTIFIER_TYPE_XML_LITERAL @@ -442,7 +439,6 @@ typedef struct { raptor_identifier_type type; raptor_uri *uri; const unsigned char *id; - int ordinal; int is_malloced; const unsigned char *literal; raptor_uri *literal_datatype; diff --git a/src/raptor_abbrev.c b/src/raptor_abbrev.c index 861d8fcc..d56b6f05 100644 --- a/src/raptor_abbrev.c +++ b/src/raptor_abbrev.c @@ -90,10 +90,6 @@ raptor_new_abbrev_node(raptor_world* world, node->value.blank.string = string; break; - case RAPTOR_IDENTIFIER_TYPE_ORDINAL: - node->value.ordinal.ordinal = *(int *)node_data; - break; - case RAPTOR_IDENTIFIER_TYPE_LITERAL: case RAPTOR_IDENTIFIER_TYPE_XML_LITERAL: string = (unsigned char*)RAPTOR_MALLOC(literal, @@ -165,7 +161,6 @@ raptor_free_abbrev_node(raptor_abbrev_node* node) break; - case RAPTOR_IDENTIFIER_TYPE_ORDINAL: case RAPTOR_IDENTIFIER_TYPE_UNKNOWN: default: /* Nothing to do */ @@ -265,16 +260,6 @@ raptor_abbrev_node_cmp(raptor_abbrev_node* node1, raptor_abbrev_node* node2) break; - case RAPTOR_IDENTIFIER_TYPE_ORDINAL: - if(node1->value.ordinal.ordinal == node2->value.ordinal.ordinal) - rv = 0; - else if(node1->value.ordinal.ordinal < node2->value.ordinal.ordinal) - rv = -1; - else - rv = 1; - - break; - case RAPTOR_IDENTIFIER_TYPE_UNKNOWN: default: /* Nothing to do */ @@ -427,9 +412,8 @@ raptor_new_abbrev_subject(raptor_abbrev_node* node) raptor_abbrev_subject* subject; if(!(node->type == RAPTOR_IDENTIFIER_TYPE_RESOURCE || - node->type == RAPTOR_IDENTIFIER_TYPE_ANONYMOUS || - node->type == RAPTOR_IDENTIFIER_TYPE_ORDINAL)) { - RAPTOR_FATAL1("Subject node must be a resource, blank, or ordinal\n"); + node->type == RAPTOR_IDENTIFIER_TYPE_ANONYMOUS)) { + RAPTOR_FATAL1("Subject node must be a resource or blank\n"); return NULL; } diff --git a/src/raptor_identifier.c b/src/raptor_identifier.c index e8b3348e..4ae546fb 100644 --- a/src/raptor_identifier.c +++ b/src/raptor_identifier.c @@ -123,7 +123,6 @@ raptor_copy_identifier(raptor_identifier *dest, raptor_identifier *src) dest->world = src->world; dest->type = src->type; - dest->ordinal = src->ordinal; dest->uri = raptor_uri_copy_v2(src->world, src->uri); @@ -237,8 +236,6 @@ raptor_identifier_print(FILE *stream, raptor_identifier *identifier) fputc('>', stream); } else if(identifier->type == RAPTOR_IDENTIFIER_TYPE_ANONYMOUS) fputs((const char*)identifier->id, stream); - else if(identifier->type == RAPTOR_IDENTIFIER_TYPE_ORDINAL) - fprintf(stream, "[rdf:_%d]", identifier->ordinal); else { fprintf(stream, "%s", raptor_uri_as_string_v2(identifier->world, identifier->uri)); } diff --git a/src/raptor_rdfxml.c b/src/raptor_rdfxml.c index c09c64e9..01b4395b 100644 --- a/src/raptor_rdfxml.c +++ b/src/raptor_rdfxml.c @@ -1303,13 +1303,6 @@ raptor_rdfxml_generate_statement(raptor_parser *rdf_parser, statement->subject.type = subject_type; statement->predicate.type = RAPTOR_IDENTIFIER_TYPE_RESOURCE; - if(predicate_type == RAPTOR_IDENTIFIER_TYPE_ORDINAL) { - /* new URI object */ - uri1 = raptor_new_uri_from_rdf_ordinal(rdf_parser->world, predicate_ordinal); - predicate_uri = uri1; - predicate_id = NULL; - predicate_type = RAPTOR_IDENTIFIER_TYPE_RESOURCE; - } statement->predicate.value = predicate_uri; statement->object.value = object_uri ? (void*)object_uri : (void*)object_id; @@ -1508,16 +1501,16 @@ raptor_rdfxml_process_property_attributes(raptor_parser *rdf_parser, */ if(attr->nspace->is_rdf_ms) { /* is rdf: namespace */ - int ordinal = 0; if(*name == '_') { + int ordinal; + /* recognise rdf:_ */ name++; ordinal = raptor_check_ordinal(name); if(ordinal < 1) { raptor_rdfxml_update_document_locator(rdf_parser); raptor_parser_error(rdf_parser, "Illegal ordinal value %d in property attribute '%s' seen on containing element '%s'.", ordinal, attr->local_name, name); - ordinal = 1; } } else { raptor_rdfxml_update_document_locator(rdf_parser); @@ -1528,28 +1521,6 @@ raptor_rdfxml_process_property_attributes(raptor_parser *rdf_parser, name); } - if(ordinal >= 1) { - /* Generate an ordinal property when there are no problems */ - raptor_rdfxml_generate_statement(rdf_parser, - resource_identifier->uri, - resource_identifier->id, - resource_identifier->type, - - NULL, - NULL, - RAPTOR_IDENTIFIER_TYPE_ORDINAL, - ordinal, - - (raptor_uri*)value, - NULL, - RAPTOR_IDENTIFIER_TYPE_LITERAL, - NULL, - - NULL, /* Property attributes are never reified*/ - resource_element); - handled = 1; - } - } /* end is RDF namespace property */ @@ -2450,16 +2421,20 @@ raptor_rdfxml_end_element_grammar(raptor_parser *rdf_parser, /* Handle rdf:li as the rdf:parseType="resource" property */ if(element_in_rdf_ns && raptor_uri_equals_v2(rdf_parser->world, raptor_xml_element_get_name(xml_element)->uri, RAPTOR_RDF_li_URI(rdf_xml_parser))) { + raptor_uri* ordinal_predicate_uri; + element->parent->last_ordinal++; + ordinal_predicate_uri = raptor_new_uri_from_rdf_ordinal(rdf_parser->world, element->parent->last_ordinal); + raptor_rdfxml_generate_statement(rdf_parser, element->parent->subject.uri, element->parent->subject.id, element->parent->subject.type, + ordinal_predicate_uri, NULL, - NULL, - RAPTOR_IDENTIFIER_TYPE_ORDINAL, - element->parent->last_ordinal, + RAPTOR_IDENTIFIER_TYPE_RESOURCE, + 0, element->subject.uri, element->subject.id, @@ -2468,6 +2443,7 @@ raptor_rdfxml_end_element_grammar(raptor_parser *rdf_parser, &element->reified, element->parent); + raptor_free_uri_v2(rdf_parser->world, ordinal_predicate_uri); } else { raptor_rdfxml_generate_statement(rdf_parser, element->parent->subject.uri, @@ -2695,8 +2671,7 @@ raptor_rdfxml_end_element_grammar(raptor_parser *rdf_parser, */ if(1) { raptor_uri *predicate_uri = NULL; - raptor_identifier_type predicate_type; - int predicate_ordinal = 0; + int predicate_ordinal = -1; raptor_uri *object_uri; raptor_identifier_type object_type; raptor_uri *literal_datatype = NULL; @@ -2705,11 +2680,11 @@ raptor_rdfxml_end_element_grammar(raptor_parser *rdf_parser, if(state == RAPTOR_STATE_MEMBER_PROPERTYELT) { element->parent->last_ordinal++; predicate_ordinal = element->parent->last_ordinal; - predicate_type = RAPTOR_IDENTIFIER_TYPE_ORDINAL; + + predicate_uri = raptor_new_uri_from_rdf_ordinal(rdf_parser->world, predicate_ordinal); } else { predicate_uri = raptor_xml_element_get_name(xml_element)->uri; - predicate_type = RAPTOR_IDENTIFIER_TYPE_RESOURCE; } @@ -2747,8 +2722,8 @@ raptor_rdfxml_end_element_grammar(raptor_parser *rdf_parser, predicate_uri, NULL, - predicate_type, - predicate_ordinal, + RAPTOR_IDENTIFIER_TYPE_RESOURCE, + 0, object_uri, element->object.id, @@ -2757,7 +2732,9 @@ raptor_rdfxml_end_element_grammar(raptor_parser *rdf_parser, &element->reified, element->parent); - + + if(predicate_ordinal >= 0) + raptor_free_uri_v2(rdf_parser->world, predicate_uri); } break; @@ -2792,16 +2769,20 @@ raptor_rdfxml_end_element_grammar(raptor_parser *rdf_parser, if(state == RAPTOR_STATE_MEMBER_PROPERTYELT) { + raptor_uri* predicate_uri; + element->parent->last_ordinal++; + predicate_uri = raptor_new_uri_from_rdf_ordinal(rdf_parser->world, element->parent->last_ordinal); + raptor_rdfxml_generate_statement(rdf_parser, element->parent->subject.uri, element->parent->subject.id, element->parent->subject.type, + predicate_uri, NULL, - NULL, - RAPTOR_IDENTIFIER_TYPE_ORDINAL, - element->parent->last_ordinal, + RAPTOR_IDENTIFIER_TYPE_RESOURCE, + 0, (raptor_uri*)buffer, NULL, @@ -2810,6 +2791,8 @@ raptor_rdfxml_end_element_grammar(raptor_parser *rdf_parser, &element->reified, element->parent); + + raptor_free_uri_v2(rdf_parser->world, predicate_uri); } else { raptor_rdfxml_generate_statement(rdf_parser, element->parent->subject.uri, diff --git a/src/raptor_serialize_dot.c b/src/raptor_serialize_dot.c index de40abc9..0fccd6c7 100644 --- a/src/raptor_serialize_dot.c +++ b/src/raptor_serialize_dot.c @@ -108,7 +108,6 @@ raptor_dot_serializer_free_node(raptor_dot_serializer_node *node) break; - case RAPTOR_IDENTIFIER_TYPE_ORDINAL: case RAPTOR_IDENTIFIER_TYPE_UNKNOWN: default: /* Nothing to do */ @@ -123,8 +122,7 @@ raptor_dot_serializer_free_node(raptor_dot_serializer_node *node) * raptor_dot_serializer_node_matches: * @node: #raptor_node to compare * @node_type: Raptor identifier type - * @node_data: For node_type RAPTOR_IDENTIFIER_TYPE_ORDINAL, int* to the - * ordinal. + * @node_data: node URI or literal string * @datatype: Literal datatype or NULL * @language: Literal language or NULL * @@ -186,7 +184,6 @@ raptor_dot_serializer_node_matches(raptor_dot_serializer_node* node, break; - case RAPTOR_IDENTIFIER_TYPE_ORDINAL: case RAPTOR_IDENTIFIER_TYPE_UNKNOWN: default: /* Nothing to do */ @@ -201,8 +198,7 @@ raptor_dot_serializer_node_matches(raptor_dot_serializer_node* node, * raptor_dot_serializer_new_node implementation: * @world: raptor_world object * @node_type: Raptor identifier type - * @node_data: For node_type RAPTOR_IDENTIFIER_TYPE_ORDINAL, int* to the - * ordinal. + * @node_data: node URI or literal string. * @datatype: Literal datatype or NULL * @language: Literal language or NULL * @@ -261,7 +257,6 @@ raptor_dot_serializer_new_node(raptor_world* world, } break; - case RAPTOR_IDENTIFIER_TYPE_ORDINAL: case RAPTOR_IDENTIFIER_TYPE_UNKNOWN: default: RAPTOR_FREE(raptor_dot_serializer_node, node); @@ -403,7 +398,6 @@ raptor_dot_serializer_write_node_type(raptor_serializer * serializer, raptor_iostream_write_byte(serializer->iostream, 'R'); break; - case RAPTOR_IDENTIFIER_TYPE_ORDINAL: case RAPTOR_IDENTIFIER_TYPE_UNKNOWN: raptor_iostream_write_byte(serializer->iostream, '?'); break; @@ -481,7 +475,6 @@ raptor_dot_serializer_write_node(raptor_serializer * serializer, raptor_dot_serializer_write_uri(serializer, (raptor_uri*)term); break; - case RAPTOR_IDENTIFIER_TYPE_ORDINAL: case RAPTOR_IDENTIFIER_TYPE_UNKNOWN: default: RAPTOR_FATAL2("Unknown type %d", type); @@ -519,7 +512,6 @@ raptor_dot_serializer_assert_node(raptor_serializer* serializer, break; case RAPTOR_IDENTIFIER_TYPE_UNKNOWN: - case RAPTOR_IDENTIFIER_TYPE_ORDINAL: break; } @@ -613,7 +605,6 @@ raptor_dot_serializer_write_colors(raptor_serializer* serializer, break; - case RAPTOR_IDENTIFIER_TYPE_ORDINAL: case RAPTOR_IDENTIFIER_TYPE_XML_LITERAL: case RAPTOR_IDENTIFIER_TYPE_UNKNOWN: default: diff --git a/src/raptor_serialize_json.c b/src/raptor_serialize_json.c index 1dbdd5ba..c7426d90 100644 --- a/src/raptor_serialize_json.c +++ b/src/raptor_serialize_json.c @@ -202,7 +202,6 @@ raptor_json_serialize_statement(raptor_serializer* serializer, case RAPTOR_IDENTIFIER_TYPE_LITERAL: case RAPTOR_IDENTIFIER_TYPE_XML_LITERAL: - case RAPTOR_IDENTIFIER_TYPE_ORDINAL: case RAPTOR_IDENTIFIER_TYPE_UNKNOWN: default: RAPTOR_FATAL1("Unsupported identifier type\n"); @@ -242,7 +241,6 @@ raptor_json_serialize_statement(raptor_serializer* serializer, (const char*)statement->object.value); break; - case RAPTOR_IDENTIFIER_TYPE_ORDINAL: case RAPTOR_IDENTIFIER_TYPE_UNKNOWN: default: RAPTOR_FATAL1("Unsupported identifier type\n"); @@ -328,7 +326,6 @@ raptor_json_serialize_avltree_visit(int depth, void* data, void *user_data) case RAPTOR_IDENTIFIER_TYPE_LITERAL: case RAPTOR_IDENTIFIER_TYPE_XML_LITERAL: - case RAPTOR_IDENTIFIER_TYPE_ORDINAL: case RAPTOR_IDENTIFIER_TYPE_UNKNOWN: default: RAPTOR_FATAL2("Unsupported statement subject identifier type %d\n", @@ -402,7 +399,6 @@ raptor_json_serialize_avltree_visit(int depth, void* data, void *user_data) raptor_json_writer_newline(context->json_writer); break; - case RAPTOR_IDENTIFIER_TYPE_ORDINAL: case RAPTOR_IDENTIFIER_TYPE_UNKNOWN: default: RAPTOR_FATAL2("Unsupported statement object identifier type %d\n", diff --git a/src/raptor_serialize_ntriples.c b/src/raptor_serialize_ntriples.c index b1d2dfdf..b5ab11ae 100644 --- a/src/raptor_serialize_ntriples.c +++ b/src/raptor_serialize_ntriples.c @@ -152,15 +152,6 @@ raptor_iostream_write_statement_part_ntriples(raptor_world* world, raptor_iostream_write_string(iostr, term); break; - case RAPTOR_IDENTIFIER_TYPE_ORDINAL: - raptor_iostream_write_counted_string(iostr, "<_", 1); - raptor_iostream_write_counted_string(iostr, raptor_rdf_namespace_uri, - raptor_rdf_namespace_uri_len); - raptor_iostream_write_counted_string(iostr, "_", 1); - raptor_iostream_write_decimal(iostr, *((int*)term)); - raptor_iostream_write_byte(iostr, '>'); - break; - case RAPTOR_IDENTIFIER_TYPE_RESOURCE: raptor_iostream_write_byte(iostr, '<'); term = raptor_uri_as_counted_string_v2(world, (raptor_uri*)term, &len); diff --git a/src/raptor_serialize_rdfxml.c b/src/raptor_serialize_rdfxml.c index abfdccdf..a5357757 100644 --- a/src/raptor_serialize_rdfxml.c +++ b/src/raptor_serialize_rdfxml.c @@ -350,7 +350,6 @@ raptor_rdfxml_serialize_statement(raptor_serializer* serializer, raptor_rdfxml_serializer_context* context = (raptor_rdfxml_serializer_context*)serializer->context; raptor_xml_writer* xml_writer = context->xml_writer; unsigned char* uri_string = NULL; /* predicate URI */ - unsigned char ordinal_name[20]; unsigned char* name = NULL; /* where to split predicate name */ unsigned char* subject_uri_string = NULL; unsigned char* object_uri_string = NULL; @@ -372,11 +371,7 @@ raptor_rdfxml_serialize_statement(raptor_serializer* serializer, if(raptor_rdfxml_ensure_writen_header(serializer, context)) return 1; - if(statement->predicate.type == RAPTOR_IDENTIFIER_TYPE_ORDINAL) { - predicate_ns = context->rdf_nspace; - sprintf((char*)ordinal_name, "_%d", *((int*)statement->predicate.value)); - name = ordinal_name; - } else if(statement->predicate.type == RAPTOR_IDENTIFIER_TYPE_RESOURCE) { + if(statement->predicate.type == RAPTOR_IDENTIFIER_TYPE_RESOURCE) { unsigned char *p; size_t uri_len; size_t name_len = 1; @@ -455,25 +450,16 @@ raptor_rdfxml_serialize_statement(raptor_serializer* serializer, break; case RAPTOR_IDENTIFIER_TYPE_RESOURCE: - case RAPTOR_IDENTIFIER_TYPE_ORDINAL: allocated = 1; - if(statement->subject.type == RAPTOR_IDENTIFIER_TYPE_ORDINAL) { - subject_uri_string = (unsigned char*)RAPTOR_MALLOC(cstring, raptor_rdf_namespace_uri_len+13); + if(serializer->feature_relative_uris) { + subject_uri_string = raptor_uri_to_relative_uri_string_v2(serializer->world, + serializer->base_uri, + (raptor_uri*)statement->subject.value); if(!subject_uri_string) goto oom; - sprintf((char*)subject_uri_string, "%s_%d", - raptor_rdf_namespace_uri, *((int*)statement->subject.value)); } else { - if(serializer->feature_relative_uris) { - subject_uri_string = raptor_uri_to_relative_uri_string_v2(serializer->world, - serializer->base_uri, - (raptor_uri*)statement->subject.value); - if(!subject_uri_string) - goto oom; - } else { - subject_uri_string = raptor_uri_as_string_v2(serializer->world, (raptor_uri*)statement->subject.value); - allocated = 0; - } + subject_uri_string = raptor_uri_as_string_v2(serializer->world, (raptor_uri*)statement->subject.value); + allocated = 0; } attrs[attrs_count] = raptor_new_qname_from_namespace_local_name_v2(serializer->world, context->rdf_nspace, (const unsigned char*)"about", subject_uri_string); @@ -605,26 +591,17 @@ raptor_rdfxml_serialize_statement(raptor_serializer* serializer, break; case RAPTOR_IDENTIFIER_TYPE_RESOURCE: - case RAPTOR_IDENTIFIER_TYPE_ORDINAL: allocated = 1; - if(object_type == RAPTOR_IDENTIFIER_TYPE_ORDINAL) { - object_uri_string = (unsigned char*)RAPTOR_MALLOC(cstring, raptor_rdf_namespace_uri_len+13); + /* must be URI */ + if(serializer->feature_relative_uris) { + object_uri_string = raptor_uri_to_relative_uri_string_v2(serializer->world, + serializer->base_uri, + (raptor_uri*)statement->object.value); if(!object_uri_string) goto oom; - sprintf((char*)object_uri_string, "%s_%d", - raptor_rdf_namespace_uri, *((int*)statement->object.value)); } else { - /* must be URI */ - if(serializer->feature_relative_uris) { - object_uri_string = raptor_uri_to_relative_uri_string_v2(serializer->world, - serializer->base_uri, - (raptor_uri*)statement->object.value); - if(!object_uri_string) - goto oom; - } else { - object_uri_string = raptor_uri_to_string_v2(serializer->world, (raptor_uri*)statement->object.value); - allocated = 0; - } + object_uri_string = raptor_uri_to_string_v2(serializer->world, (raptor_uri*)statement->object.value); + allocated = 0; } attrs[attrs_count] = raptor_new_qname_from_namespace_local_name_v2(serializer->world, context->rdf_nspace, (const unsigned char*)"resource", object_uri_string); diff --git a/src/raptor_serialize_rdfxmla.c b/src/raptor_serialize_rdfxmla.c index ea5eca93..656f3958 100644 --- a/src/raptor_serialize_rdfxmla.c +++ b/src/raptor_serialize_rdfxmla.c @@ -523,8 +523,6 @@ raptor_rdfxmla_emit_subject_list_items(raptor_serializer* serializer, rv = raptor_rdfxmla_emit_blank(serializer, element, object, depth+1); break; - case RAPTOR_IDENTIFIER_TYPE_ORDINAL: - /* ordinals should never appear as an object with current parsers */ case RAPTOR_IDENTIFIER_TYPE_UNKNOWN: default: RAPTOR_FATAL1("Unsupported identifier type\n"); @@ -622,32 +620,15 @@ raptor_rdfxmla_emit_subject_properties(raptor_serializer* serializer, predicate= nodes[0]; object= nodes[1]; - if(predicate->type == RAPTOR_IDENTIFIER_TYPE_ORDINAL) { - /* we should only get here in rare cases -- usually when there - * are multiple ordinals with the same value. */ - - unsigned char uri_string[MAX_ASCII_INT_SIZE + 2]; - - sprintf((char*)uri_string, "_%d", predicate->value.ordinal.ordinal); - - qname = raptor_new_qname_from_namespace_local_name_v2(serializer->world, - context->rdf_nspace, - uri_string, - NULL); - if(!qname) - goto oom; - - } else { - qname = raptor_new_qname_from_resource(context->namespaces, - context->nstack, - &context->namespace_count, - predicate); - if(!qname) { - raptor_serializer_error(serializer, - "Cannot split URI '%s' into an XML qname", - raptor_uri_as_string_v2(serializer->world, predicate->value.resource.uri)); - continue; - } + qname = raptor_new_qname_from_resource(context->namespaces, + context->nstack, + &context->namespace_count, + predicate); + if(!qname) { + raptor_serializer_error(serializer, + "Cannot split URI '%s' into an XML qname", + raptor_uri_as_string_v2(serializer->world, predicate->value.resource.uri)); + continue; } if(serializer->base_uri) @@ -679,8 +660,6 @@ raptor_rdfxmla_emit_subject_properties(raptor_serializer* serializer, depth+1); break; - case RAPTOR_IDENTIFIER_TYPE_ORDINAL: - /* ordinals should never appear as an object with current parsers */ case RAPTOR_IDENTIFIER_TYPE_UNKNOWN: default: RAPTOR_FATAL1("Unsupported identifier type\n"); @@ -818,16 +797,6 @@ raptor_rdfxmla_emit_subject(raptor_serializer *serializer, attr_name = (unsigned char*)"nodeID"; attr_value = subject->node->value.blank.string; } - } else if(subject->node->type == RAPTOR_IDENTIFIER_TYPE_ORDINAL) { - attr_name = (unsigned char*)"about"; - attr_value = (unsigned char *)RAPTOR_MALLOC(string, - raptor_rdf_namespace_uri_len + MAX_ASCII_INT_SIZE + 2); - if(!attr_value) { - RAPTOR_FREE(qnamearray, attrs); - goto oom; - } - sprintf((char*)attr_value, "%s_%d", raptor_rdf_namespace_uri, - subject->node->value.ordinal.ordinal); } if(attr_name) { @@ -1420,8 +1389,7 @@ raptor_rdfxmla_serialize_statement(raptor_serializer* serializer, int object_created = 0; if(!(statement->subject.type == RAPTOR_IDENTIFIER_TYPE_RESOURCE || - statement->subject.type == RAPTOR_IDENTIFIER_TYPE_ANONYMOUS || - statement->subject.type == RAPTOR_IDENTIFIER_TYPE_ORDINAL)) { + statement->subject.type == RAPTOR_IDENTIFIER_TYPE_ANONYMOUS)) { raptor_serializer_error(serializer, "Cannot serialize a triple with subject node type %d\n", statement->subject.type); @@ -1449,8 +1417,7 @@ raptor_rdfxmla_serialize_statement(raptor_serializer* serializer, if(!(object_type == RAPTOR_IDENTIFIER_TYPE_RESOURCE || object_type == RAPTOR_IDENTIFIER_TYPE_ANONYMOUS || object_type == RAPTOR_IDENTIFIER_TYPE_LITERAL || - object_type == RAPTOR_IDENTIFIER_TYPE_XML_LITERAL || - object_type == RAPTOR_IDENTIFIER_TYPE_ORDINAL)) { + object_type == RAPTOR_IDENTIFIER_TYPE_XML_LITERAL)) { raptor_serializer_error(serializer, "Cannot serialize a triple with object node type %d\n", object_type); @@ -1537,27 +1504,6 @@ raptor_rdfxmla_serialize_statement(raptor_serializer* serializer, } } - } else if(statement->predicate.type == RAPTOR_IDENTIFIER_TYPE_ORDINAL) { - int idx = *(int*)statement->predicate.value; - rv = raptor_abbrev_subject_add_list_element(subject, idx, object); - if(rv) { - /* An ordinal might already exist at that location, the fallback - * is to just put in the properties list */ - predicate = raptor_abbrev_node_lookup(context->nodes, - statement->predicate.type, - statement->predicate.value, NULL, NULL, - &predicate_created); - if(!predicate) - return 1; - - rv = raptor_abbrev_subject_add_property(subject, predicate, object); - if(rv < 0) { - raptor_serializer_error(serializer, - "Unable to add properties to subject %p\n", - subject); - return rv; - } - } } else { raptor_serializer_error(serializer, "Cannot serialize a triple with predicate node type %d\n", diff --git a/src/raptor_serialize_rss.c b/src/raptor_serialize_rss.c index 0fd7a6f7..59c854bb 100644 --- a/src/raptor_serialize_rss.c +++ b/src/raptor_serialize_rss.c @@ -954,16 +954,15 @@ raptor_rss10_build_items(raptor_rss10_serializer_context *rss_serializer) fake_uri = raptor_uri_copy_v2(rss_serializer->world, (raptor_uri*)s->subject.value); if(raptor_uri_equals_v2(rss_serializer->world, fake_uri, rss_serializer->seq_uri)) { + const unsigned char* uri_str; /* found triple */ - if(s->predicate.type == RAPTOR_IDENTIFIER_TYPE_ORDINAL) - ordinal= *((int*)s->predicate.value); - else { /* predicate is a resource */ - const unsigned char* uri_str; - uri_str = raptor_uri_as_string_v2(rss_serializer->world, (raptor_uri*)s->predicate.value); - if(!strncmp((const char*)uri_str, "http://www.w3.org/1999/02/22-rdf-syntax-ns#_", 44)) - ordinal= raptor_check_ordinal(uri_str+44); - } + /* predicate is a resource */ + uri_str = raptor_uri_as_string_v2(rss_serializer->world, + (raptor_uri*)s->predicate.value); + if(!strncmp((const char*)uri_str, "http://www.w3.org/1999/02/22-rdf-syntax-ns#_", 44)) + ordinal= raptor_check_ordinal(uri_str+44); + RAPTOR_DEBUG3("Found RSS 1.0 item %d with URI <%s>\n", ordinal, raptor_uri_as_string_v2(rss_serializer->world, (raptor_uri*)s->object.value)); diff --git a/src/raptor_serialize_simple.c b/src/raptor_serialize_simple.c index 4408513a..be04a07f 100644 --- a/src/raptor_serialize_simple.c +++ b/src/raptor_serialize_simple.c @@ -96,17 +96,11 @@ raptor_simple_serialize_statement(raptor_serializer* serializer, raptor_iostream_write_counted_string(iostr, ", ", 2); - if(statement->predicate.type == RAPTOR_IDENTIFIER_TYPE_ORDINAL) { - raptor_iostream_write_counted_string(iostr, "[rdf:_", 6); - raptor_iostream_write_decimal(iostr, *((int*)statement->predicate.value)); - raptor_iostream_write_byte(iostr, ']'); - } else { #ifdef RAPTOR_DEBUG - if(!statement->predicate.value) - RAPTOR_FATAL1("Statement has NULL predicate URI\n"); + if(!statement->predicate.value) + RAPTOR_FATAL1("Statement has NULL predicate URI\n"); #endif - raptor_iostream_write_uri_v2(serializer->world, iostr, (raptor_uri*)statement->predicate.value); - } + raptor_iostream_write_uri_v2(serializer->world, iostr, (raptor_uri*)statement->predicate.value); raptor_iostream_write_counted_string(iostr, ", ", 2); @@ -124,12 +118,8 @@ raptor_simple_serialize_statement(raptor_serializer* serializer, raptor_iostream_write_byte(iostr, '"'); raptor_iostream_write_string(iostr, statement->object.value); raptor_iostream_write_byte(iostr, '"'); - } else if(statement->object.type == RAPTOR_IDENTIFIER_TYPE_ANONYMOUS) + } else if(statement->object.type == RAPTOR_IDENTIFIER_TYPE_ANONYMOUS) { raptor_iostream_write_string(iostr, statement->object.value); - else if(statement->object.type == RAPTOR_IDENTIFIER_TYPE_ORDINAL) { - raptor_iostream_write_counted_string(iostr, "[rdf:_", 6); - raptor_iostream_write_decimal(iostr, *((int*)statement->object.value)); - raptor_iostream_write_byte(iostr, ']'); } else { #ifdef RAPTOR_DEBUG if(!statement->object.value) diff --git a/src/raptor_serialize_turtle.c b/src/raptor_serialize_turtle.c index eb498f0a..3b3bdbc7 100644 --- a/src/raptor_serialize_turtle.c +++ b/src/raptor_serialize_turtle.c @@ -349,8 +349,6 @@ raptor_turtle_emit_subject_list_items(raptor_serializer* serializer, rv = raptor_turtle_emit_blank(serializer, object, depth+1); break; - case RAPTOR_IDENTIFIER_TYPE_ORDINAL: - /* ordinals should never appear as an object with current parsers */ case RAPTOR_IDENTIFIER_TYPE_UNKNOWN: default: RAPTOR_FATAL1("Unsupported identifier type\n"); @@ -439,8 +437,6 @@ raptor_turtle_emit_subject_collection_items(raptor_serializer* serializer, rv = raptor_turtle_emit_blank(serializer, object, depth+1); break; - case RAPTOR_IDENTIFIER_TYPE_ORDINAL: - /* ordinals should never appear as an object with current parsers */ case RAPTOR_IDENTIFIER_TYPE_UNKNOWN: default: RAPTOR_FATAL1("Unsupported identifier type\n"); @@ -550,24 +546,8 @@ raptor_turtle_emit_subject_properties(raptor_serializer* serializer, raptor_turtle_writer_newline(turtle_writer); } - if(predicate->type == RAPTOR_IDENTIFIER_TYPE_ORDINAL) { - /* we should only get here in rare cases -- usually when there - * are multiple ordinals with the same value. */ - - unsigned char uri_string[MAX_ASCII_INT_SIZE + 2]; - - sprintf((char*)uri_string, "_%d", predicate->value.ordinal.ordinal); - - qname = raptor_new_qname_from_namespace_local_name_v2(serializer->world, - context->rdf_nspace, - uri_string, - NULL); - - } else { - qname = raptor_namespaces_qname_from_uri(context->nstack, - predicate->value.resource.uri, 10); - - } + qname = raptor_namespaces_qname_from_uri(context->nstack, + predicate->value.resource.uri, 10); if(raptor_abbrev_node_equals(predicate, context->rdf_type)) raptor_turtle_writer_raw(turtle_writer, (const unsigned char*)"a"); @@ -601,8 +581,6 @@ raptor_turtle_emit_subject_properties(raptor_serializer* serializer, rv = raptor_turtle_emit_xml_literal(serializer, object, depth+1); break; - case RAPTOR_IDENTIFIER_TYPE_ORDINAL: - /* ordinals should never appear as an object with current parsers */ case RAPTOR_IDENTIFIER_TYPE_UNKNOWN: default: RAPTOR_FATAL1("Unsupported identifier type\n"); @@ -717,19 +695,6 @@ raptor_turtle_emit_subject(raptor_serializer *serializer, raptor_turtle_writer_raw(turtle_writer, subject_str); RAPTOR_FREE(cstring, subject_str); } - } else if(subject->node->type == RAPTOR_IDENTIFIER_TYPE_ORDINAL) { - unsigned char* subject_str; - subject_str = (unsigned char *)RAPTOR_MALLOC(string, - raptor_rdf_namespace_uri_len + MAX_ASCII_INT_SIZE + 2); - if(!subject_str) - return 1; - - sprintf((char*)subject, "%s_%d", raptor_rdf_namespace_uri, - subject->node->value.ordinal.ordinal); - - raptor_turtle_writer_raw(turtle_writer, subject_str); - RAPTOR_FREE(cstring, subject_str); - return blank = 0; } if(collection) { @@ -1107,8 +1072,7 @@ raptor_turtle_serialize_statement(raptor_serializer* serializer, int object_created = 0; if(!(statement->subject.type == RAPTOR_IDENTIFIER_TYPE_RESOURCE || - statement->subject.type == RAPTOR_IDENTIFIER_TYPE_ANONYMOUS || - statement->subject.type == RAPTOR_IDENTIFIER_TYPE_ORDINAL)) { + statement->subject.type == RAPTOR_IDENTIFIER_TYPE_ANONYMOUS)) { raptor_serializer_error(serializer, "Do not know how to serialize node type %d\n", statement->subject.type); @@ -1137,8 +1101,7 @@ raptor_turtle_serialize_statement(raptor_serializer* serializer, if(!(object_type == RAPTOR_IDENTIFIER_TYPE_RESOURCE || object_type == RAPTOR_IDENTIFIER_TYPE_ANONYMOUS || object_type == RAPTOR_IDENTIFIER_TYPE_LITERAL || - object_type == RAPTOR_IDENTIFIER_TYPE_XML_LITERAL || - object_type == RAPTOR_IDENTIFIER_TYPE_ORDINAL)) { + object_type == RAPTOR_IDENTIFIER_TYPE_XML_LITERAL)) { raptor_serializer_error(serializer, "Cannot serialize a triple with object node type %d\n", object_type); @@ -1170,27 +1133,6 @@ raptor_turtle_serialize_statement(raptor_serializer* serializer, return rv; } - } else if(statement->predicate.type == RAPTOR_IDENTIFIER_TYPE_ORDINAL) { - int idx = *(int*)statement->predicate.value; - rv = raptor_abbrev_subject_add_list_element(subject, idx, object); - if(rv) { - /* An ordinal might already exist at that location, the fallback - * is to just put in the properties list */ - predicate = raptor_abbrev_node_lookup(context->nodes, - statement->predicate.type, - statement->predicate.value, NULL, NULL, - &predicate_created); - if(!predicate) - return 1; - - rv = raptor_abbrev_subject_add_property(subject, predicate, object); - if(rv < 0) { - raptor_serializer_error(serializer, - "Unable to add properties to subject %p\n", - subject); - return rv; - } - } } else { raptor_serializer_error(serializer, "Do not know how to serialize node type %d\n", diff --git a/src/raptor_statement.c b/src/raptor_statement.c index 8c2a40ac..77d2fa54 100644 --- a/src/raptor_statement.c +++ b/src/raptor_statement.c @@ -88,21 +88,14 @@ raptor_statement_copy(const raptor_statement *statement) goto oom; strcpy((char*)new_blank, (const char*)statement->subject.value); s->subject.value = new_blank; - } else if(statement->subject.type == RAPTOR_IDENTIFIER_TYPE_ORDINAL) { - s->subject.value = raptor_new_uri_from_rdf_ordinal(statement->world, *((int*)statement->subject.value)); - s->subject.type = RAPTOR_IDENTIFIER_TYPE_RESOURCE; } else s->subject.value = raptor_uri_copy_v2(statement->world, (raptor_uri*)statement->subject.value); s->predicate.type = RAPTOR_IDENTIFIER_TYPE_RESOURCE; - if(statement->predicate.type == RAPTOR_IDENTIFIER_TYPE_ORDINAL) - s->predicate.value = raptor_new_uri_from_rdf_ordinal(statement->world, - *((int*)statement->predicate.value)); - else - s->predicate.value = raptor_uri_copy_v2(statement->world, - (raptor_uri*)statement->predicate.value); - + s->predicate.value = raptor_uri_copy_v2(statement->world, + (raptor_uri*)statement->predicate.value); + s->object.type = statement->object.type; if(statement->object.type == RAPTOR_IDENTIFIER_TYPE_LITERAL || @@ -140,9 +133,6 @@ raptor_statement_copy(const raptor_statement *statement) goto oom; strcpy((char*)new_blank, (const char*)blank); s->object.value = new_blank; - } else if(statement->object.type == RAPTOR_IDENTIFIER_TYPE_ORDINAL) { - s->object.value = raptor_new_uri_from_rdf_ordinal(statement->world, *((int*)statement->object.value)); - s->object.type = RAPTOR_IDENTIFIER_TYPE_RESOURCE; } else { raptor_uri *uri = raptor_uri_copy_v2(statement->world, (raptor_uri*)statement->object.value); @@ -224,16 +214,12 @@ raptor_print_statement(const raptor_statement * statement, FILE *stream) fputs(", ", stream); - if(statement->predicate.type == RAPTOR_IDENTIFIER_TYPE_ORDINAL) - fprintf(stream, "[rdf:_%d]", *((int*)statement->predicate.value)); - else { #ifdef RAPTOR_DEBUG - if(!statement->predicate.value) - RAPTOR_FATAL1("Statement has NULL predicate URI\n"); + if(!statement->predicate.value) + RAPTOR_FATAL1("Statement has NULL predicate URI\n"); #endif - fputs((const char*)raptor_uri_as_string_v2(statement->world, + fputs((const char*)raptor_uri_as_string_v2(statement->world, (raptor_uri*)statement->predicate.value), stream); - } fputs(", ", stream); @@ -254,8 +240,6 @@ raptor_print_statement(const raptor_statement * statement, FILE *stream) fputc('"', stream); } else if(statement->object.type == RAPTOR_IDENTIFIER_TYPE_ANONYMOUS) fputs((const char*)statement->object.value, stream); - else if(statement->object.type == RAPTOR_IDENTIFIER_TYPE_ORDINAL) - fprintf(stream, "[rdf:_%d]", *((int*)statement->object.value)); else { #ifdef RAPTOR_DEBUG if(!statement->object.value) @@ -369,16 +353,6 @@ raptor_statement_part_as_counted_string(raptor_world* world, strcpy((char*)s, (const char*)term); break; - case RAPTOR_IDENTIFIER_TYPE_ORDINAL: - len = raptor_rdf_namespace_uri_len + 13; - buffer = (unsigned char*)RAPTOR_MALLOC(cstring, len+1); - if(!buffer) - return NULL; - - sprintf((char*)buffer, "<%s_%d>", - raptor_rdf_namespace_uri, *((int*)term)); - break; - case RAPTOR_IDENTIFIER_TYPE_RESOURCE: uri_string = raptor_uri_as_counted_string_v2(world, (raptor_uri*)term, &uri_len); @@ -480,11 +454,6 @@ raptor_print_statement_part_as_ntriples(raptor_world* world, fputs((const char*)term, stream); break; - case RAPTOR_IDENTIFIER_TYPE_ORDINAL: - fprintf(stream, "<%s_%d>", - raptor_rdf_namespace_uri, *((int*)term)); - break; - case RAPTOR_IDENTIFIER_TYPE_RESOURCE: fputc('<', stream); raptor_print_ntriples_string(stream, raptor_uri_as_string_v2(world, (raptor_uri*)term), '\0'); diff --git a/utils/rdfdiff.c b/utils/rdfdiff.c index f42cc25e..a0d6019b 100644 --- a/utils/rdfdiff.c +++ b/utils/rdfdiff.c @@ -275,26 +275,6 @@ rdfdiff_free_blank(rdfdiff_blank *blank) } -static int -rdfdiff_ordinal_equals_resource(raptor_world* world, int ordinal, raptor_uri *resource) -{ - unsigned char ordinal_string[ORDINAL_STRING_LEN + 1]; - raptor_uri *ordinal_uri; - int equal; - - snprintf((char *)ordinal_string, ORDINAL_STRING_LEN, "%s_%d", - raptor_rdf_namespace_uri, ordinal); - - ordinal_uri = raptor_new_uri_v2(world, ordinal_string); - - equal = raptor_uri_equals_v2(world, ordinal_uri, resource); - - raptor_free_uri_v2(world, ordinal_uri); - - return equal; -} - - static int rdfdiff_statement_equals(raptor_world *world, const raptor_statement *s1, const raptor_statement *s2) { @@ -310,48 +290,24 @@ rdfdiff_statement_equals(raptor_world *world, const raptor_statement *s1, const raptor_print_statement(s2, stderr); #endif - if(s1->subject.type == RAPTOR_IDENTIFIER_TYPE_ORDINAL && - s2->subject.type == RAPTOR_IDENTIFIER_TYPE_RESOURCE) { - - /* check for ordinal/resource equivalence */ - if(!rdfdiff_ordinal_equals_resource(world, - *(int *)s1->subject.value, - (raptor_uri *)s2->subject.value)) { - rv = 0; - goto done; - } - - } else if(s1->subject.type == RAPTOR_IDENTIFIER_TYPE_RESOURCE && - s2->subject.type == RAPTOR_IDENTIFIER_TYPE_ORDINAL) { + /* normal comparison */ + if(s1->subject.type != s2->subject.type) { + rv = 0; + goto done; + } - /* check for ordinal/resource equivalence */ - if(!rdfdiff_ordinal_equals_resource(world, - *(int *)s2->subject.value, - (raptor_uri *)s1->subject.value)) { - rv = 0; - goto done; - } - + if(s1->subject.type == RAPTOR_IDENTIFIER_TYPE_ANONYMOUS) { + /* Here for completeness. Anonymous nodes are taken care of + * elsewhere */ + /*if(strcmp((const char *)s1->subject, (const char *)s2->subject.value) != 0) + return 0;*/ } else { - /* normal comparison */ - if(s1->subject.type != s2->subject.type) { + if(!raptor_uri_equals_v2(world, + (raptor_uri *)s1->subject.value, + (raptor_uri *)s2->subject.value)) { rv = 0; goto done; } - - if(s1->subject.type == RAPTOR_IDENTIFIER_TYPE_ANONYMOUS) { - /* Here for completeness. Anonymous nodes are taken care of - * elsewhere */ - /*if(strcmp((const char *)s1->subject, (const char *)s2->subject.value) != 0) - return 0;*/ - } else { - if(!raptor_uri_equals_v2(world, - (raptor_uri *)s1->subject.value, - (raptor_uri *)s2->subject.value)) { - rv = 0; - goto done; - } - } } if(s1->predicate.type != s2->predicate.type) { @@ -359,18 +315,11 @@ rdfdiff_statement_equals(raptor_world *world, const raptor_statement *s1, const goto done; } - if(s1->predicate.type == RAPTOR_IDENTIFIER_TYPE_ORDINAL) { - if(*(int *)s1->predicate.value != *(int *)s2->predicate.value) { - rv = 0; - goto done; - } - } else { - if(!raptor_uri_equals_v2(world, - (raptor_uri *)s1->predicate.value, - (raptor_uri *)s2->predicate.value)) { - rv = 0; - goto done; - } + if(!raptor_uri_equals_v2(world, + (raptor_uri *)s1->predicate.value, + (raptor_uri *)s2->predicate.value)) { + rv = 0; + goto done; } if(s1->object.type != s2->object.type) { @@ -406,11 +355,6 @@ rdfdiff_statement_equals(raptor_world *world, const raptor_statement *s1, const * elsewhere */ /* if(strcmp((const char *)s1->object, (const char *)s2->object.value) != 0) return 0; */ - } else if(s1->object.type == RAPTOR_IDENTIFIER_TYPE_ORDINAL) { - if(*(int *)s1->object.value != *(int *)s2->object.value) { - rv = 0; - goto done; - } } else { if(!raptor_uri_equals_v2(world, (raptor_uri *)s1->object.value, (raptor_uri *)s2->object.value)) rv = 0; -- cgit v1.2.1