Module 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§

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

Macros§

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

Structs§

IriRef
See IriRef::new.
Namespace
A custom namespace.
NsTerm
A Term produced by a Namespace.