Data Types

January 15, 2019 ยท View on GitHub

Knowledge statements contain scalar objects -- literals. Literals are either language-tagged string rdf:langString or type-safe values containing a reference to data-type (e.g. xsd:string). This section defines rules how semantic data types are serialized to Erlang native formats.

Primitive Data Types

Knowledge statements contain scalar objects -- literals. Literals are either language-tagged string rdf:langString or type-safe values containing a reference to data-type (e.g. xsd:string). This section defines data-types supported by the library, its mapping to Erlang native types and relation to existed schema(s) and ontologies.

URI / IRI

The data type represents a Uniform Resource Identifier / Internationalized Resource Identifier. Used to uniquely identify concept, objects, etc.

LangData type
Erlang`-type {iri, uri()}
Semantic?XSD_ANYURI
Text<uri>
prefix:suffix
RDFxmlns:xsd="http://www.w3.org/2001/XMLSchema#string"

binary

The binary data-type represents character strings in knowledge statements. The language strings are annotated with corresponding language tag.

LangData type
Erlang-type binary().
Semantic?XSD_STRING
Text"string"
"string"^^xsd:string
"string"@en
RDFxmlns:xsd="http://www.w3.org/2001/XMLSchema#string"

integer

The library derives an arbitrary-precision Integers from Erlang (only limited by available memory on the machine).

LangData type
Erlang-type integer().
Semantic?XSD_INTEGER
?XSD_LONG
?XSD_INT
?XSD_SHORT
?XSD_BYTE
Text10
"10"^^xsd:integer
RDFxmlns:xsd="http://www.w3.org/2001/XMLSchema#integer"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#long"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#int"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#short"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#byte"

float

The value is the IEEE 754 double-precision 64-bit floating point type.

LangData type
Erlang-type float().
Semantic?XSD_DECIMAL
?XSD_FLOAT
?XSD_DOUBLE
Text10.1
"10.1"^^xsd:decimal
RDFxmlns:xsd="http://www.w3.org/2001/XMLSchema#decimal"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#float"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#double"

boolean

The value is either true or false, representing a logic values

LangData type
Erlang-type true | false.
Semantic?XSD_BOOLEAN
Text`true
RDFxmlns:xsd="http://www.w3.org/2001/XMLSchema#boolean"

datetime

The date-time value is closely related to calendar dates and times described by ISO 8601, covering AD and BC eras. Erlang native date format is triple of integers giving micro-seconds precision. The external representation is ISO 8601.

LangData type
Erlang-type {integer(), integer(), integer()}.
Semantic?XSD_DATETIME
TextISO8601
2007-04-05T14:30:00Z
RDFxmlns:xsd="http://www.w3.org/2001/XMLSchema#dateTime"

recursive date/times

XSD defines set of recursive data-types. These types are also translated to native datetime format.

LangData type
Erlang-type {{integer(), integer(), integer()}, {integer(), integer(), integer()}}.
Semantic?XSD_DATE
?XSD_TIME
?XSD_YEARMONTH
?XSD_YEAR
?XSD_MONTHDAY
?XSD_MONTH
?XSD_DAY
TextISO8601
2007-04-05
14:30:00Z
2007-04
--04-05
2007
04
05
RDFxmlns:xsd="http://www.w3.org/2001/XMLSchema#date"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#time"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#gYearMonth"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#gYear"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#gMonthDay"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#gMonth"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#gDay"

Geo Point

The geographical coordinates are encoded using either GeoHash or latitude/longitude pair. GeoHash is encoded using georss:hash that ensures precision about 3.7cm x 1.8cm. The latitude/longitude pair is encoded georss:point as tuple of floats.

LangData type
Erlang`-type binary()
Semantic?GEORSS_HASH
?GEORSS_POINT
Text"ueh6xc"^^georss:hash
25.7,62.1
RDFxmlns:georss="http://www.georss.org/georss/point"
xmlns:georss="http://www.georss.org/georss/hash"

GeoJson

The data type facilitates operations with geospatial data as defined by https://tools.ietf.org/html/rfc7946

LangData type
Erlang-type #{<<"type">> => _, <<"coordinates">> => _}.
Semantic?GEORSS_JSON
Text(type: ..., coordinates: ...)
RDFxmlns:georss="http://www.georss.org/georss/json"

not supported

Reference

  1. http://www.w3.org/TR/xmlschema-2/
  2. https://en.wikipedia.org/wiki/Geohash