I query an API with a simple SPARQL query:
PREFIX ...
SELECT DISTINCT *
WHERE {
?item dct:date ?date .
?item dct:title ?title .
?item rdfs:info ?info .
}
And this returns me an xml
<results>
<result>
<binding name='title'>
<literal>titletitle</literal>
</binding>
<binding name='info'>
<uri>link</uri>
</binding>
<binding name='date'>
<literal datatype='http://www.w3.org/2001/XMLSchema#dateTime'>
2012-12-21T02:26:00+00:00
</literal>
</binding>
<binding name='item'>
<uri>link</uri>
</binding>
</result>
...
</results>
But the problem is: I know, that there are more than one links of rdfs:info matched to this item. How can I query such that I get
...
<binding name='info'>
<uri>link1</uri>
</binding>
<binding name='info'>
<uri>link2</uri>
</binding>
<binding name='info'>
<uri>link3</uri>
</binding>
...
? Is this simple, or do I need a subquery or some strange UNION?
If I just try
PREFIX ...
SELECT DISTINCT *
WHERE {
?item dct:date ?date .
?item dct:title ?title .
OPTIONAL (?item rdfs:info ?info1 ).
OPTIONAL (?item rdfs:info ?info2 ).
}
that would return all possible permutations of the values of ?info1 and ?info2. Plus, I don't know the number of info items.
If I add FILTER (?info1 != ?info2), I still get some permutations. I think from an algebraic point of view it would be possible to FILTER (?info1<?info2), to discard permutations. But how can I apply < on uris?
asked
15 Jan, 05:23
Milla Well
33●5
accept rate:
0%
I also could imagine a
DISTINCT ONwhich ignores the optional parameters, but google couldn't find such a thing. Could you?Asked on Stack Overflow http://stackoverflow.com/questions/14334252/sparql-get-more-than-one-subitem . Please avoid broadcasting your questions everywhere. You are using contributors' time, free of charge. Don't spend multiple audience's time. In general be assured that you'll get good responses on answers.semanticweb.com for anything Semantic-Webish. Most of the time, the people who are likely to answer you on Stack Overflow (for SemWeb questions) are the very same as the ones who answer you here. Advice: ask the question here first and if you don't get an answer after few days, try SO.
I did, and had almost no reaction, then, as I already commented on stackoverflow: voted for closing there, because I just found this site. Thanks for voting for closing on SO
Ok, good that you posted a link from SO. My comment is also for other readers who may be tempted to ask the question wherever they can. We get this often and not many have the diligence to put a link as you did.
BTW, there is an answer on Stack Overflow.
@Milla Well You really need to be prepared to wait a bit longer than an hour to get an answer! As @Antoine Zimmerman said sites like Answers and SO are not paid support services, they run by people donating their time to answer questions. And don't forget many people are likely in very different time zones from you, you should be prepared to wait a day or two to get answers particularly when posting on a relatively niche topic like Semantic Web