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