# Write Turtle

> Write a class schema in Folio's Turtle Editor: pick a profile, let typeahead fill each slot, fix the warnings the profile raises, and read the file back.

Source: https://semvia.io/docs/authoring/turtle

[Turtle](https://www.w3.org/TR/turtle/) is the plain-text format [RDF](https://www.w3.org/TR/rdf11-concepts/) is usually written in. Each statement is a triple: a subject, a predicate and an object. Folio's Turtle Editor completes each one as you type, adds the punctuation and prefix lines for you, and checks the file against the profile you pick.

This guide builds `films.ttl`, a Film class schema checked by the Class Schema profile, from an empty file. The [Form view guide](https://semvia.io/docs/authoring/form-view) goes on to edit the same class schema as a form.

## Create the file

Select **New file** in the Explorer and pick **Turtle**, the format marked "Best for modeling". Folio adds `Untitled.ttl` to the Explorer with its name selected. Type `films` and press Enter.

The file opens empty. Its toolbar holds **+ Resource**, **View ▾**, the **Profile** menu, and the **Code | Form** switch, which starts on Code.

Figure: Folio's left sidebar: the activity bar at the window edge, then the Explorer under its Files header, with the New file menu open below its toolbar. It lists Markdown, Best for connected notes and text; Turtle, Best for modeling, highlighted; Spreadsheet; and SPARQL Query, Ask questions across your data. Each shows its file extension.

New file offers Turtle as a .ttl file.

## Pick a profile

A profile is the set of vocabularies and shapes a file is written against. Folio warns about any term in the file outside of the selected profiles.

Open the **Profile** menu at the top right of the editor. It reads your workspace's name. Pick **Class Schema**. Folio writes two lines into the file, `@prefix dct:` and a `<> dct:conformsTo` statement that names the profile, and the menu reads **Class Schema**.

Figure: films.ttl with the Profile menu open under the toolbar, whose trigger reads Class Schema. The menu lists Class Schema, checked, then Dataset and Package, Graph View, MCP, Markdown Document, Markdown Mapping, Note, RDF Schema, RML Mapping, SKOS Taxonomy, SKOS Vocabulary, Semvia Authoring Profile and Web of Things unchecked. The file holds a @prefix dct: line, then Edit resource above the statement <> dct:conformsTo the class-schema profile, then a full stop.

Class Schema picked for this file. Folio wrote the line that says so.

## Name the file's namespace

Every name in the file is short for a full IRI, and the empty prefix `:` is the one you will use most. At the end of the `@prefix dct:` line, press Enter and type the line below. Folio draws a grey ` .` at the end of the line; press Enter to write it.

The address is your package's base IRI followed by `films#`. On a new workspace the base IRI is `https://example.org/my-semantic-package/`; if your package has its own, use that. With this line, `:Film` means `https://example.org/my-semantic-package/films#Film`.

```turtle
@prefix : <https://example.org/my-semantic-package/films#> .
```

## Typeahead fills each slot

Below the `<>` statement, start a new one with the subject `:Film`, then `a`, Turtle's word for "is a". Type `Cla` and the list offers `svs:ClassSchema`. Press Enter to take it, then Enter again to take the grey ` ;` after it.

In the predicate slot, type `Lab`. The list is headed **PROPERTIES OF CLASSSCHEMA**: the properties Class Schema gives a class, each with its label beside it. Take `rdfs:label`, then type `"Film"@en` as its object. Take the ` ;`, type `descr`, take `rdfs:comment` and type `"A feature film whose rights the studio licenses to distributors."@en`.

Figure: The Turtle Editor with Edit resource above :Film a svs:ClassSchema ; and the cursor on the empty line below it. A list headed PROPERTIES OF CLASSSCHEMA offers a, rdf:type; rdfs:label, Label; rdfs:comment, Description; rdfs:subClassOf, Extends; sh:property, Properties; rml:template, ID template; sh:class, Class; svs:conformsTo, Conforms to; and sh:datatype, Datatype. A hint at its foot reads: The subject is an instance of a class.

The predicate slot on a Class Schema. Each property shows the label its form field uses.

## The grey ; and .

After an object, Folio draws a grey ` ;` beside it and a grey `.` on the line below. Neither is in the file until you take it. Press Enter to take the ` ;` and start the next line of the same subject. The first ` ;` you take writes the `.` below as well, so the statement is closed while you add to it.

When the last line is done, leave its ` ;` and move on.

## Add a field and fix its warnings

Each field of a class schema is a `sh:property`. On the line after the description, type `Prop` and take `sh:property`. Type ` [` and Folio closes it as `[]`. Press Escape, then Enter, to open the brackets onto their own lines. Inside them, type `Pa`, take `sh:path`, then type ` title` and take `dct:title`.

A warning triangle appears beside `sh:path`. Hover it for the two warnings the profile raises: the field has no Label and no Description. Fix both inside the brackets:

1. Take the grey ` ;`, type `nam`, take `sh:name` and type `"Title"@en`.
2. Take the ` ;`, type `descr`, take `sh:description` and type `"The name the film is released under."@en`.
3. Take the ` ;` and type `sh:minCount 1`. Every Film now needs a title.

The warning triangle goes. Put the cursor after the closing `]`, press Enter to take its ` ;`, and add two more fields the same way:

- `dct:rightsHolder` (type ` rightsH`), with the Label `"Rights holder"@en`, the Description `"The company that holds the rights to the film."@en`, and `sh:nodeKind sh:IRI` (type `nodeK`, then ` I`), so it points at a company.
- `dct:issued`, with the Label `"Release date"@en`, the Description `"The date the film was first released."@en`, and `sh:datatype xsd:date` (type `dataty`, then ` da`), so it holds a date.

Figure: The Turtle Editor. :Film a svs:ClassSchema ; is followed by rdfs:label Film in English and rdfs:comment A feature film whose rights the studio licenses to distributors., then sh:property [ on one line and sh:path dct:title with a grey semicolon on the next. A warning triangle sits in the gutter beside sh:path. Its tooltip reads: This property has no Description, so its field has no help text. Add a Description. And: This property has no Label, so forms name the field after its Path. Add a Label.

A field with only a path. The profile asks for its Label and Description.

## Folio declares the prefix

Each time you take a name whose prefix the file doesn't declare yet, Folio adds the `@prefix` line at the top of the file. Taking `svs:ClassSchema` added `svs:`, `rdfs:label` added `rdfs:`, `sh:property` added `sh:`, and `xsd:date` added `xsd:`. Folio saves as you type; this is `films.ttl` on disk.

Graph

Figure: Two cards in Folio's Graph View. films, the file, shows its namespace and conforms to Class Schema. Film, a Class Schema, shows its comment A feature film whose rights the studio licenses to distributors. and lists its instance properties Release date (date), Rights holder, and Title (1..*).

Film, a Class Schema with three properties, and the file that conforms to Class Schema, in [Graph View](https://semvia.io/docs/authoring/graph-view).

Turtle

```turtle
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix svs: <https://pkg.semvia.io/semvia/core/meta-schema#> .
@prefix dct: <http://purl.org/dc/terms/> .
@prefix : <https://example.org/my-semantic-package/films#> .

<> dct:conformsTo <https://pkg.semvia.io/semvia/core/profiles/class-schema> ;
.

:Film a svs:ClassSchema ;
  rdfs:label "Film"@en ;
  rdfs:comment "A feature film whose rights the studio licenses to distributors."@en ;
  sh:property [
    sh:path dct:title ;
    sh:name "Title"@en ;
    sh:description "The name the film is released under."@en ;
    sh:minCount 1
  ] ;
  sh:property [
    sh:path dct:rightsHolder ;
    sh:name "Rights holder"@en ;
    sh:description "The company that holds the rights to the film."@en ;
    sh:nodeKind sh:IRI
  ] ;
  sh:property [
    sh:path dct:issued ;
    sh:name "Release date"@en ;
    sh:description "The date the film was first released."@en ;
    sh:datatype xsd:date
  ]
.
```

## Read it back

Every statement in `films.ttl` reads left to right as subject, predicate, object: a [triple](https://www.w3.org/TR/turtle/#simple-triples). Each row is a piece of Turtle beside what it means, as `films.ttl` writes it. `films.ttl` uses no `,`, typed value or comment, so those three rows give a film example of their own. Each construct's name links its section of the Turtle specification.

- **@prefix dct: <http://purl.org/dc/terms/> .** — A [prefix declaration](https://www.w3.org/TR/turtle/#prefixed-name). Makes `dct:` short for the [IRI](https://www.w3.org/TR/turtle/#sec-iri) in angle brackets, so `dct:title` means `http://purl.org/dc/terms/title`. The `@prefix :` line does the same for the empty prefix, the file's own namespace.
- **<>** — A [relative IRI](https://www.w3.org/TR/turtle/#relative-iri), read against the file's own address. Empty, it is the file itself: `<> dct:conformsTo <…>` names the profile the file is checked against.
- **:Film** — The [subject](https://www.w3.org/TR/turtle/#simple-triples): the first term of a statement, the thing it describes. `:Film` is a [prefixed name](https://www.w3.org/TR/turtle/#prefixed-name) in the file's own namespace, short for `https://example.org/my-semantic-package/films#Film`.
- **a** — "Is a". [Short for `rdf:type`](https://www.w3.org/TR/turtle/#iri-a), so `:Film a svs:ClassSchema` says Film is a class schema.
- **;** — A [predicate list](https://www.w3.org/TR/turtle/#predicate-lists): another predicate for the same subject. `:Film` has a label, a description and three fields, and its name is written once. A `;` with nothing after it, as on the `<>` statement, adds nothing.
- **,** — An [object list](https://www.w3.org/TR/turtle/#object-lists): another object for the same subject and predicate. When [Form view](https://semvia.io/docs/authoring/form-view) adds a field, it writes `sh:property [ … ], [ … ]`: two fields without repeating `sh:property`.
- **.** — [Ends the statement](https://www.w3.org/TR/turtle/#simple-triples). The next subject starts a new one.
- **[ … ]** — A [blank node](https://www.w3.org/TR/turtle/#unlabeled-bnodes): a resource with no name of its own, described in place by the predicates between the brackets. Each field of Film is one, such as `sh:property [ sh:path dct:title ; … ]`.
- **"Film"@en** — A [string with a language tag](https://www.w3.org/TR/turtle/#turtle-literals). The tag after `@` names the language, here English. Quoted text with no tag is a plain string.
- **"2025-06-13"^^xsd:date** — A [typed value](https://www.w3.org/TR/turtle/#turtle-literals): quoted text, `^^`, then its [XSD datatype](https://www.w3.org/TR/xmlschema11-2/). A film's release date is written this way, the value `sh:datatype xsd:date` asks the Release date field for.
- **sh:minCount 1** — A [number](https://www.w3.org/TR/turtle/#abbrev). A whole number needs no quotes: `1` is short for `"1"^^xsd:integer`. Here it means at least one value, so the field is required.
- **# Feature films the studio licenses.** — A [comment](https://www.w3.org/TR/turtle/#sec-grammar-comments), from `#` to the end of the line. It adds nothing to the graph. Folio keeps a comment on the line above a subject when [Form view](https://semvia.io/docs/authoring/form-view) edits the file.

## One graph, whichever format wrote it

Folio reads every file in a workspace into one graph. `films.ttl` writes its statements directly. A [Markdown](https://semvia.io/docs/authoring/markdown) page builds them from headings and lists, and a Spreadsheet builds them from rows. Nothing is imported or converted: a query or a form sees what every file says at once.

Choose the format that suits what you're writing. Turtle suits exact statements, like the fields Film has here or the concepts of a [taxonomy](https://semvia.io/docs/modeling/taxonomies). Markdown suits prose and domain models written as headings, as in [Markdown syntax](https://semvia.io/docs/authoring/markdown). A Spreadsheet suits many rows of the same kind of thing.

## Ask your agent to…

- "Add a box-office revenue field to :Film, then check films.ttl against the Class Schema profile and fix every warning it raises."

[Next: Form view](https://semvia.io/docs/authoring/form-view): Edit the same class schema as a form.
