* @param context The dynamic context, giving access to the current node,
* the current variables, etc.
*/
public void process(XPathContext context, int locationId, int options) throws XPathException {
SequenceReceiver out = context.getReceiver();
if (isSingleton && isAtomic) {
Item item = select.evaluateItem(context);
if (item != null) {
out.characters(item.getStringValueCS(), locationId, options);
}
} else {
SequenceIterator iter = select.iterate(context);
boolean prevText = false;
boolean first = true;
CharSequence sep = null;
while (true) {
Item item = iter.next();
if (item==null) {
break;
}
if (item instanceof NodeInfo) {
if (((NodeInfo)item).getNodeKind() == Type.TEXT) {
CharSequence s = item.getStringValueCS();
if (s.length() > 0) {
if (!first && !prevText) {
if (sep == null) {
sep = separator.evaluateItem(context).getStringValueCS();
}
out.characters(sep, locationId, options);
}
first = false;
out.characters(s, locationId, options);
prevText = true;
}
} else {
prevText = false;
SequenceIterator iter2 = item.getTypedValue();
while (true) {
Item item2 = iter2.next();
if (item2 == null) {
break;
}
if (!first) {
if (sep == null) {
sep = separator.evaluateItem(context).getStringValueCS();
}
out.characters(sep, locationId, options);
}
first = false;
out.characters(item2.getStringValueCS(), locationId, options);
}
}
} else {
if (!first) {
if (sep == null) {
sep = separator.evaluateItem(context).getStringValueCS();
}
out.characters(sep, locationId, options);
}
first = false;
prevText = false;
out.characters(item.getStringValueCS(), locationId, options);
}
}
}
}