gpt4 book ai didi

net.sf.saxon.query.XQueryFunctionLibrary类的使用及代码示例

转载 作者:知者 更新时间:2024-03-27 08:17:05 26 4
gpt4 key购买 nike

本文整理了Java中net.sf.saxon.query.XQueryFunctionLibrary类的一些代码示例,展示了XQueryFunctionLibrary类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XQueryFunctionLibrary类的具体详情如下:
包路径:net.sf.saxon.query.XQueryFunctionLibrary
类名称:XQueryFunctionLibrary

XQueryFunctionLibrary介绍

[英]An XQueryFunctionLibrary is a function library containing all the user-defined functions available for use within a particular XQuery module: that is, the functions declared in that module, and the functions imported from other modules. It also contains (transiently during compilation) a list of function calls within the module that have not yet been bound to a specific function declaration.
[中]XQueryFunctionLibrary是一个函数库,包含可在特定XQuery模块中使用的所有用户定义函数:即在该模块中声明的函数,以及从其他模块导入的函数。它还包含(在编译期间暂时)模块内尚未绑定到特定函数声明的函数调用列表。

代码示例

代码示例来源:origin: net.sourceforge.saxon/saxon

/**
 * This method creates a copy of a FunctionLibrary: if the original FunctionLibrary allows
 * new functions to be added, then additions to this copy will not affect the original, or
 * vice versa.
 *
 * @return a copy of this function library. This must be an instance of the original class.
 */
public FunctionLibrary copy() {
  XQueryFunctionLibrary qfl = new XQueryFunctionLibrary(config);
  qfl.functions = new HashMap(functions);
  return qfl;
}

代码示例来源:origin: net.sourceforge.saxon/saxon

/**
 * Declare an imported XQuery function
 * @param function the imported function
 */
protected void declareXQueryFunction(XQueryFunction function) throws XPathException {
  queryFunctions.declareFunction(function);
}

代码示例来源:origin: net.sourceforge.saxon/saxon

/**
 * Output "explain" information about each declared function.
 * <p/>
 * This method is intended primarily for internal use.
 * @param out the expression presenter used to display the output
 */
public void explainGlobalFunctions(ExpressionPresenter out) {
  globalFunctionLibrary.explainGlobalFunctions(out);
}

代码示例来源:origin: dsukhoroslov/bagri

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;
}

代码示例来源:origin: net.sourceforge.saxon/saxon

/**
 * Look for cyclic variable references that go via one or more function calls
 * @param f a used-defined function
 * @param referees a list of variables and functions that refer directly or indirectly to this variable
 * @param globalFunctionLibrary the library containing all global functions
 */
private static void lookForFunctionCycles(
    XQueryFunction f, Stack referees, XQueryFunctionLibrary globalFunctionLibrary) throws XPathException {
  Expression body = f.getBody();
  referees.push(f);
  List list = new ArrayList(10);
  ExpressionTool.gatherReferencedVariables(body, list);
  for (int i=0; i<list.size(); i++) {
    Binding b = (Binding)list.get(i);
    if (b instanceof GlobalVariable) {
      ((GlobalVariable)b).lookForCycles(referees, globalFunctionLibrary);
    }
  }
  list.clear();
  ExpressionTool.gatherCalledFunctionNames(body, list);
  for (int i=0; i<list.size(); i++) {
    XQueryFunction qf = globalFunctionLibrary.getDeclarationByKey((String)list.get(i));
    if (!referees.contains(qf)) {
      // recursive function calls are allowed
      lookForFunctionCycles(qf, referees, globalFunctionLibrary);
    }
  }
  referees.pop();
}

代码示例来源:origin: net.sourceforge.saxon/saxon

final String uri = functionName.getNamespaceURI();
if (namespaces.contains(uri)) {
  Expression call = baseLibrary.bind(functionName, staticArgs, env);
  if (call != null) {
    XQueryFunction def = baseLibrary.getDeclaration(functionName, staticArgs);
    importingModule.checkImportedFunctionSignature(def);

代码示例来源:origin: org.opengis.cite.saxon/saxon9

/**
   * Test whether an extension function with a given name and arity is available. This supports
   * the function-available() function in XSLT. This method may be called either at compile time
   * or at run time. If the function library is to be used only in an XQuery or free-standing XPath
   * environment, this method may throw an UnsupportedOperationException.
   *
   * @param functionName the name of the function in question
   * @param arity       The number of arguments. This is set to -1 in the case of the single-argument
   *                    function-available() function; in this case the method should return true if there is some
   */

  public boolean isAvailable(StructuredQName functionName, int arity) {
    return namespaces.contains(functionName.getNamespaceURI()) &&
        baseLibrary.isAvailable(functionName, arity);
  }
}

代码示例来源:origin: org.opengis.cite.saxon/saxon9

/**
 * Fixup all references to global functions. This method is called
 * on completion of query parsing. Each XQueryFunction is required to
 * bind all references to that function to the object representing the run-time
 * executable code of the function.
 * <p/>
 * This method is for internal use only. It is called only on the StaticQueryContext for the main
 * query body (not for library modules).
 */
public void fixupGlobalFunctions() throws XPathException {
  globalFunctionLibrary.fixupGlobalFunctions(this);
}

代码示例来源:origin: org.opengis.cite.saxon/saxon9

/**
 * Get the function declaration corresponding to a given function name and arity
 * @return the XQueryFunction if there is one, or null if not.
 */
public XQueryFunction getDeclaration(StructuredQName functionName, Expression[] staticArgs) {
  if (namespaces.contains(functionName.getNamespaceURI())) {
    return baseLibrary.getDeclaration(functionName, staticArgs);
  } else {
    return null;
  }
}

代码示例来源:origin: net.sf.saxon/Saxon-HE

/**
 * Get the function with a given name and arity. This method is provided so that XQuery functions
 * can be called directly from a Java application. Note that there is no type checking or conversion
 * of arguments when this is done: the arguments must be provided in exactly the form that the function
 * signature declares them.
 *
 * @param uri       the uri of the function name
 * @param localName the local part of the function name
 * @param arity     the number of arguments.
 * @return the user-defined function, or null if no function with the given name and arity can be located
 * @since 8.4
 */
public UserFunction getUserDefinedFunction(String uri, String localName, int arity) {
  return globalFunctionLibrary.getUserDefinedFunction(uri, localName, arity);
}

代码示例来源:origin: net.sf.saxon/Saxon-HE

return baseLibrary.bind(symbolicName, staticArgs, env, reasons);
} else {
  return null;

代码示例来源:origin: org.opengis.cite.saxon/saxon9

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);
  }
}

代码示例来源:origin: org.opengis.cite.saxon/saxon9

/**
 * Look for cyclic variable references that go via one or more function calls
 * @param f a used-defined function
 * @param referees a list of variables and functions that refer directly or indirectly to this variable
 * @param globalFunctionLibrary the library containing all global functions
 */
private static void lookForFunctionCycles(
    XQueryFunction f, Stack referees, XQueryFunctionLibrary globalFunctionLibrary) throws XPathException {
  Expression body = f.getBody();
  referees.push(f);
  List list = new ArrayList(10);
  ExpressionTool.gatherReferencedVariables(body, list);
  for (int i=0; i<list.size(); i++) {
    Binding b = (Binding)list.get(i);
    if (b instanceof GlobalVariable) {
      ((GlobalVariable)b).lookForCycles(referees, globalFunctionLibrary);
    }
  }
  list.clear();
  ExpressionTool.gatherCalledFunctionNames(body, list);
  for (int i=0; i<list.size(); i++) {
    XQueryFunction qf = globalFunctionLibrary.getDeclarationByKey((String)list.get(i));
    if (!referees.contains(qf)) {
      // recursive function calls are allowed
      lookForFunctionCycles(qf, referees, globalFunctionLibrary);
    }
  }
  referees.pop();
}

代码示例来源:origin: org.opengis.cite.saxon/saxon9

final String uri = functionName.getNamespaceURI();
if (namespaces.contains(uri)) {
  Expression call = baseLibrary.bind(functionName, staticArgs, env);
  if (call != null) {
    XQueryFunction def = baseLibrary.getDeclaration(functionName, staticArgs);
    importingModule.checkImportedFunctionSignature(def);

代码示例来源:origin: net.sourceforge.saxon/saxon

/**
   * Test whether an extension function with a given name and arity is available. This supports
   * the function-available() function in XSLT. This method may be called either at compile time
   * or at run time. If the function library is to be used only in an XQuery or free-standing XPath
   * environment, this method may throw an UnsupportedOperationException.
   *
   * @param functionName the name of the function in question
   * @param arity       The number of arguments. This is set to -1 in the case of the single-argument
   *                    function-available() function; in this case the method should return true if there is some
   */

  public boolean isAvailable(StructuredQName functionName, int arity) {
    return namespaces.contains(functionName.getNamespaceURI()) &&
        baseLibrary.isAvailable(functionName, arity);
  }
}

代码示例来源:origin: net.sourceforge.saxon/saxon

/**
 * Fixup all references to global functions. This method is called
 * on completion of query parsing. Each XQueryFunction is required to
 * bind all references to that function to the object representing the run-time
 * executable code of the function.
 * <p/>
 * This method is for internal use only. It is called only on the StaticQueryContext for the main
 * query body (not for library modules).
 */
public void fixupGlobalFunctions() throws XPathException {
  globalFunctionLibrary.fixupGlobalFunctions(this);
}

代码示例来源:origin: net.sourceforge.saxon/saxon

/**
 * Get the function declaration corresponding to a given function name and arity
 * @return the XQueryFunction if there is one, or null if not.
 */
public XQueryFunction getDeclaration(StructuredQName functionName, Expression[] staticArgs) {
  if (namespaces.contains(functionName.getNamespaceURI())) {
    return baseLibrary.getDeclaration(functionName, staticArgs);
  } else {
    return null;
  }
}

代码示例来源:origin: net.sourceforge.saxon/saxon

/**
 * Get the function with a given name and arity. This method is provided so that XQuery functions
 * can be called directly from a Java application. Note that there is no type checking or conversion
 * of arguments when this is done: the arguments must be provided in exactly the form that the function
 * signature declares them.
 *
 * @param uri       the uri of the function name
 * @param localName the local part of the function name
 * @param arity     the number of arguments.
 * @return the user-defined function
 * @since 8.4
 */
public UserFunction getUserDefinedFunction(String uri, String localName, int arity) {
  return globalFunctionLibrary.getUserDefinedFunction(uri, localName, arity);
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.saxon

return baseLibrary.bind(symbolicName, staticArgs, env, reasons);
} else {
  return null;

代码示例来源:origin: net.sourceforge.saxon/saxon

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);
  }
}

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com