View get-latest-created-document.xq
xquery version "3.1";
(: See discussion at :)
import module namespace util="";
import module namespace xmldb="";
declare function local:get-latest-created-document($collection-uri as xs:string) as map(*) {
if (xmldb:collection-available($collection-uri)) then
let $documents := xmldb:xcollection($collection-uri) ! util:document-name(.)
View frus-volume-titles.xq
xquery version "3.1";
element volumes {
let $vols := collection("/db/apps/frus/bibliography")/volume[publication-status eq "published"]
for $vol in $vols
let $vol-id := $vol/@id
let $title :=
$vol/title[@type eq "sub-series"],
$vol/title[@type eq "volume-number"],

Full text search of Chinese text, with eXist-db and lucene

This gist contains some sample files showing how to configure full text queries on Chinese text with eXist.

It assumes you have already installed eXist 3.5.0+.

Set up

The default eXist installation does not ship with the "SmartCN" analyzer for Lucene, so you need to install it. To do so, download the full distribution of Lucene, being sure to download the same version of Lucene as is bundled with eXist. For eXist 3.5.0, the version of Lucene is 4.10.4, so download lucene-4.10.4.tgz or from Expand the archive, and find lucene-analyzers-smartcn-4.10.4.jar in the analysis/smartcn folder. Place this jar file into EXIST_HOME/extensions/indexes/lucene/lib. With this jar file in place, start eXist.

View date-processing.xqm
xquery version "3.1";
module namespace dp = "";
declare variable $dp:month-regex := "(January|February|March|April|May|June|July|August|September|October|November|December)";
declare variable $dp:day-regex := "(\d{1,2})(?:st|d|nd|rd|th)?";
declare variable $dp:regexes :=
map {
View list-abbreviations.xq
xquery version "3.1";
(: Force oXygen to indent the output :)
declare namespace output="";
declare option output:method "xml";
declare option output:indent "yes";
(: Assumed context: you're running this in oXygen's XPath/XQuery Builder pane
: with an XML document open in the main editor :)
View try-catch-boilerplate.xq
xquery version "3.1";
try {
} catch * {
map {
"code": $err:code,
"description": $err:description,
"value": $err:value,
"module": $err:module,
View populate-github-issue.xq
xquery version "3.1";
(: Note: the environment-variable functions only work if the user running the query has DBA access :)
(: Probe available environment variables with the following query :)
available-environment-variables() ! map:entry(., environment-variable(.))

Install eXist via Homebrew on macOS

First time

  • Install Homebrew via instructions at
  • Delete previous installation of eXist at /Applications/ (if present), because Homebrew will refuse to install over a non-Homebrew installation.
  • Install eXist via:
$ brew cask install exist-db
View map-find.xqm
xquery version "3.1";
: An implementation of XQuery 3.1's map:find function for eXist, which does not support it natively as of 3.4.0.
: @author Joe Wicentowski
: @see
module namespace mf="";
View unparsed-text.xqm
xquery version "3.1";
: An implementation of XQuery 3.1's fn:unparsed-text* functions for eXist, which does not support them natively as of 3.4.0.
: Known limitations:
: - Does not enforce encoding aspects of the XQuery spec beyond functionality natively supplied by the EXPath HTTP Client and eXist's internals.
: @author Joe Wicentowski
: @version 0.2
: @see