Skip to content

Instantly share code, notes, and snippets.

@taoyou
taoyou / facets.xq
Created November 5, 2015 22:56
get facets based on path variable
xquery version "3.1";
declare function local:get_facet ($books as element()*, $path as xs:string ) as element()?
{
<binding>{
for $book in $books
let $fld := $book/*[name()=$path]
group by $f := $fld
@jeffreycwitt
jeffreycwitt / iiifsearch.xq
Created October 2, 2015 01:15
existdb to IIIF search results
xquery version "3.0";
declare namespace tei="http://www.tei-c.org/ns/1.0";
declare namespace output="http://www.w3.org/2010/xslt-xquery-serialization";
import module namespace console="http://exist-db.org/xquery/console";
declare option output:method "json";
declare option output:media-type "application/json";
declare function local:render($node) {
@adamretter
adamretter / anon-recursion.xqy
Created September 18, 2015 14:01
Anonymous function recursion in XQuery
xquery version "3.0";
(:~
: Anonymous function recursion in XQuery
:
: @author Adam Retter <adam.retter@googlemail.com>
:)
let $factorialHelper := function($f, $x) {
if($x eq 0) then
@joewiz
joewiz / strip-diacritics.xq
Last active October 22, 2022 14:42
Strip diacritics, with XQuery
xquery version "3.1";
declare function local:strip-diacritics($string as xs:string) as xs:string {
$string
=> normalize-unicode("NFD")
=> replace("\p{IsCombiningDiacriticalMarks}", "")
};
declare function local:inspect-diacritics($string as xs:string) as element() {
let $normalized := normalize-unicode($string, "NFD")
@timathom
timathom / get-turtle.xhtml
Last active September 7, 2016 06:34
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"
@timathom
timathom / sparql-query.xhtml
Last active March 17, 2016 23:08
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"
@timathom
timathom / select-all-by-group
Last active August 29, 2015 14:23
XForms select-all-by-group checkboxes in XSLTForms
<?xml-stylesheet type="text/xsl" href="http://localhost:8080/exist/apps/xsltforms/xsltforms.xsl"?><?css-conversion no?><?xsltforms-options debug="yes"?><?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:bf="http://bibframe.org/vocab/"
xmlns:cwb="http://libserv6.princeton.edu/cwb/"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<head>
<meta
@joewiz
joewiz / payload.xq
Created May 10, 2015 07:23
Receive payloads from BitBucket.org POST hooks with eXist
xquery version "3.1";
(:
Receive payloads from BitBucket.org POST hooks with eXist
Prerequisites:
1. A post-January 2015 build of the develop branch of eXist, which adds support
for XQuery 3.1's JSON parsing and serialization features.
@no-reply
no-reply / thoughts.md
Last active March 23, 2017 20:09
Records, Documents, & Graphs: Accounting for record scope & mutability in metadata management

Records, Documents, & Graphs

Accounting for record scope & mutability in metadata management.

Smoothies cannot be edited @anarchivist -- 6:52 PM PDT - 23 Apr 2015

Questions

The key question I'm setting out to answer is: How can we account for routine change and updates in our metadata records. An initial attempt to derive a model for change from current practice has led to some corollary questions about the relationship between Records, Documents, Description Sets, Application Profiles, Resources, and RDF Sourceslit review:

@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">