Skip to content

Instantly share code, notes, and snippets.

@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>
@mnyrop
mnyrop / which-framwork-for-which-concerns.md
Last active March 11, 2024 02:19
How I think about Omeka, CollectionBuilder, and Wax (the messy version)

How I think about Omeka, CollectionBuilder, and Wax

(the messy version)

Tl;dr

  • the more you move to spreadsheets, text editors, and the command line from applications with admin interfaces:
    • the more control you get!
    • the more work + thinking you need to put in to the workflow and how it will include your collaborators
  • sometimes this control is worth it, sometimes it isn't; it depends on your goals + resources.
  • minimal computing isn't about purity politics! it's a provocation to clarify your goals and consider alternative tools and methods to best suit the goals and resources you have.
@joewiz
joewiz / generate-xconfs.xq
Created April 27, 2020 19:49
Generate eXist facet definitions for xconf index configuration files programmatically
xquery version "3.1";
(: WIP! :)
declare boundary-space preserve;
let $xconfs :=
array {
map {
"qname": "tei:div",
@joewiz
joewiz / date-parser.xqm
Created August 26, 2018 16:01
Parse various formats of date strings, in XQuery
xquery version "3.1";
(:
Various Date String Parser
- Parses various flavors of date strings, returns as xs:dateTime or xs:date
- Key functions: dates:parseDateTime() and dates:parseDate()
- Adapted by Joe Wicentowski from
https://github.com/marklogic-community/commons/blob/master/dates/date-parser.xqy
- Adapted to standard XQuery (instead of the MarkLogic 0.9-ml flavor)
- TODO: test against https://github.com/marklogic-community/commons/blob/master/dates/date-parser-tests.xqy
@jonathanrobie
jonathanrobie / nfkc.py
Created June 27, 2018 16:54
Convert files to Unicode (NFKC)
#!/usr/bin/env python3
import unicodedata
import fnmatch
import sys
import os
for file in os.listdir('.'):
for arg in sys.argv:
if fnmatch.fnmatch(file, arg):
@baskaufs
baskaufs / construct-vanderbilt-people.sparql
Created March 12, 2018 14:20
Starter query for constructing
PREFIX adhoc: <https://rawgit.com/HeardLibrary/semantic-web/master/adhoc#>
PREFIX dcterms: <http://purl.org/dc/terms/>
CONSTRUCT {
?person adhoc:status "student". # use "employee" for employees
?person adhoc:identifierSource "wikidata".
?person rdfs:label ?label.
?person dcterms:description ?description.
}
WHERE {
@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

@lcahlander
lcahlander / tsgen.xqm
Last active May 29, 2019 14:00
This library module walks an XML Schema and generates the stubs for a typeswitch transform to process a document from that schema.
(:
Copyright (c) 2017. EasyMetaHub, LLC
This work is licensed under a
<a rel="license" href="https://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0 International License</a>.
:)
xquery version "3.1";
(:~
This library module walks an XML Schema and generates the stubs for a typeswitch
@joewiz
joewiz / README.md
Last active February 13, 2018 14:01
Full text search of Chinese text, with eXist-db and Lucene

Full text search of Chinese text, with eXist-db and lucene

Note: This gist has been superseded by https://github.com/joewiz/exist-cjk but is left here should it be useful to anyone. Please post questions in an issue there.

This gist contains some sample files showing how to configure full text queries on Chinese text with eXist.

It assumes you have already installed eXist 3.5.0+.

Set up

@joewiz
joewiz / map-find.xqm
Last active June 10, 2020 16:43
An implementation of XQuery 3.1's map:find function for eXist
xquery version "3.1";
(:~
: An implementation of XQuery 3.1's map:find function for eXist, which does not support it natively as of 3.4.0.
:
: @author Joe Wicentowski
: @see https://www.w3.org/TR/xpath-functions-31/#func-map-find
:)
module namespace mf="http://joewiz.org/ns/xquery/map-find";