Using the following query:
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX uni: <http://localhost/SemanticSearch/semanticsearch.owl#>
SELECT
DISTINCT *
WHERE {
?uri uni:altLabel "5"^^xsd:integer.
?uri rdf:type ?type
}
Also returns URIs which have an altLabel
with xsd:decimal
5.x
I really need it to return only the ?uri
which have altLabel
of xsd:integer
. Is there anyway to achieve this?
It's always easier if you can provide actual data that we can query. In the future, please provide data that we can query. because then we can actually test queries against it. In any case, here's a very simple dataset with two resources, one which has an xsd:decimal value and one with an xsd:integer value.
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
@prefix uni: <http://localhost/SemanticSearch/semanticsearch.owl#>.
@prefix : <urn:ex:>.
:a uni:altLabel "5"^^xsd:integer ; a :somethingWithAnInteger .
:b uni:altLabel "5"^^xsd:decimal ; a :somethingWithADecimal .
You can filter for the particular datatypes that you want using the datatype function:
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX uni: <http://localhost/SemanticSearch/semanticsearch.owl#>
SELECT DISTINCT * WHERE {
?uri uni:altLabel ?altLabel .
?uri rdf:type ?type
filter(?altLabel = "5"^^xsd:integer && datatype(?altLabel) = xsd:integer)
}
-----------------------------------------------------------
| uri | altLabel | type |
===========================================================
| <urn:ex:a> | 5 | <urn:ex:somethingWithAnInteger> |
-----------------------------------------------------------
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With