Type-Safe RDF Vocabularies
Stop wrestling with RDF vocabulary URIs.
Type-safe Dart constants with IDE autocompletion and compile-time validation.
Why Not Just Use Strings?
String-based RDF development is error-prone, lacks IDE support, and makes discovering vocabulary relationships nearly impossible.
β The String-Based Approach
// Typos detected only at runtime
Triple(subject, predicate,
IriTerm('http://schema.org/Persn')); // Oops!
// No IDE assistance
Triple(subject,
IriTerm('http://xmlns.com/foaf/0.1/knows'), ...);
// Hidden relationships
// How do you know foaf:knows works with schema:Person?
// You need to manually research vocabulary compatibility - Runtime errors from typos
- No autocompletion
- Manual vocabulary research
- Hidden cross-vocabulary patterns
β The Type-Safe Solution
// Compile-time validation
Triple(subject, SchemaPerson.rdfType,
SchemaPerson.classIri);
// IDE shows foafKnows, foafAge, etc.
SchemaPerson. // β autocomplete!
// Discover cross-vocabulary properties
// SchemaPerson includes FOAF properties automatically
Triple(person, SchemaPerson.foafAge,
LiteralTerm.integer(42)); - Catch errors before runtime
- Full IDE autocompletion
- Discover valid combinations
- Learn relationships naturally
Choose Your Package
Modular packages from 27KB to 12MB β take only what you need.
Core Vocabularies
locorda_rdf_terms_core
~27KB
Foundational RDF vocabularies: RDF, RDFS, OWL, XSD. Essential for most applications.
Common Vocabularies
locorda_rdf_terms_common
~800KB
Essential semantic web vocabularies: FOAF, Dublin Core, DCAT, SKOS, vCard, ACL, Solid, and more.
Schema.org
locorda_rdf_terms_schema
~5MB
Complete Schema.org vocabulary with HTTPS URIs. Modern standard for structured data.
Schema.org (HTTP)
locorda_rdf_terms_schema_http
~5MB
Schema.org vocabulary with HTTP URIs for legacy compatibility.
Custom Generation
locorda_rdf_terms_generator
Need different vocabularies? Generate your own custom packages with exactly the vocabularies you need.
Learn about the generator βπ‘ Quick Selection Guide
- Most projects: Start with
locorda_rdf_terms_common(~800KB) - Using RDF/RDFS/OWL/XSD directly? Add
locorda_rdf_terms_core(~27KB) - Need Schema.org? Add
locorda_rdf_terms_schema - Custom vocabularies? Use the generator
Getting Started
Install packages
# Most projects: common vocabularies
dart pub add locorda_rdf_terms_common
# Add core if using RDF/RDFS/OWL/XSD directly
dart pub add locorda_rdf_terms_core
# Add Schema.org if needed
dart pub add locorda_rdf_terms_schema Class-Specific Approach
Use class-specific constants that guide you to the correct properties. Perfect for RDF newcomers!
/// Example demonstrating the class-specific approach to using RDF vocabularies.
///
/// This approach is beginner-friendly and provides IDE autocompletion for
/// properties that are valid for a specific RDF class.
library;
import 'package:locorda_rdf_core/core.dart';
import 'package:locorda_rdf_terms_common/foaf.dart';
void main() {
final personIri = IriTerm('http://example.org/person/jane_doe');
// Create a graph using class-specific constants
// FoafPerson provides all properties relevant to a FOAF Person
final graph = RdfGraph.fromTriples([
// Use FoafPerson class for type-safe property access
Triple(personIri, FoafPerson.rdfType, FoafPerson.classIri),
Triple(personIri, FoafPerson.name, LiteralTerm.string('Jane Doe')),
Triple(personIri, FoafPerson.givenName, LiteralTerm.string('Jane')),
Triple(personIri, FoafPerson.familyName, LiteralTerm.string('Doe')),
Triple(personIri, FoafPerson.age, LiteralTerm.integer(42)),
Triple(personIri, FoafPerson.mbox, IriTerm('mailto:jane.doe@example.com')),
]);
print('Class-Specific Approach Example:');
print(RdfCore.withStandardCodecs().encode(graph));
} Direct Vocabulary Approach
Use vocabulary classes directly for maximum flexibility. Ideal for RDF experts!
/// Example demonstrating the direct vocabulary approach to using RDF vocabularies.
///
/// This approach is for RDF experts who want maximum flexibility and concise syntax.
library;
import 'package:locorda_rdf_core/core.dart';
import 'package:locorda_rdf_terms_common/foaf.dart';
import 'package:locorda_rdf_terms_core/rdf.dart';
import 'package:locorda_rdf_terms_common/dc.dart';
void main() {
final personIri = IriTerm('http://example.org/person/jane_doe');
// Create a graph with direct vocabulary access
// Mix vocabularies freely for maximum flexibility
final graph = RdfGraph.fromTriples([
Triple(personIri, Rdf.type, Foaf.Person),
Triple(personIri, Foaf.name, LiteralTerm.string('Jane Doe')),
Triple(personIri, Foaf.age, LiteralTerm.integer(42)),
Triple(personIri, Dc.creator, LiteralTerm.string('System')),
]);
print('Direct Vocabulary Approach Example:');
print(RdfCore.withStandardCodecs().encode(graph));
} Cross-Vocabulary Properties
Discover how class-specific constants include properties from related vocabularies automatically.
/// Example demonstrating cross-vocabulary properties in class-specific constants.
///
/// Shows how SchemaPerson includes properties from related vocabularies like FOAF,
/// enabling seamless vocabulary mixing through IDE autocompletion.
library;
import 'package:locorda_rdf_core/core.dart';
import 'package:locorda_rdf_terms_schema/schema.dart';
void main() {
final personIri = IriTerm('http://example.org/person/jane_doe');
final friendIri = IriTerm('http://example.org/person/john_smith');
// SchemaPerson includes common FOAF properties
// Discover them via IDE autocompletion!
final graph = RdfGraph.fromTriples([
// Related RDF properties like rdf:type are accessible through SchemaPerson context
Triple(personIri, SchemaPerson.rdfType, SchemaPerson.classIri),
// Pure schema.org properties for schema:Person
Triple(personIri, SchemaPerson.name, LiteralTerm.string('Jane Doe')),
Triple(
personIri, SchemaPerson.email, LiteralTerm.string('jane@example.com')),
// Related FOAF properties are accessible through SchemaPerson context
Triple(personIri, SchemaPerson.foafAge,
LiteralTerm.integer(42)), // FOAF property!
Triple(personIri, SchemaPerson.foafKnows, friendIri), // FOAF relationship!
]);
print('Cross-Vocabulary Properties Example:');
print(RdfCore.withStandardCodecs().encode(graph));
} Key Benefits
Zero Runtime Overhead
All constants are compile-time. No performance impact, just pure type safety.
Type Safety
Catch vocabulary errors at compile time, not runtime. Full IDE support with autocompletion.
Tree Shaking
Unused vocabularies are eliminated from builds. Only pay for what you use.
IDE Integration
Full autocompletion and inline documentation. Hover to see ontology descriptions.
Cross-Vocabulary Discovery
Class-specific constants include properties from related vocabularies. Learn relationships naturally.
Modular Packages
Choose from 27KB to 12MB. Take only what you need for optimal bundle size.
Ready to Build with Type-Safe RDF?
Join developers using Locorda RDF vocabularies to build semantic applications in Dart and Flutter.