package rdf

  1. Overview
  2. Docs

RDF terms.

type literal = {
  1. lit_value : string;
  2. lit_language : string option;
  3. lit_type : Iri.t option;
}

Literal terms contain a value, an optional language and an optional data type IRI.

type blank_id

Type for blank node ids.

type term =
  1. | Iri of Iri.t
  2. | Literal of literal
  3. | Blank
  4. | Blank_ of blank_id

Various kinds of terms.

val compare : term -> term -> int
val equal : term -> term -> bool
module Ordered_term : sig ... end
module TSet : Stdlib.Set.S with type elt = term
module TMap : Stdlib.Map.S with type key = term
type triple = term * Iri.t * term

A RDF triple is triple (term, iri, term).

type datetime = {
  1. stamp : Ptime.t;
  2. tz : Ptime.tz_offset_s option;
}
val string_of_datetime : datetime -> string

Return RFC 3339 representation of datetime.

val datetime_of_string : string -> datetime

Read datetime from RFC 3339 representation.

val string_of_blank_id : blank_id -> string

Get a string from a blank term id.

val blank_id_of_string : string -> blank_id

Make a blank term id from a string.

val blank : string -> term

Make a blank node with given string id.

val blank_ : blank_id -> term

Make a blank node with given id.

val term_of_iri_string : string -> term

Shortcut for Iri (Iri.of_string string).

val mk_literal : ?typ:Iri.t -> ?lang:string -> string -> literal

Creation of a literal.

val now : unit -> datetime
val mk_literal_datetime : ?d:datetime -> unit -> literal

Create a datetime literal with type iri from the given datetime d. If no date is given, now() is used.

val term_of_datetime : ?d:datetime -> unit -> term

Create a literal term from the given datetime. (see mk_literal_datetime).

val datetime_of_literal : literal -> datetime

Parse a literal to get a datetime.

val mk_literal_bool : bool -> literal

Create a boolean literal with type iri from the given boolean.

val mk_literal_int : ?typ:Iri.t -> int -> literal

Create an integer literal. Default typ is Rdf.xsd_integer.

val mk_literal_double : float -> literal

Create a double literal.

val bool_of_literal : literal -> bool

Parse a literal to get a boolean.

val term_of_literal_string : ?typ:Iri.t -> ?lang:string -> string -> term

Shortcut for Literal (mk_literal ?typ ?lang string)

val term_of_int : ?typ:Iri.t -> int -> term

Shortcut for Literal (mk_literal ?typ int).

val term_of_double : float -> term

Shortcut for Literal (mk_literal ~typ: Rdf.xsd_double float)

val term_of_bool : bool -> term

Create a literal term from the given boolean. (see mk_literal_bool).

val quote_str : string -> string

quote_str str returns the given string str between quotes, with correct literal string escapes.

val string_of_literal : literal -> string

Create a string from the given RDF literal, using turtle syntax.

val string_of_term : term -> string

Create a string for the given term, using RDF turtle syntax conventions.

val pp_term : Stdlib.Format.formatter -> term -> unit

Print the given term to the given formatter.

val term_hash : term -> int64

term_hash term returns an int64 identifiying (hopefully unically)) a given term.

val lit_true : literal

Literal "true" with according type.

val lit_false : literal

Literal "false" with according type.

OCaml

Innovation. Community. Security.