Hi,
I know that it is possible to create a module with functions (I have even done that once), but I can't find the documentation anymore on how to do that. Could please someone provide the URL to this information?
Thanks,
Ben Engbers
Hi Ben,
On Fri, Feb 25, 2022 at 8:25 AM Ben Engbers Ben.Engbers@be-logical.nl wrote:
Hi,
I know that it is possible to create a module with functions (I have even done that once), but I can't find the documentation anymore on how to do that. Could please someone provide the URL to this information?
Here is the specification: http://expath.org/spec/pkg
and the BaseX-specific documentation: https://docs.basex.org/wiki/Repository
If those aren't the pages you're thinking of, please say! :)
Thanks,
Ben Engbers
HTH
best, Bridger
The link to expath is new to me!
Thanx
Ben
Op 25-02-2022 om 14:35 schreef Bridger Dyson-Smith:
Hi Ben,
On Fri, Feb 25, 2022 at 8:25 AM Ben Engbers <Ben.Engbers@be-logical.nl mailto:Ben.Engbers@be-logical.nl> wrote:
Hi, I know that it is possible to create a module with functions (I have even done that once), but I can't find the documentation anymore on how to do that. Could please someone provide the URL to this information?
Here is the specification: http://expath.org/spec/pkg http://expath.org/spec/pkg and the BaseX-specific documentation: https://docs.basex.org/wiki/Repository https://docs.basex.org/wiki/Repository
If those aren't the pages you're thinking of, please say! :)
Thanks, Ben Engbers
HTH
best, Bridger
Ben,
Apologies - I think I misread your email (and let some things I was thinking of steer the linking!).
For an XQuery module; e.g. utilities.xqm ``` xquery version "3.1"; module namespace utils = "http://canofbees.org/ns/xquery/utilities";
declare function utils:atty( $att as attribute() ) as xs:string* { "[@" || name($att) || "='" || data($att) || "']" };
declare function utils:pathing( $result as xs:string, $node as node() ) { concat( $result, "/"[$result], name($node), $node/@* ! utils:atty(.) => string-join("") ) };
declare function utils:build-path( $nodes as node()* ) as xs:string* { distinct-values( $nodes//* ! fold-left(ancestor-or-self::*, '', utils:pathing(?, ?)) ) }; ```
and is called from an XQuery by: ``` xquery version "3.1"; import module namespace utils = "http://canofbees.org/ns/xquery/utilities"; declare variable $input := <t> <a>one</a> <b i="two"/> </t>;
utils:build-path($input) ```
I have this particular module installed in my $BASEX/repo directory - more on that in the packaging link from earlier. Hope that's more helpful :) (and closer to the mark!)
Best, Bridger
On Fri, Feb 25, 2022 at 8:35 AM Bridger Dyson-Smith bdysonsmith@gmail.com wrote:
Hi Ben,
On Fri, Feb 25, 2022 at 8:25 AM Ben Engbers Ben.Engbers@be-logical.nl wrote:
Hi,
I know that it is possible to create a module with functions (I have even done that once), but I can't find the documentation anymore on how to do that. Could please someone provide the URL to this information?
Here is the specification: http://expath.org/spec/pkg
and the BaseX-specific documentation: https://docs.basex.org/wiki/Repository
If those aren't the pages you're thinking of, please say! :)
Thanks,
Ben Engbers
HTH
best, Bridger
basex-talk@mailman.uni-konstanz.de