30.33 Dart Package: rdflib

20220924

See https://pub.dev/packages/rdflib.

wget https://raw.githubusercontent.com/anusii/rdflib/main/example/rdflib_example.dart

Manage package dependencies by creating the file pubspec.yaml:

editor pubspec.yaml

with the contents

name: example

environment:
  sdk: ">=2.12.0 <3.0.0"

dependencies:
  rdflib: ^0.1.1

Manage the dependencies by running the following:

dart pub get

Then run the application:

dart run rdflib_example.dart

to produce the console output:

------------------------------
URIRef(http://example.org/donna) URIRef(http://www.w3.org/1999/02/22-rdf-syntax-ns#type) URIRef(http://xmlns.com/foaf/0.1/Person) .
URIRef(http://example.org/donna) URIRef(http://xmlns.com/foaf/0.1/nick) Literal(donna, lang: en) .
URIRef(http://example.org/donna) URIRef(http://xmlns.com/foaf/0.1/name) Literal(Donna Fales, datatype: URIRef(http://www.w3.org/2001/XMLSchema#string)) .
URIRef(http://example.org/donna) URIRef(http://xmlns.com/foaf/0.1/name) Literal(Donna Fales, datatype: URIRef(http://www.w3.org/2001/XMLSchema#string)) .
URIRef(http://example.org/donna) URIRef(http://xmlns.com/foaf/0.1/mbox) URIRef(mailto:donna@example.org) .
URIRef(http://example.org/edward) URIRef(http://www.w3.org/1999/02/22-rdf-syntax-ns#type) URIRef(http://xmlns.com/foaf/0.1/Person) .
URIRef(http://example.org/edward) URIRef(http://xmlns.com/foaf/0.1/nick) Literal(ed, datatype: URIRef(http://www.w3.org/2001/XMLSchema#string)) .
URIRef(http://example.org/edward) URIRef(http://xmlns.com/foaf/0.1/name) Literal(Edward Scissorhands, datatype: URIRef(http://www.w3.org/2001/XMLSchema#string)) .
URIRef(http://example.org/edward) URIRef(http://xmlns.com/foaf/0.1/mbox) Literal(e.scissorhands@example.org, datatype: URIRef(http://www.w3.org/2001/XMLSchema#anyURI)) .
------------------------------
URIRef(mailto:donna@example.org)
Literal(e.scissorhands@example.org, datatype: URIRef(http://www.w3.org/2001/XMLSchema#anyURI))

and the file example/ex1.ttl:

@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .

<http://example.org/donna> rdf:type foaf:Person ;
    foaf:nick "donna"@en ;
    foaf:name "Donna Fales"^^xsd:string ;
    foaf:name "Donna Fales"^^xsd:string ;
    foaf:mbox <mailto:donna@example.org> .

<http://example.org/edward> rdf:type foaf:Person ;
    foaf:nick "ed"^^xsd:string ;
    foaf:name "Edward Scissorhands"^^xsd:string ;
    foaf:mbox "e.scissorhands@example.org"^^xsd:anyURI .


Your donation will support ongoing availability and give you access to the PDF version of this book. Desktop Survival Guides include Data Science, GNU/Linux, and MLHub. Books available on Amazon include Data Mining with Rattle and Essentials of Data Science. Popular open source software includes rattle, wajig, and mlhub. Hosted by Togaware, a pioneer of free and open source software since 1984. Copyright © 1995-2022 Graham.Williams@togaware.com Creative Commons Attribution-ShareAlike 4.0