Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Importing a Turtle file

Agrafe can create a project from one or more existing Turtle (.ttl) ontologies, so you do not have to retype them in Dolfin.

Video 6.1 · Turtle projects, opening (0:04–0:32). Watch on PeerTube

How to import

  1. Open the project list and choose Import from Turtle.
  2. Pick (or drop) one or more .ttl or .turtle files. Each must be UTF-8 text. .n3 files are accepted too: N3 rules ({ … } => { … } .), inline in a Turtle file or alone in an .n3, become rule blocks in the .dlf. A rule that cannot be translated is skipped with a warning (the import still goes through); a rules-only file added to a project joins that project’s package. The live sync leaves rules alone.
  3. One new project appears with the placeholder name New project, with every file as a source. Rename it inline, exactly as after New project.

Every file is checked and translated before anything is stored. If one cannot be read, you get an error naming it (Could not read turtle (foo.ttl): …) and no project is created, whatever the other files hold. One import carries at most 10 MiB of Turtle in total; import more in several steps (create the project, then add sources).

Imported projects always start private, and an import counts as one project against your private-project limit, however many files it has. The import is refused if your licence has expired, if you are at your project limit, or if the generated Dolfin files would exceed your per-project file limit. That limit counts the Dolfin files after merging, without package.dlf; the .ttl files themselves never count.

Adding a Turtle source to a project

Owners and editors can add Turtle files to an existing project, from the file tree:

  • Import → Add Turtle source… picks one or more .ttl files from your computer.
  • A .ttl file that is already in the project as a plain file can be promoted: right-click it and choose Add as Turtle source.

Each file is translated and becomes a new source. Its Dolfin files are added to the project, or merged into the files of the same name already there (see below). The same checks as an import apply: a file that cannot be read refuses the whole action and the project is left untouched, and the file limit counts the existing Dolfin files plus the new ones.

A Turtle whose text is identical to an existing source, or a file that already is a source, is refused (… is already a Turtle source of this project.): adding it twice never duplicates anything.

How several turtles are merged

  • Same file name, one file. When two sources produce a Dolfin file of the same name (same rdfs:isDefinedBy file, or the same IRI-structure split), the project gets one file holding the declarations of both. It is a shared file, listed under each of its sources. Identical declarations and identical prefix lines appear once. The result only depends on the files and their order (the order you picked them in, or existing files first when adding).
  • One package.dlf. It comes from the first source’s owl:Ontology metadata, and later sources never overwrite it (when adding to a project, the project keeps its own). A later Turtle with a different ontology IRI is still imported; that IRI becomes the base IRI of its own source only.
  • Turtle file names. Each source is stored under its own name. A name already taken gets a numeric suffix: onto.ttl, onto-2.ttl, onto-3.ttl…

What you get

  • Dolfin files. The Turtle is translated to .dlf files. Each entity goes into the file named by its rdfs:isDefinedBy triple; Turtle without that information is split by IRI structure. See Turtle & OWL Correspondence for the exact rules.
  • package.dlf. Built from the Turtle’s owl:Ontology metadata. If the Turtle has none, a default manifest is generated.
  • The original Turtle. It is stored in the project as a normal file named <file name>.ttl and recorded as one of the project’s sources (its origin). Everything that follows (the editor, Reveal, sync and Re-translate) works on this file.

The base IRI of a source is the subject of its Turtle’s owl:Ontology. A Turtle without one is still imported: the IRI is taken from its empty prefix (@prefix : <…>), else its @base, else the namespace most of its classes and properties use, else the project’s IRI, and a warning says which (re-exporting adds an owl:Ontology header). It is recorded once per source at import, and later features reuse it so that translation and sync always agree.

Projects with several Turtle sources

A project can have more than one origin Turtle, called its sources. Each source keeps its own record: its base IRI, its sync state, its sync reference point, and the list of Dolfin files it generated. Sync, Re-translate and Reveal work per source, on the files that source generated.

Two sources can generate the same Dolfin file (same file name). Such a file is shared: it holds declarations from both. A shared file is never synced back to any Turtle, and a Re-translate never removes another source’s declarations from it. See Shared files.

A project with a single source works exactly as described on the other pages: its source owns every Dolfin file in the project. When a second source is added, the first one keeps the files it was in sync with.

The origin file in the file tree

Every source file has an origin badge. A source at the root of the project is pinned at the top of the tree, in the order the sources were added. A source moved into a folder keeps its badge there, but is no longer pinned. The Dolfin files a source generated are nested under it; a shared file appears under each of its sources. A source in a folder with none of its Dolfin files beside it shows them nested under it, wherever they are stored. Otherwise a source file behaves like any file:

  • It is editable, collaborative, versioned and included in project ZIP exports.
  • You can rename it. The project remembers it by identity, not by name.
  • It does not count against the per-project file limit.
  • It is ignored by everything Dolfin: compilation, linting, the wire format and deployments only look at .dlf files.

Deleting an origin file

Deleting a source file asks for confirmation:

This is a Turtle source of this project. Deleting it detaches this source only: its Dolfin files stop syncing back to it and “Reveal in turtle source” no longer looks in it. Other Turtle sources keep working. Delete anyway?

If you confirm, only that source is detached: its record, sync reference point and sync state are removed, and its Dolfin files stay as ordinary files. The other sources keep syncing and revealing as before. When the last source is deleted, the project stops being a turtle-origin project: Reveal falls back to Reveal in turtle export, and there is no automatic sync or Re-translate any more.

Projects imported before this feature

Older imported projects have no origin: the original Turtle was discarded at import and cannot be recovered. They keep working normally, and Reveal in turtle export is available, but they have no sync and no Re-translate. To get the full feature, import the Turtle again as a new project.

Plain .ttl files

A .ttl file created in the tree (for example with New file) is a plain file: it opens in the Turtle editor and is otherwise ignored (no sync, no Re-translate, no Reveal in dolfin). To turn it into a source, right-click it and choose Add as Turtle source. Only Import from Turtle and Add Turtle source create sources.