(: This solution was provided by Michael Wenger, a student at the University of W�g. :)
(: B.Biro Altova GmbH - the parameter of the function might be a seq with length != 1, so * added :)
declare function local:section-summary($book-or-section as element()*)
as element()*
{
for $section in $book-or-section
return
{ $section/@* }
{ $section/title }
{ count($section/figure) }
{ local:section-summary($section/section) }
};