Skip to content

Instantly share code, notes, and snippets.

@wsalesky
wsalesky / set-uid.xql
Last active March 6, 2016 13:42
Set UID xquery for eXistdb, since I never remember the syntax.
xquery version "3.0";
sm:chmod(xs:anyURI('/db/apps/srophe-data/git-sync.xql'), "rwsr-xr-x")
@wsalesky
wsalesky / spear-uri.xql
Created February 25, 2016 14:42
Simple update script to add uri attributes to SPEAR data (that does not already have uris).
xquery version "3.0";
import module namespace functx="http://www.functx.com";
declare namespace tei = "http://www.tei-c.org/ns/1.0";
declare namespace fn="http://www.w3.org/2005/xpath-functions";
for $b in collection('/db/apps/srophe-data/data/spear/tei')//tei:TEI
let $id := substring-before($b/descendant::tei:idno[starts-with(.,'http://syriaca.org/')],'/tei')
return
for $div at $pos in $b/descendant::tei:body/tei:div
@wsalesky
wsalesky / BHSE-data.xml
Last active February 3, 2016 18:36
Updates to works TEI
<?xml version="1.0" encoding="UTF-8"?>
<root>
<row>
<BHS>1</BHS>
<French_Prologue>On nous a réclamé de raconter l’histoire des amis du Christ, et nous n’avons pas assez de force pour nous acquitter de ce qui nous a été réclamé, car la petitesse est notre mesure…</French_Prologue>
<Text_French_Title>Pierre, apôtre</Text_French_Title>
</row>
<row>
<BHS>2</BHS>
<French_Prologue>Venons-en donc à l’histoire des hauts faits du bienheureux Paul, lui qui, plus que tous, peina comme parole de l’Esprit qui parla en lui; il acheva sa course, garda son ministère, et pour notre Seigneur Jésus-Christ, il répandit la libation de son sang en vue de réconcilier son troupeau…</French_Prologue>
@wsalesky
wsalesky / bitbucket-github-issues.xql
Last active September 29, 2015 18:02
Migrate bitbucket issues to github repository, assumes repo has already been migrated. Also assumes you have exported BitBucket issues, see BitBucket instructions on how to do that.
xquery version "3.0";
(:~
: POC: Migrate bitbucket issues to github repository, run in eXistdb 2.2
: Prerequisites:
: In order to run the module, you will need a github Authorization token.
: When you create authorization token your OAuth Scope will need to include repo, allowing you to update files.
: @see https://github.com/blog/1509-personal-api-tokens
:
: Github API Steps for migrating issues:
: 1. Get BitBucket JSON output, serialize as xml
@wsalesky
wsalesky / name-matches.xq
Last active September 2, 2015 17:24 — forked from joewiz/highlight-matches.xq
Repurpose @joewiz highlight-match.xql to do primitive NER on Syriaca.org data. Matches against Syriaca.org English place names. XQuery highlights regex pattern matches in XML while preserving node structure, with XQuery
xquery version "3.0";
declare namespace tei = "http://www.tei-c.org/ns/1.0";
declare namespace fn="http://www.w3.org/2005/xpath-functions";
(:
: A simple addaptation of @joewiz highlight-match.xql [https://gist.github.com/joewiz/5937897] for POC of simple NER based on predefined list.
: Allow placeName recognition against a pre determined list of names, in this case uses place names in https://github.com/srophe/srophe-app-data
: Names a wrapped in a placeName tag with a @ref attribute linking them to the authority record in https://github.com/srophe/srophe-app-data
:)
@wsalesky
wsalesky / git-commit-expath-http.xql
Last active September 28, 2015 16:22
Version of git-commit using expath http client. Still a work in progress.
xquery version "3.0";
(:~
: POC: eXist DB module to commit files to github reop via github API
: Prerequisites:
: In order to run the module, you will need a github Authorization token.
: When you create authorization token your OAuth Scope will need to include repo, allowing you to update files.
: @see https://github.com/blog/1509-personal-api-tokens
:
: @Notes
@wsalesky
wsalesky / get-names.xql
Last active August 29, 2015 14:25 — forked from davidamichelson/gist:857733cac083c270013b
Get all Syriac names and English counterparts from Syriaca.org data.
xquery version "1.0";
declare namespace tei="http://www.tei-c.org/ns/1.0";
<root>
{
(
for $place in collection('/db/apps/srophe-data/data/places/tei')//tei:place[tei:placeName[matches(@xml:lang, '^syr')]]
let $id := $place/tei:idno[starts-with(.,'http://syriaca.org/')]/text()
return
<row>
@wsalesky
wsalesky / fix-dates.xql
Created June 23, 2015 19:29
Fix dates script in srophe data
xquery version "3.0";
import module namespace functx="http://www.functx.com";
declare namespace tei = "http://www.tei-c.org/ns/1.0";
(: Add correct padding to dates. :)
declare function local:fix-dates($date as xs:string){
let $plain-date := if(starts-with($date,'-')) then substring($date,2) else $date
let $add-padding :=
if(contains($plain-date,'-')) then
let $year := functx:pad-integer-to-length(xs:integer(tokenize($plain-date,'-')[1]),4)
@wsalesky
wsalesky / git-commit.xql
Created June 22, 2015 16:25
Proof of Concept: eXist DB module to commit files to github repository via github API
xquery version "3.0";
(:~
: POC: eXist DB module to commit files to github reop via github API
: Prerequisites:
: In order to run the module, you will need a github Authorization token.
: When you create authorization token your OAuth Scope will need to include repo, allowing you to update files.
: @see https://github.com/blog/1509-personal-api-tokens
:
: @Notes
@wsalesky
wsalesky / saints-works.xslt
Created June 18, 2015 18:34
Saints-works transformation.
<?xml version="1.0" encoding="UTF-8"?>
<?xml-model href="http://www.tei-c.org/release/xml/tei/custom/schema/relaxng/tei_all.rng" type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"?>
<?xml-model href="http://www.tei-c.org/release/xml/tei/custom/schema/relaxng/tei_all.rng" type="application/xml"
schematypens="http://purl.oclc.org/dsdl/schematron"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs" version="2.0" xmlns:syriaca="http://syriaca.org"
xmlns:saxon="http://saxon.sf.net/" xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl" xmlns:functx="http://www.functx.com">
<xsl:output encoding="UTF-8" indent="yes" method="xml" name="xml" />