code: function xsltForEach(input, template, output) {
    var select = xmlGetAttribute(template, 'select');
    var nodes = xpathEval(select, input).nodeSetValue();
    var sortContext = input.clone(nodes[0], 0, nodes);
    xsltSort(sortContext, template);
    for (var i = 0; i < sortContext.contextSize(); ++i) {
      var ni = sortContext.nodelist[i];
      xsltChildNodes(sortContext.clone(ni, i), template, output);
    }
  }
docs: Implements xsl:for-each.