# Tree API

Treeql is a fairly thin query facility over Trees. It implements an ordered set of nodes which are generated and filtered by application of the treeql query language to each node in turn.

Some naming confusion arises because some interesting trees can represent things which have 'attributes', whereas some tree abstractions also provide per-node 'attributes'. We try, in this, to adopt the convention that the abstract tree has 'attributes', whereas the concrete tree may implement node 'properties'.

As treeql iterates over the ordered set of nodes applying query terms to each node in the set - the functionality of treeql is therefore determined by that of the underlying tree.

The main value add of Treeql is that it maintains a node set and handles the distribution of functions over that node set.

Several more abstract 'pre-canned' queries are provided by Treeql, implemented in terms of lower level tree functions.

Some minimal functionality of the underlying tree is assumed by treeql to implement a minimal set of queries deemed necessary.

The underlying tree must provide the following API:

Structural generators
tree
rootname
returns the tree's root
tree
children
node
return all immediate children of node
tree
next
node
return next right sibling of node
tree
parent
node
return node's parent
tree
previous
node
return left sibling of node
Property generators
tree
get
node
key
get value of property named key
tree
keys
node
glob
get all node property (names,values) whose keys match glob (default *)
tree
set
node
prop
val
set node key to value
Predicates
tree
keyexists
node
key
node
has property key