Hi Jordan, I’m glad to hear you solved the problem. Just a minor observation:
> let $attributes := $begin//*[@xmi:id=$id]/ownedAttribute/[@name | > @xmi:type | @xmi:id] This query will create an XQuery array for each ownedAttribute element (with 3 attributes inside). You could additionally create an array for each stereotype item: > let $combined := [ $id, $stereo1/name(), $stereo2/name(), $comments, > $attributes, "" ] Later on, if you use subsequence(), head() or ...[1], you will get one single stereotype array item… let $first := subsequence($stereotypes, 1) let $first := head($subsequence) (: equivalent :) let $first := $subsequence[1] (: equivalent :) …and you can further process the array entries in the next step: let $first-id := $first(1) (: access first array entry :) return $first-id Maybe this helps you to build up the final map representation? The lookup operator (?) can be used for positional access. If $stereotype contains the array sequence (as generated above in my reply), it is very simple to retrieve the first member of all all arrays: let $ids := $sterotypes?1 See [1,2] for more information on arrays and the lookup operator. Cheers, Christian [1] http://docs.basex.org/wiki/XQuery_3.1 [2] http://docs.basex.org/wiki/Array_Module