private <R> List<R> lookupFunctions(FunctionLibraryList fll, FunctionExtractor<R> ext) { List<R> fl = new ArrayList<>(); for (FunctionLibrary lib: fll.getLibraryList()) { logger.trace("lookupFunctions; function library: {}; class: {}", lib.toString(), lib.getClass().getName()); if (lib instanceof FunctionLibraryList) { fl.addAll(lookupFunctions((FunctionLibraryList) lib, ext)); //} else if (lib instanceof ExecutableFunctionLibrary) { // ExecutableFunctionLibrary efl = (ExecutableFunctionLibrary) lib; // Iterator<UserFunction> itr = efl.iterateFunctions(); // while (itr.hasNext()) { // fl.add(getFunctionDeclaration(itr.next())); // } } else if (lib instanceof XQueryFunctionLibrary) { XQueryFunctionLibrary xqfl = (XQueryFunctionLibrary) lib; Iterator<XQueryFunction> itr = xqfl.getFunctionDefinitions(); while (itr.hasNext()) { XQueryFunction fn = itr.next(); logger.trace("lookupFunctions; fn: {}", fn.getDisplayName()); R result = ext.extractFunction(fn.getUserFunction()); if (result != null) { fl.add(result); } } } } return fl; }
/** * Register a user-defined XQuery function * @param function the function to be registered * @throws XPathException if there is an existing function with the same name and arity */ public void declareFunction(XQueryFunction function) throws XPathException { String keyObj = function.getIdentificationKey(); XQueryFunction existing = (XQueryFunction)functions.get(keyObj); if (existing != null) { XPathException err = new XPathException("Duplicate definition of function " + function.getDisplayName() + " (see line " + existing.getLineNumber() + " in " + existing.getSystemId() + ')'); err.setErrorCode("XQST0034"); err.setIsStaticError(true); err.setLocator(function); throw err; } functions.put(keyObj, function); }
/** * Register a user-defined XQuery function * @param function the function to be registered * @throws XPathException if there is an existing function with the same name and arity */ public void declareFunction(XQueryFunction function) throws XPathException { String keyObj = function.getIdentificationKey(); XQueryFunction existing = (XQueryFunction)functions.get(keyObj); if (existing != null) { XPathException err = new XPathException("Duplicate definition of function " + function.getDisplayName() + " (see line " + existing.getLineNumber() + " in " + existing.getSystemId() + ')'); err.setErrorCode("XQST0034"); err.setIsStaticError(true); err.setLocator(function); throw err; } functions.put(keyObj, function); }
/** * Register a user-defined XQuery function * * @param function the function to be registered * @throws XPathException if there is an existing function with the same name and arity */ public void declareFunction(/*@NotNull*/ XQueryFunction function) throws XPathException { SymbolicName keyObj = function.getIdentificationKey(); XQueryFunction existing = functions.get(keyObj); if (existing == function) { return; } if (existing != null) { XPathException err = new XPathException("Duplicate definition of function " + function.getDisplayName() + " (see line " + existing.getLineNumber() + " in " + existing.getSystemId() + ')'); err.setErrorCode("XQST0034"); err.setIsStaticError(true); err.setLocator(function); throw err; } functions.put(keyObj, function); }
/** * Register a user-defined XQuery function * * @param function the function to be registered * @throws XPathException if there is an existing function with the same name and arity */ public void declareFunction(/*@NotNull*/ XQueryFunction function) throws XPathException { SymbolicName keyObj = function.getIdentificationKey(); XQueryFunction existing = functions.get(keyObj); if (existing == function) { return; } if (existing != null) { XPathException err = new XPathException("Duplicate definition of function " + function.getDisplayName() + " (see line " + existing.getLineNumber() + " in " + existing.getSystemId() + ')'); err.setErrorCode("XQST0034"); err.setIsStaticError(true); err.setLocator(function); throw err; } functions.put(keyObj, function); }
} else { msg += "signature of imported function " + ((XQueryFunction)declaration).getDisplayName();
} else { msg += "signature of imported function " + ((XQueryFunction)declaration).getDisplayName();
/** * Register a user-defined XQuery function. * <p>This method is intended for internal use only.</p> * * @param function the function being declared * @throws net.sf.saxon.trans.XPathException * if an error occurs, for example * a duplicate function name */ public void declareFunction(/*@NotNull*/ XQueryFunction function) throws XPathException { Configuration config = getConfiguration(); if (function.getNumberOfArguments() == 1) { StructuredQName name = function.getFunctionName(); SchemaType t = config.getSchemaType(name); if (t != null && t.isAtomicType()) { XPathException err = new XPathException("Function name " + function.getDisplayName() + " clashes with the name of the constructor function for an atomic type"); err.setErrorCode("XQST0034"); err.setIsStaticError(true); throw err; } } XQueryFunctionLibrary local = getLocalFunctionLibrary(); local.declareFunction(function); //if (!function.isPrivate()) { QueryModule main = getTopLevelModule(); main.globalFunctionLibrary.declareFunction(function); //} }
/** * Register a user-defined XQuery function. * <p>This method is intended for internal use only.</p> * * @param function the function being declared * @throws net.sf.saxon.trans.XPathException * if an error occurs, for example * a duplicate function name */ public void declareFunction(/*@NotNull*/ XQueryFunction function) throws XPathException { Configuration config = getConfiguration(); if (function.getNumberOfArguments() == 1) { StructuredQName name = function.getFunctionName(); SchemaType t = config.getSchemaType(name); if (t != null && t.isAtomicType()) { XPathException err = new XPathException("Function name " + function.getDisplayName() + " clashes with the name of the constructor function for an atomic type"); err.setErrorCode("XQST0034"); err.setIsStaticError(true); throw err; } } XQueryFunctionLibrary local = getLocalFunctionLibrary(); local.declareFunction(function); //if (!function.isPrivate()) { QueryModule main = getTopLevelModule(); main.globalFunctionLibrary.declareFunction(function); //} }
/** * Register a user-defined XQuery function. * <p/> * This method is intended for internal use only. * @param function the function being declared */ public void declareFunction(XQueryFunction function) throws XPathException { Configuration config = getConfiguration(); if (function.getNumberOfArguments() == 1) { StructuredQName name = function.getFunctionName(); int fingerprint = config.getNamePool().getFingerprint(name.getNamespaceURI(), name.getLocalName()); if (fingerprint != -1) { SchemaType t = config.getSchemaType(fingerprint); if (t != null && t.isAtomicType()) { XPathException err = new XPathException("Function name " + function.getDisplayName() + " clashes with the name of the constructor function for an atomic type"); err.setErrorCode("XQST0034"); err.setIsStaticError(true); throw err; } } } XQueryFunctionLibrary local = getLocalFunctionLibrary(); local.declareFunction(function); QueryModule main = getTopLevelModule(); main.globalFunctionLibrary.declareFunction(function); }
/** * Register a user-defined XQuery function. * <p/> * This method is intended for internal use only. * @param function the function being declared */ public void declareFunction(XQueryFunction function) throws XPathException { Configuration config = getConfiguration(); if (function.getNumberOfArguments() == 1) { StructuredQName name = function.getFunctionName(); int fingerprint = config.getNamePool().getFingerprint(name.getNamespaceURI(), name.getLocalName()); if (fingerprint != -1) { SchemaType t = config.getSchemaType(fingerprint); if (t != null && t.isAtomicType()) { XPathException err = new XPathException("Function name " + function.getDisplayName() + " clashes with the name of the constructor function for an atomic type"); err.setErrorCode("XQST0034"); err.setIsStaticError(true); throw err; } } } XQueryFunctionLibrary local = getLocalFunctionLibrary(); local.declareFunction(function); QueryModule main = getTopLevelModule(this); main.globalFunctionLibrary.declareFunction(function); }
body = opt.makeByteCodeCandidate(compiledFunction, body, getDisplayName(), Expression.PROCESS_METHOD | Expression.ITERATE_METHOD);
body = opt.makeByteCodeCandidate(compiledFunction, body, getDisplayName(), Expression.PROCESS_METHOD | Expression.ITERATE_METHOD);