I'm trying to set up some lightweight, on-demand data validation outside of any reasoning system or triple-store provided load-time validation. I'm using GraphDB 8.3.
Let's say I load the following triples, using the Ontology of Biomedical Investigations (OBI), http://purl.obolibrary.org/obo/obi.owl:
PREFIX : <http://example.com/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
insert data {
graph :data
{
:measurement1 a <http://purl.obolibrary.org/obo/IAO_0000032> ;
<http://purl.obolibrary.org/obo/IAO_0000004> "100.1"^^xsd:double .
:measurement2 a <http://purl.obolibrary.org/obo/IAO_0000032> ;
<http://purl.obolibrary.org/obo/IAO_0000004> "100"^^xsd:int .
}
}
That says that :measurement1
and :measurement2
have measurement values. The range of <http://purl.obolibrary.org/obo/IAO_0000004>
is xsd:double
. I know that I can check for datatypes that aren't exactly the same as the specified range with something like the query below.
As you can see in the comments embedded in my query, I'd like to say that that :measurement2
's value of "100"^^xsd:int
is acceptable because all integers are contained within the set of double-precision floating point numbers. (Right?)
Is there an existing ontology that says that xsd:int
is a sub-something of xsd:double
?
PREFIX : <http://example.com/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX obo: <http://purl.obolibrary.org/obo/>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
# loaded obi into http://example.com/ontology
select distinct ?stype ?p ?ptype ?propdom ?proprange ?otype ?odatatype where {
{
graph :data
{
?s ?p ?o .
bind (datatype(?o) as ?odatatype)
}
optional {
graph <http://example.com/ontology> {
values ?ptype {
owl:ObjectProperty owl:DatatypeProperty
}
?p a ?ptype
}
}
optional {
?o a ?otype
}
optional {
?s a ?stype
}
optional {
{
graph <http://example.com/ontology> {
?p rdfs:domain ?propdom
}
}
}
optional {
{
graph <http://example.com/ontology> {
?p rdfs:range ?proprange
}
}
}
}
minus
{
?s rdf:type ?o
}
# minus
# {
# ?odatatype rdfs:subClassOf+ ?proprange
# }
filter ( ?odatatype != ?proprange )
}