testMap.put(te.getId(), te); } else if (name.equals("function")) { FunctionEntry fe = new FunctionEntry(el); List<FunctionEntry> functions = functionsMap .get(fe.getId()); if (functions == null) { functions = new ArrayList<FunctionEntry>(); functions.add(fe); functionsMap.put(fe.getId(), functions); } else { functions.add(fe);
public boolean isAvailable(StructuredQName functionName, int arity) { String key = functionName.getClarkName(); List<FunctionEntry> functions = index.getFunctions(key); if (functions != null) { for (FunctionEntry fe : functions) { if (arity == -1) { return true; } if (arity >= fe.getMinArgs() && arity <= fe.getMaxArgs()) { return true; } } } return false; }
setJava(false); setJava(true); } else { throw new RuntimeException("Invalid function type"); if (this.getParams() != null) { minArgs = this.getParams().size(); if (usesContext()) { minArgs++; maxArgs++; setClassName(e.getAttribute("class")); setMethod(e.getAttribute("method")); setInitialized(Boolean.parseBoolean(e.getAttribute("initialized"))); nl = e.getElementsByTagName("with-param"); if (initialized && nl.getLength() > 0) {
public NodeInfo executeXSLFunction(XPathContext context, FunctionEntry fe, NodeInfo params) throws Exception { String oldFnPath = fnPath; CRC32 crc = new CRC32(); crc.update((fe.getPrefix() + fe.getId()).getBytes()); fnPath += Long.toHexString(crc.getValue()) + "/"; XdmNode n = executeTemplate(fe, S9APIUtils.makeNode(params), context); fnPath = oldFnPath; if (n == null) { return null; } return n.getUnderlyingNode(); }
methods = new Method[fe.getMaxArgs() + 1]; for (int i = fe.getMinArgs(); i <= fe.getMaxArgs(); i++) { try { methods[i] = Misc.getMethod(fe.getClassName(), fe.getMethod(), cl, i); } catch (Exception e) { throw new XPathException("Error: Unable to bind function " + fe.getName(), e); if (fe.isInitialized()) { instance = core.getFunctionInstance(fe.hashCode()); if (instance == null) { try { instance = Misc.makeInstance(fe.getClassName(), fe.getClassParams(), cl); core.putFunctionInstance(fe.hashCode(), instance); } catch (Exception e) { Class[] types; int argsIndex; if (fe.usesContext()) { m = methods[argExpressions.length + 1]; types = m.getParameterTypes(); String msg = "Error invoking " + fe.getId() + "\n" + cause.getClass().getName(); if (cause.getMessage() != null) {
"param"); for (FunctionEntry fe : functions) { if (!fe.isJava()) { boolean valid = true; for (Element el : paramElements) { javax.xml.namespace.QName qname = new javax.xml.namespace.QName( uri, name, prefix); if (!fe.getParams().contains(qname)) { valid = false; break; if (fe.isJava()) { int argCount = paramElements.size(); if (fe.getMinArgs() >= argCount && fe.getMaxArgs() <= argCount) { TEClassLoader cl = engine.getClassLoader(opts .getSourcesName()); Method method = Misc.getMethod(fe.getClassName(), fe.getMethod(), cl, argCount); Class<?>[] types = method.getParameterTypes(); Object[] args = new Object[argCount]; if (fe.isInitialized()) { try { instance = Misc.makeInstance( fe.getClassName(), fe.getClassParams(), cl); putFunctionInstance(fe.hashCode(), instance);
public Expression bind(StructuredQName functionName, Expression[] staticArgs, StaticContext env) throws XPathException { if (functionName.getNamespaceURI().equals(Test.TE_NS) && functionName.getLocalName().equals("get-type")) { return new GetTypeFunctionCall(functionName, staticArgs, env); } String key = functionName.getClarkName(); List<FunctionEntry> functions = index.getFunctions(key); int argCount = staticArgs.length; if (functions != null) { for (FunctionEntry fe : functions) { if (argCount >= fe.getMinArgs() && argCount <= fe.getMaxArgs()) { if (fe.isJava()) { TEJavaFunctionCall fc = new TEJavaFunctionCall(fe, functionName, staticArgs, env); return fc; } else { TEXSLFunctionCall fc = new TEXSLFunctionCall(fe, functionName, staticArgs, env); return fc; } } } } // Just return null rather than throw an exception, because there may be // another function library that supports this function return null; }
String key = sourcesName + "," + entry.getId(); if (entry instanceof FunctionEntry) { key += "_" + Integer.toString(((FunctionEntry) entry).getMinArgs());
List<QName> params = fe.getParams(); for (int i = 0; i < params.size(); i++) { QName param = params.get(i);
methods = new Method[fe.getMaxArgs() + 1]; for (int i = fe.getMinArgs(); i <= fe.getMaxArgs(); i++) { try { methods[i] = Misc.getMethod(fe.getClassName(), fe.getMethod(), cl, i); } catch (Exception e) { throw new XPathException("Error: Unable to bind function " + fe.getName(), e); if (fe.isInitialized()) { instance = core.getFunctionInstance(fe.hashCode()); if (instance == null) { try { instance = Misc.makeInstance(fe.getClassName(), fe.getClassParams(), cl); core.putFunctionInstance(fe.hashCode(), instance); } catch (Exception e) { Class[] types; int argsIndex; if (fe.usesContext()) { m = methods[argExpressions.length + 1]; types = m.getParameterTypes(); String msg = "Error invoking " + fe.getId() + "\n" + cause.getClass().getName(); if (cause.getMessage() != null) {
"param"); for (FunctionEntry fe : functions) { if (!fe.isJava()) { boolean valid = true; for (Element el : paramElements) { javax.xml.namespace.QName qname = new javax.xml.namespace.QName( uri, name, prefix); if (!fe.getParams().contains(qname)) { valid = false; break; if (fe.isJava()) { int argCount = paramElements.size(); if (fe.getMinArgs() >= argCount && fe.getMaxArgs() <= argCount) { TEClassLoader cl = engine.getClassLoader(opts .getSourcesName()); Method method = Misc.getMethod(fe.getClassName(), fe.getMethod(), cl, argCount); Class<?>[] types = method.getParameterTypes(); Object[] args = new Object[argCount]; if (fe.isInitialized()) { try { instance = Misc.makeInstance( fe.getClassName(), fe.getClassParams(), cl); putFunctionInstance(fe.hashCode(), instance);
public Expression bind(StructuredQName functionName, Expression[] staticArgs, StaticContext env) throws XPathException { if (functionName.getNamespaceURI().equals(Test.TE_NS) && functionName.getLocalName().equals("get-type")) { return new GetTypeFunctionCall(functionName, staticArgs, env); } String key = functionName.getClarkName(); List<FunctionEntry> functions = index.getFunctions(key); int argCount = staticArgs.length; if (functions != null) { for (FunctionEntry fe : functions) { if (argCount >= fe.getMinArgs() && argCount <= fe.getMaxArgs()) { if (fe.isJava()) { TEJavaFunctionCall fc = new TEJavaFunctionCall(fe, functionName, staticArgs, env); return fc; } else { TEXSLFunctionCall fc = new TEXSLFunctionCall(fe, functionName, staticArgs, env); return fc; } } } } // Just return null rather than throw an exception, because there may be // another function library that supports this function return null; }
public NodeInfo executeXSLFunction(XPathContext context, FunctionEntry fe, NodeInfo params) throws Exception { String oldFnPath = fnPath; CRC32 crc = new CRC32(); crc.update((fe.getPrefix() + fe.getId()).getBytes()); fnPath += Long.toHexString(crc.getValue()) + "/"; XdmNode n = executeTemplate(fe, S9APIUtils.makeNode(params), context); fnPath = oldFnPath; if (n == null) { return null; } return n.getUnderlyingNode(); }
String key = sourcesName + "," + entry.getId(); if (entry instanceof FunctionEntry) { key += "_" + Integer.toString(((FunctionEntry) entry).getMinArgs());
List<QName> params = fe.getParams(); for (int i = 0; i < params.size(); i++) { QName param = params.get(i);
setJava(false); setJava(true); } else { throw new RuntimeException("Invalid function type"); if (this.getParams() != null) { minArgs = this.getParams().size(); if (usesContext()) { minArgs++; maxArgs++; setClassName(e.getAttribute("class")); setMethod(e.getAttribute("method")); setInitialized(Boolean.parseBoolean(e.getAttribute("initialized"))); nl = e.getElementsByTagName("with-param"); if (initialized && nl.getLength() > 0) {
public boolean isAvailable(StructuredQName functionName, int arity) { String key = functionName.getClarkName(); List<FunctionEntry> functions = index.getFunctions(key); if (functions != null) { for (FunctionEntry fe : functions) { if (arity == -1) { return true; } if (arity >= fe.getMinArgs() && arity <= fe.getMaxArgs()) { return true; } } } return false; }
testMap.put(te.getId(), te); } else if (name.equals("function")) { FunctionEntry fe = new FunctionEntry(el); List<FunctionEntry> functions = functionsMap .get(fe.getId()); if (functions == null) { functions = new ArrayList<FunctionEntry>(); functions.add(fe); functionsMap.put(fe.getId(), functions); } else { functions.add(fe);