This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xquery version "1.0-ml"; | |
(:~ | |
@author derickson | |
@date 2013-05-22 | |
Example of a Recursive Typeswitch for simple data conversion | |
Works in MarkLogic Server 6+ | |
:) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xquery version "1.0-ml"; | |
declare namespace ns = "http://www.marklogic.com/MLU/logbook"; | |
declare variable $bbox as xs:string? := xdmp:get-request-field("BBOX", ()); | |
xdmp:set-response-content-type("text/kml; charset=utf-8"), | |
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2"> | |
<Document> | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xquery version "1.0-ml"; | |
import module namespace mkf = "http://derickson/kmlalert/model/m-kf" at "/model/m-kmlfence.xqy"; | |
import module namespace lk = "http://derickson/kmlalert/lib/kml" at "/lib/l-kml.xqy"; | |
declare namespace kml ="http://www.opengis.net/kml/2.2"; | |
declare namespace gx ="http://www.google.com/kml/ext/2.2"; | |
mkf:insert-fence( | |
lk:get-google-map("https://maps.google.com/maps/ms?msid=2041XXXXXX Your URL GOES HERE") | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xquery version("1.0-ml"); | |
let $d := fn:doc("/wireshark.xml") | |
for $p in $d//packet | |
let $hex := fn:string($p//proto[@name eq "fake-field-wrapper"]/field[@name eq "data"]/@value) | |
let $len := fn:string-length($hex) | |
return | |
fn:string-join(( | |
for $i in (1 to $len) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xquery version "1.0-ml"; | |
import module namespace lh = "http://derickson/lib/l-mlhue" | |
at "/lib/l-mlhue.xqy"; | |
for $i in (1 to 10) | |
for $state in ( | |
$lh:RED, $lh:MAGENTA, $lh:PURPLE, | |
$lh:BLUE, $lh:GREEN, $lh:YELLOW, | |
$lh:ORANGE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//book[author eq "J K. Rowling"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(: 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 := |