declare function local:concerto($doc){ { { fn:count($doc//book) } , for $book in $doc//book return ( {$book/author} {($book/price | $book/@price)/data() } {($book/title | $book/@title)/data() } ) } }; let $message := ( local:concerto(doc('http://cin.ufpe.br/~dsmp/xquery/xml/catalog.xml')) | local:concerto(doc('http://cin.ufpe.br/~dsmp/xquery/xml/outroCatalogo.xml')) ) return { $message }