diff options
-rw-r--r-- | src/writer.c | 15 | ||||
-rw-r--r-- | wscript | 3 |
2 files changed, 17 insertions, 1 deletions
diff --git a/src/writer.c b/src/writer.c index fe29563b..697d0e7c 100644 --- a/src/writer.c +++ b/src/writer.c @@ -165,6 +165,12 @@ supports_abbrev(const SerdWriter* writer) return writer->syntax == SERD_TURTLE || writer->syntax == SERD_TRIG; } +static bool +supports_uriref(const SerdWriter* writer) +{ + return writer->syntax == SERD_TURTLE || writer->syntax == SERD_TRIG; +} + static SerdStatus free_context(SerdWriter* writer) { @@ -674,6 +680,15 @@ write_uri_node(SerdWriter* const writer, } } + if (!has_scheme && !supports_uriref(writer) && + !serd_env_base_uri(writer->env)) { + SERD_LOG_ERRORF(world, + SERD_ERR_INVALID, + "syntax does not support URI reference <%s>\n", + serd_node_string(node)); + return SERD_ERR_INVALID; + } + TRY(st, esink("<", 1, writer)); if (!(writer->flags & SERD_WRITE_UNRESOLVED) && serd_env_base_uri(writer->env)) { @@ -737,7 +737,7 @@ def test(tst): check([serdi, '%s/serd.ttl' % srcdir], stdout=os.devnull) check([serdi, '-v']) check([serdi, '-h']) - check([serdi, '-k', '512', '-s', '<foo> a <#Thingie> .']) + check([serdi, '-k', '512', '-s', '<urn:eg:s> a <urn:eg:T> .']) check([serdi, os.devnull]) with tempfile.TemporaryFile(mode='r') as stdin: @@ -792,6 +792,7 @@ def test(tst): check([serdi, '-s']) check([serdi, '-z']) check([serdi] + ['%s/tests/bad/bad-base.ttl' % srcdir] * 2) + check([serdi, '-s', '<foo> a <Bar> .']) with tst.group('IoErrors', expected=1) as check: check([serdi, '-e', 'file://%s/' % srcdir], name='Read directory') |