User-defined functions

By analogy with the use of xsl:function under the XSLT QLBs, user-defined XQuery functions are supported by XQS. These will be included for use in the (evaluated or compiled) schema when placed before the patterns, using element function in the XQuery namespace, http://www.w3.org/2012/xquery, e.g.

<sch:schema>
  <sch:ns prefix='myfunc' uri='xyz'/>
  <function xmlns='http://www.w3.org/2012/xquery'>
  declare function myfunc:test($arg as xs:string) as xs:string{$arg};
  </function>
  <sch:pattern>
    <sch:rule context="/">
      <sch:report test="root"><sch:value-of select='myfunc:test(name(root))'/></sch:report>
    </sch:rule>
  </sch:pattern>
</sch:schema>