aboutsummaryrefslogtreecommitdiffstats
path: root/src/writer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/writer.c')
-rw-r--r--src/writer.c32
1 files changed, 17 insertions, 15 deletions
diff --git a/src/writer.c b/src/writer.c
index 3cfb8c55..fe29563b 100644
--- a/src/writer.c
+++ b/src/writer.c
@@ -643,7 +643,8 @@ write_uri_node(SerdWriter* const writer,
const SerdField field,
const SerdStatementFlags flags)
{
- SerdStatus st = SERD_SUCCESS;
+ const SerdWorld* const world = writer->world;
+ SerdStatus st = SERD_SUCCESS;
if (is_inline_start(writer, field, flags)) {
TRY(st, write_sep(writer, flags, SEP_ANON_BEGIN));
@@ -656,20 +657,21 @@ write_uri_node(SerdWriter* const writer,
SerdStringView suffix = {NULL, 0};
const char* node_str = serd_node_string(node);
const bool has_scheme = serd_uri_string_has_scheme(node_str);
- if (field == SERD_PREDICATE && supports_abbrev(writer) &&
- serd_node_equals(node, writer->world->rdf_type)) {
- return esink("a", 1, writer);
- } else if (supports_abbrev(writer) &&
- serd_node_equals(node, writer->world->rdf_nil)) {
- return esink("()", 2, writer);
- } else if (has_scheme && supports_abbrev(writer) &&
- !(writer->flags & SERD_WRITE_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)) {
- TRY(st, write_uri_from_node(writer, prefix));
- TRY(st, esink(":", 1, writer));
- return ewrite_uri(writer, suffix.buf, suffix.len);
+
+ if (supports_abbrev(writer)) {
+ if (field == 1 && serd_node_equals(node, world->rdf_type)) {
+ return esink("a", 1, writer);
+ } else if (serd_node_equals(node, world->rdf_nil)) {
+ return esink("()", 2, writer);
+ } else if (has_scheme &&
+ !(writer->flags & SERD_WRITE_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)) {
+ TRY(st, write_uri_from_node(writer, prefix));
+ TRY(st, esink(":", 1, writer));
+ return ewrite_uri(writer, suffix.buf, suffix.len);
+ }
}
TRY(st, esink("<", 1, writer));