15 Module schema
(require rdf/core/schema) | package: rdf-core |
This module provides a higher-level interface for creating RDF Schema graphs, accepting more raw types which are converted, providing type-specific constructors with common properties as keyword arguments, and a method to convert a schema value into a set of statements.
Schema Module Overview
> (require rdf/core/graph rdf/core/io rdf/core/nsmap rdf/core/resource rdf/core/schema)
> (define example (make-schema "http://example.com/ns/" #:label "An example schema" (assert 'version 2) (class 'Identity) (class 'Entity) (class 'Campaign #:subClassOf 'Entity) (class 'AdGroup #:subClassOf 'Entity) (class 'Ad #:subClassOf 'Entity) (property 'hasIdentity #:domain 'Entity #:range 'Identity) (property 'hasDependentPart #:label "has dependent part") (property 'hasIndependentPart #:label "has independent part") (property 'hasGroup #:label "has group" #:subPropertyOf 'hasIndependentPart #:domain 'Campaign #:range 'AdGroup) (property 'hasAd #:label "has ad" #:subPropertyOf 'hasIndependentPart #:domain 'AdGroup #:range 'Ad)))
> (let ((ns-map (make-common-nsmap))) (nsmap-set-default! ns-map (string->resource "http://example.com/ns/")) (write-ntriple-graph (unnamed-graph (schema->statements example) ns-map)))
<http://example.com/ns/hasAd> <http://www.w3.org/2000/01/rdf-schema#domain> <http://example.com/ns/AdGroup> .
<http://example.com/ns/hasDependentPart> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/1999/02/22-rdf-syntax-ns#Property> .
<http://example.com/ns/Campaign> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Class> .
<http://example.com/ns/hasGroup> <http://www.w3.org/2000/01/rdf-schema#range> <http://example.com/ns/AdGroup> .
<http://example.com/ns/AdGroup> <http://www.w3.org/2000/01/rdf-schema#subClassOf> <http://example.com/ns/Entity> .
<http://example.com/ns/hasIdentity> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/1999/02/22-rdf-syntax-ns#Property> .
<http://example.com/ns/Ad> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Class> .
<http://example.com/ns/hasAd> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/1999/02/22-rdf-syntax-ns#Property> .
<http://example.com/ns/> <http://www.w3.org/2000/01/rdf-schema#label> "An example schema" .
<http://example.com/ns/hasAd> <http://www.w3.org/2000/01/rdf-schema#label> "has ad" .
<http://example.com/ns/Campaign> <http://www.w3.org/2000/01/rdf-schema#subClassOf> <http://example.com/ns/Entity> .
<http://example.com/ns/hasGroup> <http://www.w3.org/2000/01/rdf-schema#domain> <http://example.com/ns/Campaign> .
<http://example.com/ns/hasAd> <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> <http://example.com/ns/hasIndependentPart> .
<http://example.com/ns/hasGroup> <http://www.w3.org/2000/01/rdf-schema#label> "has group" .
<http://example.com/ns/> <http://example.com/ns/version> "2"^^<http://www.w3.org/2001/XMLSchema#integer> .
<http://example.com/ns/hasGroup> <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> <http://example.com/ns/hasIndependentPart> .
<http://example.com/ns/hasIndependentPart> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/1999/02/22-rdf-syntax-ns#Property> .
<http://example.com/ns/hasIdentity> <http://www.w3.org/2000/01/rdf-schema#range> <http://example.com/ns/Identity> .
<http://example.com/ns/Identity> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Class> .
<http://example.com/ns/Ad> <http://www.w3.org/2000/01/rdf-schema#subClassOf> <http://example.com/ns/Entity> .
<http://example.com/ns/hasIndependentPart> <http://www.w3.org/2000/01/rdf-schema#label> "has independent part" .
<http://example.com/ns/Entity> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Class> .
<http://example.com/ns/AdGroup> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Class> .
<http://example.com/ns/hasDependentPart> <http://www.w3.org/2000/01/rdf-schema#label> "has dependent part" .
<http://example.com/ns/hasGroup> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/1999/02/22-rdf-syntax-ns#Property> .
<http://example.com/ns/hasIdentity> <http://www.w3.org/2000/01/rdf-schema#domain> <http://example.com/ns/Entity> .
<http://example.com/ns/hasAd> <http://www.w3.org/2000/01/rdf-schema#range> <http://example.com/ns/Ad> .