Skip to content

Instantly share code, notes, and snippets.

David Erickson derickson

Block or report user

Report or block derickson

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@derickson
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
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='http://fonts.googleapis.com/css?family=Aguafina+Script|Vast+Shadow' rel='stylesheet' type='text/css'/>
<link rel="stylesheet" href="/css/mobshake-jm.min.css"/>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0rc2/jquery.mobile.structure-1.0rc2.min.css"/>
<link rel="stylesheet" href="/css/mobshake.css" />
<script src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
<script src="http://code.jquery.com/mobile/1.0rc2/jquery.mobile-1.0rc2.min.js"></script>
@derickson
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
derickson / event.xml
Created Jan 10, 2012
XQuery Choropleth
View event.xml
<?xml version="1.0" encoding="UTF-8"?>
<event>
<name>Bethesda</name>
<point>38.9846520, -77.0947092</point>
</event>
@derickson
derickson / map.xqy
Created Jan 10, 2012
XQuery Choropleth complete
View map.xqy
xquery version "1.0-ml";
import module namespace search="http://marklogic.com/appservices/search"
at "/MarkLogic/appservices/search/search.xqy";
declare namespace kml = "http://www.opengis.net/kml/2.2";
(:White to red color scale in BBGGRR format :)
declare variable $COLOR_SCALE :=
View bookload.xqy
let $books :=
<bookstore>
<book category="COOKING">
<title lang="en">Everyday Italian</title>
<author>Giada De Laurentiis</author>
<year>2005</year>
<price>30.00</price>
</book>
... other books from W3Schools example ...
</bookstore>
@derickson
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)
return
View xpath.xqy
//book[author eq "J K. Rowling"]
@derickson
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")
return
xdmp:eval('
xquery version"1.0-ml";
declare variable $character as xs:string external;
for $line in cts:search(/line-doc, $character)
return
xdmp:node-replace(
You can’t perform that action at this time.