if (contextSet.getLength() == 0)
if (contextSet.isEmpty())
    protected NodeSet getAttributes(XQueryContext context, NodeSet contextSet) {        if (test.isWildcardTest()) {            NodeSet result = new VirtualNodeSet(axis, test, contextId,                    contextSet);            ((VirtualNodeSet) result)                    .setInPredicate(Expression.NO_CONTEXT_ID != contextId);            return result;            // if there's just a single known node in the context, it is faster            // do directly search for the attribute in the parent node.        } else if (!(contextSet instanceof VirtualNodeSet)                && axis == Constants.ATTRIBUTE_AXIS                && contextSet.getLength() < ATTR_DIRECT_SELECT_THRESHOLD) {            if (context.getProfiler().isEnabled())                context.getProfiler().message(this, Profiler.OPTIMIZATIONS,                        "OPTIMIZATION", "direct attribute selection");            if (contextSet.getLength() == 0)            	return NodeSet.EMPTY_SET;            NodeProxy proxy = contextSet.get(0);            if (proxy != null                    && proxy.getInternalAddress() != StoredNode.UNKNOWN_NODE_IMPL_ADDRESS)                return contextSet.directSelectAttribute(test.getName(),                        contextId);        }        if (preloadNodeSets()) {            DocumentSet docs = getDocumentSet(contextSet);            if (currentSet == null || currentDocs == null                    || !(docs.equals(currentDocs))) {                ElementIndex index = context.getBroker().getElementIndex();                if (context.getProfiler().isEnabled())                    context.getProfiler().message(this, Profiler.OPTIMIZATIONS,                            "OPTIMIZATION",                            "Using structural index '" + index.toString() + "'");                // TODO : why a null selector here ? We have one below !                currentSet = index.findElementsByTagName(                        ElementValue.ATTRIBUTE, docs, test.getName(), null);                currentDocs = docs;                registerUpdateListener();            }            switch (axis) {                case Constants.ATTRIBUTE_AXIS:                    return currentSet.selectParentChild(contextSet,                            NodeSet.DESCENDANT, contextId);                case Constants.DESCENDANT_ATTRIBUTE_AXIS:                    return currentSet.selectAncestorDescendant(contextSet,                            NodeSet.DESCENDANT, false, contextId);                default:                    throw new IllegalArgumentException(                            "Unsupported axis specified");            }        } else {            NodeSelector selector;            DocumentSet docs = getDocumentSet(contextSet);            // TODO : why a selector here ? We havn't one above !            switch (axis) {                case Constants.ATTRIBUTE_AXIS:                    selector = new ChildSelector(contextSet, contextId);                    break;                case Constants.DESCENDANT_ATTRIBUTE_AXIS:                    selector = new DescendantSelector(contextSet, contextId);                    break;                default:                    throw new IllegalArgumentException(                            "Unsupported axis specified");            }            ElementIndex index = context.getBroker().getElementIndex();            if (context.getProfiler().isEnabled())                context.getProfiler().message(this, Profiler.OPTIMIZATIONS,                        "OPTIMIZATION",                        "Using structural index '" + index.toString() + "'");            if (contextSet instanceof ExtArrayNodeSet) {                return index.findDescendantsByTagName(ElementValue.ATTRIBUTE, test.getName(), axis,                        docs, (ExtArrayNodeSet) contextSet, contextId);            } else {                return index.findElementsByTagName(ElementValue.ATTRIBUTE, docs, test.getName(), selector);            }        }    }