0

I have an ontology entity instance in RDF/XML like this:

<owl:NamedIndividual rdf:about="http://example.org#x1">
    <rdf:type rdf:resource="http://example.org/Example"/>
    <ex:amount rdf:datatype="http://www.w3.org/2001/XMLSchema#float">uuid-v4</ex:amount>
    <rdfs:label xml:lang="en">An example instance</rdfs:label>
</owl:NamedIndividual>

I need to select this instance given only its <ex:amount> value which, in this case, is a string. The SPARQL query that I have looks like this:

SELECT * WHERE {
    ?s ?p "uuid-v4" .
}

As you can see, the specified value "uuid-v4" is a string, but the <ex:amount> property's datatype is float.

Questions:

  1. Why is the result empty? Is it because of the mismatched datatypes?
  2. What should I do to make this query work? I cannot change the rdf:datatype to http://www.w3.org/2001/XMLSchema#string. What are the options?

It looks like specifying the datatype helps.

SELECT * WHERE {
    ?s ?p "uuid-v4"^^xsd:float .
}

But I do not know anything about the property until I select the instance. The only information available is the "uuid-v4"

nvbach91
  • 166
  • 8
  • 1
    `select ?s ?p {?s ?p ?o . filter (str(?o)="uuid-v4")}` is a workaround. – Stanislav Kralin Dec 10 '18 at 11:44
  • 1
    just as a comment. The first problem is the data, isn't it? I mean, obviously, the datatype is wrong. this should be fixed in the instance data. tools will most likely fail to parse the literal into their internal data structures. That said, the solution from StanislavKralin will do the trick. – UninformedUser Dec 10 '18 at 12:23
  • @StanislavKralin thanks man, I guess there is no other way – nvbach91 Dec 10 '18 at 14:24
  • @AKSW thx for your comment, my use case doesn't allow me to do otherwise – nvbach91 Dec 10 '18 at 14:25

0 Answers0