### Example file:sync Deletion Report Source: https://github.com/exist-db/function-documentation/blob/master/src/main/xar-resources/data/docs/file/sync.md An XML output example showing the structure of the document-node() returned by file:sync, specifically detailing files that were deleted from the filesystem. ```xml ``` -------------------------------- ### Store XProc Output in eXist-db Source: https://github.com/exist-db/function-documentation/blob/master/src/main/xar-resources/data/docs/xproc/xproc.md Describes the usage of the XProc `` step for writing documents to the eXist-db database. The URL must be an absolute URL starting with 'xmldb://'. ```XProc The XProc `` step works and can write documents to the database. The URL must be an absolute URL pointing to a location in the database. **Watch out:** It must begin with the pre fix *xmldb://* (instead of the usual *xmldb:exist://*). ``` -------------------------------- ### Provide Stdin Input to Shell Commands in eXist-DB Source: https://github.com/exist-db/function-documentation/blob/master/src/main/xar-resources/data/docs/process/execute.md Demonstrates how to pipe data into a shell command executed by eXist-DB's process:execute. The example uses '' to provide lines of text to the 'wc -l' command, which counts the number of lines received. ```XQuery let $options := return process:execute(("wc", "-l"), $options) ``` -------------------------------- ### XQuery: List Terms from Lucene Index Starting with 'kin' Source: https://github.com/exist-db/function-documentation/blob/master/src/main/xar-resources/data/docs/util/index-keys_5.md This XQuery example shows how to query the Lucene full-text index for terms starting with a specific string. It targets a collection of Shakespeare documents, filters terms beginning with 'kin', and formats the output to show the term, its frequency, and the number of documents it appears in. ```xquery xquery version "3.1"; declare namespace tei="http://www.tei-c.org/ns/1.0"; { util:index-keys(collection("/db/apps/shakespeare")//tei:sp, "kin", function($key, $count) { }, -1, "lucene-index") } ``` -------------------------------- ### Sync Collection to Git Repository with Exclusions Source: https://github.com/exist-db/function-documentation/blob/master/src/main/xar-resources/data/docs/file/sync.md Example of synchronizing an eXist-DB collection to a local directory, preserving dotfiles like .git and .gitignore by excluding them from the pruning process. ```xquery file:sync("/db/apps/my-app", "/Users/me/projects/my-app", map { "prune": true(), (: remove anything not in the database :) "exclude": (".*") (: do not remove dotfiles, this will leave .git folder and .gitignore untouched :) }) ``` -------------------------------- ### Set Environment Variables for Shell Commands in eXist-DB Source: https://github.com/exist-db/function-documentation/blob/master/src/main/xar-resources/data/docs/process/execute.md Shows how to pass environment variables to a shell command executed via eXist-DB's process:execute. The example sets the 'DATA' variable and echoes it using 'sh -c', illustrating environment isolation and access. ```XQuery let $options := return process:execute(("sh", "-c", "echo $DATA"), $options) ``` -------------------------------- ### XQuery: Get Structural Index Statistics for Elements and Attributes Source: https://github.com/exist-db/function-documentation/blob/master/src/main/xar-resources/data/docs/util/index-keys_5.md This XQuery snippet demonstrates how to use util:index-keys to retrieve statistics for the structural index. It processes a collection, extracts element and attribute names, and displays their frequency and document count using a custom callback function. ```xquery { util:index-keys(collection("/db/test"), (), function($key, $count) { }, -1, "structural-index") } ``` -------------------------------- ### APIDOC: util:index-keys Function for eXist-DB Index Statistics Source: https://github.com/exist-db/function-documentation/blob/master/src/main/xar-resources/data/docs/util/index-keys_5.md The util:index-keys function retrieves statistics from various indexes within eXist-DB. It supports structural, range, Lucene, and NGram indexes, providing details on index keys, their frequency within a dataset, and their occurrence across documents. The function requires a node set, an optional search term, a callback function for formatting output, a starting position, and the index name. ```APIDOC util:index-keys(node-set, search-term?, callback-function, start-position?, index-name) Description: Retrieves statistics from specified indexes in eXist-DB. Parameters: - node-set: The context node set from which to retrieve index keys. Must contain elements for which an index is defined. - search-term (optional): A string to filter index keys. If omitted, all keys are considered. - callback-function: A function that accepts two arguments: $key (the index key) and $count (an array containing frequency and document count). This function formats the output for each key. - start-position (optional): An integer specifying the starting position for retrieving keys. Defaults to -1 (all). - index-name: A string specifying the type of index to query. Supported values include 'structural-index', 'range-index', 'lucene-index', and 'ngram-index'. Returns: An XML fragment generated by the callback-function for each matching index key. Limitations: The node-set provided in the first argument must contain elements that are indexed. If no indexed elements are present, the function will return an empty result. Related Functions: - util:index-info: Provides general information about available indexes. ``` -------------------------------- ### Clone eXist-db Function Docs Repository Source: https://github.com/exist-db/function-documentation/blob/master/README.md Clones the eXist-db function documentation browser app repository from GitHub to your local system. ```bash git clone https://github.com/exist-db/function-documentation.git ``` -------------------------------- ### Build eXist-db Function Docs App with Maven Source: https://github.com/exist-db/function-documentation/blob/master/README.md Builds the eXist-db function documentation application using Maven. This process compiles the application and generates a .xar file in the /target directory. ```bash cd function-documentation mvn clean package ``` -------------------------------- ### Configure XProc Pipeline Options Source: https://github.com/exist-db/function-documentation/blob/master/src/main/xar-resources/data/docs/xproc/xproc.md Demonstrates how to pass string values for XProc pipeline options using the ` process:execute(("sh", "-c", "ls *.xml"), ) ``` -------------------------------- ### XQuery format-date Basic Formatting Source: https://github.com/exist-db/function-documentation/blob/master/src/main/xar-resources/data/docs/fn/format-date.md Demonstrates the basic usage of the XQuery format-date function with different format strings to control the output of date values. The function takes a date value and a format string as primary arguments. ```XQuery format-date($d, "[Y0001] [M01]-[D01]") | 2014-02-22 ``` ```XQuery format-date($d, "[D1o] [MNn], [Y]", "en", (), ()) | 22nd February, 2014 ``` ```XQuery format-date($d, "[MNn] [D], [Y]", "en", (), ()) | February 22, 2014 ``` -------------------------------- ### Execute Command with Custom Working Directory in eXist-DB Source: https://github.com/exist-db/function-documentation/blob/master/src/main/xar-resources/data/docs/process/execute.md Demonstrates how to execute a shell command ('ls -l') within a specified working directory ('/etc') using eXist-DB's process:execute function. This ensures commands operate in the intended file system context. ```XQuery let $options := return process:execute(("ls","-l"),$options) ``` -------------------------------- ### Pass Options to xproc:process in XQuery Source: https://github.com/exist-db/function-documentation/blob/master/src/main/xar-resources/data/docs/xproc/xproc.md Illustrates how to pass processing options and additional inputs to the `xproc:process` function. This allows for more complex pipeline execution by providing named options or specifying input documents for different ports. ```xquery xproc:process( $xproc, (