2.7 Environment — Serd 0.32.2 documentation

# 2.7 Environment

typedef struct SerdEnvImpl SerdEnv

  Lexical environment for relative URIs or CURIEs (base URI and namespaces)

SerdEnv *serd_env_new(const SerdNode *base_uri)

  Create a new environment.

void serd_env_free(SerdEnv *env)

  Free `env`

const SerdNode *serd_env_get_base_uri(const SerdEnv *env, SerdURI *out)

  Get the current base URI.

SerdStatus serd_env_set_base_uri(SerdEnv *env, const SerdNode *uri)

  Set the current base URI.

SerdStatus serd_env_set_prefix(SerdEnv *env, const SerdNode *name, const SerdNode *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”.

SerdStatus serd_env_set_prefix_from_strings(SerdEnv *env, const uint8_t *name, const uint8_t *uri)

  Set a namespace prefix.

bool serd_env_qualify(const SerdEnv *env, const SerdNode *uri, SerdNode *prefix, SerdChunk *suffix)

  Qualify `uri` into a CURIE if possible.

SerdStatus serd_env_expand(const SerdEnv *env, const SerdNode *curie, SerdChunk *uri_prefix, SerdChunk *uri_suffix)

  Expand `curie`.

  Errors: SERD_ERR_BAD_ARG if `curie` is not valid, or SERD_ERR_BAD_CURIE if prefix is not defined in `env`.

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

  Expand `node`, which must be a CURIE or URI, to a full URI.

  Returns null if `node` can not be expanded.

void serd_env_foreach(const SerdEnv *env, SerdPrefixSink func, void *handle)

  Call `func` for each prefix defined in `env`