while (nodeSet != null && nodeSet.hasMoreNodes()) {
final Object element = nodeSet.getNextNode();
if (element instanceof Attr) {
Attr n = (Attr) element;
Element holder = doc.createElementNS(XindiceCollection.QUERY_NS, "xq:result");
holder.setAttribute(NodeImpl.XMLNS_PREFIX + ":xq", XindiceCollection.QUERY_NS);
holder.setAttributeNode((Attr) doc.importNode(n, true));
if (expandSource && n instanceof DBNode) {
((DBNode) holder).setSource(((DBNode) n).getSource());