0

I have been trying to do some formatting of date/time values to make them display as string literals in the result. I am using Jena ARQ from apache-jena-2.11.0 .

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX prov: <http://www.w3.org/ns/prov#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

SELECT ?activity  ?agent ?time ?time (YEAR(?time) as ?year )   WHERE {
     ?activity prov:endedAtTime ?time ;
            prov:wasAssociatedWith ?agent .

}

ARQ reports the date time as

"2015-02-20T13:07:53+00:00:00"^^<xsd:dateTime>  to me.

This is how the property looks in RDF as a TTL :

<http://www.w3.org/ns/prov#endedAtTime>
    "2014-08-04T15:35:09+01:00:00"^^<xsd:dateTime> ;

This was created with the following use of the Jena API:

resource.addProperty(PROVO.endedAtTime,
                model.createTypedLiteral(date, "xsd:dateTime"));

Maybe I am using the API wrong?

Joshua Taylor
  • 84,998
  • 9
  • 154
  • 353
Interition
  • 381
  • 2
  • 15

1 Answers1

2

Yes, Jena supports all the SPARQL 1.1 functions.

You have having problems because

"2015-01-07T15:22:53+00:00:00"^^<xsd:dateTime> 

is not a datetime.

"2015-01-07T15:22:53+00:00:00"^^http://www.w3.org/2001/XMLSchema#dateTime> 

or

"2015-01-07T15:22:53+00:00:00"^^xsd:dateTime 

<xsd:dateTime> is a completely different URI, URI scheme name "xsd".

AndyS
  • 16,345
  • 17
  • 21
  • Thanks Andy. Still a little unsure. I added some info about how I was using the Jena API. Is it my use that produces the wrong type for the property ? – Interition Mar 14 '15 at 10:19
  • 1
    Put the URI in when creating the literal: `model.createTypedLiteral(date, "http://www.w3.org/2001/XMLSchema#dateTime")` – AndyS Mar 14 '15 at 15:38
  • 1
    @Interition Even more explicitly, the *string* "xsd:dateTime" is what you're passing to createTypedLiteral. Jena expect an actual URI string. Note that that the TTL include `"..."^^` with `<>` around the string `xsd:dateTime`. When you use the actual URI, you'll get `"..."^^xsd:dateTime` with the proper URI. – Joshua Taylor Mar 15 '15 at 01:27
  • Ah, I got it. Thanks. Is there a constant in the Jena API somewhere in the API for "http://www.w3.org/2001/XMLSchema#dateTime" ? Seems a bit untidy to have to explicitly provide a string like that. – Interition Mar 15 '15 at 08:38
  • 1
    XSDDatatype for all your XSD needs. Then you don't have to use the string form at all but use a typed constant. – AndyS Mar 15 '15 at 11:30