protected NodeIterator sortNodes(
XPathContext xctxt, Vector keys, NodeIterator sourceNodes)
throws TransformerException
{
NodeSorter sorter = new NodeSorter(xctxt);
NodeSet nodeList;
if (sourceNodes instanceof NodeSet)
{
nodeList = ((NodeSet) sourceNodes);
nodeList.setShouldCacheNodes(true);
nodeList.runTo(-1);
}
else
{
nodeList = new NodeSet(sourceNodes);
sourceNodes = nodeList;
((ContextNodeList) sourceNodes).setCurrentPos(0);
}
xctxt.pushContextNodeList((ContextNodeList) sourceNodes);
try
{
sorter.sort(nodeList, keys, xctxt);
nodeList.setCurrentPos(0);
}
finally
{
xctxt.popContextNodeList();