Skip to content

Instantly share code, notes, and snippets.

@holmesw
holmesw / factorial.md
Last active July 27, 2024 09:27
Factorial Example in XQuery 3.1

Factorial XQuery 3.1 Module

This module contains a function to calculate the factorial of any given non-negative whole number. The factorial is a textbook example of recursion.

Module Information

@holmesw
holmesw / xqdoc.xqy
Created October 22, 2012 21:28
XQuery XQDoc Style Comment Example
(:~
: XQuery main module to demonstrate comments in XQDoc style
:
: @see: http://xqdoc.org/
: @see: https://github.com/xquery/xquerydoc
:
: @version 1.0
:)
xquery version "1.0-ml";
@holmesw
holmesw / higher-order-functions.xqy
Created October 28, 2012 16:20
Higher-order Function Example in XQuery 1.0-ml
(:~
: XQuery library module to use higher order functions
:
: @version 1.0
:)
xquery version "1.0-ml";
module namespace higher-order-functions =
"http://www.example.org/xquery/functions/higher-order-functions";
@holmesw
holmesw / fibonacci.md
Last active March 31, 2024 13:07
fibonacci numbers example in XQuery 3.1

XQuery 3.1 Library Module for Fibonacci Numbers

This XQuery 3.1 library module provides functions to generate Fibonacci numbers and sequences.

Namespace

The module's namespace is http://marklogic.com/xdmp/math with the prefix fibonacci.

Functions

@holmesw
holmesw / factorial-test-with-xray.xqy
Created November 7, 2012 17:12
Factorial Example Test With XRay XQuery 1.0-ml
xquery version "1.0-ml";
module namespace test = "http://github.com/robwhitby/xray/test";
(: I assume you know what factorial looks like, if not, see: https://gist.github.com/3927580 :)
import module namespace factorial = "http://marklogic.com/xdmp/math" at "/xqy/modules/factorial.xqy";
import module namespace assert = "http://github.com/robwhitby/xray/assertions" at "/xray/src/assertions.xqy";
declare function factorial-empty () {
assert:equal(
@holmesw
holmesw / identity.xsl
Created November 8, 2012 13:10
XSLT 2.0 Identity Transform Example
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0">
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
@holmesw
holmesw / create-sec-uri-privileges-directory.xqy
Created November 9, 2012 16:26
Create URI Privileges For Directories/Collections XQuery 1.0-ml
(:~
: XQuery main module to create URI Privileges in ML Security Database
:
: @version 3.1
:)
xquery version "1.0-ml";
import module namespace sec="http://marklogic.com/xdmp/security" at "/MarkLogic/security.xqy";
declare variable $uri-stubs as xs:string* :=
@holmesw
holmesw / build-csv-collections-list.xqy
Created November 12, 2012 13:37
generate CSV Containing List of Mark Logic Collections
(:~
: XQuery main module to generate CSV file of Mark Logic Collections
: Assumes collections lexicon is enabled for database
:
: @see: http://en.wikipedia.org/wiki/Comma-separated_values
: @see: http://api.xqueryhacker.com/#cts:collections
: @see: http://api.xqueryhacker.com/#xdmp:save
:
: @version 1.0
:)
@holmesw
holmesw / xslt-invoke.xqy
Created November 14, 2012 22:04
XQuery 1.0-ml Function Mapping Wrapper Function Example (xslt-invoke)
(:~
: Function mapping is a very useful feature of Mark Logic
: however, xdmp:xslt-invoke does not support function mapping
: the functions in this library module
: act as wrapper functions for xdmp:xslt-invoke
:
: @see: http://blakeley.com/blogofile/2012/03/19/let-free-style-and-streaming/
: @see: http://api.xqueryhacker.com/#xdmp:xslt-invoke
: @see: http://www.w3schools.com/xsl/
:
@holmesw
holmesw / rotate-cipher.xqy
Created November 20, 2012 10:35
Rotation Substitution Cipher in XQuery 1.0-ml Example
(:~
: XQuery library module to convert strings using rotation cipher
:
: @version 2.0
:)
xquery version "1.0-ml";
module namespace rotate-cipher = "http://marklogic.com/xdmp";
(: variable to store the base alphabet :)