}
if (offsets != null) {
FastQSort.sort(offsets, 0, offsets.size() - 1);
final XMLString str = text.getXMLString();
int pos = 0;
for (final Match.Offset offset : offsets) {
if (offset.getOffset() > pos) {
nodeNr = builder.characters(str.substring(pos, offset.getOffset() - pos));
result.add(builder.getDocument().getNode(nodeNr));
}
final Sequence params[] = {
new StringValue(str.substring(offset.getOffset(), offset.getLength())),
proxy,
extraArgs
};
result.addAll(callback.evalFunction(null, null, params));
pos = offset.getOffset() + offset.getLength();
}
if (pos < str.length()) {
nodeNr = builder.characters(str.substring(pos, str.length() - pos));
result.add(builder.getDocument().getNode(nodeNr));
}
} else {
nodeNr = builder.characters(text.getXMLString());
result.add(builder.getDocument().getNode(nodeNr));