aboutsummaryrefslogtreecommitdiffstats
path: root/src/writer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/writer.c')
-rw-r--r--src/writer.c21
1 files changed, 8 insertions, 13 deletions
diff --git a/src/writer.c b/src/writer.c
index 329a29ad..05be0500 100644
--- a/src/writer.c
+++ b/src/writer.c
@@ -131,7 +131,7 @@ struct SerdWriterImpl {
SerdSink iface;
SerdSyntax syntax;
SerdWriterFlags flags;
- SerdEnv* env;
+ const SerdEnv* env;
SerdNode* root_node;
SerdURIView root_uri;
WriteContext* anon_stack;
@@ -1367,7 +1367,7 @@ SerdWriter*
serd_writer_new(SerdWorld* world,
SerdSyntax syntax,
SerdWriterFlags flags,
- SerdEnv* env,
+ const SerdEnv* env,
SerdOutputStream* output,
size_t block_size)
{
@@ -1426,20 +1426,15 @@ serd_writer_set_base_uri(SerdWriter* writer, const SerdNode* uri)
{
assert(writer);
+ SerdStatus st = SERD_SUCCESS;
+
if (uri && serd_node_type(uri) != SERD_URI) {
return SERD_BAD_ARG;
}
- if (serd_node_equals(serd_env_base_uri(writer->env), uri)) {
- return SERD_SUCCESS;
- }
-
const SerdStringView uri_string =
uri ? serd_node_string_view(uri) : serd_empty_string();
- SerdStatus st = SERD_SUCCESS;
- TRY(st, serd_env_set_base_uri(writer->env, uri_string));
-
if (uri && (writer->syntax == SERD_TURTLE || writer->syntax == SERD_TRIG)) {
TRY(st, terminate_context(writer));
TRY(st, esink("@base <", 7, writer));
@@ -1476,16 +1471,16 @@ serd_writer_set_prefix(SerdWriter* writer,
{
SerdStatus st = SERD_SUCCESS;
- TRY(st,
- serd_env_set_prefix(
- writer->env, serd_node_string_view(name), serd_node_string_view(uri)));
+ if (name->type != SERD_LITERAL || uri->type != SERD_URI) {
+ return SERD_BAD_ARG;
+ }
if (writer->syntax == SERD_TURTLE || writer->syntax == SERD_TRIG) {
TRY(st, terminate_context(writer));
TRY(st, esink("@prefix ", 8, writer));
TRY(st, esink(serd_node_string(name), name->length, writer));
TRY(st, esink(": <", 3, writer));
- TRY(st, ewrite_uri(writer, serd_node_string(uri), uri->length));
+ TRY(st, write_uri_from_node(writer, uri));
TRY(st, esink(">", 1, writer));
writer->last_sep = SEP_NODE;
TRY(st, write_sep(writer, writer->context.flags, SEP_END_DIRECT));