Can you show us the input structure? A sequence of arrays with a string literal as the first array item but an element or document node as the second array item?
I stumbled on the design challenge if the sequence of nested arrays would be constructed by another FLWOR expression (instead of the mentioned test data literal). Would such an XQuery script variant become more interesting?
Are any more information sources available for similar use cases?
Regards, Markus