amphibient
amphibient

Reputation: 31238

How to import dateTime literal using TTL?

I am copying data from one RDF store to another.

The way dateTime comes from the source (in XML format) is:

<binding name="o"><literal datatype="http://www.w3.org/2001/XMLSchema#dateTime">2016-12-01T15:31:10-05:00</literal></binding>

I try to take the value as is and import it via a TTL file myFile.ttl:

<http://test.com>
    a   <http://test.com/catalog/someType> ;
    <http://test.com#modifiedDate>
        "2016-12-01T15:31:10-05:00" ; # http://www.w3.org/2001/XMLSchema#dateTime
    <http://test.com#numberTest>
        5 . # http://www.w3.org/2001/XMLSchema#integer

but that inserts "2016-12-01T15:31:10-05:00" as a string. The last triple with object 5 is properly inserted as an integer.

How can I import dateTime data using TTL files? I am using Virtuoso. I am importing TTL files in isql:

DB.DBA.TTLP_MT(file_to_string_output('myFile.ttl'), '', 'http://my.domain.com/mygraph', 255);

Upvotes: 2

Views: 912

Answers (2)

TallTed
TallTed

Reputation: 9434

In Turtle, "2016-12-01T15:31:10-05:00" is an untyped quoted literal -- i.e., a string.

You need to have one of these instead --

  • "2016-12-01T15:31:10-05:00"^^<http://www.w3.org/2001/XMLSchema#dateTime>
  • "2016-12-01T15:31:10-05:00"^^xsd:dateTime

As for 5 (no quotes), it isn't a quoted literal, and is a numeric string, so you got lucky with auto-typing. Strictly speaking, the Turtle for this should probably (you didn't include the XML for this) be one of these --

  • "5"^^<http://www.w3.org/2001/XMLSchema#integer>
  • "5"^^xsd:integer

Upvotes: 4

amphibient
amphibient

Reputation: 31238

Instead of the "val" # type format, the following worked:

<http://test.com>
    a   <http://test.com/catalog/someType> ;
    <http://test.com#modifiedDate>
        '2016-12-01T15:31:10-05:00'^^<http://www.w3.org/2001/XMLSchema#dateTime> ;
    <http://test.com#numberTest>
        '5'^^<http://www.w3.org/2001/XMLSchema#integer> .

Note that even integers need to be wrapped in quotes with the ^^<type> notation.

Upvotes: 2

Related Questions