Environment

SerdEnv *serd_env_new(SerdStringView base_uri)

Create a new environment.

SerdEnv *serd_env_copy(const SerdEnv *env)

Copy an environment.

bool serd_env_equals(const SerdEnv *a, const SerdEnv *b)

Return true iff a is equal to b

void serd_env_free(SerdEnv *env)

Free env

const SerdNode *serd_env_base_uri(const SerdEnv *env)

Get the current base URI.

SerdStatus serd_env_set_base_uri(SerdEnv *env, SerdStringView uri)

Set the current base URI.

SerdStatus serd_env_set_prefix(SerdEnv *env, SerdStringView name, SerdStringView uri)

Set a namespace prefix.

A namespace prefix is used to expand CURIE nodes, for example, with the prefix “xsd” set to “http://www.w3.org/2001/XMLSchema#”, “xsd:decimal” will expand to “http://www.w3.org/2001/XMLSchema#decimal”.

SerdNode *serd_env_qualify(const SerdEnv *env, const SerdNode *uri)

Qualify uri into a CURIE if possible.

Returns null if uri can not be qualified (usually because no corresponding prefix is defined).

SerdNode *serd_env_expand(const SerdEnv *env, const SerdNode *node)

Expand node, transforming CURIEs and URI references into absolute URIs.

If node is a relative URI reference, it is expanded to a full URI if possible. If node is a literal, its datatype is expanded if necessary. If node is a CURIE, it is expanded to a full URI if possible.

For simple nodes that do not require expansion, a copy is returned. Null is returned if node is/contains a CURIE or relative URI that can not be expanded.

void serd_env_write_prefixes(const SerdEnv *env, const SerdSink *sink)

Write all prefixes in env to sink