java api/x-plorer xquery result mismatch

Problem overlooking something very basic here, but there’s a mismatch between what I get in X-Plorer and what I get in the Java API using the same query.

I’ve got a collection of documents of the following structure:


I’m trying to retrieve the contents of the “text” element node. The following query works correctly in X-Plorer:
for $q in input()/ClinicalDocument/component/StructuredBody/component/section
let $t := $q/:text
where $q/code[@code=“40471”]
return $t

This query (in X-Plorer) returns the correct 42 matching nodes. However, when run through the Java API, it returns 42 documents, each of which contains the 42 matching nodes. I could, of course, just take the first document returned by the iterator, but that seems a bit hacky. Any suggestions as to why there is a mismatch, and how I can fix the query to return a single document containing the matching nodes?

Thanks in advance.