Skip to content

Instantly share code, notes, and snippets.

Joe Wicentowski joewiz

View GitHub Profile
@joewiz
joewiz / create-travels-tsv.xq
Last active Mar 14, 2019
Generate a TSV of Travels of the Secretary of State
View create-travels-tsv.xq
xquery version "3.1";
(: Generate a TSV of Travels of President and Secretary of State.
: Assumes https://github.com/HistoryAtState/travels has been installed.
:)
(:~
: A function for constructing a TSV (tab-separated value) file
:
: @param A sequence of column headings
@joewiz
joewiz / xquery-3.1-boilerplate.xq
Created Mar 4, 2019
XQuery 3.1 module boilerplate
View xquery-3.1-boilerplate.xq
xquery version "3.1";
(: Standard namespaces from https://www.w3.org/TR/xpath-functions-31/#namespace-prefixes :)
declare namespace array="http://www.w3.org/2005/xpath-functions/array";
declare namespace err="http://www.w3.org/2005/xqt-errors";
declare namespace fn="http://www.w3.org/2005/xpath-functions";
declare namespace map="http://www.w3.org/2005/xpath-functions/map";
declare namespace math="http://www.w3.org/2005/xpath-functions/math";
declare namespace output="http://www.w3.org/2010/xslt-xquery-serialization";
declare namespace xs="http://www.w3.org/2001/XMLSchema";
@joewiz
joewiz / package-library.md
Created Feb 5, 2019
Thoughts on a "package library" to replace eXist's "public repo"
View package-library.md

package-library

API

  1. add package
    • receive uploaded xar(s)
    • store upload(s) in "temp" folder
    • for each new package:
      • extract package metadata
      • validate package metadata
@joewiz
joewiz / data-composition.xqy
Last active Jan 23, 2019 — forked from xquery/data-composition.xqy
This works in BaseX and Saxon, but eXist returns an error: `exerr:ERROR cannot convert function(*)('') to a node set [at line 59, column 15]`
View data-composition.xqy
xquery version "3.0";
(: discovered via https://twitter.com/_james_fuller/status/1087706435176288257, updated with HTTP URL for data.xq :)
(: the power of algebraic data types in xquery
This example shows how we can composite up data models
which 'carry' their own operations along with them.
:)
@joewiz
joewiz / CompareTools.plist
Last active Feb 14, 2019
Add oXygen as Diff & Merge Tool for Git Tower
View CompareTools.plist
<?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 Oct 29, 2018
Calculate Levenshtein Distance, using XQuery
View 01-levenshtein-distance.xq
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
@joewiz
joewiz / adaptive-serialization.xq
Created Sep 15, 2018
Boilerplate for declaring Adaptive serialization in XQuery
View adaptive-serialization.xq
xquery version "3.1";
declare namespace output="http://www.w3.org/2010/xslt-xquery-serialization";
declare option output:method "adaptive";
declare option output:indent "yes";
map { "reference": xs:anyURI("https://www.w3.org/TR/xslt-xquery-serialization-31/#adaptive-output") }
@joewiz
joewiz / date-parser.xqm
Created Aug 26, 2018
Parse various formats of date strings, in XQuery
View date-parser.xqm
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
@joewiz
joewiz / create-travels-tsv.xq
Last active Mar 14, 2019
Generate a TSV of Travels of President and Secretary of State
View create-travels-tsv.xq
xquery version "3.1";
(: Generate a TSV of Travels of President and Secretary of State.
: Assumes https://github.com/HistoryAtState/travels has been installed.
:)
(:~
: A function for constructing a TSV (tab-separated value) file
:
: @param A sequence of column headings
@joewiz
joewiz / entities.xql
Last active Aug 3, 2018
Look up HTML character entities and convert references to XML-compatible characters in XQuery
View entities.xql
xquery version "3.1";
(:~ A module containing a lookup table, in the form of a map, for HTML entities
: that aren't defined in XML, and a function for converting HTML entities in
: strings to the appropriate characters. Look up characters via map lookup:
:
: $entities:entities?ograve?character => ò
:
: @author Joe Wicentowski
: @see https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Character_entity_references_in_HTML
You can’t perform that action at this time.