RDF.PrefixMap.merge
merge
, go back to RDF.PrefixMap module for more information.
Specs
Merges two RDF.PrefixMap
s.
The second prefix map can also be given as any structure which can converted
to a RDF.PrefixMap
via new/1
.
If the prefix maps can be merged without conflicts, that is there are no
prefixes mapped to different namespaces an :ok
tuple is returned.
Otherwise an :error
tuple with the list of prefixes with conflicting
namespaces is returned.
See also merge/3
which allows you to resolve conflicts with a function.
Specs
merge(t(), t() | map() | keyword(), conflict_resolver() | nil) :: {:ok, t()} | {:error, [atom() | String.t()]}
Merges two RDF.PrefixMap
s, resolving conflicts through the given conflict_resolver
function.
The second prefix map can also be given as any structure which can converted
to a RDF.PrefixMap
via new/1
.
The given function will be invoked when there are conflicting mappings of
prefixes to different namespaces; its arguments are prefix
, namespace1
(the namespace for the prefix in the first prefix map),
and namespace2
(the namespace for the prefix in the second prefix map).
The value returned by the conflict_resolver
function is used as the namespace
for the prefix in the resulting prefix map.
Non-RDF.IRI
values will be tried to be converted to RDF.IRI
s via
RDF.IRI.new
implicitly.
The most common conflict resolution strategies on can be chosen directly with the following atoms:
:ignore
: keep the original namespace fromprefix_map1
:overwrite
: use the other namespace fromprefix_map2
If a conflict can't be resolved, the provided function can return nil
.
This will result in an overall return of an :error
tuple with the list of
prefixes for which the conflict couldn't be resolved.
If everything could be merged, an :ok
tuple is returned.