You use a TreeAppearance to create a hierarchical view of your data. A common use case is to show the subclasses of some class, or the articles within a document. Any data that is hierarchical in nature is possible.

To populate the tree appearance, you create a result set that contains the relations between parent-resources and child-resources. The child-resource should be the subject of the triple, the parent should be the object of the triple.

If your data contains loops, or childs have multiple parents, the child is only displayed the first time it is found in the result set. Because the result set is technically unordered, you cannot control which one is used after the result set is created. The advise is to formulate your query in a way that every child has only one parent.

Tree appearance

Example

This example shows a tree containing the taxonomy of concepts

@prefix elmo: <http://bp4mc2.org/elmo/def#>.
@prefix xhtml: <http://www.w3.org/1999/xhtml/vocab#>.
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
@prefix stage: <http://localhost:8080/stage#>. 
stage:TreeAppearance a elmo:Part;
	elmo:appearance elmo:TreeAppearance;
	elmo:query '''
		construct {
			?child skos:broader ?parent.
			?child rdfs:label ?childlabel.
			?parent rdfs:label ?parentlabel.
		}
		where {
			?child skos:broader ?parent.
			?child rdfs:label ?childlabel.
			?parent rdfs:label ?parentlabel.
		}
	'''
.