XForms/Folding Menus

Motivation
You want to display a complex list of choices in a tree structure where each branch could be opened and closed.

Discussion
There are some interesteing XPath expressions in this example. For example the following counts the number of ancestor nodes of the current node:

count(current/ancestor::*)

The following gets all of the decendant groups within the instance data:

instance('instanceData')/descendant::group

The following returns a "+" if the nodelist contains the value in the id attribute and a "-" if it does not.

if(contains(instance('foldedNodes')/nodelist, ./@id), '+', '-')

Credits
Thanks to Fraser for posting this on the Mozilla XForms developer newsgroup in Oct. of 2007