I agree with Lorenz that you probably want to look at SPARQL CONSTRUCT and more 
specifically CONSTRUCT *WHERE* 
(https://www.w3.org/TR/sparql11-query/#constructWhere).

Your query would become:

CONSTRUCT WHERE {
        ?person :LastName; :FirstName ?FirstName; :Address ?Address .
        ?Address :Street ?Street; :City ?City; :State ?State; :Zip ?Zip
}

-----Original Message-----
From: Lorenz Buehmann <[email protected]> 
Sent: dinsdag 22 december 2020 14:49
To: [email protected]
Subject: Re: Returning a Triple from a QuerySolution for each Solution Variable

Not sure if I understand your question, but should you just use SPARQL 
CONSTRUCT queries if you want to get triples?

On 22.12.20 14:34, Erich Bremer wrote:
> After executing a select statement like:
>
> select ?person ?LastName ?FirstName ?Street ?City ?State ?Zip where 
> {?person :LastName; :FirstName ?FirstName; :Address ?Address .
>                      ?Address :Street ?Street; :City ?City; :State 
> ?State; :Zip ?Zip}
>
> and iterating through the ResultSet I can get (each person can have 
> multiple addresses linked via a blank node):
> <person1> "Smith" "John" "3 RDF Road" "Semantic" "New York" "12345"
> <person1> "Smith" "John" "22 Linked Lane" "Data City" "New York" "22113"
>
> Is there any way to get the underlying TriplePaths (defined in the 
> where clause of the Select) for each QuerySolution as I iterate 
> through the ResultSet, something like:
>
> qs.getTriple("City") ;
>    <_:b1> :City "Semantic" .
> qs = rs.next();
> qs.getTriple("City");
>    <_:b2> :City "Data City" .
>
> or possibly even iterators of Triples since each solution variable 
> could be part of multiple TriplePaths.
>
>   - Erich
>
This message may contain information that is not intended for you. If you are 
not the addressee or if this message was sent to you by mistake, you are 
requested to inform the sender and delete the message. TNO accepts no liability 
for the content of this e-mail, for the manner in which you use it and for 
damage of any kind resulting from the risks inherent to the electronic 
transmission of messages.

Reply via email to