public Sequence eval(Sequence<? extends Item> contextSeq, ValueSequence argv, DynamicContext dynEnv)
throws XQueryException {
assert (argv != null && argv.size() == 2);
// If $qname is the empty sequence, returns the empty sequence.
Item firstItem = argv.getItem(0);
if(firstItem.isEmpty()) {
return ValueSequence.EMPTY_SEQUENCE;
}
XString qname = (XString) firstItem;
String qnameStr = qname.getValue();
final int pos = qnameStr.indexOf(':');
final String nsuri;
if(pos == -1) {
// If the $qname has no prefix, and there is no namespace binding for $element
// corresponding to the default (unnamed) namespace, then the resulting expanded-QName
// has no namespace part.
nsuri = XMLUtils.NULL_NS_URI;
} else {
final String prefix = qnameStr.substring(0, pos - 1);
Item secondItem = argv.getItem(1);
XQNode element = (XQNode) secondItem;
nsuri = NamespaceUriForPrefix.resolveNamespaceUri(element, prefix);
if(nsuri == null) {
// If the $qname has a prefix and if there is no namespace binding for $element
// that matches this prefix, then an error is raised [err:FONS0004].