Skip to content

Instantly share code, notes, and snippets.

@joewiz
joewiz / check-text-for-ocr-typo-patterns.xq
Last active April 9, 2021 03:30
Check a text for OCR typo patterns, using XQuery
xquery version "3.1";
(:~
: Find possible OCR errors in a text by checking for patterns that an OCR
: process is known to misread, e.g., "day" misread as "clay", or "France"
: misread as "Prance." If the OCR engine just misread some instances of these
: words but got other instances correct, then this query will highlight
: candidates for correction.
:
: The query lets you configure a source text and define pattern sets to be used.
@adamretter
adamretter / dtx.xqm
Last active January 22, 2020 21:22
Date/Time/DateTime XQuery functions
import module namespace functx = "http://www.functx.com";
(: NOTE -- functx uses 1 to 7 to represent MON-SUN, whereas eXist-db's datetime module used 1 to 7 to represent SUN-SAT :)
declare variable $local:MON := 1;
declare variable $local:TUES := 2;
declare variable $local:WEDS := 3;
declare variable $local:THURS := 4;
declare variable $local:FRI := 5;
declare variable $local:SAT := 6;
@grantmacken
grantmacken / .env
Last active February 19, 2019 21:54
Use prove to get TAP output from running #existdb unit tests
NAME=newBase60
CONTAINER=exDev
PORT=8282
USE_DC_OVERRIDE=yes
DC_OVERRIDE_NETWORK=www
xquery version "3.1";
declare namespace io = "http://io";
(: IO version of get-char :)
declare function local:get-char() as map(*) {
local:create-io(function($realworld as element(io:realworld)) {
($realworld, 123)
})
};
@egucciar
egucciar / README.md
Last active August 4, 2023 13:22
Shadow Dom Commands

ShadowDom

Quick Start

In the index.js or the root file of your cypress/support folder,

@joewiz
joewiz / CompareTools.plist
Last active February 28, 2023 05:25
Add oXygen as Diff & Merge Tool for Git Tower
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>ApplicationIdentifier</key>
<string>ro.sync.exml.DiffDirs</string>
<key>ApplicationName</key>
<string>Diff Directories</string>
@joewiz
joewiz / 01-levenshtein-distance.xq
Last active July 5, 2022 17:18
Calculate Levenshtein Distance, using XQuery
xquery version "3.1";
(:~
Calculate Levenshtein Distance, using XQuery
@author Guillaume Mella
@see http://apps.jmmc.fr/~mellag/xquery/levenshtein/2018/01/19/xquery-levenshtein-distance/
:)
declare function local:levenshtein-distance($string1 as xs:string?, $string2 as xs:string?)
as xs:integer
@ijlyttle
ijlyttle / .block
Created August 22, 2018 18:43
Vega-Lite: multiple data
license: mit
height: 500
scrolling: yes
border: yes
@dizzzz
dizzzz / functionSignatureTests.xquery
Last active October 23, 2020 19:39
A script to generate function-signature-tests for xquery functions in eXist-db
xquery version "3.1";
module namespace xqfunctions="http://exist-db.org/xquery/test/xqfunctions";
import module namespace inspect="http://exist-db.org/xquery/inspection" at "java:org.exist.xquery.functions.inspect.InspectionModule";
declare namespace test="http://exist-db.org/xquery/xqsuite";
declare function xqfunctions:cardinality($cardinality as xs:string) as xs:string {
@joewiz
joewiz / an-introduction-to-recursion-in-xquery.md
Last active January 3, 2024 15:30
An introduction to recursion in XQuery

An introduction to recursion in XQuery

  • Created: Nov 28, 2017
  • Updated: Nov 29, 2017: Now covers transformation of XML documents

Recursion is a powerful programming technique, but the idea is simple: instead of performing a single operation, a function calls itself repeatedly to whittle through a larger task. In XQuery, recursion can be used to accomplish complex tasks on data that a plain FLWOR expression (which iterates through a sequence) cannot, such as transforming an entire XML document from one format into another, like TEI or DocBook into HTML, EPUB, LaTeX, or XSL-FO. Transforming a document is well-suited to recursion because each of the document's nodes may need to be examined and manipulated based on the node's type, name, and location in the document; and once a node has been processed, the transformation must continue processing the nodes' children and descendants until the deepest leaf node has been processed. But learning the technique of recursion is often hard for a beginning program