Rosetta¶
Rosetta, inspired by the Rosetta Stone, transforms e.g. between:
- Text Encodings (e.g. UTF-8 β ISO 8859-1 etc.)
- RDF Turtle β JSON-LD β YAML-LD β Enola Things
- YAML & JSON β RDF Turtle with JSON-LD Contexts
YAML
βJSON
βTextProto
β Binary Protocol Buffer “Wire” formats- Graph Diagrams from RDF et al.
- Many other formats!
- XML
Specifying the --schema
flag is optional for YAML <=> JSON conversion, but required for TextProto.
Rosetta transforms a (single) input resource into one output resource of another format. Alternatively, generate can load (possibly several) resources (or “logical IRIs”) which contain Things and transform them into (some of) these formats.
Graph Diagrams¶
Enola can generate Graph Diagrams like this, through DocGen (see Tutorial), or Rosetta.
Graphviz¶
Similarly to e.g. rdflib’s rdf2dot
(and rdfs2dot
):
$ ./enola rosetta --in test/picasso.ttl --out "docs/BUILT/picasso.gv?full=true" && dot -Tsvg -O docs/BUILT/picasso.gv
produces picasso.gv
and picasso.gv.svg
:
The full
URL query string can be used to control appearance, and --no-file-loader
suppresses the file; see:
$ ./enola rosetta --no-file-loader --in test/picasso.ttl --out "docs/BUILT/picasso-small.gv?full=false" && dot -Tsvg -O docs/BUILT/picasso-small.gv
GEXF¶
$ ./enola rosetta --in test/picasso.ttl --out docs/BUILT/picasso.gexf
produces picasso.gexf
in GEXF format (see also GEXF examples), which can be opened e.g. in Gephi Lite or Retina.
Tika¶
YAML to JSON¶
$ ./enola rosetta --in test/picasso.yaml --out /tmp/picasso.json
Turtle π’ to JSON-LD π¶
$ ./enola rosetta --in test/picasso.ttl --out picasso.jsonld
JSON & YAML to Turtle π’ via JSON-LD¶
XML¶
$ ./enola rosetta --in test/greeting1-nested.xml --out="fd:1?mediaType=text/turtle"
@prefix calibre: <http://calibre.kovidgoyal.net/2009/metadata> .
@prefix marc: <http://id.loc.gov/vocabulary/> .
@prefix epubsc: <http://idpf.org/epub/vocab/sc/#> .
@prefix Iptc4xmpCore: <http://iptc.org/std/Iptc4xmpCore/1.0/xmlns/> .
@prefix crs: <http://ns.adobe.com/camera-raw-settings/1.0/> .
@prefix exif: <http://ns.adobe.com/exif/1.0/> .
@prefix pdf: <http://ns.adobe.com/pdf/1.3/> .
@prefix photoshop: <http://ns.adobe.com/photoshop/1.0/> .
@prefix tiff: <http://ns.adobe.com/tiff/1.0/> .
@prefix xmp: <http://ns.adobe.com/xap/1.0/> .
@prefix xmpBJ: <http://ns.adobe.com/xap/1.0/bj/> .
@prefix xmpMM: <http://ns.adobe.com/xap/1.0/mm/> .
@prefix xmpRights: <http://ns.adobe.com/xap/1.0/rights/> .
@prefix xmpDM: <http://ns.adobe.com/xmp/1.0/DynamicMedia/> .
@prefix dc: <http://purl.org/dc/elements/1.1/> .
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix onix: <http://www.editeur.org/ONIX/book/codelists/current.html#> .
@prefix opf: <http://www.idpf.org/2007/opf#> .
@prefix epub: <http://www.idpf.org/2007/ops#> .
@prefix media: <http://www.idpf.org/epub/vocab/overlays/#> .
@prefix a11y: <http://www.idpf.org/epub/vocab/package/a11y/#> .
@prefix msv: <http://www.idpf.org/epub/vocab/structure/magazine/#> .
@prefix rendition: <http://www.idpf.org/vocab/rendition/#> .
@prefix prism: <http://www.prismstandard.org/specifications/3.0/PRISM_CV_Spec_3.0.htm#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xhtml: <http://www.w3.org/1999/xhtml/> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix xmpTPg: <https://developer.adobe.com/xmp/docs/XMPNamespaces/xmpTPg/> .
@prefix enola: <https://enola.dev/> .
@prefix ex: <https://example.org/> .
@prefix schema: <https://schema.org/> .
<file:/home/runner/work/enola/enola/test/greeting1-nested.xml> ex:greeting1 [
ex:message "hello, world"
] .
Turtle π’ to Things βοΈ¶
$ ./enola rosetta --in test/picasso.ttl --out picasso.thing.yaml
UTF-8 to ISO 8859-1¶
$ file docs/use/rosetta/hello.txt
docs/use/rosetta/hello.txt: Unicode text, UTF-8 text
$ cat docs/use/rosetta/hello.txt
hello, wΓΆrld π
$ ./enola rosetta --in 'docs/use/rosetta/hello.txt?charset=UTF-8' --out '/tmp/hello-windows.txt?charset=ISO-8859-1'
$ file /tmp/hello-windows.txt
/tmp/hello-windows.txt: ISO-8859 text
$ cat /tmp/hello-windows.txt
hello, wοΏ½rld ?