 <p>I've spent two days fighting with it. Adding "*" namespace to xPath solved the issue for me (my input file did not have any).</p> <pre><code>return &lt;label&gt;{fn:doc(fn:concat($collection, '/', $child))//*:testResult/text()}&lt;/label&gt; </code></pre>