/** * Adds a local function. * * @param fun function instance * @param ii input info * @return function id * @throws QueryException query exception */ public int add(final UserFunc fun, final InputInfo ii) throws QueryException { final QNm name = fun.name; final byte[] uri = name.uri(); if (uri.length == 0) FUNNONS.thrw(ii, name.string()); if (NSGlobal.reserved(uri)) { if (fun.declared) NAMERES.thrw(ii, name.string()); funError(name, ii); } final byte[] ln = name.local(); for (int l = 0; l < funcs.length; ++l) { final QNm qn = funcs[l].name; final byte[] u = qn.uri(); final byte[] nm = qn.local(); if (eq(ln, nm) && eq(uri, u) && fun.args.length == funcs[l].args.length) { // declare function that has been called before if (!funcs[l].declared) { funcs[l] = fun; return l; } // duplicate declaration FUNCDEFINED.thrw(ii, fun.name.string()); } } // add function skeleton funcs = Array.add(funcs, fun); calls = Array.add(calls, new UserFuncCall[0]); return funcs.length - 1; }
@Override public Item item(final QueryContext qc, final InputInfo ii) throws QueryException { final ANode node = toEmptyNode(arg(0, qc), qc); final QNm qname = node != null ? node.qname() : null; return qname != null ? Uri.uri(qname.uri(), false) : Uri.EMPTY; }
/** * Returns the module namespace URI. * * @return URI */ public byte[] uri() { return name.uri(); }