Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

75 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RDF for Dart

A comprehensive implementation of the RDF 1.2 standard for the Dart programming language.

Overview

This package aims to provide a complete and compliant implementation of the RDF 1.2 Concepts and Abstract Data Model and related specifications. It is designed to modernize RDF support in Dart, incorporating the latest advancements from the W3C, including support for RDF-star (Triple Terms).

This implementation will also be fully compatible with RDF 1.1.

Features

  • RDF 1.2 Data Model: Full support for IRIs, Literals, Blank Nodes, and Triple Terms.
  • Datasets: Native support for RDF Datasets (Default Graph + Named Graphs).
  • Strong Typing: leveraged Dart's type system for correct RDF term representation.
  • Modern Standards: Built to align with specifications like xsd:duration and xsd:dayTimeDuration.
  • Serialization: Fully compliant RDF 1.2 Turtle and N-Triples codecs.

Usage

Turtle Serialization

The TurtleEncoder provides human-readable, terse output with support for prefixes, base URIs, and RDF 1.2 features like annotations and triple terms.

import 'package:rdf_dart/rdf_dart.dart';

void main() {
  final s = Iri('http://example.org/alice');
  final p = Iri('http://xmlns.com/foaf/0.1/name');
  final o = Literal('Alice');

  final triples = [Triple(subject: s, predicate: p, object: o)];

  final turtle = TurtleEncoder(
    prefixes: {'foaf': 'http://xmlns.com/foaf/0.1/', 'ex': 'http://example.org/'},
    baseUri: 'http://example.org/',
  ).convert(triples);

  print(turtle);
  // Output:
  // PREFIX ex: <http://example.org/>
  // PREFIX foaf: <http://xmlns.com/foaf/0.1/>
  // 
  // ex:alice
  //     foaf:name "Alice" .
}

Vocabulary Constants

The package includes type-safe Iri constants for standard vocabularies:

  • Rdf: Standard RDF terms (Rdf.type, Rdf.nil, Rdf.first, etc.)
  • Rdfs: RDF Schema terms (Rdfs.label, Rdfs.subClassOf, etc.)
  • Xsd: XML Schema datatypes (Xsd.string, Xsd.integer, Xsd.boolean, etc.)
import 'package:rdf_dart/rdf_dart.dart';

void main() {
  final type = Rdf.type;
  final label = Rdfs.label;
  final integer = Xsd.integer;

  print(type); // http://www.w3.org/1999/02/22-rdf-syntax-ns#type
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages