upvote
> like XQuery

My favorite thing about XQuery is that it supports logically named functions, not just templates that happen to work upon whatever one provides it as with XSLT. I think golang's text/template suffers from the same problem - good luck being disciplined enough to always give it the right context, or you get bad outcomes

An example I had lying around:

  declare function local:find-outline-num( $from as element(), $num as xs:integer ) as element()* {
    for $el in $from/following-sibling::h:div[@class=concat('outline-', $num)]/*[local-name()=concat('h', $num)]
    return $el
  };
reply