module Rdf_dt: sig
.. end
Computing values in Sparql, mapping to/from RDF terms.
A value can be an error, and propagated in computations.
type
error =
type
value =
| |
Err of error |
| |
Blank of string |
| |
Iri of Rdf_uri.uri |
| |
String of string |
| |
Int of int |
| |
Float of float |
| |
Bool of bool |
| |
Datetime of Netdate.t |
| |
Ltrl of string * string option |
| |
Ltrdt of string * Rdf_uri.uri |
exception Error of error
val error : error -> 'a
val date_fmt : string
Default date format.
val string_of_value : value -> string
Return a string to show the given value.
module ValueOrdered: sig
.. end
module VMap: Map.S
with type key = value
Maps over values.
module VSet: Set.S
with type elt = value
Sets of values.
val string_of_error : error -> string
Return a human-readable message from the given error.
val iri : Rdf_uri.uri -> value -> value
iri base v
returns a Iri
value, ensure the given value is
an URI. If it is a literal string, convert it to an URI, eventually
appending to the base
uri if the string expresses a relative URI.
val datatype : value -> value
datatype v
returns the URI of the datatype of the value.
If v is Err
, Blank
or Iri
, return Err
.
val string_literal : value -> string * string option
string_literal v
returns a pair (string, optional language tag) if
v
is String
of Ltrl
. Else return Err
.
val string : value -> value
string v
returns a String
value, converting any value
to a string, except Err
and Blank
for which Err
is returned.
val int : value -> value
int v
returns a Int
value, trying to convert literal values
to an integer. Return Err
if v
is Err
, Blank
or Iri
, or
if the literal value could not be converted to an integer. Floats
are truncated.
val float : value -> value
val bool : value -> value
Same as
Rdf_dt.int
but for booleans.
Bool true
,
String "true"
,
String "1"
,
Int n
with
n<>0
and
Float f
when
f
is not nan nor zero evaluate
to
Bool true
.
Bool false
,
String "false"
,
String "0"
,
Int 0
and
Float f
when
f
is
nan
or zero evaluate to
Bool false
.
Any other value evaluates to
Err
.
val datetime : value -> value
datetime v
returns a Datetime
, if possible. String literals are converted if
possible; else Err
is returned.
val ltrl : value -> value
Same as
Rdf_dt.string
, but languge tag is kept is present (i.e. if
the value is a
Ltrl
).
val numeric : value -> value
Try to convert the given value to an Int
or else to a Float
,
if the value is not already Int
or Float
.
val of_literal : Rdf_node.literal -> value
of_literal lit
returns a value from a literal node.
val of_node : Rdf_node.node -> value
of_node node
returns a value from an RDF node.
val to_node : value -> Rdf_node.node
to_node v
converts the given value to an RDF node.
If v
is Error e
, then exception e
is raised.