Re: Re: XSD date functions broken?

2023-04-18 Thread Enrico . Daga
Hi Simon,

Thanks for the analysis; very useful!
The roundtrip with `xsd:duration` it's clever, I will use that.

Many thanks!

Enrico


--
Enrico Daga, PhD

www.enridaga.net | @enridaga

SPARQL Anything http://sparql-anything.cc
Polifonia http://polifonia-project.eu
SPICE http://spice-h2020.eu
Open Knowledge Graph http://data.open.ac.uk

Senior Research Fellow, Knowledge Media Institute, STEM Faculty
The Open University
Level 4 Berrill Building, Walton Hall, Milton Keynes, MK7 6AA
Direct: +44 (0) 1908 654887

From: Simon Bin 
Sent: 18 April 2023 17:54
To: users@jena.apache.org 
Subject: Re: Re: XSD date functions broken?

There is no way to do it in Plain Sparql as far as I know

There are many choices, some:


 * use Sparql-Generate[1] and

```
select * {
 
bind((1649185973*1000)
 as ?dateTime)
}
```


 * RdfProcessingToolkit[2] / Norse and Javascript:

```
PREFIX xsd: 
>
select * {
 
bind(strdt(("_
 => new Date(_).toISOString()", 1649185973*1000), xsd:dateTime) as ?dateTime)
}
```


 * Jena Javascript extensions[3] and define the above function in your
   own JS file


 * Your custom Java extension function


 * Convert it before you use SPARQL, with Bash/Java/Python/etc


 * Abuse the Jena Duration extension to SPARQL


```
PREFIX xsd: 
>
select * {
 bind("1970-01-01T00:00:00Z"^^xsd:dateTime as ?unixEpochStart)
 bind(strdt(concat("PT", str(1649185973), "S"), xsd:duration) as ?passedSeconds)
 bind(?unixEpochStart + ?passedSeconds as ?dateTimeDuration)
}
```


   1. 
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fci.mines-stetienne.fr%2Fsparql-generate%2F=05%7C01%7Cenrico.daga%40open.ac.uk%7C0f3c27bf48e94f82d54f08db402da455%7C0e2ed45596af4100bed3a8e5fd981685%7C0%7C0%7C638174336999814557%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=JKXPcE6YtmJQIoma6HjVMolNDBtoR9c4TlRrmJJZN2k%3D=0
   2. 
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FSmartDataAnalytics%2FRdfProcessingToolkit=05%7C01%7Cenrico.daga%40open.ac.uk%7C0f3c27bf48e94f82d54f08db402da455%7C0e2ed45596af4100bed3a8e5fd981685%7C0%7C0%7C638174336999814557%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=yVhCMp5gTo%2BZzpVxsJK7zVSOZIH7mBY9aqpQclvw3WM%3D=0
   3. 
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fjena.apache.org%2Fdocumentation%2Fquery%2Fjavascript-=05%7C01%7Cenrico.daga%40open.ac.uk%7C0f3c27bf48e94f82d54f08db402da455%7C0e2ed45596af4100bed3a8e5fd981685%7C0%7C0%7C638174336999814557%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=2drhAqogn7cO%2FDHcv0F0UvDwY9FuSe%2FHablhxaqUouc%3D=0
  functions.html

On Tue, 2023-04-18 at 13:07 +, Enrico.Daga wrote:
> Hi Martynas,
>
> I think you are right; my mistake. But how would you handle the case
> of converting a Unix timestamp into a readable date in SPARQL?
>
> Enrico
>
> --

Re: Re: XSD date functions broken?

2023-04-18 Thread Simon Bin
There is no way to do it in Plain Sparql as far as I know

There are many choices, some:


 * use Sparql-Generate[1] and

```
select * {
 bind((1649185973*1000) as 
?dateTime)
}
```


 * RdfProcessingToolkit[2] / Norse and Javascript:

```
PREFIX xsd: 
select * {
 bind(strdt(("_ => new 
Date(_).toISOString()", 1649185973*1000), xsd:dateTime) as ?dateTime)
}
```


 * Jena Javascript extensions[3] and define the above function in your
   own JS file


 * Your custom Java extension function


 * Convert it before you use SPARQL, with Bash/Java/Python/etc


 * Abuse the Jena Duration extension to SPARQL


```
PREFIX xsd: 
select * {
 bind("1970-01-01T00:00:00Z"^^xsd:dateTime as ?unixEpochStart)
 bind(strdt(concat("PT", str(1649185973), "S"), xsd:duration) as ?passedSeconds)
 bind(?unixEpochStart + ?passedSeconds as ?dateTimeDuration)
}
```


   1. https://ci.mines-stetienne.fr/sparql-generate/
   2. https://github.com/SmartDataAnalytics/RdfProcessingToolkit
   3. https://jena.apache.org/documentation/query/javascript-
  functions.html

On Tue, 2023-04-18 at 13:07 +, Enrico.Daga wrote:
> Hi Martynas,
> 
> I think you are right; my mistake. But how would you handle the case
> of converting a Unix timestamp into a readable date in SPARQL?
> 
> Enrico
> 
> --
> Enrico Daga, PhD
> 
> www.enridaga.net | @enridaga
> 
> SPARQL Anything http://sparql-anything.cc
> Polifonia http://polifonia-project.eu
> SPICE http://spice-h2020.eu
> Open Knowledge Graph http://data.open.ac.uk
> 
> Senior Research Fellow, Knowledge Media Institute, STEM Faculty
> The Open University
> Level 4 Berrill Building, Walton Hall, Milton Keynes, MK7 6AA
> Direct: +44 (0) 1908 654887
> 
> From: Martynas Jusevičius 
> Sent: 18 April 2023 14:04
> To: users@jena.apache.org 
> Subject: Re: XSD date functions broken?
> 
> Neither 1649185973 nor “1649185973” is a valid xsd:date value. Isn’t
> that
> the issue?
> 
> On Tue, 18 Apr 2023 at 14.00, Enrico.Daga
> 
> wrote:
> 
> > Hi Simon,
> > 
> > > The question is what the function should do??
> > 
> > Convert a timestamp into a date time format (and then later into a
> > readable string).
> > 
> > Thanks for pointing out the casting issue; however, I tried passing
> > it as
> > a string and it does not work either.
> > 
> > What would you recommend?
> > 
> > Thanks!
> > 
> > Enrico
> > 
> > 
> > --
> > Enrico Daga, PhD
> > 
> > https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.enridaga.net%2F=05%7C01%7Cenrico.daga%40open.ac.uk%7C28d24f570de747ce9c0e08db400d7a51%7C0e2ed45596af4100bed3a8e5fd981685%7C0%7C0%7C638174198852403818%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=p6HEWVpg5eSanObasQx%2BPP2ooCF7mysQNdEcGrtkcic%3D=0
> > <
> > https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.enridaga.net%2F=05%7C01%7Cenrico.daga%40open.ac.uk%7C28d24f570de747ce9c0e08db400d7a51%7C0e2ed45596af4100bed3a8e5fd981685%7C0%7C0%7C638174198852403818%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=p6HEWVpg5eSanObasQx%2BPP2ooCF7mysQNdEcGrtkcic%3D=0
> > > | @enridaga
> > 
> > SPARQL Anything
> > https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fsparql-anything.cc%2F=05%7C01%7Cenrico.daga%40open.ac.uk%7C28d24f570de747ce9c0e08db400d7a51%7C0e2ed45596af4100bed3a8e5fd981685%7C0%7C0%7C638174198852403818%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=m08QOKmLG%2B%2Fb8stsndWMq989GXfT8oZ009wt5T4GNok%3D=0
> > <
> > https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fsparql-anything.cc%2F=05%7C01%7Cenrico.daga%40open.ac.uk%7C28d24f570de747ce9c0e08db400d7a51%7C0e2ed45596af4100bed3a8e5fd981685%7C0%7C0%7C638174198852403818%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=m08QOKmLG%2B%2Fb8stsndWMq989GXfT8oZ009wt5T4GNok%3D=0
> > >
> > Polifonia
> > https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fpolifonia-project.eu%2F=05%7C01%7Cenrico.daga%40open.ac.uk%7C28d24f570de747ce9c0e08db400d7a51%7C0e2ed45596af4100bed3a8e5fd981685%7C0%7C0%7C638174198852403818%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=NFdA%2FYtjXi0lFLkl2S9CB9r4dzoTQxFl2ddx2O32rqc%3D=0
> > <
> > 

Re: XSD date functions broken?

2023-04-18 Thread Enrico . Daga
Hi Martynas,

I think you are right; my mistake. But how would you handle the case of 
converting a Unix timestamp into a readable date in SPARQL?

Enrico

--
Enrico Daga, PhD

www.enridaga.net | @enridaga

SPARQL Anything http://sparql-anything.cc
Polifonia http://polifonia-project.eu
SPICE http://spice-h2020.eu
Open Knowledge Graph http://data.open.ac.uk

Senior Research Fellow, Knowledge Media Institute, STEM Faculty
The Open University
Level 4 Berrill Building, Walton Hall, Milton Keynes, MK7 6AA
Direct: +44 (0) 1908 654887

From: Martynas Jusevičius 
Sent: 18 April 2023 14:04
To: users@jena.apache.org 
Subject: Re: XSD date functions broken?

Neither 1649185973 nor “1649185973” is a valid xsd:date value. Isn’t that
the issue?

On Tue, 18 Apr 2023 at 14.00, Enrico.Daga 
wrote:

> Hi Simon,
>
> > The question is what the function should do??
>
> Convert a timestamp into a date time format (and then later into a
> readable string).
>
> Thanks for pointing out the casting issue; however, I tried passing it as
> a string and it does not work either.
>
> What would you recommend?
>
> Thanks!
>
> Enrico
>
>
> --
> Enrico Daga, PhD
>
> https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.enridaga.net%2F=05%7C01%7Cenrico.daga%40open.ac.uk%7C28d24f570de747ce9c0e08db400d7a51%7C0e2ed45596af4100bed3a8e5fd981685%7C0%7C0%7C638174198852403818%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=p6HEWVpg5eSanObasQx%2BPP2ooCF7mysQNdEcGrtkcic%3D=0
>  | @enridaga
>
> SPARQL Anything 
> https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fsparql-anything.cc%2F=05%7C01%7Cenrico.daga%40open.ac.uk%7C28d24f570de747ce9c0e08db400d7a51%7C0e2ed45596af4100bed3a8e5fd981685%7C0%7C0%7C638174198852403818%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=m08QOKmLG%2B%2Fb8stsndWMq989GXfT8oZ009wt5T4GNok%3D=0
> Polifonia 
> https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fpolifonia-project.eu%2F=05%7C01%7Cenrico.daga%40open.ac.uk%7C28d24f570de747ce9c0e08db400d7a51%7C0e2ed45596af4100bed3a8e5fd981685%7C0%7C0%7C638174198852403818%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=NFdA%2FYtjXi0lFLkl2S9CB9r4dzoTQxFl2ddx2O32rqc%3D=0
> SPICE 
> https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fspice-h2020.eu%2F=05%7C01%7Cenrico.daga%40open.ac.uk%7C28d24f570de747ce9c0e08db400d7a51%7C0e2ed45596af4100bed3a8e5fd981685%7C0%7C0%7C638174198852403818%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=LuXIx0F8FycPuLt5PIVI74JxZdvbT32%2FS0roiqYSJpM%3D=0
> Open Knowledge Graph http://data.open.ac.uk
>
> Senior Research Fellow, Knowledge Media Institute, STEM Faculty
> The Open University
> Level 4 Berrill Building, Walton Hall, Milton Keynes, MK7 6AA
> Direct: +44 (0) 1908 654887
> 
> From: Simon Bin 
> Sent: 18 April 2023 11:43
> To: users@jena.apache.org 
> Subject: Re: XSD date functions broken?
>
> The question is what the function should do??
>
> if you look 

Re: XSD date functions broken?

2023-04-18 Thread Martynas Jusevičius
Neither 1649185973 nor “1649185973” is a valid xsd:date value. Isn’t that
the issue?

On Tue, 18 Apr 2023 at 14.00, Enrico.Daga 
wrote:

> Hi Simon,
>
> > The question is what the function should do??
>
> Convert a timestamp into a date time format (and then later into a
> readable string).
>
> Thanks for pointing out the casting issue; however, I tried passing it as
> a string and it does not work either.
>
> What would you recommend?
>
> Thanks!
>
> Enrico
>
>
> --
> Enrico Daga, PhD
>
> www.enridaga.net | @enridaga
>
> SPARQL Anything http://sparql-anything.cc
> Polifonia http://polifonia-project.eu
> SPICE http://spice-h2020.eu
> Open Knowledge Graph http://data.open.ac.uk
>
> Senior Research Fellow, Knowledge Media Institute, STEM Faculty
> The Open University
> Level 4 Berrill Building, Walton Hall, Milton Keynes, MK7 6AA
> Direct: +44 (0) 1908 654887
> 
> From: Simon Bin 
> Sent: 18 April 2023 11:43
> To: users@jena.apache.org 
> Subject: Re: XSD date functions broken?
>
> The question is what the function should do??
>
> if you look here:
> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.w3.org%2FTR%2Fsparql11-query%2F%23FunctionMapping=05%7C01%7Cenrico.daga%40open.ac.uk%7C8afbac578cf644e8ba0808db3ff9c74a%7C0e2ed45596af4100bed3a8e5fd981685%7C0%7C0%7C638174114243585920%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=DEaRRBUhUobpuseI8EwQGbA1ABo7M9XRj9taVmPpj6M%3D=0
> 
>
> it is "N"ot allowed to cast from int to dateTime
>
> On Tue, 2023-04-18 at 10:19 +, Enrico.Daga wrote:
> > Hi,
> >
> > I need help using XSD date/time functions, I tried versions 4.2.0 and
> > 4.7.0 and both don't seem to work.
> >
> > Considering this Java code:
> >
> >
> > Dataset kb = DatasetFactory.createGeneral();
> > Query q = QueryFactory.create(q);
> > result = QueryExecutionFactory.create(q, kb).execSelect();
> >
> > The following throws an NPE (no results)
> >
> >
> > String q = "\n" +
> > "PREFIX xsd: <
> https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema%23=05%7C01%7Cenrico.daga%40open.ac.uk%7C8afbac578cf644e8ba0808db3ff9c74a%7C0e2ed45596af4100bed3a8e5fd981685%7C0%7C0%7C638174114243585920%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=3%2BRsVgMKF8vR2T5a6SkwfKCYLDpn3LVgj4iH2vX%2Fv64%3D=0
> >" +
> > "SELECT ?date WHERE { BIND(xsd:dateTime (1649185973) AS ?date
> > ) }";
> >
> > ...
> > System.err.println(result.next().get("date").toString());
> >
> > While the cast to int works fine:
> >
> >
> > String q = "\n" +
> > "PREFIX xsd: <
> https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema%23=05%7C01%7Cenrico.daga%40open.ac.uk%7C8afbac578cf644e8ba0808db3ff9c74a%7C0e2ed45596af4100bed3a8e5fd981685%7C0%7C0%7C638174114243585920%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=3%2BRsVgMKF8vR2T5a6SkwfKCYLDpn3LVgj4iH2vX%2Fv64%3D=0
> >" +
> > "SELECT ?date WHERE { BIND(xsd:int (1649185973) AS ?date )
> > }";
> > System.err.println(executeARQ(q).next().get("date").toString());
> >
> > 1649185973^^
> https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema%23int=05%7C01%7Cenrico.daga%40open.ac.uk%7C8afbac578cf644e8ba0808db3ff9c74a%7C0e2ed45596af4100bed3a8e5fd981685%7C0%7C0%7C638174114243585920%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=82aUfvHAyPRbCeKNeJEQ0QQtiNKNKnr3N3Afw8w0v70%3D=0
> >
> > Am I missing anything?
> >
> > Best,
> >
> > Enrico
> >
> > --
> > Enrico Daga, PhD
> >
> >
> https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.enridaga.net%2F=05%7C01%7Cenrico.daga%40open.ac.uk%7C8afbac578cf644e8ba0808db3ff9c74a%7C0e2ed45596af4100bed3a8e5fd981685%7C0%7C0%7C638174114243585920%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=2l7urXsu9EwIB59M3fA1epW9mkCZfMc19gAaZ%2FLC%2BJE%3D=0
> <
> https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.enridaga.net%2F=05%7C01%7Cenrico.daga%40open.ac.uk%7C8afbac578cf644e8ba0808db3ff9c74a%7C0e2ed45596af4100bed3a8e5fd981685%7C0%7C0%7C638174114243585920%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=2l7urXsu9EwIB59M3fA1epW9mkCZfMc19gAaZ%2FLC%2BJE%3D=0
> > | @enridaga
> >
> > SPARQL Anything
> 

Re: XSD date functions broken?

2023-04-18 Thread Enrico . Daga
Hi Simon,

> The question is what the function should do??

Convert a timestamp into a date time format (and then later into a readable 
string).

Thanks for pointing out the casting issue; however, I tried passing it as a 
string and it does not work either.

What would you recommend?

Thanks!

Enrico


--
Enrico Daga, PhD

www.enridaga.net | @enridaga

SPARQL Anything http://sparql-anything.cc
Polifonia http://polifonia-project.eu
SPICE http://spice-h2020.eu
Open Knowledge Graph http://data.open.ac.uk

Senior Research Fellow, Knowledge Media Institute, STEM Faculty
The Open University
Level 4 Berrill Building, Walton Hall, Milton Keynes, MK7 6AA
Direct: +44 (0) 1908 654887

From: Simon Bin 
Sent: 18 April 2023 11:43
To: users@jena.apache.org 
Subject: Re: XSD date functions broken?

The question is what the function should do??

if you look here: 
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.w3.org%2FTR%2Fsparql11-query%2F%23FunctionMapping=05%7C01%7Cenrico.daga%40open.ac.uk%7C8afbac578cf644e8ba0808db3ff9c74a%7C0e2ed45596af4100bed3a8e5fd981685%7C0%7C0%7C638174114243585920%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=DEaRRBUhUobpuseI8EwQGbA1ABo7M9XRj9taVmPpj6M%3D=0

it is "N"ot allowed to cast from int to dateTime

On Tue, 2023-04-18 at 10:19 +, Enrico.Daga wrote:
> Hi,
>
> I need help using XSD date/time functions, I tried versions 4.2.0 and
> 4.7.0 and both don't seem to work.
>
> Considering this Java code:
>
>
> Dataset kb = DatasetFactory.createGeneral();
> Query q = QueryFactory.create(q);
> result = QueryExecutionFactory.create(q, kb).execSelect();
>
> The following throws an NPE (no results)
>
>
> String q = "\n" +
> "PREFIX xsd: 
> >"
>  +
> "SELECT ?date WHERE { BIND(xsd:dateTime (1649185973) AS ?date
> ) }";
>
> ...
> System.err.println(result.next().get("date").toString());
>
> While the cast to int works fine:
>
>
> String q = "\n" +
> "PREFIX xsd: 
> >"
>  +
> "SELECT ?date WHERE { BIND(xsd:int (1649185973) AS ?date )
> }";
> System.err.println(executeARQ(q).next().get("date").toString());
>
> 1649185973^^https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema%23int=05%7C01%7Cenrico.daga%40open.ac.uk%7C8afbac578cf644e8ba0808db3ff9c74a%7C0e2ed45596af4100bed3a8e5fd981685%7C0%7C0%7C638174114243585920%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=82aUfvHAyPRbCeKNeJEQ0QQtiNKNKnr3N3Afw8w0v70%3D=0
>
> Am I missing anything?
>
> Best,
>
> Enrico
>
> --
> Enrico Daga, PhD
>
> https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.enridaga.net%2F=05%7C01%7Cenrico.daga%40open.ac.uk%7C8afbac578cf644e8ba0808db3ff9c74a%7C0e2ed45596af4100bed3a8e5fd981685%7C0%7C0%7C638174114243585920%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=2l7urXsu9EwIB59M3fA1epW9mkCZfMc19gAaZ%2FLC%2BJE%3D=0
>  | @enridaga
>
> SPARQL Anything 
> https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fsparql-anything.cc%2F=05%7C01%7Cenrico.daga%40open.ac.uk%7C8afbac578cf644e8ba0808db3ff9c74a%7C0e2ed45596af4100bed3a8e5fd981685%7C0%7C0%7C638174114243585920%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=3dbOsh39XbtPv5dG7%2FUCVbin0LwolO90bUPawiUSsdM%3D=0
> Polifonia 
> 

Re: XSD date functions broken?

2023-04-18 Thread Simon Bin
The question is what the function should do??

if you look here: https://www.w3.org/TR/sparql11-query/#FunctionMapping

it is "N"ot allowed to cast from int to dateTime

On Tue, 2023-04-18 at 10:19 +, Enrico.Daga wrote:
> Hi,
> 
> I need help using XSD date/time functions, I tried versions 4.2.0 and
> 4.7.0 and both don't seem to work.
> 
> Considering this Java code:
> 
> 
> Dataset kb = DatasetFactory.createGeneral();
> Query q = QueryFactory.create(q);
> result = QueryExecutionFactory.create(q, kb).execSelect();
> 
> The following throws an NPE (no results)
> 
> 
> String q = "\n" +
>     "PREFIX xsd: " +
>     "SELECT ?date WHERE { BIND(xsd:dateTime (1649185973) AS ?date
> ) }";
> 
> ...
> System.err.println(result.next().get("date").toString());
> 
> While the cast to int works fine:
> 
> 
> String q = "\n" +
>     "PREFIX xsd: " +
>     "SELECT ?date WHERE { BIND(xsd:int (1649185973) AS ?date )
> }";
> System.err.println(executeARQ(q).next().get("date").toString());
> 
> 1649185973^^http://www.w3.org/2001/XMLSchema#int
> 
> Am I missing anything?
> 
> Best,
> 
> Enrico
> 
> --
> Enrico Daga, PhD
> 
> www.enridaga.net | @enridaga
> 
> SPARQL Anything http://sparql-anything.cc
> Polifonia http://polifonia-project.eu
> SPICE http://spice-h2020.eu
> Open Knowledge Graph http://data.open.ac.uk
> 
> Senior Research Fellow, Knowledge Media Institute, STEM Faculty
> The Open University
> Level 4 Berrill Building, Walton Hall, Milton Keynes, MK7 6AA
> Direct: +44 (0) 1908 654887
> -- The Open University is incorporated by Royal Charter (RC 000391),
> an exempt charity in England & Wales and a charity registered in
> Scotland (SC 038302). The Open University is authorised and regulated
> by the Financial Conduct Authority in relation to its secondary
> activity of credit broking.



XSD date functions broken?

2023-04-18 Thread Enrico . Daga
Hi,

I need help using XSD date/time functions, I tried versions 4.2.0 and 4.7.0 and 
both don't seem to work.

Considering this Java code:


Dataset kb = DatasetFactory.createGeneral();
Query q = QueryFactory.create(q);
result = QueryExecutionFactory.create(q, kb).execSelect();

The following throws an NPE (no results)


String q = "\n" +
"PREFIX xsd: " +
"SELECT ?date WHERE { BIND(xsd:dateTime (1649185973) AS ?date ) }";

...
System.err.println(result.next().get("date").toString());

While the cast to int works fine:


String q = "\n" +
"PREFIX xsd: " +
"SELECT ?date WHERE { BIND(xsd:int (1649185973) AS ?date ) }";
System.err.println(executeARQ(q).next().get("date").toString());

1649185973^^http://www.w3.org/2001/XMLSchema#int

Am I missing anything?

Best,

Enrico

--
Enrico Daga, PhD

www.enridaga.net | @enridaga

SPARQL Anything http://sparql-anything.cc
Polifonia http://polifonia-project.eu
SPICE http://spice-h2020.eu
Open Knowledge Graph http://data.open.ac.uk

Senior Research Fellow, Knowledge Media Institute, STEM Faculty
The Open University
Level 4 Berrill Building, Walton Hall, Milton Keynes, MK7 6AA
Direct: +44 (0) 1908 654887
-- The Open University is incorporated by Royal Charter (RC 000391), an exempt 
charity in England & Wales and a charity registered in Scotland (SC 038302). 
The Open University is authorised and regulated by the Financial Conduct 
Authority in relation to its secondary activity of credit broking.