Skip to content

Instantly share code, notes, and snippets.

View emchateau's full-sized avatar

Emmanuel Château-Dutier emchateau

View GitHub Profile
@wsalesky
wsalesky / teiupdates.xql
Last active August 29, 2015 14:06
TEI updates
xquery version "3.0";
declare namespace tei="http://www.tei-c.org/ns/1.0";
declare function local:do-alt-names($abstracts, $docs, $rec-id){
for $alt-name in $abstracts/Alternate_Name
return
if(string-length($alt-name) gt 1) then
(
let $addName :=
@wsalesky
wsalesky / facets.xqm
Created February 6, 2015 18:49
XQuery Facets POC
xquery version "3.0";
(:~
: A facet library module
:
: Builds facets from nodes passed by search or browse modules.
: Uses group by
: Built for use with eXistdb, if using with eXistdb be sure to define your range
: indexes in your collectio.xconf file for best performance.
:
: @author Winona Salesky
@xquery
xquery / gist:350831de91841b84edd9
Created February 13, 2015 16:54
xslt fold example - apply a series of xslt against a single source doc
the following is an example of a left fold xslt
java -jar /Applications/depify-1.0/deps/xmlcalabash/calabash.jar -isource=test.xml -istylesheets=test1.xsl -istylesheets=test2.xsl -oresult=- xslt-fold.xpl
<p:declare-step version="1.0"
xmlns:p="http://www.w3.org/ns/xproc"
xmlns:c="http://www.w3.org/ns/xproc-step"
xmlns:ex="http://www.example.com"
name="main">
#!/usr/bin/env python
"""
print rudimentary stats about the revisions to a Wikipedia article on the command line
"""
MAX_ARTICLES = 10000 # some bots have edited millions of articles
import sys
import json
@nickdunn
nickdunn / EventTutorial.md
Created May 17, 2011 08:29 — forked from brendo/EventTutorial.md
Symphony Events: A Detailed Look

Forms have been an integral part of any interactive site since the dawn of time — they promote interactivity and are usually the most common way users interact with a site. It's commonplace that when a form is submitted (input), the website will take 'action' and do something with the data (processing) and then provide a user with the result (output). Symphony provides this logic layer via events.

This tutorial assumes you have a basic understanding of how events work in Symphony (if not, this may be a good introduction) and are semi-comfortable writing some PHP code. I'll be showing you some of the lesser-known features of Symphony events, including event priority, event chaining, and a brief demonstration of how to write a custom event. The difficulty level progresses as we go through, but with any luck you'll be able to learn a thing or two :)

Getting Started

The Scenario

Our client requires a form that allows a user to submit some detai

@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
@joewiz
joewiz / parse-tweets.xq
Last active October 4, 2015 01:28
Parse and transform tweets using XQuery 3.1's JSON support
xquery version "3.1";
(: parse tweets using XQuery 3.1's JSON support
: see http://www.w3.org/TR/xpath-functions-31/#json
: sample JSON from https://dev.twitter.com/rest/reference/get/statuses/user_timeline
:)
let $json := json-doc('/db/user_timeline.json')
let $tweets := $json?*
return
@LegoStormtroopr
LegoStormtroopr / input.xml
Created August 19, 2012 00:20
Using XPath1.0 to resolve the correct implied value of an XML elements xml:lang attribute
<?xml version="1.0" encoding="utf-8"?>
<data>
<foo xml:lang="en">
<bar>
<tog xml:lang="fr">
<wel>
<vay xml:lang="sv"/>
</wel>
</tog>
<tog>
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="././xsltforms-beta2/xsltforms/xsltforms.xsl" type="text/xsl"?><?xsltforms-options debug="no"?><html xmlns="http://www.w3.org/1999/xhtml"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:fn="http://www.w3.org/2005/xpath-functions"
xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:rml="http://legostormtoopr/response">
<head>
@apb2006
apb2006 / actions.xml
Last active October 13, 2015 00:27
TXQ
<div>
<h2>{$heading} - {count($actions/generate)}</h2>
<p>Actions are processes that generate a new item from an existing item.</p>
<div>
{$partial("action1.xml","action",$actions/generate )}
</div>
</div>