-
Notifications
You must be signed in to change notification settings - Fork 581
Closed
Labels
Milestone
Description
Filters on xsd:dateTime work with literals, i.e.
FILTER(?start > "2016-01-01 20:01"^^xsd:dateTime)
But if there are two variables of xsd:dateTime then filter does not work properly, i.e.
FILTER(?start < ?end)
Script illustrating the issue below. It should show c1 and c2 entities, but nothing is shown instead.
from pprint import pprint
import rdflib
import io
data = """
@prefix : <#>.
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
:C a rdfs:Class.
:start a rdf:Property;
rdfs:domain :C;
rdfs:range xsd:dateTime.
:end a rdf:Property;
rdfs:domain :C;
rdfs:range xsd:dateTime.
:c1 a :C;
:start "2016-01-01 20:00:00"^^xsd:dateTime;
:end "2016-01-02 20:01:00"^^xsd:dateTime.
:c2 a :C;
:start "2016-01-01 20:05:00"^^xsd:dateTime;
:end "2016-01-01 20:30:00"^^xsd:dateTime.
"""
graph = rdflib.Graph()
f = io.StringIO(data)
graph.parse(f, format='n3')
result = graph.query("""
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
SELECT ?c
WHERE {
?c :start ?start;
:end ?end.
# FILTER(?start > "2016-01-01 20:01"^^xsd:dateTime) # this works!
FILTER(?start < ?end)
}
""")
pprint(list(result))