linkeddata / rdflib.js

Linked Data API for JavaScript
http://linkeddata.github.io/rdflib.js/doc/
Other
564 stars 143 forks source link

Serializer set namespace prefix #534

Closed pduchesne closed 2 years ago

pduchesne commented 2 years ago

This PR adds the possibility to (forcefully) set namespaces prefixes on a Serializer instance, as opposed to the current suggestNamespaces and suggestPrefix methods that propose prefixes but cannot override defaults prefixes.

What it does is

As a result ,

const graph: IndexedFormula = ...;

graph.serialize(base, contentType, provenance);
// is equivalent to
serialize(provenance, graph, base, contentType, undefined, { namespaces: graph.namespaces });

and keeps the graph namespace prefixes, while

serialize(provenance, graph, base, contentType, undefined);

behaves as before, i.e. giving priority to default prefixes