Turtle
From Just Solve the File Format Problem
Revision as of 08:11, 14 May 2025 by Ross-spencer (Talk | contribs)
Turtle (Terse RDF Triple Language) is a W3C Recommendation described a textual syntax for RDF called Turtle that allows an RDF graph to be completely written in a compact and natural text form, with abbreviations for common usage patterns and datatypes.
Examples
Examples from the recommendation.
Describes the relationship between Green Goblin and Spiderman:
@base <http://example.org/> . @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . @prefix foaf: <http://xmlns.com/foaf/0.1/> . @prefix rel: <http://www.perceive.net/schemas/relationship/> . <#green-goblin> rel:enemyOf <#spiderman> ; a foaf:Person ; # in the context of the Marvel universe foaf:name "Green Goblin" . <#spiderman> rel:enemyOf <#green-goblin> ; a foaf:Person ; foaf:name "Spiderman", "Человек-паук"@ru .
An example showing how numbers can be encoded:
@prefix : <http://example.org/elements> . <http://en.wikipedia.org/wiki/Helium> :atomicNumber 2 ; # xsd:integer :atomicMass 4.002602 ; # xsd:decimal :specificGravity 1.663E-4 . # xsd:double
An example of Turtle embedded in a HTML document:
<script type="text/turtle"> @prefix dc: <http://purl.org/dc/terms/> . @prefix frbr: <http://purl.org/vocab/frbr/core#> . <http://books.example.com/works/45U8QJGZSQKDH8N> a frbr:Work ; dc:creator "Wil Wheaton"@en ; dc:title "Just a Geek"@en ; frbr:realization <http://books.example.com/products/9780596007683.BOOK>, <http://books.example.com/products/9780596802189.EBOOK> . <http://books.example.com/products/9780596007683.BOOK> a frbr:Expression ; dc:type <http://books.example.com/product-types/BOOK> . <http://books.example.com/products/9780596802189.EBOOK> a frbr:Expression ; dc:type <http://books.example.com/product-types/EBOOK> . </script>