boolean lastWasTextNode = false; ValueSequence result = new ValueSequence(); for(Iterator i = steps.iterator(); i.hasNext(); ) { Sequence temp = ((Expression)i.next()).eval(contextSequence, contextItem); if(temp != null && !temp.isEmpty()) {  if (lastWasTextNode) { org.w3c.dom.Text previous = (org.w3c.dom.Text)result.itemAt(result.getLength() - 1); previous.appendData(((org.w3c.dom.Text)temp).getData()); } else result.addAll(temp); lastWasTextNode = (temp instanceof org.w3c.dom.Text || Type.subTypeOf(temp.getItemType(), Type.TEXT)); } }
ValueSequence result = new ValueSequence(); for(Iterator i = steps.iterator(); i.hasNext(); ) { Sequence temp = ((Expression)i.next()).eval(contextSequence, contextItem); if(temp != null && !temp.isEmpty()) { result.addAll(temp); } }
	public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathException {        if (context.getProfiler().isEnabled()) {            context.getProfiler().start(this);                   context.getProfiler().message(this, Profiler.DEPENDENCIES, "DEPENDENCIES", Dependency.getDependenciesName(this.getDependencies()));            if (contextSequence != null)                context.getProfiler().message(this, Profiler.START_SEQUENCES, "CONTEXT SEQUENCE", contextSequence);            if (contextItem != null)                context.getProfiler().message(this, Profiler.START_SEQUENCES, "CONTEXT ITEM", contextItem.toSequence());        }        		boolean lastWasTextNode = false;		ValueSequence result = new ValueSequence();		for(Iterator i = steps.iterator(); i.hasNext(); ) {			Sequence temp = ((Expression)i.next()).eval(contextSequence, contextItem);			if(temp != null && !temp.isEmpty()) {				//Costly operation to coalesce text nodes				if (lastWasTextNode) {					org.w3c.dom.Text previous = (org.w3c.dom.Text)result.itemAt(result.getLength() - 1);					previous.appendData(((org.w3c.dom.Text)temp).getData());				} else					result.addAll(temp);				lastWasTextNode = (temp instanceof org.w3c.dom.Text || Type.subTypeOf(temp.getItemType(), Type.TEXT));							}					}		        if (context.getProfiler().isEnabled())             context.getProfiler().end(this, "", result);        		return result;	}