Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View joewiz's full-sized avatar

Joe Wicentowski joewiz

  • Arlington, Virginia
View GitHub Profile
@timathom
timathom / jaro-winkler.xqy
Last active February 27, 2024 04:59
Jaro-Winkler similarity in XQuery 4.0
xquery version "4.0";
(:~
:
: Module Name: Jaro-Winkler String Similarity
: Date: February 26, 2024
: License: GPLv3
: XQuery specification: 4.0
: Dependencies: BaseX 11.0
: @author @timathom
@line-o
line-o / latest-news.html
Last active June 19, 2023 14:53
Prerender HTML with eXist-db's templating library
<main class="news-list__latest">
<ul>
<li data-template="templates:each" data-template-from="articles" data-template-to="article">
<a data-template="pr:article-link"/>
</li>
</ul>
</main>
@gimsieke
gimsieke / invocation.sh
Created September 18, 2022 16:28
REx EBNF for a parsing problem presented by Martynas Jusevičius on the xml.com slack
# Go to https://bottlecaps.de/rex/ and use this command line on nested-parentheses.ebnf: -xslt -main -tree -ll 3 -backtrack
# Assumption: A Saxon front-end script called 'saxon' is on the path
saxon -o:out.xml -it:main -xsl:nested-parentheses.xslt input='{(((40 40, 20 45, 45 30, 40 40)), ((20 35, 10 30, 10 10, 30 5, 45 20, 20 35), (30 20, 20 15, 20 25, 30 20)))}' '!indent=yes'
# Looking at the main template of the generated XSLT, you need to surround the input string with curly braces; otherweise it will be interpreted as a file name
@adamretter
adamretter / xdm-type.xqm
Last active January 7, 2023 06:22
xdm-type.xqm
declare function local:xdm-type($value as item()?) as xs:QName? {
typeswitch($value)
case array(*) return xs:QName("array")
case map(*) return xs:QName("map")
case function(*) return xs:QName("function")
case document-node() return xs:QName("document")
case element() return xs:QName("element")
case attribute() return xs:QName("attribute")
case comment() return xs:QName("comment")
case processing-instruction() return xs:QName("processing-instruction")
@ubermichael
ubermichael / build.xml
Last active May 13, 2022 16:34
Example of an ant build.xml file for uploading files to eXistDb with credentials stored in a properties file
<?xml version="1.0" encoding="UTF-8"?>
<project default="xar" name="wilde" xmlns:xdb="http://exist-db.org/ant">
<description>Wilde Trials International News Archive</description>
<property name="host" value="localhost"/>
<property file="${host}.properties"/>
<path id="classpath.core">
<fileset dir="${local.dir}/lib">
<include name="*.jar"/>
@wsalesky
wsalesky / xformsRepeats.xhtml
Created February 1, 2022 01:17
XForms repeats following XML document order.
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xf="http://www.w3.org/2002/xforms" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<head>
<title>Insert with Origin</title>
<style type="text/css">
@namespace xf url("http://www.w3.org/2002/xforms");
body {font-family:Helvetica, sans-serif}
</style>
<xf:model>
<xf:instance id="i-rec">
<TEI xmlns="http://www.tei-c.org/ns/1.0">
@line-o
line-o / dicey.xq
Last active May 5, 2021 06:28
dicey - use randomness with comfort
xquery version "3.1";
declare namespace dicey="http://line-o.de/ns/dicey";
declare function dicey:sequence ($n as xs:integer,
$generator as map(xs:string, item())) as item()* {
fold-left(
1 to $n,
map { "sequence": (), "generator": $generator},
dicey:reducer#2
xquery version "3.1";
map {
"date" : current-dateTime(),
"packages" : array {
for $get-package-event in collection("/db/apps/public-repo-data/logs")//type[.="get-package"]/..
group by $name := $get-package-event/package-name/string()
let $event-count := count($get-package-event)
order by $event-count descending
return
@ciceronianus
ciceronianus / eXide-customCSS.css
Created January 25, 2021 13:02
eXide - custom CSS
#toolbar-current-app {
color:red !important;
background-color:yellow;
border-radius: 5px;
padding-left: 5px;
padding-right: 5px;
border: 1px solid #f1c871;
}
@line-o
line-o / fib-exist.xq
Last active October 12, 2020 14:45 — forked from joewiz/fib-exist.xq
XQuery Fibonacci reducer function, with timing, for eXist-db
xquery version "3.1";
(: adapted from https://stackoverflow.com/a/4936099 :)
declare function local:fib-reducer ($r, $n) { $r[1] + $r[2], $r[1] };
declare function local:fib($n as xs:integer) {
fold-left((1 to $n), (0,1), local:fib-reducer#2)[1]
};
let $results :=