public boolean next(IFocus focus) throws XQueryException {
   final int attsize = elem.getAttributesCount();
   for (int i = focus.getPosition(); i < attsize; i = focus.incrPosition()) {
     DTMAttribute att = elem.attribute(i);
     if (att != null && filterNodeTest.accepts(att)) {
       focus.setContextItem(att);
       focus.incrPosition();
       return true;
     }
   }
   return false;
 }
 @Override
 public boolean next(IFocus focus) throws XQueryException {
   final int nslen = elem.getNamespaceDeclCount();
   for (int i = focus.getPosition(); i < nslen; i = focus.incrPosition()) {
     DTMNamespace ns = elem.getNamespace(i);
     if (ns != null && filterNodeTest.accepts(ns)) {
       focus.setContextItem(ns);
       focus.incrPosition();
       return true;
     }
   }
   return false;
 }
 public Sequence<? extends Item> eval(Sequence<? extends Item> contextSeq, DynamicContext dynEnv)
     throws XQueryException {
   if (contextSeq == null) {
     throw new DynamicError("err:XPDY0002", "ContextItem is not set");
   }
   if (contextSeq instanceof XQNode) {
     final XQNode n = (XQNode) contextSeq;
     if (n.nodeKind() == NodeKind.ELEMENT) {
       if (n instanceof DMElement) {
         return ((DMElement) n).attribute(_nodeTest, dynEnv);
       } else {
         return new AttributeEmurationSequence((DTMElement) n, _nodeTest, dynEnv);
       }
     } else {
       return NodeSequence.<XQNode>emptySequence();
     }
   }
   final INodeSequence<XQNode> src = ProxyNodeSequence.wrap(contextSeq, dynEnv);
   final IFocus<XQNode> srcItor = src.iterator();
   if (srcItor.hasNext()) {
     final XQNode n = srcItor.next();
     if (srcItor.hasNext()) {
       srcItor.closeQuietly();
       reportError(
           "err:XPTY0020", "Context item is expected to be a node, but was node sequence.");
     }
     if (n.nodeKind() == NodeKind.ELEMENT) {
       srcItor.closeQuietly();
       return new AttributeEmurationSequence((DTMElement) n, _nodeTest, dynEnv);
     }
   }
   srcItor.closeQuietly();
   return NodeSequence.<XQNode>emptySequence();
 }