* Iterator over the results of the expression
*/
public SequenceIterator iterate(final XPathContext context) throws XPathException {
final NodeInfo element = (NodeInfo)argument[0].evaluateItem(context);
final IntIterator iter = NamespaceCodeIterator.iterateNamespaces(element);
final NamePool pool = context.getNamePool();
return new SequenceIterator() {
private Item current = null;
private int position = 0;
public Item current() {
return current;
}
public SequenceIterator getAnother() throws XPathException {
return iterate(context);
}
public int getProperties() {
return 0;
}
public Item next() throws XPathException {
if (position == 0) {
current = new StringValue("xml");
position++;
return current;
} else if (iter.hasNext()) {
String prefix = pool.getPrefixFromNamespaceCode(iter.next());
if (prefix.length() == 0) {
current = StringValue.EMPTY_STRING;
} else {
current = StringValue.makeRestrictedString(
prefix, BuiltInAtomicType.NCNAME, null).asAtomic();