subquery passing parameter to SERVICE request

3 views
Skip to first unread message

PaulZH

unread,
Jun 10, 2016, 2:00:47 AM6/10/16
to Stardog
I have following snippet which works:

SELECT ?nis WHERE
 
{GRAPH <virtual://CRAB>
       
{<http://id.vlaanderen.be/id/gemeente/2> xkos:classifiedUnder ?nis. }
 
}      

I have following snippet which works:

SELECT ?nis ?label
WHERE
{SERVICE <http://id.fedstats.be/sparql>
 
{?nis skos:prefLabel ?label.    
 
}
VALUES
?nis {<http://id.fedstats.be/nis/11002#id>}        
}  

where ?nis is bound to the result of the first snippet.

Combining both now

SELECT ?nis ?label
WHERE
{SERVICE <http://id.fedstats.be/sparql>
 
{?nis skos:prefLabel ?label.
 
{SELECT ?nis WHERE
 
{GRAPH <virtual://CRAB>
       
{<http://id.vlaanderen.be/id/gemeente/2> xkos:classifiedUnder ?nis. }
 
}
 
}      
 
}
}      


no results.

Now I put the triples locally in the default graph, to avoid the SERVICE request

SELECT ?nis ?label
WHERE
 
{?nis skos:prefLabel ?label.
 
{SELECT ?nis WHERE
 
{GRAPH <virtual://CRAB>
       
{<http://id.vlaanderen.be/id/gemeente/2> xkos:classifiedUnder ?nis. }
 
}
 
}      
 
}

Works.

What am I missing in combining both subquery and service request?

Zachary Whitley

unread,
Jun 10, 2016, 6:01:13 AM6/10/16
to sta...@clarkparsia.com
You're sending the virtual graph query to the remote endpoint that doesn't know how to interpret the virtual graph. It is probably treating it simply as an IRI and not returning any results. It works when you run it locally because Stardog knows what to do with virtual graphs. 

--
-- --
You received this message because you are subscribed to the C&P "Stardog" group.
To post to this group, send email to sta...@clarkparsia.com
To unsubscribe from this group, send email to
stardog+u...@clarkparsia.com
For more options, visit this group at
http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en
---
You received this message because you are subscribed to the Google Groups "Stardog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to stardog+u...@clarkparsia.com.

PaulZH

unread,
Jun 10, 2016, 6:05:30 AM6/10/16
to Stardog
Indeed. So obvious.

Thanks.

Paul

PaulZH

unread,
Jun 10, 2016, 7:17:01 AM6/10/16
to sta...@clarkparsia.com
FWIW, This is a working solution: the other way round.

SELECT ?label
WHERE
{GRAPH <virtual://CRAB>
       
{<http://id.vlaanderen.be/id/gemeente/2> xkos:classifiedUnder ?nis.

 FILTER
(?nisconcept = ?nis)
{SELECT ?nisconcept ?label
WHERE
   
{SERVICE <http://id.fedstats.be/sparql>
   
{?nisconcept a skos:Concept;
        skos
:inScheme <http://id.fedstats.be/conceptscheme/nis#id>;
       
^skos:member <http://id.fedstats.be/classificationlevel/municipality#id>;
        skos
:prefLabel ?label;
        skos
:notation ?nis.
        FILTER
(lang(?label) = 'nl')
 
}
 
}
}
}}

Zachary Whitley

unread,
Jun 10, 2016, 9:51:17 AM6/10/16
to Stardog
That should do it. Looks like there's a typo. You have a circumflex at ^skos:member  (I'm assuming you weren't intending a property path)

One interesting thing I discovered. I was going to suggest that if the data isn't changing very often you could just load the remote data locally with a LOAD query.

The following direct url works

id.fedstats.be/sparql?query=construct%20%7B%3Fnisconcept%20a%20skos%3AConcept%3B%0A%20%20%20%20%20%20%20%20skos%3AinScheme%20%3Chttp%3A%2F%2Fid.fedstats.be%2Fconceptscheme%2Fnis%23id%3E%3B%0A%20%20%20%20%20%20%20%20skos%3Amember%20%3Chttp%3A%2F%2Fid.fedstats.be%2Fclassificationlevel%2Fmunicipality%23id%3E%3B%0A%20%20%20%20%20%20%20%20skos%3AprefLabel%20%3Flabel%3B%0A%20%20%20%20%20%20%20%20skos%3Anotation%20%3Fnis.%7D%0AWHERE%0A%20%20%20%20%0A%20%20%20%20%7B%3Fnisconcept%20a%20skos%3AConcept%3B%0A%20%20%20%20%20%20%20%20skos%3AinScheme%20%3Chttp%3A%2F%2Fid.fedstats.be%2Fconceptscheme%2Fnis%23id%3E%3B%0A%20%20%20%20%20%20%20%20%5Eskos%3Amember%20%3Chttp%3A%2F%2Fid.fedstats.be%2Fclassificationlevel%2Fmunicipality%23id%3E%3B%0A%20%20%20%20%20%20%20%20skos%3AprefLabel%20%3Flabel%3B%0A%20%20%20%20%20%20%20%20skos%3Anotation%20%3Fnis.%0A%20%20%20%20%20%20%20%20FILTER%20(lang(%3Flabel)%20%3D%20%27nl%27)%0A%20%7D%0A%20

but the following sparql query doesn't work

stardog query test "load <http://id.fedstats.be/sparql?query=construct%20%7B%3Fnisconcept%20a%20skos%3AConcept%3B%0A%20%20%20%20%20%20%20%20skos%3AinScheme%20%3Chttp%3A%2F%2Fid.fedstats.be%2Fconceptscheme%2Fnis%23id%3E%3B%0A%20%20%20%20%20%20%20%20skos%3Amember%20%3Chttp%3A%2F%2Fid.fedstats.be%2Fclassificationlevel%2Fmunicipality%23id%3E%3B%0A%20%20%20%20%20%20%20%20skos%3AprefLabel%20%3Flabel%3B%0A%20%20%20%20%20%20%20%20skos%3Anotation%20%3Fnis.%7D%0AWHERE%0A%20%20%20%20%0A%20%20%20%20%7B%3Fnisconcept%20a%20skos%3AConcept%3B%0A%20%20%20%20%20%20%20%20skos%3AinScheme%20%3Chttp%3A%2F%2Fid.fedstats.be%2Fconceptscheme%2Fnis%23id%3E%3B%0A%20%20%20%20%20%20%20%20%5Eskos%3Amember%20%3Chttp%3A%2F%2Fid.fedstats.be%2Fclassificationlevel%2Fmunicipality%23id%3E%3B%0A%20%20%20%20%20%20%20%20skos%3AprefLabel%20%3Flabel%3B%0A%20%20%20%20%20%20%20%20skos%3Anotation%20%3Fnis.%0A%20%20%20%20%20%20%20%20FILTER%20(lang(%3Flabel)%20%3D%20%27nl%27)%0A%20%7D%0A%20>"

returning the following error message

Expected an RDF value here, found '{' [line 1]


I believe Stardog is doing the right thing as the results are JSON-LD containing graphs and I don't believe that you can load data with explicit graphs but I'm not completely clear on what the sparql update specification expects here. You can certainly run curl against the first url and then manually load it.

On Fri, Jun 10, 2016 at 7:17 AM, PaulZH <pa...@proxml.be> wrote:
FWIW, This is a working solution: the other way round.


SELECT
?label
WHERE

PaulZH

unread,
Jun 10, 2016, 9:59:24 AM6/10/16
to Stardog


On Friday, June 10, 2016 at 3:51:17 PM UTC+2, Zachary Whitley wrote:
That should do it. Looks like there's a typo. You have a circumflex at ^skos:member  (I'm assuming you weren't intending a property path)

It's intended to be a property path.
 

One interesting thing I discovered. I was going to suggest that if the data isn't changing very often you could just load the remote data locally with a LOAD query.

The following direct url works

id.fedstats.be/sparql?query=construct%20%7B%3Fnisconcept%20a%20skos%3AConcept%3B%0A%20%20%20%20%20%20%20%20skos%3AinScheme%20%3Chttp%3A%2F%2Fid.fedstats.be%2Fconceptscheme%2Fnis%23id%3E%3B%0A%20%20%20%20%20%20%20%20skos%3Amember%20%3Chttp%3A%2F%2Fid.fedstats.be%2Fclassificationlevel%2Fmunicipality%23id%3E%3B%0A%20%20%20%20%20%20%20%20skos%3AprefLabel%20%3Flabel%3B%0A%20%20%20%20%20%20%20%20skos%3Anotation%20%3Fnis.%7D%0AWHERE%0A%20%20%20%20%0A%20%20%20%20%7B%3Fnisconcept%20a%20skos%3AConcept%3B%0A%20%20%20%20%20%20%20%20skos%3AinScheme%20%3Chttp%3A%2F%2Fid.fedstats.be%2Fconceptscheme%2Fnis%23id%3E%3B%0A%20%20%20%20%20%20%20%20%5Eskos%3Amember%20%3Chttp%3A%2F%2Fid.fedstats.be%2Fclassificationlevel%2Fmunicipality%23id%3E%3B%0A%20%20%20%20%20%20%20%20skos%3AprefLabel%20%3Flabel%3B%0A%20%20%20%20%20%20%20%20skos%3Anotation%20%3Fnis.%0A%20%20%20%20%20%20%20%20FILTER%20(lang(%3Flabel)%20%3D%20%27nl%27)%0A%20%7D%0A%20

but the following sparql query doesn't work

stardog query test "load <http://id.fedstats.be/sparql?query=construct%20%7B%3Fnisconcept%20a%20skos%3AConcept%3B%0A%20%20%20%20%20%20%20%20skos%3AinScheme%20%3Chttp%3A%2F%2Fid.fedstats.be%2Fconceptscheme%2Fnis%23id%3E%3B%0A%20%20%20%20%20%20%20%20skos%3Amember%20%3Chttp%3A%2F%2Fid.fedstats.be%2Fclassificationlevel%2Fmunicipality%23id%3E%3B%0A%20%20%20%20%20%20%20%20skos%3AprefLabel%20%3Flabel%3B%0A%20%20%20%20%20%20%20%20skos%3Anotation%20%3Fnis.%7D%0AWHERE%0A%20%20%20%20%0A%20%20%20%20%7B%3Fnisconcept%20a%20skos%3AConcept%3B%0A%20%20%20%20%20%20%20%20skos%3AinScheme%20%3Chttp%3A%2F%2Fid.fedstats.be%2Fconceptscheme%2Fnis%23id%3E%3B%0A%20%20%20%20%20%20%20%20%5Eskos%3Amember%20%3Chttp%3A%2F%2Fid.fedstats.be%2Fclassificationlevel%2Fmunicipality%23id%3E%3B%0A%20%20%20%20%20%20%20%20skos%3AprefLabel%20%3Flabel%3B%0A%20%20%20%20%20%20%20%20skos%3Anotation%20%3Fnis.%0A%20%20%20%20%20%20%20%20FILTER%20(lang(%3Flabel)%20%3D%20%27nl%27)%0A%20%7D%0A%20>"

returning the following error message

Expected an RDF value here, found '{' [line 1]


I believe Stardog is doing the right thing as the results are JSON-LD containing graphs and I don't believe that you can load data with explicit graphs but I'm not completely clear on what the sparql update specification expects here. You can certainly run curl against the first url and then manually load it.

Thanks for the tip. 


Reply all
Reply to author
Forward
0 new messages