View typeswitch.xqy
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 variable $stuff := | |
<doc> | |
<content> | |
<change-me my-attr="look at me">some text</change-me> | |
<count>1</count> | |
<name>Fred Smith</name> | |
</content> | |
</doc>; |
View add-namespace.xqy
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
declare namespace dmc = "dmc"; | |
declare function local:change($node) | |
{ | |
typeswitch($node) | |
case element(change-me) return | |
element { xs:QName("dmc:" || fn:local-name($node)) } { | |
$node/@*, | |
$node/node() ! local:change(.) | |
} |
View functx-namespace.xqy
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 functx = "http://www.functx.com" at "/MarkLogic/functx/functx-1.0-nodoc-2007-01.xqy"; | |
declare namespace dmc = "dmc"; | |
declare variable $stuff := | |
<doc> | |
<content> | |
<change-me my-attr="look at me">some text</change-me> |
View typeswitch-multiple.xqy
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
declare function local:change($node) | |
{ | |
typeswitch($node) | |
case element(change-me) return | |
element { xs:QName("dmc:" || fn:local-name($node)) } { | |
$node/@*, | |
$node/node() ! local:change(.) | |
} | |
case element(name) return element name { "redacted" } | |
case element(count) return |
View import-mem.xqy
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
import module namespace mem = "http://xqdev.com/in-mem-update" at | |
"/MarkLogic/appservices/utils/in-mem-update.xqy"; |
View distinct-sequence.xqy
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 $seq1 := (: some sequence of values :) | |
let $seq2 := (: some sequence of values :) | |
return fn:distinct-values($seq1[fn:not(.=$seq2)]) |
View original-compliance-map.xqy
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
declare function gs:doc-compliance-map($uri as xs:string) | |
{ | |
let $query := cts:document-query($uri) | |
let $map := map:map() | |
let $doc := gs:highlight($uri, 'a') | |
let $header1 := | |
for $s in $doc/document/body//(section|subsection) | |
where fn:contains($s/fn:data(compliance), $TERM1) | |
return fn:count($s) |
View highlight.xqy
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
declare function gs:highlight($uri, $search) | |
{ | |
for $x in cts:search(fn:doc(xdmp:url-decode($uri)), $search) | |
return cts:highlight($x, $search, <b>{$cts:text}</b>) | |
}; |
View highlight2.xqy
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
declare function gs:highlight($uri, $search) | |
{ | |
cts:highlight( | |
fn:doc(xdmp:url-decode($uri)), | |
$search, | |
<b>{$cts:text}</b> | |
) | |
}; | |
View consolidated-compliance-map.xqy
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
declare function local:doc-compliance-map($uri, $terms) | |
{ | |
let $map := map:new( | |
for $term in $terms | |
return map:entry($term, 0) | |
) | |
let $doc := fn:doc($uri) | |
let $_ := | |
for $s in $doc/document/body//(section|subsection) |
OlderNewer