Module sophia_api::ns

source ·
Expand description

Standard and custom namespaces.

This module provides:

  • the Namespace type for defining custom dynamic namespace;
  • the namespace macro, for defning custom static namespaces;
  • modules corresponding to the most common namespaces (generated via the namespace macro).

Example use

use sophia_api::ns::{Namespace, rdf, rdfs, xsd};

let schema = Namespace::new("http://schema.org/").unwrap();
let s_name = schema.get("name").unwrap();

// you can now populate a graph like this:
let mut g = vec![];
g.push([&s_name, &rdf::type_, &rdf::Property]);
g.push([&s_name, &rdfs::range, &xsd::string]);

Datatyped literals

Note also that the terms generated via the namespace macro can be used to easily produce datatyped literals, by simply “multiplying” a string by its datatype:

let date = "2023-11-15" * xsd::date ;
assert!(date.is_literal());
assert_eq!(date.lexical_form().unwrap(), "2023-11-15");
assert_eq!(date.datatype().unwrap(), xsd::date.iri().unwrap());

Modules

  • The standard owl: namespace
  • The standard rdf: namespace.
  • The standard rdfs: namespace.
  • The standard xml: namespace
  • The standard xsd: namespace.

Macros

  • Create a “namespace module” defining a set of terms within a given IRI space.
  • Create a term in a “namespace module”. In general, you should use the namespace! macro instead.

Structs