Quick and dirty Canonical N-Triples for your RDF files, on the command-line.
Pachelbel takes and RDF file as input, and outputs the RDF graph in its Canonical N-Triples form. This can be useful if you want to diff
two graphs, or if you want to digitaly sign an RDF graph.
Pachelbel is a simple wrapper around a few RDF::Trine functions; as such it can parse all RDF serialisation formats with a corresponding RDF::Trine::Parser. At the time of writing, this means pretty much all common and uncommon RDF serialisations except for JSON-LD.
pachelbel.pl filename.rdf
converts your RDF data to its canonical N-Triples serialisation, output to filename-canonical.nt
(where .rdf
is a file extension appropriate to the serialisation format you happen to be using).
This script exists mostly to scratch an itch: I needed to serialise some RDF as Canonical N-Triples, and to my surprise could not find a simple command-line utility that would do this for me. rdfpipe
does not seem to do it; I know that Apache Jena can do it, because I seem to recall that that's part of the method its rdfcompare
tool uses to determine graph isomorphism – but the documentation of the Jena command-line tools is so poor that I gave up trying to work out how to do it using arq
or any of the other tools, and wrote this instead. If anyone knows of a better, faster solution, please let me know! I'm sure there is one, I've just not been able to find it!