Skip to content

Instantly share code, notes, and snippets.

View xquery's full-sized avatar

James Fuller xquery

View GitHub Profile
@xquery
xquery / gist:9057019
Last active August 29, 2015 13:56
playing around with this and @jpcs parser.xq, yes dashes ....
{
"p-pipeline": [
{
"name": "my-pipeline",
"p-import": "../test.xpl",
"p-source": {
"sequence": false
},
"p-results": {},
"myuri": "http://www.example.org/test.xslt",
@xquery
xquery / gist:3b527eaf04a02dc7f693
Last active August 29, 2015 14:02
simple markov chain example using xquery (requires MarkLogic)
xquery version "1.0-ml";
import module namespace functx = "http://www.functx.com" at
"/MarkLogic/functx/functx-1.0-nodoc-2007-01.xqy";
(: extracts //p from web page and tokenizes to lower case words :)
declare function local:generate-corpus(
$uri
){
@xquery
xquery / gist:885d227151ee9ee9ac06
Created September 9, 2014 15:24
check out the new annotations for RXQ functions (%output: , %xdmp:gzip) ... neat
(: -------------------------------------------------------------------------- :)
(: XSLT and XQuery Serialization 3.0 :)
(: -------------------------------------------------------------------------- :)
declare
%rxq:produces('text/plain')
%output:method('text')
%output:encoding('iso-8859-1')
%output:omit-xml-declaration('no')
### Keybase proof
I hereby claim:
* I am xquery on github.
* I am jimfuller (https://keybase.io/jimfuller) on keybase.
* I have a public key whose fingerprint is F971 F4C2 13BB BE1A FF88 9AB4 0617 80A7 7257 D3E2
To claim this, I am signing this object:
@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">
@xquery
xquery / gist:4eebf54c11aa48f88ca1
Last active August 29, 2015 14:15
xproc tests run via gradle
apply plugin: 'izpack'
defaultTasks 'assemble', 'test'
ant.importBuild 'build.xml'
buildscript {
repositories {
mavenCentral()
jcenter()
@xquery
xquery / test.gradle
Created April 13, 2015 11:59
Run xmlcalabash with gradle
gradle -b test.gradle -Dexec.args="-isource=test1.xpl -oresult=- test1.xpl"
@xquery
xquery / memoization.xqy
Created May 4, 2011 05:57
Inline caching (memoization) for higher order xquery functions
xquery version "1.0-ml";
(: xquery memoization example for use with MarkLogic :)
declare variable $cache := map:map();
declare function local:factorial($n as xs:integer) as xs:integer {
if ($n < 0) then
(0)
else if ($n = 0) then
@xquery
xquery / gist:956835
Created May 5, 2011 10:24
idiv operator in xquery
xquery version "1.0";
(: The idiv operator returns an integer as a result, rounding toward 0. :)
let $a as xs:decimal := 20.1
let $b as xs:decimal := 1.678
let $result := $a idiv $b
return
$result
@xquery
xquery / gist:956929
Created May 5, 2011 12:03
using xpath id() function on xml:id
(: xml:id attribute needs to be unique within the specific document scope :)
let $xml := document{ <employees>
<employee xml:id="n001">
<name>Johny Rotten</name>
</employee>
<employee xml:id="n002">
<name>Billy Idol</name>
</employee>
</employees>}