diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/env.c | 36 | ||||
-rw-r--r-- | src/serdi.c | 2 |
2 files changed, 38 insertions, 0 deletions
@@ -93,6 +93,29 @@ serd_env_add(SerdEnv env, SERD_API bool +serd_env_qualify(const SerdEnv env, + const SerdNode* uri, + SerdNode* prefix_name, + SerdChunk* suffix) +{ + for (size_t i = 0; i < env->n_prefixes; ++i) { + const SerdNode* const prefix_uri = &env->prefixes[i].uri; + if (uri->n_bytes >= prefix_uri->n_bytes) { + if (!strncmp((const char*)uri->buf, + (const char*)prefix_uri->buf, + prefix_uri->n_bytes)) { + *prefix_name = env->prefixes[i].name; + suffix->buf = uri->buf + prefix_uri->n_bytes; + suffix->len = uri->n_bytes - prefix_uri->n_bytes; + return true; + } + } + } + return false; +} + +SERD_API +bool serd_env_expand(const SerdEnv env, const SerdNode* qname, SerdChunk* uri_prefix, @@ -114,3 +137,16 @@ serd_env_expand(const SerdEnv env, } return false; } + +SERD_API +void +serd_env_foreach(const SerdEnv env, + SerdPrefixSink func, + void* handle) +{ + for (size_t i = 0; i < env->n_prefixes; ++i) { + func(handle, + &env->prefixes[i].name, + &env->prefixes[i].uri); + } +} diff --git a/src/serdi.c b/src/serdi.c index 5d7244b2..7736f773 100644 --- a/src/serdi.c +++ b/src/serdi.c @@ -237,6 +237,8 @@ main(int argc, char** argv) ? SERD_STYLE_ASCII : SERD_STYLE_ABBREVIATED; + output_style |= SERD_STYLE_RESOLVED; + const SerdNode base_uri_node = { SERD_URI, base_uri_n_bytes, base_uri_n_bytes - 1, |