Wolfgang Hoschek wrote: > problem 1) the recursive query can be reduced to > > let $x := doc("test.xml")/S/A > return count($x/ancestor-or-self::element()) that's more smart for sure. Thanks, Sergio