Node n = null; if (contextItem != null) contextSequence = contextItem.toSequence(); if (getArgumentCount() > 0) { NodeSet result = getArgument(0).eval(contextSequence).toNodeSet(); if (result.getLength() > 0) n = result.item(0); } else { if (contextSequence.getLength() > 0 && contextSequence.getItemType() == Type.NODE) n = ((NodeSet) contextSequence).item(0); } if (n != null) { switch (n.getNodeType()) { case Node.ELEMENT_NODE : case Node.ATTRIBUTE_NODE : return new StringValue(n.getNamespaceURI()); default : return new StringValue(""); } } return new StringValue("");
if(contextItem != null) contextSequence = contextItem.toSequence(); Item item = null;   if(getArgumentCount() > 0) { Sequence seq = getArgument(0).eval(contextSequence); if(seq.getLength() > 0) item = seq.itemAt(0); } else { if(contextSequence.getLength() > 0) item = contextSequence.itemAt(0); else throw new XPathException(getASTNode(), "undefined context item"); } if(item == null) return Sequence.EMPTY_SEQUENCE; if(!Type.subTypeOf(item.getType(), Type.NODE)) throw new XPathException(getASTNode(), "context item is not a node; got: " + Type.getTypeName(item.getType()));  Node n = ((NodeValue)item).getNode(); switch(n.getNodeType()) { case Node.ELEMENT_NODE: case Node.ATTRIBUTE_NODE: return new StringValue(n.getNamespaceURI()); default: return new StringValue(""); }
	public Sequence eval(		Sequence contextSequence,		Item contextItem)		throws XPathException {		Node n = null;		if (contextItem != null)			contextSequence = contextItem.toSequence();		if (getArgumentCount() > 0) {			NodeSet result =				getArgument(0).eval(contextSequence).toNodeSet();			if (result.getLength() > 0)				n = result.item(0);		} else {			if (contextSequence.getLength() > 0				&& contextSequence.getItemType() == Type.NODE)				n = ((NodeSet) contextSequence).item(0);		}		if (n != null) {			switch (n.getNodeType()) {				case Node.ELEMENT_NODE :				case Node.ATTRIBUTE_NODE :					return new StringValue(n.getNamespaceURI());				default :					return new StringValue("");			}		}		return new StringValue("");	}