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 "3.0"; | |
let $results := | |
for $trip in collection('/db/cms/apps/travels/data/secretaries')/trips/trip[country/@id = 'israel'] | |
let $duration := days-from-duration(sum($trip ! (./xs:date(end-date) - ./xs:date(start-date) + xs:dayTimeDuration('P1D')))) | |
group by $secretary := $trip/name | |
return | |
<trips secretary="{$secretary}" trips="{count($trip)}" days="{$duration}">{ | |
$trip ! | |
<trip>{ |
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 "3.1"; | |
declare namespace html="http://www.w3.org/TR/REC-html40"; (: the version of HTML used by the URL below :) | |
declare namespace output="http://www.w3.org/2010/xslt-xquery-serialization"; (: use XQuery 3.1's JSON serialization :) | |
import module namespace http="http://expath.org/ns/http-client"; (: @see http://expath.org/spec/http-client :) | |
declare option output:method "json"; | |
declare option output:media-type "application/json"; |
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 $path-to-xq := '/db/cms/apps/tei-content/views/ebook-batch.xq' | |
return | |
sm:chmod(xs:anyURI($path-to-xq), 'rwxr-xr-x') |
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 "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. |
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 "3.0"; | |
(: Sometimes you need to turn a list of words into a sequence-style string :) | |
declare function local:string-to-sequence($string as xs:string) as xs:string { | |
let $string := normalize-space($string) | |
let $items := tokenize($string, '\s') | |
let $quoted := $items ! concat("'", ., "'") | |
return | |
concat( |
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 "3.0"; | |
(: Construct a tab-separated value (TSV) file and save it to the file system. | |
: | |
: This should work in any XQuery 3.0-enabled processor that supports the EXPath File | |
: Module. | |
: | |
: Tested in oXygen 16.1 in the "XPath/XQuery Builder" view, using the "Saxon-EE XQuery" | |
: engine, with "Enable XQuery 3.0 support" option selected (in the "Saxon-HE/PE/EE" | |
: portion of oXygen's preferences). |
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 "3.0"; | |
for $trip in collection('/db/cms/apps/travels/data/secretaries')/trips/trip | |
let $duration := xs:date($trip/end-date) - xs:date($trip/start-date) | |
order by $duration descending | |
return <trip duration="{$duration}">{ $trip }</trip> |
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 "3.0"; | |
(: Examine query duration from JMX logs collected by monex :) | |
declare namespace jmx="http://exist-db.org/jmx"; | |
declare function local:milliseconds-to-time($timestamp as xs:long) as xs:dateTime { | |
let $days := xs:int($timestamp div 1000 div 24 div 60 div 60) | |
let $remainder := $timestamp - ($days * 24 * 60 * 60 * 1000) | |
let $hours := xs:int($remainder div 1000 div 60 div 60) |
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 "3.0"; | |
module namespace r = "http://joewiz.org/ns/xquery/roman-numerals"; | |
(: Converts standard Roman numerals to integers. | |
: Handles additive and subtractive but not double subtractive. | |
: Case insensitive. | |
: Doesn't attempt to validate a numeral other than a naïve character check. | |
: See discussion of standard modern Roman numerals at: | |
: http://en.wikipedia.org/wiki/Roman_numerals. |
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
javascript:(function(){window.location=loadTimeData.data_.summary.failedUrl.replace(/.*\?url=/,'');})() |