private void loadLibraryModule() throws XPathException { if (href==null && moduleURI==null) { // error already reported return; } try { XSLStylesheet top = getPrincipalStylesheet(); QueryModule importedModule = loadModule(); // Do the importing Iterator it = importedModule.getGlobalFunctionLibrary().getFunctionDefinitions(); while (it.hasNext()) { XQueryFunction def = (XQueryFunction)it.next(); // don't import functions transitively if (def.getFunctionName().getNamespaceURI().equals(moduleURI)) { top.declareXQueryFunction(def); } // Note, we are not importing global variables at present } } catch (XPathException err) { compileError(err); } }
private void loadLibraryModule() throws XPathException { if (href==null && moduleURI==null) { // error already reported return; } try { XSLStylesheet top = getPrincipalStylesheet(); QueryModule importedModule = loadModule(); // Do the importing Iterator it = importedModule.getGlobalFunctionLibrary().getFunctionDefinitions(); while (it.hasNext()) { XQueryFunction def = (XQueryFunction)it.next(); // don't import functions transitively if (def.getFunctionName().getNamespaceURI().equals(moduleURI)) { top.declareXQueryFunction(def); } // Note, we are not importing global variables at present } } catch (XPathException err) { compileError(err); } }
} else if (referees.get(i + 1) instanceof XQueryFunction) { XQueryFunction next = (XQueryFunction) referees.get(i + 1); messageBuilder.append(" calls ").append(next.getFunctionName().getDisplayName()).append("#").append(next.getNumberOfArguments()).append("()");
} else if (referees.get(i + 1) instanceof XQueryFunction) { XQueryFunction next = (XQueryFunction) referees.get(i + 1); messageBuilder.append(" calls ").append(next.getFunctionName().getDisplayName()).append("#").append(next.getNumberOfArguments()).append("()");
} else if (referees.get(i + 1) instanceof XQueryFunction) { XQueryFunction next = (XQueryFunction)referees.get(i + 1); message += " calls " + next.getFunctionName().getDisplayName() + "#" + next.getNumberOfArguments() + "()";
} else if (referees.get(i + 1) instanceof XQueryFunction) { XQueryFunction next = (XQueryFunction)referees.get(i + 1); message += " calls " + next.getFunctionName().getDisplayName() + "#" + next.getNumberOfArguments() + "()";
private FunctionDefinition[] getFunctionDefinitions() { ArrayList<FunctionDefinition> functionDefinitions = new ArrayList<FunctionDefinition>(); Iterator<XQueryFunction> functions = queryModule.getLocalFunctionLibrary().getFunctionDefinitions(); while (functions.hasNext()) { XQueryFunction function = functions.next(); UserFunctionParameter[] params = function.getParameterDefinitions(); Variable[] args = new Variable[params.length]; for (int i = 0; i < params.length; i++) { QName argname = qnameFor (params[i].getVariableQName()); addNamespaceDeclaration(argname); args[i] = new Variable (argname, getTypeDescription(params[i].getRequiredType())); } QName fname = qnameFor(function.getFunctionName()); addNamespaceDeclaration(fname); SequenceType resultType = function.getResultType(); ItemType returnType = resultType.getPrimaryType(); QName returnTypeName = null; if (returnType instanceof NameTest) { returnTypeName = qnameForNameCode (((NameTest) returnType).getFingerprint()); } FunctionDefinition fdef = new FunctionDefinition(fname, valueTypeForItemType(resultType.getPrimaryType()), cardinalityOf(resultType), returnTypeName, args, exprFor (function.getBody())); functionDefinitions.add (fdef); } return functionDefinitions.toArray(new FunctionDefinition[0]); }
ufc.setFunctionName(fd.getFunctionName()); ufc.setArguments(arguments); ufc.setStaticType(fd.getResultType());
ufc.setFunctionName(fd.getFunctionName()); ufc.setArguments(arguments); ufc.setStaticType(fd.getResultType());
if (fd != null) { UserFunctionCall ufc = new UserFunctionCall(); ufc.setFunctionName(fd.getFunctionName()); ufc.setArguments(arguments); ufc.setStaticType(fd.getResultType());
if (fd != null) { UserFunctionCall ufc = new UserFunctionCall(); ufc.setFunctionName(fd.getFunctionName()); ufc.setArguments(arguments); ufc.setStaticType(fd.getResultType());
/** * 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); }
aFunctionResolver.addUniqueFunction (aXQueryFunction.getFunctionName ().getNamespaceBinding ().getURI (), aXQueryFunction.getFunctionName ().getLocalPart (), aXQueryFunction.getNumberOfArguments (), new XPathFunctionFromUserFunction (aConfiguration,
aFunctionResolver.addUniqueFunction (aXQueryFunction.getFunctionName ().getNamespaceBinding ().getURI (), aXQueryFunction.getFunctionName ().getLocalPart (), aXQueryFunction.getNumberOfArguments (), new XPathFunctionFromUserFunction (aConfiguration,
if (config.getCountDown() == 0) { ICompilerService compilerService = config.makeCompilerService(Configuration.XQUERY); Expression cbody = opt.compileToByteCode(compilerService, body, getFunctionName().getDisplayName(), Expression.PROCESS_METHOD | Expression.ITERATE_METHOD); if (cbody != null) {
if (config.getCountDown() == 0) { ICompilerService compilerService = config.makeCompilerService(Configuration.XQUERY); Expression cbody = opt.compileToByteCode(compilerService, body, getFunctionName().getDisplayName(), Expression.PROCESS_METHOD | Expression.ITERATE_METHOD); if (cbody != null) {