diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/serdi.c | 23 | ||||
-rw-r--r-- | src/writer.c | 6 |
2 files changed, 8 insertions, 21 deletions
diff --git a/src/serdi.c b/src/serdi.c index 8939ae3b..9bf42ac2 100644 --- a/src/serdi.c +++ b/src/serdi.c @@ -205,25 +205,10 @@ main(int argc, char** argv) SerdWorld* world = serd_world_new(); SerdEnv* env = serd_env_new(base); - SerdStyleFlags output_style = 0; - if (output_syntax == SERD_NTRIPLES || ascii) { - output_style |= SERD_STYLE_ASCII; - } else if (output_syntax == SERD_TURTLE) { - output_style |= SERD_STYLE_ABBREVIATED; - if (!full_uris) { - output_style |= SERD_STYLE_CURIED; - } - } - - if ((input_syntax == SERD_TURTLE || input_syntax == SERD_TRIG) || - (output_style & SERD_STYLE_CURIED)) { - // Base URI may change and/or we're abbreviating URIs, so must resolve - output_style |= SERD_STYLE_RESOLVED; - } - - if (bulk_write) { - output_style |= SERD_STYLE_BULK; - } + const SerdStyleFlags output_style = + ((ascii ? SERD_STYLE_ASCII : 0) | // + (bulk_write ? SERD_STYLE_BULK : 0) | // + (full_uris ? (SERD_STYLE_UNQUALIFIED | SERD_STYLE_UNRESOLVED) : 0)); SerdWriter* writer = serd_writer_new(world, output_syntax, diff --git a/src/writer.c b/src/writer.c index fc8f86b4..3e918a0c 100644 --- a/src/writer.c +++ b/src/writer.c @@ -512,7 +512,8 @@ write_uri_node(SerdWriter* const writer, return sink("a", 1, writer) == 1; } else if (supports_abbrev(writer) && !strcmp(node_str, NS_RDF "nil")) { return sink("()", 2, writer) == 2; - } else if (has_scheme && (writer->style & SERD_STYLE_CURIED) && + } else if (has_scheme && supports_abbrev(writer) && + !(writer->style & SERD_STYLE_UNQUALIFIED) && serd_env_qualify_in_place(writer->env, node, &prefix, &suffix) && is_name(serd_node_string(prefix), serd_node_length(prefix)) && is_name(suffix.buf, suffix.len)) { @@ -523,7 +524,8 @@ write_uri_node(SerdWriter* const writer, } write_sep(writer, SEP_URI_BEGIN); - if (writer->style & SERD_STYLE_RESOLVED) { + if (!(writer->style & SERD_STYLE_UNRESOLVED) && + serd_env_base_uri(writer->env)) { const SerdURI* base_uri = serd_env_get_parsed_base_uri(writer->env); SerdURI uri; SerdURI abs_uri; |