Hi Christian,
 
> This sounds interesting indeed! Could you provide us with a link to
> the Saxon extension functions?
 
it's an option when generating a parser in Java on the REx website, http://bottlecaps.de/rex/
 
For parsing XQuery from XQuery via a Saxon extension function,
 
   - download the XQuery grammar, e.g. http://bottlecaps.de/rex/CR-xquery-31-20151217.ebnf
 
   - generate a Java-coded parser from it, using these command line options
 
         -java -tree -saxon
 
   - compile the result
 
         javac CR_xquery_31_20151217.java
 
   - register the extension function, e.g. using the generated Saxon initializer class:
 
         java net.sf.saxon.Query -init:CR_xquery_31_20151217$SaxonInitializer -qs:"declare namespace p='CR_xquery_31_20151217'; p:parse-XQuery('42')" !indent=yes
 
The Saxon API that is used for building the parse tree has changed recently, so be sure to use Saxon 9.7.0.4 or later.
 
Best regards
Gunther