Jheald added a subscriber: Jheald. Jheald added a comment. Not quite clear what the original poster is asking for.
It's pretty straightforward to output a list of child nodes and parent nodes, which is enough to define a tree. Here <http://demo.seco.tkk.fi/visu/#/?sparqlEndpoint=https:%2F%2Fquery.wikidata.org%2Fbigdata%2Fnamespace%2Fwdq%2Fsparql&query=PREFIX%20wikibase:%20%3Chttp:%2F%2Fwikiba.se%2Fontology%23%3E%0APREFIX%20wd:%20%3Chttp:%2F%2Fwww.wikidata.org%2Fentity%2F%3E%20%0APREFIX%20wdt:%20%3Chttp:%2F%2Fwww.wikidata.org%2Fprop%2Fdirect%2F%3E%0APREFIX%20rdfs:%20%3Chttp:%2F%2Fwww.w3.org%2F2000%2F01%2Frdf-schema%23%3E%0APREFIX%20p:%20%3Chttp:%2F%2Fwww.wikidata.org%2Fprop%2F%3E%0APREFIX%20v:%20%3Chttp:%2F%2Fwww.wikidata.org%2Fprop%2Fstatement%2F%3E%0APREFIX%20pq:%20%3Chttp:%2F%2Fwww.wikidata.org%2Fprop%2Fqualifier%2F%3E%0A%0ASELECT%20%3FaLabel%20%3FbLabel%20WHERE%20%7B%0A%20%20%20%3Fa%20wdt:P171%20%3Fb%20.%0A%20%20%20%3Fa%20wdt:P171*%20wd:Q42602%0A%0A%20%20%20SERVICE%20wikibase:label%20%7B%0A%20%20%20%20%20bd:serviceParam%20wikibase:language%20%22en%22%20.%0A%20%20%20%7D%0A%20%7D%20&outputType=gchart&chartConfig=%7B%22containerId%22:%22chart%22,%22options%22:%7B%22annotations%22:%7B%22domain%22:%7B%22style%22 :%22line%22%7D%7D,%22hAxis%22:%7B%22useFormatFromData%22:true,%22viewWindow%22:%7B%22max%22:null,%22min%22:null%7D,%22minValue%22:null,%22maxValue%22:null%7D,%22legend%22:%22in%22,%22series%22:%7B%221%22:%7B%22color%22:%22none%22%7D%7D,%22title%22:%22VISUalization%22,%22allowCollapse%22:true,%22booleanRole%22:%22certainty%22,%22vAxes%22:%5B%7B%22viewWindow%22:%7B%22max%22:null,%22min%22:null%7D,%22minValue%22:null,%22maxValue%22:null,%22useFormatFromData%22:true%7D,%7B%22viewWindow%22:%7B%22max%22:null,%22min%22:null%7D,%22minValue%22:null,%22maxValue%22:null,%22useFormatFromData%22:true%7D%5D,%22width%22:600,%22height%22:371%7D,%22state%22:%7B%7D,%22view%22:%7B%22columns%22:%5B0,%7B%22sourceColumn%22:1,%22properties%22:%7B%22role%22:%22annotation%22%7D,%22label%22:%22bLabel%22%7D%5D%7D,%22isDefaultVisualization%22:false,%22chartType%22:%22OrgChart%22%7D>, for example, is a Wikidata query being run from the website at demo.seco.tkk.fi/visu which then has an option to draw the results as a tree -- in this case, a tree of taxa in the family felidae (linked page may need to be scrolled down to make tree visible). On the other hand, if what you're asking for is a deep tree-like JSON or XML structure, then no, that's not what SPARQL does -- it emits flat reports, or lists of triples. But as the link above shows, given an appropriate list of links from child nodes to parent nodes, that list can be arranged into a tree by a downstream application (particularly if it knows the top node). TASK DETAIL https://phabricator.wikimedia.org/T89853 EMAIL PREFERENCES https://phabricator.wikimedia.org/settings/panel/emailpreferences/ To: Jheald Cc: Jheald, Smalyshev, Lydia_Pintscher, Aklapper, Jdouglas, jkroll, Wikidata-bugs, aude, Deskana, Manybubbles, JanZerebecki _______________________________________________ Wikidata-bugs mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/wikidata-bugs
