Get XQilla at Fast, secure and Free Open Source software downloads

XQilla : ExternalFunctionFAQ

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: Login/Register

How can I call native C++ from XQuery? How can I provide an implementation for an external function?

You can use the ExternalFunction interface to implement an external function in C++, and add it to the context using StaticContext::addExternalFunction(). You would then have to declare the function in your query using the "external" keyword:

declare namespace my = "myuri";
declare function my:externalFunction($a as xs:string) as item()* external;

An implementation of the ExternalFunction interface for the function declaration above might look like this:

class MyFunction : public ExternalFunction
  MyFunction(XPath2MemoryManager *mm)
    : ExternalFunction(X("myuri"), X("externalFunction"), 1, mm)

  virtual Result execute(const Arguments *args, DynamicContext *context) const
    return args->getArgument(0, context);



There are no comments on this page. [Add comment]

Powered by Wikka Wakka Wiki
Page was generated in 0.0896 seconds