Search code examples
xqueryexist-db

How to retrieve the source code of an XQuery module stored in eXist-db?


I am looking for a way how to retrieve the source code of an XQuery module stored in the database.

Is there any way how to do this using eXist-db's REST API or an XQuery extension function or any other eXist-db interface?


Solution

  • If you are using the REST Server, you have two main options:

    1. Do a GET on the XQuery stored in the db, with the query string parameter _source=yes. You need to change some settings in $EXIST_HOME/descriptor.xml to enable that.

    2. Write a query for retrieving queries. A query stored in the database is like any other binary document, so you could use util:binary-doc() to get it.