W3C home > Mailing lists > Public > semantic-web@w3.org > November 2016

How to add "labels" to SPARQL output

From: Mario Valle <mvalle@cscs.ch>
Date: Thu, 10 Nov 2016 06:33:28 +0100
To: <semantic-web@w3.org>
Message-ID: <23712db4-f6a2-ce3d-ba08-e6e08632d1bd@cscs.ch>
Dear SPARQL gurus,
I have a graph, composed by nodes and link joining them, represented as 
triples. Now for a specific node I want to list the nodes that are 
pointed FROM the given node or that point TO the given node. This is easy:

SELECT  ?node_in ?node_out

	?central_node a <node> ;
		<id> 123 .
		[] <output_node_link> ?central_node ;
		   <input_node_link> ?node_in .
		[] <input_node_link> ?central_node ;
		   <output_node_link> ?node_out .

My question: instead of having two columns to distinguish linked node as 
IN or OUT, is it possible to have a single ?node_related column and a 
variable that says "IN" or "OUT"?

I think I have to put before my query a CONSTRUCT that adds this field 
to the related nodes, but I don't know if this field could be defined 
"temporary" and does not modify the db content.

Thanks for your help!

Ing. Mario Valle
Swiss National Supercomputing Centre (CSCS)
v. Trevano 131, 6900 Lugano, Switzerland
Tel: +41 (91) 610.82.60
Received on Thursday, 10 November 2016 05:34:02 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 19:50:18 UTC