NAME
rdf/datatype - RDF literal value-space helpers.
SYNOPSIS
from rdf/datatype import rdf_literal_canonical, rdf_literal_compare;
from rdf/term import rdf_literal, rdf_iri;
from rdf/ns import XSD_NS;
let a := rdf_literal("01", datatype: rdf_iri(XSD_NS _ "integer"));
let b := rdf_literal("1", datatype: rdf_iri(XSD_NS _ "integer"));
ok(rdf_literal_compare(a, b) == 0);
DESCRIPTION
This module provides value-space helpers for RDF literals. It canonicalizes common XML Schema lexical forms and compares literals after datatype-aware normalization where supported.
SUPPORTED TYPES
The helpers cover strings, language strings, booleans, integer and decimal numeric forms, doubles, dates, times, and dateTimes. Unknown datatypes are compared by exact RDF term key.
EXPORTS
Functions
rdf_literal_canonical_lexical(RDFLiteral literal)Returns the canonical lexical form for supported datatypes, or the original lexical form for unsupported datatypes.
rdf_literal_canonical(RDFLiteral literal)Returns a literal with a canonical lexical form and the same language and datatype.
rdf_literal_numeric(RDFLiteral literal)Returns a numeric value for supported numeric datatypes, or
nullwhen the literal is not numeric.rdf_literal_compare(RDFLiteral left, RDFLiteral right)Compares two literals and returns
-1,0, or1. Numeric literals are compared by numeric value; other supported types use canonical term keys.
COPYRIGHT AND LICENCE
rdf/datatype is copyright Toby Inkster.
It is free software; you may redistribute it and/or modify it under the terms of either the Artistic License 1.0 or the GNU General Public License version 2.