Canonicalization, which is also called normalization, transforms a resource into a "standard" representation.
This process is dependent on the type of the resource, but typically includes things such as:
- Formatting based on a fixed standard
- Sorting keys which do not (should not) change semantics
- Rewriting literal values
- Fixed Encoding
This is useful e.g. when testing, to compare output to a fixed expected outcome.
It also has an application in cryptography, where it's useful when "signing" things.
You can also use this as a "formatter".
enola canonicalize for RDF order statements by predicate IRI, for example:
$ ./enola canonicalize --load=test/picasso.ttl
...Future versions may implement full RDF Dataset Canonicalization, see also this Working Group.
enola canonicalize for JSON transforms e.g. this canonicalize.json:
{% include "../../../test/canonicalize.json" %}into this, using an RFC 8785 JSON Canonicalization Scheme (JCS) -inspired (but currently not fully compliant) algorithm:
$ ./enola canonicalize --load=test/canonicalize.json
...or more nicely (--pretty) formatted:
$ ./enola canonicalize --pretty --load=test/canonicalize.json
...Note how the order of the keys in the JSON changes, among other changes.
enola canonicalize for JSON-LD transforms this canonicalize.jsonld:
{% include "../../../test/canonicalize.jsonld" %}$ ./enola canonicalize --pretty --load=test/canonicalize.jsonld --output=test/canonicalize.jsonld.expected
...into this - note how the π¨ painters' order was swapped, because not just all
map keys but the list itself was also ordered alphabetically by @id:
{% include "../../../test/canonicalize.jsonld.expected" %}Markdown canonicalization is also supported.
HTML canonicalization is also supported.
XML canonicalization is also supported.