I am just learning how to write query in SPARQL (through protégé platform). So, this is a very basic question, but I could not resolve.
I have an individual named Alice (its under owl:Thing).
This individual has a data property called textualValue, which is specified as xsd:normalizedString.
I am writing below query to extract individuals starting with ali, which should in turn result alice. I am basically using regex operand for filtering. Whenever I execute SPARQL Query with this specifications, I do not get any results, can someone indicate where I am mistaken, please?
SELECT distinct ?x
WHERE { ?x rdf:type owl:NamedIndividual.
FILTER regex(?textualValue, "^ali", "i") }
You need to get the value of property textualValue
- it is not automatically put in a variable.
Here is an outline, based on your description: you need to complete the details:
PREFIX owl: ....
PREFIX rdf: ....
PREFIX x: <InsertTheRightURIhere>
SELECT distinct ?x
WHERE {
?x rdf:type owl:NamedIndividual ;
x:textualValue ?v .
FILTER regex(str(?v), "^ali", "i")
}
str
to get just the lexical part of the RDF Term in ?v
.