Skip to content

Instantly share code, notes, and snippets.

View emchateau's full-sized avatar

Emmanuel Château-Dutier emchateau

View GitHub Profile
@emchateau
emchateau / yaml-to-xml.xq
Created April 11, 2019 03:25 — forked from joewiz/yaml-to-xml.xq
Convert YAML to XML, with XQuery
xquery version "3.0";
(: doesn't support YAML indentation yet - just a start :)
declare function local:process-yaml-value($value) {
let $single-quote := "^'(.+)'$"
let $double-quote := '^"(.+)"$'
return
if (matches($value, $single-quote) or matches($value, $double-quote)) then
let $pattern := "^['""](.+)['""]$"
xquery version "3.0";
(:
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 to an eXist-compatible module from date-parser.xqy from
http://xqzone.marklogic.com/svn/commons/trunk/dates/date-parser.xqy
- by Joe Wicentowski
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs">
<xsl:param name="date">2013-11-04+11:00</xsl:param>
<xsl:param name="time">16:09:24.123+11:00</xsl:param>
<xsl:variable name="dateTime" select="concat($date,'T',$time)"/>
<xsl:template match="/">
<html>
<body>
<h1>Formatting Dates with XSLT 2.0</h1>
<p>Date: <xsl:value-of select="$date"/>
</p>
@emchateau
emchateau / sparql-iiif-annotations.txt
Created October 15, 2017 07:52 — forked from regisrob/sparql-iiif-annotations.txt
SPARQL query to retrieve and display IIIF image annotations (created with Mirador and SimpleAnnotationServer, stored in Sesame). See http://demos.biblissima-condorcet.fr/ovide-moralise/
PREFIX exif: <http://www.w3.org/2003/12/exif/ns#>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX cnt: <http://www.w3.org/2011/content#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX sc: <http://iiif.io/api/presentation/2#>
PREFIX sc1: <http://www.shared-canvas.org/ns/>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX oa: <http://www.w3.org/ns/oa#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
@emchateau
emchateau / jsVanilla4JQuery.md
Last active July 8, 2017 15:30 — forked from joyrexus/README.md
Vanilla JS equivalents of jQuery methods

Vanilla JS equivalents of jQuery methods

Events

// jQuery
$(document).ready(function() {
  // code
})
@emchateau
emchateau / dataBinding.js
Last active December 23, 2020 02:47 — forked from amowu/data-binding.js
Two-way data binding in pure Javascript
// http://stackoverflow.com/a/16484266/754377
function DataBind(element, data) {
this.data = data;
this.element = element;
element.value = data;
element.addEventListener("change", this, false);
}
DataBind.prototype.handleEvent = function(event) {
@emchateau
emchateau / sparql-query.xhtml
Created March 17, 2016 23:08 — forked from timathom/sparql-query.xhtml
XForms submission to request non-XML RDF formats from a SPARQL endpoint (DBpedia)
<?xml-stylesheet href="../build/xsltforms.xsl" type="text/xsl"?><?xsltforms-options debug="no"?><?css-conversion no?><?xml-model href="http://www.oxygenxml.com/1999/xhtml/xhtml-xforms.nvdl" schematypens="http://purl.oclc.org/dsdl/nvdl/ns/structure/1.0"?>
<html
xmlns="http://www.w3.org/1999/xhtml"
xmlns:cwb="http://example.org/cwb/"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
@emchateau
emchateau / get-turtle.xhtml
Last active March 17, 2016 23:08 — forked from timathom/get-turtle.xhtml
XForms doc and RESTXQ module for retrieving Turtle RDF data
<?xml-stylesheet href="xsltforms/xsltforms.xsl" type="text/xsl"?><?xsltforms-options debug="no"?><?css-conversion no?><?xml-model href="http://www.oxygenxml.com/1999/xhtml/xhtml-xforms.nvdl" schematypens="http://purl.oclc.org/dsdl/nvdl/ns/structure/1.0"?>
<html
xmlns="http://www.w3.org/1999/xhtml"
xmlns:cwb="http://example.org/cwb/"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
@emchateau
emchateau / turtle.xqm
Created March 17, 2016 23:07 — forked from timathom/turtle.xqm
XQuery Turtle parser (generated by Gunther Rademacher's REx)
xquery version "1.0" encoding "UTF-8";
(: This file was generated on Sat Feb 13, 2016 20:32 (UTC-05) by REx v5.35 which is Copyright (c) 1979-2015 by Gunther Rademacher <grd@gmx.net> :)
(: REx command line: turtle.ebnf -faster -xquery -tree :)
(:~
: The parser that was generated for the turtle grammar.
:)
module namespace p="turtle";
declare default function namespace "http://www.w3.org/2005/xpath-functions";
@emchateau
emchateau / MainArtists.xq
Created March 9, 2016 18:53 — forked from mathias-goebel/MainArtists.xq
DHd2016.XQuery
xquery version "3.0";
let $url := xs:anyURI('https://www.conftool.pro/dhd2016/sessions.php'),
$persist:= false(),
$request-headers := (),
$node as node() := httpclient:get($url, $persist, $request-headers)//httpclient:body/*,
$origList := tokenize(
string-join(
$node//*[contains(@class, 'paper_author')]/