Skip to content

Instantly share code, notes, and snippets.

derickson / config.xqy
Created Dec 10, 2011
Mobile Shakespeare Tutorial Part 1
View config.xqy
xquery version "1.0-ml" ;
(: config.xqy
This library module holds configuration
variables for the application
module namespace cfg = "http://framework/lib/config";
(: The rewrite library route configuration
derickson / header.html
Created Dec 12, 2011
Mobile Shakespeare Tutorial Part 2
View header.html
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link href='|Vast+Shadow' rel='stylesheet' type='text/css'/>
<link rel="stylesheet" href="/css/mobshake-jm.min.css"/>
<link rel="stylesheet" href=""/>
<link rel="stylesheet" href="/css/mobshake.css" />
<script src=""></script>
<script src=""></script>
derickson / config-snip.xqy
Created Dec 17, 2011
Mobile Shakespeare Tutorial Part 3
View config-snip.xqy
<get path="play/:id/act/:act/scene/:scene/speech/:speech"><to>play#scene</to></get>
<get path="search"><to>search#get</to></get>
<post path="search"><to>search#get</to></post>
View circles.xqy
xquery version "1.0-ml";
(: a whole bunch of random circles to make the reverse-query harder :)
let $n := 10000
for $count in (1 to $n)
let $lat := xdmp:random(180) - 90
let $lon := xdmp:random(360) - 180
let $query-doc :=
derickson / event.xml
Created Jan 10, 2012
XQuery Choropleth
View event.xml
<?xml version="1.0" encoding="UTF-8"?>
<point>38.9846520, -77.0947092</point>
derickson / map.xqy
Created Jan 10, 2012
XQuery Choropleth complete
View map.xqy
xquery version "1.0-ml";
import module namespace search=""
at "/MarkLogic/appservices/search/search.xqy";
declare namespace kml = "";
(:White to red color scale in BBGGRR format :)
declare variable $COLOR_SCALE :=
View bookload.xqy
let $books :=
<book category="COOKING">
<title lang="en">Everyday Italian</title>
<author>Giada De Laurentiis</author>
... other books from W3Schools example ...
derickson / bad.xqy
Created May 4, 2012
Learning XQuery 2
View bad.xqy
(: I assume local mathematical functions
functionA, functionB, and functionC are
defined above :)
(: this is too procedural :)
let $accumulator := 1
let $accumulator := functionA($accumulator)
let $accumulator := functionB($accumulator)
let $accumulator := functionC($accumulator)
View xpath.xqy
//book[author eq "J K. Rowling"]
derickson / enrich.xqy
Created May 20, 2012
Lord of the Rings txt to XML
View enrich.xqy
xquery version "1.0-ml";
for $character in ("Frodo", "Sam", "Merry", "Pippin", "Boromir", "Gimli", "Legolas", "Aragorn", "Gandalf")
xquery version"1.0-ml";
declare variable $character as xs:string external;
for $line in cts:search(/line-doc, $character)