summaryrefslogtreecommitdiffstats
path: root/src/sordi.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-05-11 23:32:18 +0000
committerDavid Robillard <d@drobilla.net>2011-05-11 23:32:18 +0000
commit3feaad1a898d40e54f3ef7e076a05dd960eefefa (patch)
tree3c4e557a8ca63b78470d530e0efe10263cee9bc5 /src/sordi.c
parent9f6becfdd80dfe4cf1d99d0aefa8b257eb1b0c8d (diff)
downloadsord-3feaad1a898d40e54f3ef7e076a05dd960eefefa.tar.gz
sord-3feaad1a898d40e54f3ef7e076a05dd960eefefa.tar.bz2
sord-3feaad1a898d40e54f3ef7e076a05dd960eefefa.zip
Pass environment to sord write methods for CURIE abbreviation.
git-svn-id: http://svn.drobilla.net/sord/trunk@108 3d64ff67-21c5-427c-a301-fe4f08042e5a
Diffstat (limited to 'src/sordi.c')
-rw-r--r--src/sordi.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/sordi.c b/src/sordi.c
index 1f663ea..235c67a 100644
--- a/src/sordi.c
+++ b/src/sordi.c
@@ -120,8 +120,9 @@ main(int argc, char** argv)
SordWorld* world = sord_world_new();
SordModel* sord = sord_new(world, SORD_SPO|SORD_OPS, false);
+ SerdEnv* env = serd_env_new();
- bool success = sord_read_file(sord, input, NULL, NULL);
+ bool success = sord_read_file(sord, env, input, NULL, NULL);
printf("Loaded %zu statements\n", sord_num_nodes(world));
@@ -131,13 +132,20 @@ main(int argc, char** argv)
return 1;
}
- SerdEnv* env = serd_env_new();
+ SerdEnv* write_env = serd_env_new();
+
SerdWriter* writer = serd_writer_new(
- SERD_TURTLE, SERD_STYLE_ABBREVIATED|SERD_STYLE_RESOLVED,
- env, &base_uri, file_sink, stdout);
+ SERD_TURTLE,
+ SERD_STYLE_ABBREVIATED|SERD_STYLE_RESOLVED|SERD_STYLE_CURIED,
+ write_env, &base_uri, file_sink, stdout);
+
+ // Write @prefix directives
+ serd_env_foreach(env,
+ (SerdPrefixSink)serd_writer_set_prefix,
+ writer);
- // Query
- SordQuad pat = { 0, 0, 0, 0 };
+ // Write statements
+ SordQuad pat = { 0, 0, 0, 0 };
SordIter* iter = sord_find(sord, pat);
for (; !sord_iter_end(iter); sord_iter_next(iter)) {
SordQuad tup;
@@ -156,6 +164,7 @@ main(int argc, char** argv)
serd_writer_free(writer);
serd_env_free(env);
+ serd_env_free(write_env);
sord_free(sord);