[Mulgara-general] Mulgara xsd:date

Life is hard, and then you die ronald at innovation.ch
Tue Mar 13 23:21:31 UTC 2007


On Tue, Mar 13, 2007 at 10:32:57PM +0000, 12470 at ufp.pt wrote:
> 
> This is my second post on the same topic, but I really don't know what  
> is the problem on working in dates on mulgara.
> 
> First, I really appreciate other doc resources because the actual  
> don't give me enough knowledge to do queries with dates or other  
> datatype.
> 
> I read all the docs and I have done the follow.
> 
> My rdf file is like this :
> 
> <rdf:RDF
>     xmlns:sakai="http://elearning.ufp.pt/events/opc2#"
>     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
>     xmlns:xsd="http://www.w3.org/2001/XMLSchema#" >
>   <rdf:Description rdf:nodeID="A0">
>     <sakai:date  
> rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2005-12-30  
> 17:45:07.0</sakai:date>
[snip]
> And try to do a simple query :
> 
> select $doc from <rmi://localhost/server1#sakai_events>
> where $doc <sakai:event_date> $date
> and $date <mulgara:before> '2000-01-01' in <rmi://localhost/server1#xsd>
> and $date <mulgara:after> '1899-12-31' in <rmi://localhost/server1#xsd>;
> 
> But it always return no results.

The first problem is that you inserted using the <sakai:date>
predicate but query for the <sakai:event_date> predicate.

The second problem is that you inserted a datatyped literal but are
querying for an untyped literal - those are distinct in RDF and not
comparable. So the second correction is to add the datatype to the
query.

(the xsd resolver will actually attempt to convert an untyped literal
to either an xsd:date or xsd:dateTime for you, but in the above case
where you're only supplying a date it'll convert the literal to
xsd:date which is distinct from xsd:dateTime and hence will never
compare).

Lastly, I'm not sure offhand if '2000-01-01' is a valid dateTime, but
Mulgara doesn't like that (i.e. wants a full dateTime string).

So, put this all together and you get:

  select $doc from <rmi://localhost/server1#sakai_events>
  where $doc <sakai:date> $date
  and $date <mulgara:before> '2000-01-01T00:00:00'^^<http://www.w3.org/2001/XMLSchema#dateTime> in <rmi://localhost/server1#xsd>
  and $date <mulgara:after> '1899-12-31T00:00:00'^^<http://www.w3.org/2001/XMLSchema#dateTime> in <rmi://localhost/server1#xsd>;

which should give you the desired results.


  Cheers,

  Ronald




More information about the Mulgara-general mailing list