You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Lorenz Buehmann <bu...@informatik.uni-leipzig.de> on 2021/04/01 05:57:41 UTC
Re: Triples not initialized after FILTER on SPARQL
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.
Re: Triples not initialized after FILTER on SPARQL
Posted by Andy Seaborne <an...@apache.org>.
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 <bu...@informatik.uni-leipzig.de> 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.
>>
Re: Re: Triples not initialized after FILTER on SPARQL
Posted by Lorenz Buehmann <bu...@informatik.uni-leipzig.de>.
ok, but what if there is no ?s with "Emri" and such a Class1 property? I
mean, check your data.
Check the all "entities" with "Emri" as object, then check if any of
those has the property Class1. I bet there is exactly none
On 01.04.21 09: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 <bu...@informatik.uni-leipzig.de> 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.
Re: Triples not initialized after FILTER on SPARQL
Posted by emri mbiemri <em...@gmail.com>.
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 <bu...@informatik.uni-leipzig.de> 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.
>