https://github.com/dropbear-software/rdf_dart
https://github.com/dropbear-software/rdf_dart
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/dropbear-software/rdf_dart
- Owner: dropbear-software
- Created: 2026-01-02T18:40:50.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2026-03-02T20:02:11.000Z (3 months ago)
- Last Synced: 2026-04-06T03:37:18.929Z (about 2 months ago)
- Language: HTML
- Size: 1.09 MB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# 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](https://www.w3.org/TR/rdf12-concepts/) 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.
```dart
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:
// PREFIX foaf:
//
// 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.)
```dart
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
}
```