semantic web - Duplicate output results with SPARQL -


this question has answer here:

i'm new semantic web concept, , have diploma work based on semantic web. in owl ontology, have defined individuals in following manner:

<announce rdf:id="ann1" ...>   <...>   <...>   <requiredtechnologies>     <technology rdfs:resource="tech1"/>   </requiredtechnologies>   <requiredtechnologies>     <technology rdfs:resource="tech2"/>   </requiredtechnologies> </announce> ... 

basically, there properties appear once given individual, property "required technologies" can used multiple times in 1 record (for 1 individual). so, when run sparql query, selecting data (i use jena), output:

===================================== | "ann1"      | ... | ... | "tech1" | | "ann1"      | ... | ... | "tech2" | | "ann2"      | ... | ... | "tech3" | | "ann3"      | ... | ... | "tech4" | | "ann3"      | ... | ... | "tech5" | | "ann3"      | ... | ... | "tech6" | | ...         | ... | ... | ...     | ===================================== 

the records multiple "requiredtechnologies" attribute present appear more once. question how technologies belong given individual in 1 line (something this):

=================================================== | "ann1"      | ... | ... | "tech1, tech2"        | | "ann2"      | ... | ... | "tech2"               | | "ann3"      | ... | ... | "tech4, tech5, tech6" | | ...         | ... | ... | ...                   | =================================================== 

is there way in sparql multiple attribute in list? or other workaround?

yes, use group by clause in conjunction group_concat aggregate.

here's generic example, should able adapt data model:

select ?s (group_concat(?value ; separator = ",") ?values) {   ?s <http://somepredicate> ?value . } group ?s 

Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -