That's correct. I realized the loader was pointing to an old N3 file! For a day 
or so I was really stumped :)

Nov 4, 2021 10:09:22 AM Andy Seaborne <a...@apache.org>:

> The OP has said on StackOverflow that the wrong data file was being used.
> 
> Andy
> 
> On 04/11/2021 08:30, Andy Seaborne wrote:
> 
> > David,
> > 
> > > This produces the following result:
> > > -------------------------------------------------
> > > | f | vv1 | t1 | t |
> > > =================================================
> > > | "NY635615" | | | "2014-06-30 00:00:00" |
> > > | "NY635615" | | | "2014-06-10 00:00:00" |
> > 
> > That does not look like an xsd:dateTime for ?t.
> > 
> > A plain string prints like that.
> > 
> > If ?t isn't an xsd:dateTime, the you would get ?vv1 and ?t1 being unset.
> > 
> > It has to be "2014-05-27T00:00:00Z"^^xsd:dateTime - not even
> > "2014-05-27T00:00:00Z" - there is no automatic cast in SPARQL.
> > 
> > Andy
> > 
> > On 04/11/2021 06:59, Lorenz Buehmann wrote:
> > 
> > > Hi,
> > > 
> > > I cannot reproduce this.
> > > 
> > > Works for me with
> > > 
> > > java --version
> > > openjdk 11.0.11 2021-04-20
> > > OpenJDK Runtime Environment (build 11.0.11+9-Ubuntu-0ubuntu2)
> > > OpenJDK 64-Bit Server VM (build 11.0.11+9-Ubuntu-0ubuntu2, mixed mode,
> > > sharing)
> > > 
> > > 
> > > In-memory:
> > > 
> > > apache-jena-4.2.0/bin/sparql --data data.ttl --query query.rq
> > > |-------------------------------------------------------------------||
> > > ||| f | vv1 | t1 | t |||
> > > ||===================================================================||
> > > ||| "CT992639" | 2014 | 2014 | "2014-05-27T00:00:00Z"^^xsd:dateTime |||
> > > ||-------------------------------------------------------------------|
> > > 
> > > 
> > > TDB2
> > > 
> > > apache-jena-4.2.0/bin/tdb2.tdbloader --loc tdb2-test data.ttl
> > > 
> > > apache-jena-4.2.0/bin/tdb2.tdbquery --loc tdb2-test --query query.rq
> > > |-------------------------------------------------------------------||
> > > ||| f | vv1 | t1 | t |||
> > > ||===================================================================||
> > > ||| "CT992639" | 2014 | 2014 | "2014-05-27T00:00:00Z"^^xsd:dateTime |||
> > > ||-------------------------------------------------------------------|
> > > 
> > > |
> > > |
> > > 
> > > TDB1
> > > 
> > > apache-jena-4.2.0/bin/tdbloader2 --loc tdb1-test data.ttl
> > > 
> > > apache-jena-4.2.0/bin/tdbquery --loc tdb1-test --query query.rq
> > > |-------------------------------------------------------------------||
> > > ||| f | vv1 | t1 | t |||
> > > ||===================================================================||
> > > ||| "CT992639" | 2014 | 2014 | "2014-05-27T00:00:00Z"^^xsd:dateTime |||
> > > ||-------------------------------------------------------------------|
> > > 
> > > 
> > > Minor comment:
> > > 
> > > the prefix declaration in your sample data has to be either
> > > 
> > > i) @prefix XXX: <> . (dot mandatory)
> > > ii) prefix XXX: <> (no dot allowed, this is same as in SPARQL)
> > > 
> > > 
> > > 
> > > 
> > > On 04.11.21 00:08, David Shumway wrote:
> > > 
> > > > SPARQL:
> > > > prefix sosa: 
> > > > <https://nam04.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.w3.org%2Fns%2Fsosa%2F&amp;data=04%7C01%7Cdshumw2%40groute.uic.edu%7C614dff85d906412d717408d99fa504dc%7Ce202cd477a564baa99e3e3b71a7c77dd%7C0%7C0%7C637716353621817142%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=wi53%2FcpWHF6LVi6IncLM6UnMJ2WoTFgGb983vLitzM8%3D&amp;reserved=0>
> > > > prefix xsd: 
> > > > <https://nam04.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema%23&amp;data=04%7C01%7Cdshumw2%40groute.uic.edu%7C614dff85d906412d717408d99fa504dc%7Ce202cd477a564baa99e3e3b71a7c77dd%7C0%7C0%7C637716353621817142%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=JmsinRHGh0GCcXH6He5uaX2c4kf5qQaenvvz3C0NDhA%3D&amp;reserved=0>
> > > > 
> > > > SELECT ?f ?vv1 (year(?t) as ?t1) ?t
> > > > WHERE {
> > > > ?s a sosa:Observation .
> > > > ?s sosa:hasFeatureOfInterest ?f .
> > > > ?s sosa:resultTime ?t .
> > > > bind(YEAR(?t) as ?vv1)
> > > > }
> > > > 
> > > > Where the data is e.g.:
> > > > prefix sosa: 
> > > > <https://nam04.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.w3.org%2Fns%2Fsosa%2F&amp;data=04%7C01%7Cdshumw2%40groute.uic.edu%7C614dff85d906412d717408d99fa504dc%7Ce202cd477a564baa99e3e3b71a7c77dd%7C0%7C0%7C637716353621817142%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=wi53%2FcpWHF6LVi6IncLM6UnMJ2WoTFgGb983vLitzM8%3D&amp;reserved=0>
> > > >  .
> > > > prefix xsd: 
> > > > <https://nam04.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema%23&amp;data=04%7C01%7Cdshumw2%40groute.uic.edu%7C614dff85d906412d717408d99fa504dc%7Ce202cd477a564baa99e3e3b71a7c77dd%7C0%7C0%7C637716353621817142%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=JmsinRHGh0GCcXH6He5uaX2c4kf5qQaenvvz3C0NDhA%3D&amp;reserved=0>
> > > >  .
> > > > prefix ex: 
> > > > <https://nam04.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.example.org%2F&amp;data=04%7C01%7Cdshumw2%40groute.uic.edu%7C614dff85d906412d717408d99fa504dc%7Ce202cd477a564baa99e3e3b71a7c77dd%7C0%7C0%7C637716353621817142%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=L8ORXsagizmqHWAsBt8l6b6eZCwJK%2F5FrDcYdXSvOGE%3D&amp;reserved=0>
> > > >  .
> > > > ex:beachSample-2014-0 a sosa:Observation ;
> > > > sosa:hasFeatureOfInterest "CT992639"^^xsd:string ;
> > > > sosa:resultTime "2014-05-27T00:00:00Z"^^xsd:dateTime .
> > > > 
> > > > Loaded as follows:
> > > > ./apache-jena-4.2.0/bin/tdbloader2 --loc=/A ./tmp.n3
> > > > 
> > > > And queried with (where q1.rq contains the SPARQL query above):
> > > > ./apache-jena-4.2.0/bin/tdbquery --loc=/A --query=./q1.rq
> > > > 
> > > > This produces the following result:
> > > > -------------------------------------------------
> > > > | f | vv1 | t1 | t |
> > > > =================================================
> > > > | "NY635615" | | | "2014-06-30 00:00:00" |
> > > > | "NY635615" | | | "2014-06-10 00:00:00" |
> > > > 
> > > > With the expected (hopeful) behavior being an output like this (which is
> > > > not the actual query result):
> > > > -----------------------------------------------------
> > > > | f | vv1 | t1 | t |
> > > > =====================================================
> > > > | "NY635615" | 2014 | 2014 | "2014-06-30T00:00:00Z" |
> > > > | "NY635615" | 2014 | 2014 | "2014-06-10T00:00:00Z" |
> > > > 
> > > > Columns *vv1* and *t1* are both attempts to get the year value to
> > > > appear in
> > > > the query result, without success. And column *t* is simply showing the
> > > > data being held as sosa:resultTime, where I would assume it would be
> > > > formatted as an XSD:dateTime value but instead is appearing a little
> > > > differently?
> > > > 
> > > > Any help is much appreciated!
> > > > 
> > > > 
> > > 
> > > 
> > 
> 

Reply via email to