summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/sord.c12
-rw-r--r--src/syntax.c44
2 files changed, 31 insertions, 25 deletions
diff --git a/src/sord.c b/src/sord.c
index 0a72f86..b9eb5e7 100644
--- a/src/sord.c
+++ b/src/sord.c
@@ -190,7 +190,7 @@ sord_node_compare(const SordNode* a, const SordNode* b)
int cmp;
switch (a->node.type) {
case SERD_URI:
- case SERD_BLANK_ID:
+ case SERD_BLANK:
return strcmp((const char*)a->node.buf, (const char*)b->node.buf);
case SERD_LITERAL:
cmp = strcmp((const char*)sord_node_get_string(a),
@@ -847,7 +847,7 @@ SordNodeType
sord_node_get_type(const SordNode* node)
{
switch (node->node.type) {
- case SERD_BLANK_ID:
+ case SERD_BLANK:
return SORD_BLANK;
case SERD_LITERAL:
return SORD_LITERAL;
@@ -893,7 +893,7 @@ sord_node_get_flags(const SordNode* node)
bool
sord_node_is_inline_object(const SordNode* node)
{
- return (node->node.type == SERD_BLANK_ID) && (node->refs_as_obj == 1);
+ return (node->node.type == SERD_BLANK) && (node->refs_as_obj == 1);
}
static void
@@ -936,7 +936,7 @@ sord_new_blank_counted(SordWorld* world, const uint8_t* str,
return node;
}
- node = sord_new_node(SERD_BLANK_ID, str, n_bytes, n_chars, 0, 0, 0);
+ node = sord_new_node(SERD_BLANK, str, n_bytes, n_chars, 0, 0, 0);
g_hash_table_insert(world->names, (char*)node->node.buf, node);
sord_add_node(world, node);
return node;
@@ -1041,9 +1041,7 @@ sord_node_from_serd_node(SordWorld* world,
uri_prefix.len + uri_suffix.len); // FIXME: UTF-8
return ret;
}
- case SERD_BLANK_ID:
- case SERD_ANON_BEGIN:
- case SERD_ANON:
+ case SERD_BLANK:
return sord_new_blank_counted(world, sn->buf, sn->n_bytes, sn->n_chars);
}
return NULL;
diff --git a/src/syntax.c b/src/syntax.c
index 3519b17..58ae1e4 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -62,13 +62,14 @@ event_prefix(void* handle,
}
static SerdStatus
-event_statement(void* handle,
- const SerdNode* graph,
- const SerdNode* subject,
- const SerdNode* predicate,
- const SerdNode* object,
- const SerdNode* object_datatype,
- const SerdNode* object_lang)
+event_statement(void* handle,
+ SerdStatementFlags flags,
+ const SerdNode* graph,
+ const SerdNode* subject,
+ const SerdNode* predicate,
+ const SerdNode* object,
+ const SerdNode* object_datatype,
+ const SerdNode* object_lang)
{
ReadState* const state = (ReadState*)handle;
@@ -247,31 +248,38 @@ write_statement(SordModel* sord, SerdWriter* writer, SordQuad tup,
language.buf = (const uint8_t*)lang_str;
};
+ SerdStatementFlags flags = 0;
+
SerdNode subject = *ss;
if (anon_subject) {
assert(s == anon_subject);
- subject.type = SERD_ANON;
+ // TODO: Need context to abbreviate correctly
+ //flags |= SERD_ANON_S_BEGIN;
} else if (sord_node_is_inline_object(s)) {
return;
}
if (sord_node_is_inline_object(o)) {
SerdNode anon = *so;
- anon.type = SERD_ANON_BEGIN;
- serd_writer_write_statement(
- writer, NULL, &subject, sp, &anon, sd, &language);
SordQuad sub_pat = { o, 0, 0, 0 };
SordIter* sub_iter = sord_find(sord, sub_pat);
- for (; !sord_iter_end(sub_iter); sord_iter_next(sub_iter)) {
- SordQuad sub_tup;
- sord_iter_get(sub_iter, sub_tup);
- write_statement(sord, writer, sub_tup, o);
+ flags |= (sub_iter) ? SERD_ANON_O_BEGIN : SERD_EMPTY_O;
+
+ serd_writer_write_statement(
+ writer, flags, NULL, &subject, sp, &anon, sd, &language);
+
+ if (sub_iter) {
+ for (; !sord_iter_end(sub_iter); sord_iter_next(sub_iter)) {
+ SordQuad sub_tup;
+ sord_iter_get(sub_iter, sub_tup);
+ write_statement(sord, writer, sub_tup, o);
+ }
+ sord_iter_free(sub_iter);
+ serd_writer_end_anon(writer, so);
}
- sord_iter_free(sub_iter);
- serd_writer_end_anon(writer, so);
} else if (!sord_node_is_inline_object(s) || s == anon_subject) {
serd_writer_write_statement(
- writer, NULL, &subject, sp, so, sd, &language);
+ writer, flags, NULL, &subject, sp, so, sd, &language);
}
}