This file contains hidden or 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 function local:prolog($element as element(), $position as xs:integer) { | |
| if ($element instance of element(value)) | |
| then | |
| fn:string-join( | |
| local:prolog-var($element/*, $position), | |
| " " | |
| ) |
This file contains hidden or 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 function local:prolog($element as element()) { | |
| if ($element instance of element(value)) | |
| then | |
| fn:string-join( | |
| local:prolog-ns($element/*), | |
| " " | |
| ) |
This file contains hidden or 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 $items as xs:string* := ('test', 'values', 'to', 'iterate', 'over') | |
| $bool1 as xs:boolean := fn:exists($items[. ne '']), | |
| $bool2 as xs:boolean := fn:exists(fn:subsequence($items,6)), | |
| $bool3 as xs:boolean := some $i in $items satisfies $i eq "some-value", | |
| $bool4 as xs:boolean := every $i in $items satisfies $i instance of xs:string | |
| return ( | |
| if ($bool1) | |
| then "bool1: true" | |
| else (), |
This file contains hidden or 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 $items as xs:string* := ('test', 'values', 'to', 'iterate', 'over') | |
| $bool1 as xs:boolean := if (fn:exists($items)) then fn:true() else fn:false(), | |
| $bool2 as xs:boolean? := if (fn:exists(fn:subsequence($items,6))) then fn:true() else (), | |
| $bool3 as xs:boolean* := for $i in $items return $i eq "some-value", | |
| $bool4 as xs:boolean* := for $i in $items return $i eq "iterate" | |
| return ( | |
| if ($bool1) | |
| then "bool1: true" | |
| else (), |
This file contains hidden or 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 mem = "http://maxdewpoint.blogspot.com/memory-operations" at "/memory-operations.xqy"; | |
| (: Functions for transforming xml :) | |
| declare function local:bar($node as node()) as node()* | |
| { | |
| <barr>{$node/node()}</barr> | |
| }; | |
| declare function local:baz($node as node()) as node()* | |
| { | |
| <bazz>{$node/node()}</bazz> |
This file contains hidden or 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 function local:sliding-window( | |
| $sequence as item()*, | |
| $only-start as xs:boolean, | |
| $start-condition as function(*), | |
| $only-end as xs:boolean, | |
| $end-condition as function(*), | |
| $return as function(*) | |
| ) { |
This file contains hidden or 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 function local:tumbling-window( | |
| $sequence as item()*, | |
| $only-start as xs:boolean, | |
| $start-condition as function(*), | |
| $only-end as xs:boolean, | |
| $end-condition as function(*), | |
| $return as function(*) | |
| ) { |
This file contains hidden or 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 $html as element(html) := html:html-for-page($page-uri), | |
| $content-for-page := content:page-content($page-uri), | |
| $transaction-id := mem:copy($html), | |
| $binding-lambda := function ($html, $content) { | |
| for $prop in $html/descendant-or-self::*[@itemprop] | |
| let $prop-name := fn:string($prop/@itemprop), | |
| $prop-value := $content/descendant-or-self::*[@itemprop eq $prop-name]/node() | |
| return | |
| if ($prop-name eq 'url') | |
| then mem:replace-value($transaction-id, ($prop/(@href|@src|@data))[1], $prop-value) |
This file contains hidden or 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 json = 'http://marklogic.com/xdmp/json'; | |
| declare function local:normalize-from-json($json as item()) { | |
| if (fn:type-available('json:object')) | |
| then local:_normalize-from-json($json) | |
| else $json | |
| }; |
This file contains hidden or 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 $directories-map := (cts:uris('/',('properties','map'),cts:directory-query('/','infinity')) | |
| - | |
| cts:uris('/',('document','map'),cts:directory-query('/','infinity'))) | |
| return map:keys($directories-map)[xdmp:estimate(cts:search(fn:collection(),cts:directory-query(.,'infinity'))) eq 0] |