// Execute the XPath, and have it return the result
XObject list = eval(contextNode, str, namespaceNode);
// Patch attributed to nboyd@atg.com (Norris Boyd)
NodeSet nodeset = list.mutableNodeset();
// setShouldCacheNodes(true) be called before the first nextNode() is
// called, in order that nodes can be added as they are fetched.
nodeset.setShouldCacheNodes(true);