A blank node in a query does not match a blank node in the data.
Firstly - _:b0 is not the blank node in the data. Blank node labels are
assigned per document (when printed out); the internal id is much larger.
Secondly - blank node in SPARQL patterns are variables whoich is whyyou
get many answers.
What it appears is that there is no ?s that has both
<http://www.w3.org/TR/html4/Class1> AND also passes the filter.
Try:
SELECT ?s ?p ?o {
?s ?var ?attr .
FILTER regex(?attr , "Emri").
?s ?p ?o .
}
to see what the subject ?s has and check for ?p
<http://www.w3.org/TR/html4/Class1>
Andy
On 01/04/2021 08:08, emri mbiemri wrote:
Hello,
Sorry for not being more specific.
I am trying to get all the ?s and ?p that has for instance "Emri" as object.
Then I want to use the above value of ?s, change the value of the predicate to
<http://www.w3.org/TR/html4/Class1> and get all the objects with that match.
The problem is that when I query just
?s ?p ?attr .
FILTER regex(?attr , "Emri").
-----I get the three results, one of them is:
_:b0
<http://www.w3.org/TR/html4/Name>
"Emri"
----------------
When I query just for:
_:b0 <http://www.w3.org/TR/html4/Class1> ?class .
----I get many objects as result.
But, then I try this:
?s ?p ?attr .
FILTER regex(?attr , "Emri") .
?s <http://www.w3.org/TR/html4/Class1> ?class .
then I get no matches? Is there maybe because there are three subjects returned
from the first query(?s ?p ?attr .), or can I not change the value of the
predicate on the second query after it has been initialized from the first one.
Thanks a lot for your help.
On 2021/04/01 05:57:41, Lorenz Buehmann <[email protected]>
wrote:
without showing the data impossible to help, sorry. I mean, in the end
the query has to match the data, but we only know the query know - so
how can we help here?
One possible error is the triple pattern
?s <http://www.w3.org/TR/html4/Class1> ?class .
what is the idea behind this? Is there really a property <Class1> in the
data? If not and if you want to get an instance of the Class <Class1>
you have to use
?s a <http://www.w3.org/TR/html4/Class1> .
On 31.03.21 16:12, emri mbiemri wrote:
Dear all,
I am trying to query something from an RDF/XML file with SPARQL but when I try
queries like this:
SELECT DISTINCT ?class
WHERE {
?s ?p ?attr .
FILTER regex(?attr , "Emri") .
?s <http://www.w3.org/TR/html4/Class1> ?class .
it should after the FILTER command initialize ?s = _:b0 , but it doesn't?
Hope for any support.