declare namespace ma = "http://www.example.com/problem"; declare function ma:add2Dict( $inputList, $dictionary ) { let $info := $inputList[1] let $rest := fn:subsequence($inputList,2) let $dictionary := if (fn:empty($info)) then $dictionary else ( $dictionary, {$info/*} ) return if (fn:empty($rest)) then $dictionary else ma:add2Dict( $rest, $dictionary) }; let $doc1 := "test.xml" let $doc2 := "test2.xml" let $test1 := doc($doc2)//test/* return ma:add2Dict($test1,()) (: Stylus Studio meta-information - (c) 2004-2007. Progress Software Corporation. All rights reserved. :)