### 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 `
```
--------------------------------
### Pass Wildcards to Shell Commands via sh -c in eXist-DB
Source: https://github.com/exist-db/function-documentation/blob/master/src/main/xar-resources/data/docs/process/execute.md
Illustrates how to execute shell commands that require wildcard expansion (globbing) by using 'sh -c'. This method ensures that wildcards like '*.xml' are correctly interpreted by the shell, not by eXist-DB itself.
```XQuery
let $options :=
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, (
,
)
)
```
--------------------------------
### Process Simple XProc with xproc:process in XQuery
Source: https://github.com/exist-db/function-documentation/blob/master/src/main/xar-resources/data/docs/xproc/xproc.md
Demonstrates the basic usage of the eXist XProc module by importing the module and processing a simple XProc script embedded as a document node within an XQuery query. It shows how to call the `xproc:process` function with a single argument.
```xquery
import module namespace xproc="http://exist-db.org/xproc";
let $simple-xproc as document-node() := document {
Hello world!
}
return
xproc:process($simple-xproc)
```
--------------------------------
### eXist-DB file:sync Function and Options
Source: https://github.com/exist-db/function-documentation/blob/master/src/main/xar-resources/data/docs/file/sync.md
Documents the `file:sync` function in eXist-DB, which synchronizes a collection to a file system directory. It supports an options map for fine-grained control over serialization, date filtering, pruning, and exclusions, or a deprecated xs:dateTime parameter.
```APIDOC
file:sync(collection as xs:string, directory as xs:string, options as map(*)? | xs:dateTime?) as document-node()*
Synchronizes the contents of a target collection to a target directory on the file system, including the entire tree.
Parameters:
- collection: The source collection path in eXist-DB.
- directory: The target directory path on the file system.
- options: A map of serialization and synchronization options, or a deprecated xs:dateTime for filtering.
Options Map Details:
- Serialization Options (for XML files):
- indent: xs:boolean (default true()) - Removes line-endings and extra whitespace, except in mixed content nodes.
- omit-xml-declaration: xs:boolean (default true()) - Set to false() to include the XML declaration.
- exist:expand-x-includes: xs:boolean (default false()) - Expands X-includes in files.
- exist:insert-final-newline: xs:boolean (default false()) - Adds a newline character at the end of the document.
- Synchronization Options:
- after: xs:dateTime? (default ()) - Synchronizes only files newer than the provided dateTime.
- prune: xs:boolean (default ()) - Removes surplus files on the filesystem that are not in the database collection.
- exclude: xs:string* (default ()) - A sequence of glob patterns (e.g., `*`, `?`, `**`) for files to exclude from deletion.
Returns:
A document-node() containing information about the synchronization process, including deleted files.
Related Functions:
- file:serialize: For detailed XML serialization options.
- process:execute: Used in older versions for similar file operations.
```
--------------------------------
### Connect XProc Input Ports
Source: https://github.com/exist-db/function-documentation/blob/master/src/main/xar-resources/data/docs/xproc/xproc.md
Explains how to connect input ports to documents within an XProc pipeline. Supports 'xml' type for well-formed XML documents (absolute or relative URLs) and 'data' type for base64 encoded data (absolute URLs only).
```XML
```
```XML
```
--------------------------------
### Connect XProc Output Ports
Source: https://github.com/exist-db/function-documentation/blob/master/src/main/xar-resources/data/docs/xproc/xproc.md
Details how to capture results from output ports other than the primary one. The URL must be an absolute URL pointing to a location in the database, prefixed with 'xmldb://'.
```XML
```
```XML
```
--------------------------------
### Sync Changes Made in the Last Day
Source: https://github.com/exist-db/function-documentation/blob/master/src/main/xar-resources/data/docs/file/sync.md
Demonstrates synchronizing files that have been modified within the last 24 hours using the 'after' option with the current date and time.
```xquery
file:sync("/db/apps/my-app", "/Users/me/projects/my-app", map {
"after": current-dateTime() - xs:dayTimeDuration("PT1D") (: changes in the last day :)
})
```
--------------------------------
### Sync Changes Made in the Last Day (Deprecated)
Source: https://github.com/exist-db/function-documentation/blob/master/src/main/xar-resources/data/docs/file/sync.md
Shows the older, deprecated method of synchronizing files modified in the last day by passing an xs:dateTime directly as the third argument.
```xquery
file:sync("/db/apps/my-app", "/Users/me/projects/my-app",
current-dateTime() - xs:dayTimeDuration("PT1D") (: changes in the last day :)
)
```
--------------------------------
### XQuery: fn:xml-to-json() with Control Character
Source: https://github.com/exist-db/function-documentation/blob/master/src/main/xar-resources/data/docs/fn/xml-to-json.md
Demonstrates how fn:xml-to-json() handles the control character (DEL) in an XML string. The function outputs the character directly rather than its Unicode escape sequence, following Jackson's default behavior.
```xquery
let $node :=
return fn:xml-to-json($node)
```
--------------------------------
### XQuery: fn:xml-to-json() with Escaped Slash \/
Source: https://github.com/exist-db/function-documentation/blob/master/src/main/xar-resources/data/docs/fn/xml-to-json.md
Illustrates the behavior of fn:xml-to-json() when encountering an escaped forward slash (\/) within an XML string marked as escaped. The function unescapes it to a plain slash, adhering to Jackson's unescaping rules.
```xquery
let $node := \/
return fn:xml-to-json($node)
```
--------------------------------
### XQuery: fn:xml-to-json() with Escaped Quotes ""
Source: https://github.com/exist-db/function-documentation/blob/master/src/main/xar-resources/data/docs/fn/xml-to-json.md
Details the handling of escaped double quotes ("\"") within an XML string marked as escaped by fn:xml-to-json(). The function correctly unescapes these to plain double quotes in the JSON output.
```xquery
let $node := ""
return fn:xml-to-json($node)
```
--------------------------------
### XQuery: fn:xml-to-json() with Escaped Control Character
Source: https://github.com/exist-db/function-documentation/blob/master/src/main/xar-resources/data/docs/fn/xml-to-json.md
Shows how fn:xml-to-json() processes an XML string containing an escaped control character () when the 'escaped' attribute is set to true. The function unescapes the character to its direct representation.
```xquery
let $node :=
return fn:xml-to-json($node)
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.